+struct suggestions* client_suggestions_create(const char* suggestions_string) {
+ if (suggestions_string == 0)
+ return 0;
+ int i;
+ NMEM nmem = nmem_create();
+ struct suggestions *suggestions = nmem_malloc(nmem, sizeof(*suggestions));
+ suggestions->nmem = nmem;
+ suggestions->num = 0;
+ suggestions->misspelled = 0;
+ suggestions->suggest = 0;
+ if (suggestions_string)
+ nmem_strsplit_escape2(suggestions->nmem, "\n", suggestions_string, &suggestions->suggest,
+ &suggestions->num, 1, '\\', 0);
+ /* Set up misspelled array */
+ suggestions->misspelled = (char **) nmem_malloc(nmem, suggestions->num * sizeof(**suggestions->misspelled));
+ /* replace = with \0 .. for each item */
+ for (i = 0; i < suggestions->num; i++)
+ {
+ char *cp = strchr(suggestions->suggest[i], '=');
+ if (cp) {
+ *cp = '\0';
+ suggestions->misspelled[i] = cp+1;
+ }
+ }
+ return suggestions;
+}
+
+static void client_suggestions_destroy(struct client *cl)
+{
+ nmem_destroy(cl->suggestions->nmem);
+ cl->suggestions = 0;
+}
+