add function locked_list_destroy
parent
c9cba5298a
commit
1cb1847b29
|
|
@ -24,6 +24,11 @@ extern "C" {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void locked_list_destroy(FCLockedList *list)
|
||||||
|
{
|
||||||
|
pthread_mutex_destroy(&list->lock);
|
||||||
|
}
|
||||||
|
|
||||||
static inline void locked_list_add(struct fc_list_head *_new,
|
static inline void locked_list_add(struct fc_list_head *_new,
|
||||||
FCLockedList *list)
|
FCLockedList *list)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
27
src/md5.c
27
src/md5.c
|
|
@ -311,7 +311,7 @@ MD5_memset(POINTER output, int value, unsigned int len)
|
||||||
/*
|
/*
|
||||||
* Digests a string
|
* Digests a string
|
||||||
*/
|
*/
|
||||||
int my_md5_string(char *string,unsigned char digest[16])
|
int my_md5_string(char *string, unsigned char digest[16])
|
||||||
{
|
{
|
||||||
MD5_CTX context;
|
MD5_CTX context;
|
||||||
unsigned int len = strlen(string);
|
unsigned int len = strlen(string);
|
||||||
|
|
@ -332,25 +332,22 @@ int my_md5_buffer(char *buffer, unsigned int len, unsigned char digest[16])
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int my_md5_file(char *filename,unsigned char digest[16])
|
int my_md5_file(char *filename, unsigned char digest[16])
|
||||||
{
|
{
|
||||||
FILE *file;
|
FILE *file;
|
||||||
MD5_CTX context;
|
MD5_CTX context;
|
||||||
int len;
|
int len;
|
||||||
unsigned char buffer[1024];
|
unsigned char buff[16 * 1024];
|
||||||
|
|
||||||
if ((file = fopen(filename, "rb")) == NULL)
|
if ((file = fopen(filename, "rb")) == NULL) {
|
||||||
return -1;
|
return -1;
|
||||||
else {
|
}
|
||||||
my_md5_init(&context);
|
|
||||||
while ((len = fread(buffer, 1, 1024, file)) > 0)
|
|
||||||
{
|
|
||||||
my_md5_update(&context, buffer, len);
|
|
||||||
}
|
|
||||||
my_md5_final(digest, &context);
|
|
||||||
|
|
||||||
fclose(file);
|
my_md5_init(&context);
|
||||||
}
|
while ((len = fread(buff, 1, sizeof(buff), file)) > 0) {
|
||||||
return 0;
|
my_md5_update(&context, buff, len);
|
||||||
|
}
|
||||||
|
my_md5_final(digest, &context);
|
||||||
|
fclose(file);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,12 +41,12 @@ int my_md5_file(char *filename, unsigned char digest[16]);
|
||||||
*/
|
*/
|
||||||
int my_md5_buffer(char *buffer, unsigned int len, unsigned char digest[16]);
|
int my_md5_buffer(char *buffer, unsigned int len, unsigned char digest[16]);
|
||||||
|
|
||||||
void my_md5_init (MD5_CTX *context);
|
void my_md5_init(MD5_CTX *context);
|
||||||
|
|
||||||
void my_md5_update (MD5_CTX *context, unsigned char *input,
|
void my_md5_update(MD5_CTX *context, unsigned char *input,
|
||||||
unsigned int inputLen);
|
unsigned int inputLen);
|
||||||
|
|
||||||
void my_md5_final (unsigned char digest[16], MD5_CTX *context);
|
void my_md5_final(unsigned char digest[16], MD5_CTX *context);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue