]>
jfr.im git - irc/quakenet/newserv.git/blob - helpmod2/htopic.c
5 #include "../lib/sstring.h"
9 htopic
*htopic_add(htopic
** htop
, const char* entry
, int pos
)
13 for (;*htop
&& pos
;htop
= &(*htop
)->next
, pos
--);
17 *htop
= malloc(sizeof(htopic
));
18 (*htop
)->entry
= getsstring(entry
, strlen(entry
));
24 htopic
*htopic_del(htopic
** htop
, htopic
* target
)
27 for (;*htop
;htop
= &(*htop
)->next
)
33 freesstring((*htop
)->entry
);
41 void htopic_del_all(htopic
** htop
)
44 htopic_del(htop
, *htop
);
47 htopic
*htopic_get(htopic
*htop
, int pos
)
49 for (;htop
&& pos
;htop
= htop
->next
,pos
--);
53 const char *htopic_construct(htopic
*htop
)
55 static char buffer
[512] = "";
59 for (;htop
;htop
= htop
->next
)
61 strcat(buffer
, htop
->entry
->content
);
63 strcat(buffer
, " | ");
68 int htopic_count(htopic
*htop
)
71 for (;htop
;htop
= htop
->next
)
76 int htopic_len(htopic
*htop
)
80 if (htopic_count(htop
))
81 len
+=(htopic_count(htop
) - 1) * 3;
82 for (;htop
;htop
= htop
->next
)
83 len
+=strlen(htop
->entry
->content
);