]>
jfr.im git - irc/quakenet/newserv.git/blob - helpmod2/helpmod_alias.c
1 #include "helpmod_alias.h"
5 int helpmod_alias_count(alias_tree node
)
10 return 1 + helpmod_alias_count(node
->left
) + helpmod_alias_count(node
->right
);
13 void helpmod_init_alias(alias_tree
* node
)
15 *node
= (alias_tree
)malloc(sizeof(struct alias_tree_struct
));
17 (*node
)->right
= NULL
;
19 (*node
)->state
= NULL
;
21 void helpmod_clear_aliases(alias_tree
* node
)
25 helpmod_clear_aliases(&(*node
)->left
);
26 helpmod_clear_aliases(&(*node
)->right
);
27 freesstring((*node
)->name
);
31 helpmod_entry
helpmod_get_alias(char* search
)
34 alias_tree tmp
= aliases
;
37 val
= ci_strcmp(tmp
->name
->content
, search
);
48 void helpmod_add_alias(char* name
, helpmod_entry state
)
51 alias_tree
* tmp
= &aliases
;
54 val
= strcmp((*tmp
)->name
->content
, name
);
56 return; /* duplicate, let's not do anything, silly person to create duplicates in the file.. */
62 helpmod_init_alias(tmp
);
63 (*tmp
)->state
= state
;
64 (*tmp
)->name
= getsstring(name
,strlen(name
));
65 for (val
=0;val
< strlen(name
);val
++)
66 if (isspace((*tmp
)->name
->content
[val
]))
68 (*tmp
)->name
->content
[val
] = 0x00;