feat(core): add sasa and tanzaku update functions
This commit is contained in:
parent
90e5761d3e
commit
0b0bc93a8d
@ -168,3 +168,22 @@ int tanzaku_rem(Sappyou *sappyou, uint64_t tanzaku_id) {
|
||||
sappyou->modified_ts = time(NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int tanzaku_upd(Sappyou *sappyou, uint64_t tanzaku_id, const char *name, const char *description) {
|
||||
if (tanzaku_id == HOLE_ID || tanzaku_id >= sappyou->size) {
|
||||
return 1;
|
||||
}
|
||||
_Bool changed = 0;
|
||||
if (name != NULL) {
|
||||
strcpy(sappyou->database[tanzaku_id].name, name);
|
||||
changed = 1;
|
||||
}
|
||||
if (description != NULL) {
|
||||
strcpy(sappyou->database[tanzaku_id].description, description);
|
||||
changed = 1;
|
||||
}
|
||||
if (changed) {
|
||||
sappyou->modified_ts = time(NULL);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -163,3 +163,14 @@ int sasa_rem(Sasahyou *sasahyou, uint64_t sasa_id) {
|
||||
sasahyou->modified_ts = time(NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sasa_upd(Sasahyou *sasahyou, uint64_t sasa_id, const char *path) {
|
||||
if (sasa_id == HOLE_ID || sasa_id >= sasahyou->size) {
|
||||
return 1;
|
||||
}
|
||||
if (path != NULL) {
|
||||
strcpy(sasahyou->database[sasa_id].path, path);
|
||||
sasahyou->modified_ts = time(NULL);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -111,6 +111,9 @@ int sasa_add(Sasahyou *sasahyou, const char *path);
|
||||
// Remove sasa from sasahyou
|
||||
int sasa_rem(Sasahyou *sasahyou, uint64_t sasa_id);
|
||||
|
||||
// Update sasa file path
|
||||
int sasa_upd(Sasahyou *sasahyou, uint64_t sasa_id, const char *path);
|
||||
|
||||
// ==================== SAPPYOU SECTION ==================== //
|
||||
|
||||
// Initialize empty sappyou
|
||||
@ -137,6 +140,9 @@ int tanzaku_add(Sappyou *sappyou, const char *name, const char *description);
|
||||
// Remove tanzaku from sappyou
|
||||
int tanzaku_rem(Sappyou *sappyou, uint64_t tanzaku_id);
|
||||
|
||||
// Update tanzaku name and description
|
||||
int tanzaku_upd(Sappyou *sappyou, uint64_t tanzaku_id, const char *name, const char *description);
|
||||
|
||||
// ==================== SHOPPYOU SECTION ==================== //
|
||||
|
||||
// Initialize empty shoppyou
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user