mirror of
https://github.com/fscotto/fsnap.git
synced 2026-11-26 03:09:51 +00:00
Apply RecordObject namespace to all methods
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
22
src/diff.c
22
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++;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
30
src/types.c
30
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user