feat(core): remove tanzaku alias field
This commit is contained in:
parent
68c17f0785
commit
91a53fa703
@ -28,7 +28,6 @@ typedef struct tanzaku {
|
|||||||
uint64_t created_ts; // Tanzaku creation timestamp
|
uint64_t created_ts; // Tanzaku creation timestamp
|
||||||
uint64_t modified_ts; // Tanzaku last modification timestamp
|
uint64_t modified_ts; // Tanzaku last modification timestamp
|
||||||
char *name; // Tanzaku name
|
char *name; // Tanzaku name
|
||||||
char *alias; // Tanzaku alias
|
|
||||||
char *description; // Tanzaku description
|
char *description; // Tanzaku description
|
||||||
} Tanzaku;
|
} Tanzaku;
|
||||||
|
|
||||||
@ -133,7 +132,7 @@ int sappyou_open(Sappyou *sappyou, const char *path);
|
|||||||
int sappyou_dump(Sappyou *sappyou, const char *path);
|
int sappyou_dump(Sappyou *sappyou, const char *path);
|
||||||
|
|
||||||
// Add new tanzaku to sappyou
|
// Add new tanzaku to sappyou
|
||||||
int tanzaku_add(Sappyou *sappyou, const char *name, const char *alias, const char *description);
|
int tanzaku_add(Sappyou *sappyou, const char *name, const char *description);
|
||||||
|
|
||||||
// Remove tanzaku from sappyou
|
// Remove tanzaku from sappyou
|
||||||
int tanzaku_rem(Sappyou *sappyou, uint64_t tanzaku_id);
|
int tanzaku_rem(Sappyou *sappyou, uint64_t tanzaku_id);
|
||||||
|
|||||||
@ -21,7 +21,6 @@ int sappyou_init(Sappyou *sappyou) {
|
|||||||
int sappyou_free(Sappyou *sappyou) {
|
int sappyou_free(Sappyou *sappyou) {
|
||||||
for (uint64_t i = 0; i < sappyou->size; i++) {
|
for (uint64_t i = 0; i < sappyou->size; i++) {
|
||||||
free(sappyou->database[i].name);
|
free(sappyou->database[i].name);
|
||||||
free(sappyou->database[i].alias);
|
|
||||||
free(sappyou->database[i].description);
|
free(sappyou->database[i].description);
|
||||||
}
|
}
|
||||||
free(sappyou->database);
|
free(sappyou->database);
|
||||||
@ -56,7 +55,6 @@ int sappyou_load(Sappyou *sappyou) {
|
|||||||
fread(&sappyou->database[i].created_ts, 8, 1, sappyou->file);
|
fread(&sappyou->database[i].created_ts, 8, 1, sappyou->file);
|
||||||
fread(&sappyou->database[i].modified_ts, 8, 1, sappyou->file);
|
fread(&sappyou->database[i].modified_ts, 8, 1, sappyou->file);
|
||||||
getdelim(&sappyou->database[i].name, &max_string_len, 0, sappyou->file);
|
getdelim(&sappyou->database[i].name, &max_string_len, 0, sappyou->file);
|
||||||
getdelim(&sappyou->database[i].alias, &max_string_len, 0, sappyou->file);
|
|
||||||
getdelim(&sappyou->database[i].description, &max_string_len, 0, sappyou->file);
|
getdelim(&sappyou->database[i].description, &max_string_len, 0, sappyou->file);
|
||||||
} else {
|
} else {
|
||||||
sappyou->database[i].id = HOLE_ID;
|
sappyou->database[i].id = HOLE_ID;
|
||||||
@ -86,8 +84,6 @@ int sappyou_save(Sappyou *sappyou) {
|
|||||||
fwrite(&sappyou->database[i].modified_ts, 8, 1, sappyou->file);
|
fwrite(&sappyou->database[i].modified_ts, 8, 1, sappyou->file);
|
||||||
fputs(sappyou->database[i].name, sappyou->file);
|
fputs(sappyou->database[i].name, sappyou->file);
|
||||||
fputc(0, sappyou->file);
|
fputc(0, sappyou->file);
|
||||||
fputs(sappyou->database[i].alias, sappyou->file);
|
|
||||||
fputc(0, sappyou->file);
|
|
||||||
fputs(sappyou->database[i].description, sappyou->file);
|
fputs(sappyou->database[i].description, sappyou->file);
|
||||||
fputc(0, sappyou->file);
|
fputc(0, sappyou->file);
|
||||||
} else {
|
} else {
|
||||||
@ -116,7 +112,7 @@ int sappyou_dump(Sappyou *sappyou, const char *path) {
|
|||||||
return sappyou_save(sappyou);
|
return sappyou_save(sappyou);
|
||||||
}
|
}
|
||||||
|
|
||||||
int tanzaku_add(Sappyou *sappyou, const char *name, const char *alias, const char *description) {
|
int tanzaku_add(Sappyou *sappyou, const char *name, const char *description) {
|
||||||
if (sappyou->size == -1 && sappyou->hole_cnt == 0) {
|
if (sappyou->size == -1 && sappyou->hole_cnt == 0) {
|
||||||
fprintf(stderr, "Failed to add tanzaku: sappyou is full\n");
|
fprintf(stderr, "Failed to add tanzaku: sappyou is full\n");
|
||||||
return 1;
|
return 1;
|
||||||
@ -125,14 +121,10 @@ int tanzaku_add(Sappyou *sappyou, const char *name, const char *alias, const cha
|
|||||||
newbie.created_ts = time(NULL);
|
newbie.created_ts = time(NULL);
|
||||||
newbie.modified_ts = newbie.created_ts;
|
newbie.modified_ts = newbie.created_ts;
|
||||||
size_t name_size = strlen(name),
|
size_t name_size = strlen(name),
|
||||||
alias_size = strlen(alias),
|
|
||||||
description_size = strlen(description);
|
description_size = strlen(description);
|
||||||
newbie.name = malloc(name_size + 1);
|
newbie.name = malloc(name_size + 1);
|
||||||
strcpy(newbie.name, name);
|
strcpy(newbie.name, name);
|
||||||
newbie.name[name_size] = 0;
|
newbie.name[name_size] = 0;
|
||||||
newbie.alias = malloc(alias_size + 1);
|
|
||||||
strcpy(newbie.alias, alias);
|
|
||||||
newbie.alias[alias_size] = 0;
|
|
||||||
newbie.description = malloc(description_size + 1);
|
newbie.description = malloc(description_size + 1);
|
||||||
strcpy(newbie.description, description);
|
strcpy(newbie.description, description);
|
||||||
newbie.description[description_size] = 0;
|
newbie.description[description_size] = 0;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user