mirror of
https://github.com/lxsang/ant-http
synced 2024-12-25 16:28:21 +01:00
add utils functions
This commit is contained in:
parent
22fa1a6338
commit
a49dd2c090
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,4 +1,5 @@
|
||||
# Prerequisites
|
||||
build
|
||||
*._*
|
||||
*.d
|
||||
|
||||
|
@ -335,12 +335,27 @@ unsigned simple_hash(const char* key)
|
||||
hashval = *key + 31 * hashval;
|
||||
return hashval;
|
||||
}
|
||||
int is_file(const char* f)
|
||||
int _exist(const char* f)
|
||||
{
|
||||
struct stat st;
|
||||
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
|
||||
|
||||
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 simple_hash(const char*);
|
||||
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 sha1(const char*, char*);
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user