Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Adding typedefs for digest_ctx and digest_result and using them in di…
…gup.c
  • Loading branch information
bingmann committed Oct 7, 2009
1 parent 91dc9ea commit 3d356a9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions src/digest.h
Expand Up @@ -33,19 +33,19 @@
* variable sized structure to hold binary digest results of different
* algorithms.
*/
struct digest_result
typedef struct digest_result
{
unsigned char size;
/* variable length of bytes follows:
unsigned char data[];
*/
};
} digest_result;

/**
* class-like structure with function pointers and integrated digest
* algorithm context.
*/
struct digest_ctx
typedef struct digest_ctx
{
union
{
Expand All @@ -68,7 +68,7 @@ struct digest_ctx
struct digest_result* (*read)(struct digest_ctx *ctx);

struct digest_result* (*process_buffer)(const char *buffer, size_t len);
};
} digest_ctx;

/* initialize the structure with function pointers for specific digest
* type */
Expand Down
20 changes: 10 additions & 10 deletions src/digup.c
Expand Up @@ -65,7 +65,7 @@ struct FileInfo
time_t mtime;
ssize_t size;
char* error;
struct digest_result* digest;
digest_result* digest;
char* symlink; /* target actually */
char* oldpath; /* for renamed or copied files. */
};
Expand Down Expand Up @@ -138,7 +138,7 @@ void rbtree_fileinfo_free(void *a)
/* functional for the g_filelist red-black tree */
void rbtree_digest_result_free(void *a)
{
free((struct digest_result*)a);
free((digest_result*)a);
}

/* functional for the g_filelist red-black tree */
Expand All @@ -156,8 +156,8 @@ int rbtree_string_cmp(const void *a, const void *b)
/* functional for the g_filelist red-black tree */
int rbtree_digest_result_cmp(const void *a, const void *b)
{
return digest_cmp((const struct digest_result*)a,
(const struct digest_result*)b);
return digest_cmp((const digest_result*)a,
(const digest_result*)b);
}

/* functional for qsort() on a char* array */
Expand Down Expand Up @@ -425,8 +425,8 @@ bool needescape_filename(char** str)
* outerror is filled with an error message string.
*/
bool digest_file2(const char* filepath,
struct digest_ctx* digctx,
struct digest_result** outdigest,
digest_ctx* digctx,
digest_result** outdigest,
char** outerror)
{
char buffer[1024*1024];
Expand Down Expand Up @@ -506,9 +506,9 @@ bool digest_file2(const char* filepath,
* as a malloc()ed hex string in outdigest, or returns FALSE if there
* was a read error.
*/
bool digest_file(const char* filepath, struct digest_result** outdigest, char** outerror)
bool digest_file(const char* filepath, digest_result** outdigest, char** outerror)
{
struct digest_ctx digctx;
digest_ctx digctx;

switch (gopt_digesttype)
{
Expand Down Expand Up @@ -1181,7 +1181,7 @@ bool process_file(const char* filepath, const struct stat* st)
if (fileiter != NULL)
{
struct FileInfo* fileinfo = fileiter->value;
struct digest_result* filedigest = NULL;
digest_result* filedigest = NULL;

if (fileinfo->status != FS_UNSEEN)
{
Expand Down Expand Up @@ -1304,7 +1304,7 @@ bool process_file(const char* filepath, const struct stat* st)

/* test if the oldfile still exists. */
while (nodecopy != rb_end(g_filedigestmap) &&
digest_equal((struct digest_result*)nodecopy->key, fileinfo->digest))
digest_equal((digest_result*)nodecopy->key, fileinfo->digest))
{
if (access((char*)nodecopy->value, F_OK) == 0)
{
Expand Down

0 comments on commit 3d356a9

Please sign in to comment.