feat(core): leave remove functions only by ID
This commit is contained in:
parent
cd9dddc6cd
commit
1f454f6770
@ -109,11 +109,8 @@ int sasahyou_dump(Sasahyou *sasahyou, const char *path);
|
|||||||
// Add sasa to sasahyou
|
// Add sasa to sasahyou
|
||||||
int sasa_add(Sasahyou *sasahyou, const char *path);
|
int sasa_add(Sasahyou *sasahyou, const char *path);
|
||||||
|
|
||||||
// Remove sasa from sasahyou by ID
|
// Remove sasa from sasahyou
|
||||||
int sasa_rem_by_id(Sasahyou *sasahyou, uint64_t sasa_id);
|
int sasa_rem(Sasahyou *sasahyou, uint64_t sasa_id);
|
||||||
|
|
||||||
// Remove sasa from sasahyou by file path
|
|
||||||
int sasa_rem_by_path(Sasahyou *sasahyou, const char *path);
|
|
||||||
|
|
||||||
// ==================== SAPPYOU SECTION ==================== //
|
// ==================== SAPPYOU SECTION ==================== //
|
||||||
|
|
||||||
@ -138,14 +135,8 @@ 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 *alias, const char *description);
|
||||||
|
|
||||||
// Remove tanzaku from sappyou by ID
|
// Remove tanzaku from sappyou
|
||||||
int tanzaku_rem_by_id(Sappyou *sappyou, uint64_t tanzaku_id);
|
int tanzaku_rem(Sappyou *sappyou, uint64_t tanzaku_id);
|
||||||
|
|
||||||
// Remove tanzaku from sappyou by name
|
|
||||||
int tanzaku_rem_by_name(Sappyou *sappyou, const char *name);
|
|
||||||
|
|
||||||
// Remove tanzaku from sappyou by alias
|
|
||||||
int tanzaku_rem_by_alias(Sappyou *sappyou, const char *alias);
|
|
||||||
|
|
||||||
// ==================== SHOPPYOU SECTION ==================== //
|
// ==================== SHOPPYOU SECTION ==================== //
|
||||||
|
|
||||||
|
|||||||
@ -152,7 +152,7 @@ int tanzaku_add(Sappyou *sappyou, const char *name, const char *alias, const cha
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int tanzaku_rem_by_id(Sappyou *sappyou, uint64_t tanzaku_id) {
|
int tanzaku_rem(Sappyou *sappyou, uint64_t tanzaku_id) {
|
||||||
if (tanzaku_id == HOLE_ID) {
|
if (tanzaku_id == HOLE_ID) {
|
||||||
fprintf(stderr, "Failed to remove tanzaku: got hole ID\n");
|
fprintf(stderr, "Failed to remove tanzaku: got hole ID\n");
|
||||||
return 1;
|
return 1;
|
||||||
@ -172,43 +172,3 @@ int tanzaku_rem_by_id(Sappyou *sappyou, uint64_t tanzaku_id) {
|
|||||||
sappyou->modified_ts = time(NULL);
|
sappyou->modified_ts = time(NULL);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int tanzaku_rem_by_name(Sappyou *sappyou, const char *name) {
|
|
||||||
for (uint64_t i = 0; i < sappyou->size; i++) {
|
|
||||||
if (strcmp(sappyou->database[i].name, name) == 0) {
|
|
||||||
if (sappyou->database[i].id != HOLE_ID) {
|
|
||||||
sappyou->database[i].id = HOLE_ID;
|
|
||||||
sappyou->hole_cnt++;
|
|
||||||
sappyou->holes = realloc(sappyou->holes, sappyou->hole_cnt * sizeof(Tanzaku *));
|
|
||||||
sappyou->holes[sappyou->hole_cnt - 1] = sappyou->database + i;
|
|
||||||
sappyou->modified_ts = time(NULL);
|
|
||||||
return 0;
|
|
||||||
} else {
|
|
||||||
fprintf(stderr, "Failed to remove tanzaku: target tanzaku is already removed\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fprintf(stderr, "Failed to remove tanzaku: target tanzaku does not exist\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int tanzaku_rem_by_alias(Sappyou *sappyou, const char *alias) {
|
|
||||||
for (uint64_t i = 0; i < sappyou->size; i++) {
|
|
||||||
if (strcmp(sappyou->database[i].alias, alias) == 0) {
|
|
||||||
if (sappyou->database[i].id != HOLE_ID) {
|
|
||||||
sappyou->database[i].id = HOLE_ID;
|
|
||||||
sappyou->hole_cnt++;
|
|
||||||
sappyou->holes = realloc(sappyou->holes, sappyou->hole_cnt * sizeof(Tanzaku *));
|
|
||||||
sappyou->holes[sappyou->hole_cnt - 1] = sappyou->database + i;
|
|
||||||
sappyou->modified_ts = time(NULL);
|
|
||||||
return 0;
|
|
||||||
} else {
|
|
||||||
fprintf(stderr, "Failed to remove tanzaku: target tanzaku is already removed\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fprintf(stderr, "Failed to remove tanzaku: target tanzaku does not exist\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|||||||
@ -135,7 +135,7 @@ int sasa_add(Sasahyou *sasahyou, const char *path) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int sasa_rem_by_id(Sasahyou *sasahyou, uint64_t sasa_id) {
|
int sasa_rem(Sasahyou *sasahyou, uint64_t sasa_id) {
|
||||||
if (sasa_id == HOLE_ID) {
|
if (sasa_id == HOLE_ID) {
|
||||||
fprintf(stderr, "Failed to remove sasa: got hole ID\n");
|
fprintf(stderr, "Failed to remove sasa: got hole ID\n");
|
||||||
return 1;
|
return 1;
|
||||||
@ -155,23 +155,3 @@ int sasa_rem_by_id(Sasahyou *sasahyou, uint64_t sasa_id) {
|
|||||||
sasahyou->modified_ts = time(NULL);
|
sasahyou->modified_ts = time(NULL);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int sasa_rem_by_path(Sasahyou *sasahyou, const char *path) {
|
|
||||||
for (uint64_t i = 0; i < sasahyou->size; i++) {
|
|
||||||
if (strcmp(sasahyou->database[i].path, path) == 0) {
|
|
||||||
if (sasahyou->database[i].id != HOLE_ID) {
|
|
||||||
sasahyou->database[i].id = HOLE_ID;
|
|
||||||
sasahyou->hole_cnt++;
|
|
||||||
sasahyou->holes = realloc(sasahyou->holes, sasahyou->hole_cnt * sizeof(Sasa *));
|
|
||||||
sasahyou->holes[sasahyou->hole_cnt - 1] = sasahyou->database + i;
|
|
||||||
sasahyou->modified_ts = time(NULL);
|
|
||||||
return 0;
|
|
||||||
} else {
|
|
||||||
fprintf(stderr, "Failed to remove sasa: target sasa is already removed\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fprintf(stderr, "Failed to remove sasa: target sasa does not exist\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user