diff --git a/include/types.h b/include/types.h index 3aa7143..74a3f3f 100644 --- a/include/types.h +++ b/include/types.h @@ -25,18 +25,18 @@ struct RecordObject; // Methods struct RecordObject *NewRecordObject(); -int Unpack(struct RecordObject *, char *); +int RecordObjectUnpack(struct RecordObject *, char *); int RecordObjectWrite(struct RecordObject *self, const char *path, FILE *out); -int Compare(struct RecordObject *, struct RecordObject *); -char GetFileType(const struct RecordObject *); -unsigned int GetPermissions(const struct RecordObject *); -uintmax_t GetUid(const struct RecordObject *); -uintmax_t GetGid(const struct RecordObject *); -intmax_t GetSize(const struct RecordObject *); -intmax_t GetTime(const struct RecordObject *); -const char *GetPath(const struct RecordObject *); -const char *GetTarget(const struct RecordObject *); -uintmax_t GetFingerPrint(const struct RecordObject *); -int Release(struct RecordObject *); +int RecordObjectCompare(struct RecordObject *, struct RecordObject *); +char RecordObjectFileType(const struct RecordObject *); +unsigned int RecordObjectPermissions(const struct RecordObject *); +uintmax_t RecordObjectUid(const struct RecordObject *); +uintmax_t RecordObjectGid(const struct RecordObject *); +intmax_t RecordObjectSize(const struct RecordObject *); +intmax_t RecordObjectTime(const struct RecordObject *); +const char *RecordObjectPath(const struct RecordObject *); +const char *RecordObjectTarget(const struct RecordObject *); +uintmax_t RecordObjectFingerPrint(const struct RecordObject *); +int RecordObjectRelease(struct RecordObject *); #endif diff --git a/src/create.c b/src/create.c index b3f3f79..c58e373 100644 --- a/src/create.c +++ b/src/create.c @@ -25,7 +25,7 @@ static int write_record(const char *path, void *context) { if (r == NULL) return -1; int ret = RecordObjectWrite(r, path, (FILE *)context); - Release(r); + RecordObjectRelease(r); return ret < 0 ? -1 : 0; } diff --git a/src/diff.c b/src/diff.c index 970aa22..22eddcb 100644 --- a/src/diff.c +++ b/src/diff.c @@ -37,10 +37,10 @@ static int load_in_memory(const char *file, struct RecordObject ***records, goto failure; } - int ret = Unpack(objp, buf); + int ret = RecordObjectUnpack(objp, buf); if (ret == -1) { errno = EINVAL; - Release(objp); + RecordObjectRelease(objp); goto failure; } @@ -70,7 +70,7 @@ failure: static int dealloc(struct RecordObject **records, int size) { for (int j = 0; j < size; j++) { - Release(records[j]); + RecordObjectRelease(records[j]); records[j] = NULL; } free(records); @@ -80,7 +80,7 @@ static int dealloc(struct RecordObject **records, int size) { static int order_by_path(const void *o1, const void *o2) { const struct RecordObject *r1 = *(const struct RecordObject *const *)o1; const struct RecordObject *r2 = *(const struct RecordObject *const *)o2; - return strcmp(GetPath(r1), GetPath(r2)); + return strcmp(RecordObjectPath(r1), RecordObjectPath(r2)); } int diff(const char *file1, const char *file2) { @@ -116,16 +116,16 @@ int diff(const char *file1, const char *file2) { char code = 0; const char *path = NULL; - int c = strcmp(GetPath(r1), GetPath(r2)); + int c = strcmp(RecordObjectPath(r1), RecordObjectPath(r2)); if (c < 0) { code = 'D'; - path = GetPath(r1); + path = RecordObjectPath(r1); m++; } else if (c > 0) { code = 'A'; - path = GetPath(r2); + path = RecordObjectPath(r2); n++; - } else if (Compare(r1, r2) != 0) { + } else if (RecordObjectCompare(r1, r2) != 0) { switch (field) { case TARGET: code = 'L'; @@ -137,7 +137,7 @@ int diff(const char *file1, const char *file2) { code = 'M'; break; } - path = GetPath(r1); + path = RecordObjectPath(r1); m++; n++; } else { @@ -152,13 +152,13 @@ int diff(const char *file1, const char *file2) { while (m < len1) { const struct RecordObject *r = records1[m]; - fprintf(stdout, "D\t%s\n", GetPath(r)); + fprintf(stdout, "D\t%s\n", RecordObjectPath(r)); m++; } while (n < len2) { const struct RecordObject *r = records2[n]; - fprintf(stdout, "A\t%s\n", GetPath(r)); + fprintf(stdout, "A\t%s\n", RecordObjectPath(r)); n++; } diff --git a/src/list.c b/src/list.c index 39702c4..22de0d2 100644 --- a/src/list.c +++ b/src/list.c @@ -38,17 +38,17 @@ int list(const char *snapshot) { rc = -1; goto out; } - int ret = Unpack(objp, buf); + int ret = RecordObjectUnpack(objp, buf); if (field != NONE) { fprintf(stderr, "%s:%d: invalid %s\n", snapshot, i + 1, FieldName(field)); rc = 128; - Release(objp); + RecordObjectRelease(objp); break; } if (ret == -1) { fprintf(stderr, "%s:%d: unparsable line\n", snapshot, i + 1); - Release(objp); + RecordObjectRelease(objp); rc = 128; break; } @@ -74,7 +74,7 @@ out:; free(buf); if (records != NULL) { for (int j = 0; j < arr_size; j++) { - Release(records[j]); + RecordObjectRelease(records[j]); records[j] = NULL; } free(records); diff --git a/src/types.c b/src/types.c index b36bc90..8dca42c 100644 --- a/src/types.c +++ b/src/types.c @@ -255,7 +255,7 @@ struct RecordObject *NewRecordObject() { return ret; } -int Unpack(struct RecordObject *self, char *s) { +int RecordObjectUnpack(struct RecordObject *self, char *s) { char *fields[NFIELDS]; if (split_record(s, fields, '|') == -1) return -1; @@ -329,7 +329,7 @@ int Unpack(struct RecordObject *self, char *s) { return 0; } -int Compare(struct RecordObject *self, struct RecordObject *other) { +int RecordObjectCompare(struct RecordObject *self, struct RecordObject *other) { field = NONE; if (self == NULL) @@ -433,7 +433,7 @@ int RecordObjectWrite(struct RecordObject *self, const char *path, FILE *out) { self->path); } -int Release(struct RecordObject *self) { +int RecordObjectRelease(struct RecordObject *self) { if (self == NULL) return -1; if (self->path != NULL) { @@ -449,16 +449,22 @@ int Release(struct RecordObject *self) { } // Accessors -char GetFileType(const struct RecordObject *self) { return self->file_type; } -unsigned int GetPermissions(const struct RecordObject *self) { +char RecordObjectFileType(const struct RecordObject *self) { + return self->file_type; +} +unsigned int RecordObjectPermissions(const struct RecordObject *self) { return self->perm; } -uintmax_t GetUid(const struct RecordObject *self) { return self->uid; } -uintmax_t GetGid(const struct RecordObject *self) { return self->gid; } -intmax_t GetSize(const struct RecordObject *self) { return self->size; } -intmax_t GetTime(const struct RecordObject *self) { return self->time; } -const char *GetPath(const struct RecordObject *self) { return self->path; } -const char *GetTarget(const struct RecordObject *self) { return self->target; } -uintmax_t GetFingerPrint(const struct RecordObject *self) { +uintmax_t RecordObjectUid(const struct RecordObject *self) { return self->uid; } +uintmax_t RecordObjectGid(const struct RecordObject *self) { return self->gid; } +intmax_t RecordObjectSize(const struct RecordObject *self) { return self->size; } +intmax_t RecordObjectTime(const struct RecordObject *self) { return self->time; } +const char *RecordObjectPath(const struct RecordObject *self) { + return self->path; +} +const char *RecordObjectTarget(const struct RecordObject *self) { + return self->target; +} +uintmax_t RecordObjectFingerPrint(const struct RecordObject *self) { return self->fingerprint; }