diff options
-rw-r--r-- | include/proto.h | 2 | ||||
-rw-r--r-- | mbbsd/name.c | 25 |
2 files changed, 27 insertions, 0 deletions
diff --git a/include/proto.h b/include/proto.h index a38579fd..eb303221 100644 --- a/include/proto.h +++ b/include/proto.h @@ -429,6 +429,8 @@ typedef int (*gnc_perm_func)(int); typedef char* (*gnc_getname_func)(int); extern void namecomplete2(struct Vector *namelist, const char *prompt, char *data); +extern void ShowVector(struct Vector *self, int row, int column, const char *prompt); +extern void ToggleVector(struct Vector *list, int *recipient, const char *listfile, const char *msg); void usercomplete(const char *prompt, char *data); void namecomplete(const char *prompt, char *data); diff --git a/mbbsd/name.c b/mbbsd/name.c index 064985c9..fd5a1976 100644 --- a/mbbsd/name.c +++ b/mbbsd/name.c @@ -209,6 +209,31 @@ ShowNameList(int row, int column, const char *prompt) } void +ToggleVector(struct Vector *list, int *recipient, const char *listfile, const char *msg) +{ + FILE *fp; + char genbuf[STRLEN]; + + if ((fp = fopen(listfile, "r"))) { + while (fgets(genbuf, sizeof(genbuf), fp)) { + char *space = strpbrk(genbuf, str_space); + if (space) *space = '\0'; + if (!genbuf[0]) + continue; + if (!Vector_search(list, genbuf)) { + Vector_add(list, genbuf); + (*recipient)++; + } else { + Vector_remove(list, genbuf); + (*recipient)--; + } + } + fclose(fp); + ShowVector(list, 3, 0, msg); + } +} + +void ToggleNameList(int *reciper, const char *listfile, const char *msg) { FILE *fp; |