-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathprocessing.h
157 lines (139 loc) · 3.84 KB
/
processing.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
/*
* processing.h
*
* Copyright 2012 Marc Sylvestre <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __PROCESSING_H__
#define __PROCESSING_H__
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include "config.h"
/* Structure to store information on file stream and size. */
struct filebuffer {
char *fbuffer;
long int fbsize;
};
/*
* Structure to store a list of words and the total number of words in
* the list.
*/
struct wordlist {
char **words;
size_t numwords;
size_t size;
};
/*
* Constant for wordlist types
*/
enum listtype { wordtype, phrasetype };
/*
* Covert all characters in string to lower case
* name: strToLowerCase
* @param string
* @return void
*/
void strToLowerCase(char*);
/*
* Returns a string containing no spaces
* name: stripSpace
* @param string
* @return string
*/
char *stripSpace(char*);
/*
* Returns string containing only alphabet characters
* name: stripNonAlpha
* @param string
* @return string
*/
char *stripNonAlpha(char*);
/*
* Returns string containing no potential hypertext markup (e.g., <>)
* name: stripMarkupTags
* @param string
* @return string
*/
char *stripMarkupTags(char*);
/*
* Processes a file stream to retrieve its content and size.
*
* name: filebuffer
* @param string
* @return pointer to struct filebuffer
*/
struct filebuffer *proccessFile(const char*);
/*
* Generates a list of words from a given string and loads the list onto
* an existing wordlist. If the wordlist is NULL, a new one is created.
*
* name: generateWordList
* @param pointer to struct wordlist, string
* @return pointer to struct wordlist
*/
struct wordlist *generateWordList(struct wordlist*, char*);
/*
* Generates a list of words from a given filename and loads the list onto
* an existing wordlist. If the wordlist is NULL, a new one is created.
*
* name: generateWordList
* @param pointer to struct wordlist, string
* @return pointer to struct wordlist
*/
struct wordlist *generateWordListFromFile(struct wordlist*, const char*);
/*
* Generates a list of uniquely sorted words from a given list of words.
*
* name: generateUniqueWordList
* @param pointer to struct wordlist
* @return pointer to struct wordlist
*/
struct wordlist *generateUniqueWordList(struct wordlist*);
/*
* Generates a list of phrases, each of which are of a specified
* number of words, from a given list of words.
*
* name: generatePhraseList
* @param pointer to struct wordlist, int
* @return pointer to struct wordlist
*/
struct wordlist *generatePhraseList(struct wordlist*, int);
/*
* Generates a list of uniquely sorted phrases from a given list of phrases.
*
* name: generateUniquePhraseList
* @param pointer to struct wordlist
* @return pointer to struct wordlist
*/
struct wordlist *generateUniquePhraseList(struct wordlist*);
/*
* Returns a list of words as a string.
*
* name: listToString
* @param pointer to struct wordlist, int
* @return string
*/
char *listToString(struct wordlist*, int);
/*
* Destroys wordlist items, freeing memory
*
* name: clearWordList
* @param pointer to struct wordlist
* @return void
*/
void clearWordList(struct wordlist*);
#endif /* __PROCESSING_H__ */