feat(core,lib): return new tanzaku when adding tanzaku or HOLE_TANZAKU on failure
This commit is contained in:
parent
d8de645780
commit
24c9e39084
@ -54,7 +54,7 @@ Sasa tanabata_sasa_get(Tanabata *tanabata, uint64_t sasa_id);
|
||||
// ==================== TANZAKU SECTION ==================== //
|
||||
|
||||
// Add tanzaku
|
||||
int tanabata_tanzaku_add(Tanabata *tanabata, const char *name, const char *description);
|
||||
Tanzaku tanabata_tanzaku_add(Tanabata *tanabata, const char *name, const char *description);
|
||||
|
||||
// Remove tanzaku by ID
|
||||
int tanabata_tanzaku_rem(Tanabata *tanabata, uint64_t tanzaku_id);
|
||||
|
||||
@ -64,7 +64,7 @@ int sappyou_open(Sappyou *sappyou, const char *path);
|
||||
int sappyou_dump(Sappyou *sappyou, const char *path);
|
||||
|
||||
// Add new tanzaku to sappyou
|
||||
int tanzaku_add(Sappyou *sappyou, const char *name, const char *description);
|
||||
Tanzaku tanzaku_add(Sappyou *sappyou, const char *name, const char *description);
|
||||
|
||||
// Remove tanzaku from sappyou
|
||||
int tanzaku_rem(Sappyou *sappyou, uint64_t tanzaku_id);
|
||||
|
||||
@ -150,9 +150,9 @@ int sappyou_dump(Sappyou *sappyou, const char *path) {
|
||||
return sappyou_save(sappyou);
|
||||
}
|
||||
|
||||
int tanzaku_add(Sappyou *sappyou, const char *name, const char *description) {
|
||||
Tanzaku tanzaku_add(Sappyou *sappyou, const char *name, const char *description) {
|
||||
if (name == NULL || description == NULL || sappyou->size == -1 && sappyou->hole_cnt == 0) {
|
||||
return 1;
|
||||
return HOLE_TANZAKU;
|
||||
}
|
||||
Tanzaku newbie;
|
||||
newbie.created_ts = time(NULL);
|
||||
@ -174,7 +174,7 @@ int tanzaku_add(Sappyou *sappyou, const char *name, const char *description) {
|
||||
sappyou->database[newbie.id] = newbie;
|
||||
}
|
||||
sappyou->modified_ts = newbie.created_ts;
|
||||
return 0;
|
||||
return newbie;
|
||||
}
|
||||
|
||||
int tanzaku_rem(Sappyou *sappyou, uint64_t tanzaku_id) {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
#include "../core/core_func.h"
|
||||
#include "../../include/tanabata.h"
|
||||
|
||||
int tanabata_tanzaku_add(Tanabata *tanabata, const char *name, const char *description) {
|
||||
Tanzaku tanabata_tanzaku_add(Tanabata *tanabata, const char *name, const char *description) {
|
||||
return tanzaku_add(&tanabata->sappyou, name, description);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user