-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathutils.h
61 lines (51 loc) · 2.13 KB
/
utils.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
+----------------------------------------------------------------------+
| Author: Xingzhi Liu <[email protected]> |
+----------------------------------------------------------------------+
*/
#ifndef UTILS_H
#define UTILS_H
#ifdef __cplusplus
extern "C"
{
#endif
// file...
long getfilesize(FILE *fp);
char* loadfile(const char *path, long *filesize);
char* loadfilep(FILE *fp, long *filesize);
unsigned char* loadfileb(const char *path, long *filesize);
int savefile(const char *path,void *buf,int size);
int getlinenum(const char *buf, const char *newline);
char *getaline(char *buf, const char *newline, int *linelen);
char *getalinekeep(const char *buf, const char *newline, int *linelen);
int filewriteint(const char *path,int num);
int filereadint(const char *path);
// compress...
unsigned char *compressx(const char *input, int inlen, int *outlen);
char *uncompressx(const char *input, int inlen, int *outlen);
int compressfile(const char *infilename, const char *outfilename, int chunksize);
int decompressfile(const char *infilename, const char *outfilename, int chunksize);
char *inflate4gzip(char *in,int inlen,int *outlen);
// encode...
char *urlencode(char *source , char *dest);
char* urldecode(char *s);
int xmlencode(const char *src, char *des);
int htmlencode(const char *src, char *des);
int htmlencode2(const char *src, char *des, const char *tag);
int htmlencoden(const char *src, char *des, int desSize);
int htmldecode(char *des);
int htmldecoded(const char *src, char *des);
int base64encode(const char *str, int length, char *b64store);
int base64encode4url(const char *str, int length, char *b64store);
int base64decode(const char *base64, char *to);
int base64decode4url(const char *base64, char *to);
char *binencode(char *in, int inlen, char *out, char nbits);
char *bin2hex(unsigned char *bin, int binlen, char *hex);
int hex2bin(char *hex,unsigned char *bin);
char *hexencode(char *source , char *dest);
char* hexdecode(char *s);
void format_thousands_separator(long val,char *buf,int nLen);
#ifdef __cplusplus
}
#endif
#endif