mirror of
				https://github.com/lxsang/ant-http
				synced 2025-10-31 02:15:45 +01:00 
			
		
		
		
	add utils functions
This commit is contained in:
		
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| @@ -1,4 +1,5 @@ | |||||||
| # Prerequisites | # Prerequisites | ||||||
|  | build | ||||||
| *._* | *._* | ||||||
| *.d | *.d | ||||||
|  |  | ||||||
|   | |||||||
| @@ -335,12 +335,27 @@ unsigned simple_hash(const char* key) | |||||||
|       hashval = *key + 31 * hashval; |       hashval = *key + 31 * hashval; | ||||||
| 	return hashval; | 	return hashval; | ||||||
| } | } | ||||||
| int is_file(const char* f) | int _exist(const char* f) | ||||||
| { | { | ||||||
| 	struct stat st; | 	struct stat st; | ||||||
| 	return !(stat(f, &st) == -1); | 	return !(stat(f, &st) == -1); | ||||||
| } | } | ||||||
|   | int is_file(const char* f) | ||||||
|  | { | ||||||
|  | 	int st = is_dir(f); | ||||||
|  | 	if(st == -1) return -1; | ||||||
|  | 	else return st==0; | ||||||
|  | } | ||||||
|  | int is_dir(const char* f) | ||||||
|  | { | ||||||
|  | 	struct stat st; | ||||||
|  | 	if(stat(f, &st) == -1) | ||||||
|  | 		return -1; // unknow | ||||||
|  | 	else if(st.st_mode & S_IFDIR) | ||||||
|  | 		return 1; | ||||||
|  | 	else  | ||||||
|  | 		return 0; | ||||||
|  | } | ||||||
| // These vars will contain the hash | // These vars will contain the hash | ||||||
|   |   | ||||||
| void md5(uint8_t *initial_msg, size_t initial_len, char* buff) { | void md5(uint8_t *initial_msg, size_t initial_len, char* buff) { | ||||||
|   | |||||||
| @@ -86,6 +86,8 @@ char to_hex(char code); | |||||||
| unsigned hash(const char*, int); | unsigned hash(const char*, int); | ||||||
| unsigned simple_hash(const char*); | unsigned simple_hash(const char*); | ||||||
| int is_file(const char* f); | int is_file(const char* f); | ||||||
|  | int is_dir(const char* f); | ||||||
|  | int _exist(const char* f); | ||||||
| void md5(uint8_t *, size_t , char*); | void md5(uint8_t *, size_t , char*); | ||||||
| void sha1(const char*, char*); | void sha1(const char*, char*); | ||||||
| #endif | #endif | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user