]>
jfr.im git - irc/quakenet/newserv.git/blob - helpmod2/hterm.c
5 #include "../lib/sstring.h"
11 hterm
*hterm_add(hterm
** ptr
, const char *name
, const char *desc
)
18 if (name
== NULL
|| desc
== NULL
|| hterm_get(*ptr
, name
))
21 htrm
= (hterm
*)malloc(sizeof(htrm
));
22 htrm
->name
= getsstring(name
, strlen(name
));
23 htrm
->description
= getsstring(desc
, strlen(desc
));
31 hterm
*hterm_get(hterm
*source
, const char *str
)
38 for (;ptr
;ptr
= ptr
->next
)
39 if (!ci_strcmp(ptr
->name
->content
, str
))
42 return hterm_get(NULL
, str
);
47 hterm
*hterm_find(hterm
*source
, const char *str
)
55 sprintf(buffer
, "*%s*", str
);
57 for (ptr
= source
;ptr
;ptr
= ptr
->next
)
58 if (strregexp(ptr
->name
->content
, buffer
))
60 for (ptr
= source
;ptr
;ptr
= ptr
->next
)
61 if (strregexp(ptr
->description
->content
, buffer
))
64 return hterm_find(NULL
, str
);
69 hterm
*hterm_get_and_find(hterm
*source
, const char *str
)
71 /*hterm *ptr = hterm_get(source, str);
73 ptr = hterm_find(source, str);
75 /* search order: get source, get NULL, find source, find NULL */
77 ptr
= hterm_get(source
, str
);
80 ptr
= hterm_get(NULL
, str
);
83 ptr
= hterm_find(source
, str
);
86 ptr
= hterm_find(NULL
, str
);
90 hterm
*hterm_del(hterm
** start
, hterm
*htrm
)
97 for (;*ptr
;ptr
= &(*ptr
)->next
)
100 hterm
*tmp
= (*ptr
)->next
;
101 freesstring((*ptr
)->name
);
102 freesstring((*ptr
)->description
);
110 return hterm_del(NULL
, htrm
);
115 void hterm_del_all(hterm
**source
)
121 hterm_del(source
, *source
);
124 int hterm_count(hterm
* ptr
)
127 for (;ptr
;ptr
= ptr
->next
)