4 Copyright (C) 2006-2009 Jonathan Zarate
20 const char *find_word(const char *buffer
, const char *word
)
27 while ((p
= strstr(p
, word
)) != NULL
) {
28 if ((p
== buffer
) || (*(p
- 1) == ' ') || (*(p
- 1) == ',')) {
30 if ((*q
== ' ') || (*q
== ',') || (*q
== 0)) {
40 static void add_word(char *buffer, const char *word, int max)
42 if ((*buffer != 0) && (buffer[strlen(buffer) - 1] != ' '))
43 strlcat(buffer, " ", max);
44 strlcat(buffer, word, max);
48 int remove_word(char *buffer
, const char *word
)
53 if ((p
= strstr(buffer
, word
)) == NULL
) return 0;
56 while (*p
== ' ') ++p
;
57 while ((q
> buffer
) && (*(q
- 1) == ' ')) --q
;
58 if (*q
!= 0) *q
++ = ' ';