1
0
mirror of https://github.com/Tha14/toxic.git synced 2025-06-29 06:56:44 +02:00

put string helpers in own file

This commit is contained in:
Jfreegman
2013-12-10 03:03:45 -05:00
parent 44d9f7fe61
commit ccc0640dab
7 changed files with 205 additions and 199 deletions

View File

@ -43,35 +43,3 @@ int qsort_strcasecmp_hlpr(const void *nick1, const void *nick2);
- cannot start with a space
- must not contain contiguous spaces */
bool valid_nick(uint8_t *nick);
/*
* Buffer helper tools.
*/
/* Adds char to buffer at pos */
void add_char_to_buf(wchar_t *buf, size_t *pos, size_t *len, wint_t ch);
/* Deletes the character before pos */
void del_char_buf_bck(wchar_t *buf, size_t *pos, size_t *len);
/* Deletes the character at pos */
void del_char_buf_frnt(wchar_t *buf, size_t *pos, size_t *len);
/* Deletes the line from beginning to pos */
void discard_buf(wchar_t *buf, size_t *pos, size_t *len);
/* Deletes the line from pos to len */
void kill_buf(wchar_t *buf, size_t *pos, size_t *len);
/* nulls buf and sets pos and len to 0 */
void reset_buf(wchar_t *buf, size_t *pos, size_t *len);
/* looks for the first instance in list that begins with the last entered word in buf according to pos,
then fills buf with the complete word. e.g. "Hello jo" would complete the buffer
with "Hello john".
list is a pointer to the list of strings being compared, n_items is the number of items
in the list, and size is the size of each item in the list.
Returns the difference between the old len and new len of buf on success, -1 if error */
int complete_line(wchar_t *buf, size_t *pos, size_t *len, const void *list, int n_items, int size);