2 * wordlist.c - Routines for manipulating word lists
4 * Jonathan McDowell <noodles@earth.li>
6 * Copyright 2004 Project Purple
8 * $Id: wordlist.c,v 1.1 2004/05/27 03:34:35 noodles Exp $
16 #include "decodekey.h"
21 * makewordlist - Takes a string and splits it into a set of unique words.
22 * @wordlist: The current word list.
23 * @words: The string to split and add.
25 * We take words and split it on non alpha numeric characters. These get
26 * added to the word list if they're not already present. If the wordlist
27 * is NULL then we start a new list, otherwise it's search for already
28 * added words. Note that words is modified in the process of scanning.
30 * Returns the new word list.
32 struct ll *makewordlist(struct ll *wordlist, char *word)
38 * Walk through the words string, spliting on non alphanumerics and
39 * then checking if the word already exists in the list. If not then
43 while (end != NULL && *end != 0) {
45 while (*start != 0 && !isalnum(*start)) {
49 while (*end != 0 && isalnum(*end)) {
53 if (end - start > 1) {
59 if (llfind(wordlist, start, strcmp) == NULL) {
60 wordlist = lladd(wordlist, start);
68 * makewordlistfromkey - Takes a public key and splits it into a set of
70 * @wordlist: The current word list.
71 * @key: The key to return the words from.
73 * We take words and split it on non alpha numeric characters. These get
74 * added to the word list if they're not already present. If the wordlist
75 * is NULL then we start a new list, otherwise it's search for already
76 * added words. Note that words is modified in the process of scanning.
78 * Returns the new word list.
80 struct ll *makewordlistfromkey(struct ll *wordlist,
81 struct openpgp_publickey *key)
86 uids = keyuids(key, NULL);
87 for (i = 0; uids[i] != NULL; ++i) {
88 wordlist = makewordlist(wordlist, uids[i]);