mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-22 21:35:04 +00:00
New function dequeue().
This commit is contained in:
parent
e923a4f5ec
commit
922b04b4d7
3 changed files with 25 additions and 1 deletions
20
data.c
20
data.c
|
@ -587,3 +587,23 @@ d_char *queue(snac *snac)
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
d_char *dequeue(snac *snac, char *fn)
|
||||||
|
/* dequeues a message */
|
||||||
|
{
|
||||||
|
FILE *f;
|
||||||
|
d_char *obj = NULL;
|
||||||
|
|
||||||
|
if ((f = fopen(fn, "r")) != NULL) {
|
||||||
|
/* delete right now */
|
||||||
|
unlink(fn);
|
||||||
|
|
||||||
|
xs *j = xs_readall(f);
|
||||||
|
obj = xs_json_loads(j);
|
||||||
|
|
||||||
|
fclose(f);
|
||||||
|
}
|
||||||
|
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
5
main.c
5
main.c
|
@ -21,7 +21,10 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
p = list;
|
p = list;
|
||||||
while (xs_list_iter(&p, &fn)) {
|
while (xs_list_iter(&p, &fn)) {
|
||||||
printf("%s\n", fn);
|
xs *obj;
|
||||||
|
|
||||||
|
obj = dequeue(&snac, fn);
|
||||||
|
printf("%s\n", xs_dict_get(obj, "actor"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
1
snac.h
1
snac.h
|
@ -60,3 +60,4 @@ int is_muted(snac *snac, char *actor);
|
||||||
|
|
||||||
void enqueue(snac *snac, char *actor, char *msg, int retries);
|
void enqueue(snac *snac, char *actor, char *msg, int retries);
|
||||||
d_char *queue(snac *snac);
|
d_char *queue(snac *snac);
|
||||||
|
d_char *dequeue(snac *snac, char *fn);
|
||||||
|
|
Loading…
Reference in a new issue