Changeset 8190 for trunk/Ohana/src/opihi/lib.data/queues.c
- Timestamp:
- Aug 5, 2006, 3:52:41 AM (20 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/opihi/lib.data/queues.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/lib.data/queues.c
r7917 r8190 141 141 } 142 142 143 char *Choose Key (char *line, int Key) {143 char *ChooseSingleKey (char *line, int Key) { 144 144 145 145 int i; … … 147 147 148 148 key = line; 149 if (Key != -1) { 150 for (i = 0; (i < Key) && (key != NULL); i++) { 151 p = nextword (key); 152 key = p; 149 if (Key == -1) return line; 150 151 for (i = 0; (i < Key) && (key != NULL); i++) { 152 p = nextword (key); 153 key = p; 154 } 155 key = thisword (key); 156 return (key); 157 } 158 159 /* construct merged key given keylist of the form K:N:M */ 160 char *ChooseKey (char *line, char *keylist) { 161 162 char *output, *entry, *key, *p, *q; 163 int first, keynum; 164 165 if (line == NULL) return (NULL); 166 if (keylist == NULL) return (line); 167 168 ALLOCATE (output, char, strlen(line) + 1); 169 memset (output, 0, strlen(line) + 1); 170 171 first = TRUE; 172 p = q = keylist; 173 while (q != NULL) { 174 q = strchr (p, ':'); 175 if (q == NULL) { 176 entry = strcreate (p); 177 } else { 178 entry = strncreate (p, q - p); 153 179 } 154 key = thisword (key); 155 } 156 return (key); 180 keynum = atoi (entry); 181 free (entry); 182 183 key = ChooseSingleKey (line, keynum); 184 185 if (!first) strcat (output, ":"); 186 strcat (output, key); 187 free (key); 188 189 if (q != NULL) p = q + 1; 190 first = FALSE; 191 } 192 193 return (output); 157 194 } 158 195 159 196 /* push line onto queue, skipping existing matches (optionally by key) */ 160 void PushQueueUnique (Queue *queue, char *line, intKey) {197 void PushQueueUnique (Queue *queue, char *line, char *Key) { 161 198 162 199 int i, j, N, found; … … 213 250 214 251 /* push line onto queue, replacing matches (optionally by Key) */ 215 void PushQueueReplace (Queue *queue, char *line, intKey) {252 void PushQueueReplace (Queue *queue, char *line, char *Key) { 216 253 217 254 int i, j, N, found; … … 291 328 292 329 /* pop the first entry which for which the key matches */ 293 char *PopQueueMatch (Queue *queue, intKey, char *value) {330 char *PopQueueMatch (Queue *queue, char *Key, char *value) { 294 331 295 332 int i, choice, NLINES_2;
Note:
See TracChangeset
for help on using the changeset viewer.
