23 #define CHALIAS_FILE NMSG_ETCDIR "/nmsg.chalias"
24 #define CHALIAS_FILE2 NMSG_ETCDIR "/nmsgtool.chalias"
26 #define MAX_LINE_SZ 1024
40 fp = fopen(CHALIAS_FILE,
"r");
42 fp = fopen(CHALIAS_FILE2,
"r");
47 while (fgets(line,
sizeof(line), fp) != NULL) {
48 tmp = strtok_r(line,
" \t", &saveptr);
49 if (tmp != NULL && strcmp(tmp, ch) == 0) {
50 while ((tmp = strtok_r(NULL,
" \t\n", &saveptr))
54 *alias = realloc(*alias,
55 sizeof(*alias) * num_aliases);
56 (*alias)[num_aliases - 1] = strdup(tmp);
64 *alias = realloc(*alias,
sizeof(*alias) * (num_aliases + 1));
65 (*alias)[num_aliases] = NULL;
72 for (
char **a = *alias; *a != NULL; a++)
void nmsg_chalias_free(char ***alias)
Free the memory allocated by nmsg_chalias_lookup().
int nmsg_chalias_lookup(const char *ch, char ***alias)
Lookup a channel alias.