141edb306SCy Schubert /* 241edb306SCy Schubert * Copyright (C) 2012 by Darren Reed. 341edb306SCy Schubert * 441edb306SCy Schubert * See the IPFILTER.LICENCE file for details on licencing. 541edb306SCy Schubert * 641edb306SCy Schubert * $Id: printfieldhdr.c,v 1.5.2.3 2012/07/22 08:04:24 darren_r Exp $ 741edb306SCy Schubert */ 841edb306SCy Schubert 941edb306SCy Schubert #include "ipf.h" 1041edb306SCy Schubert #include <ctype.h> 1141edb306SCy Schubert 1241edb306SCy Schubert 1341edb306SCy Schubert void printfieldhdr(wordtab_t * words,wordtab_t * field)14*efeb8bffSCy Schubertprintfieldhdr(wordtab_t *words, wordtab_t *field) 1541edb306SCy Schubert { 1641edb306SCy Schubert wordtab_t *w; 1741edb306SCy Schubert char *s, *t; 1841edb306SCy Schubert 1941edb306SCy Schubert if (field->w_value == -2) { 2041edb306SCy Schubert for (w = words; w->w_word != NULL; ) { 2141edb306SCy Schubert if (w->w_value > 0) { 2241edb306SCy Schubert printfieldhdr(words, w); 2341edb306SCy Schubert w++; 2441edb306SCy Schubert if (w->w_value > 0) 2541edb306SCy Schubert putchar('\t'); 2641edb306SCy Schubert } else { 2741edb306SCy Schubert w++; 2841edb306SCy Schubert } 2941edb306SCy Schubert } 3041edb306SCy Schubert return; 3141edb306SCy Schubert } 3241edb306SCy Schubert 3341edb306SCy Schubert for (w = words; w->w_word != NULL; w++) { 3441edb306SCy Schubert if (w->w_value == field->w_value) { 3541edb306SCy Schubert if (w->w_word == field->w_word) { 3641edb306SCy Schubert s = strdup(w->w_word); 3741edb306SCy Schubert } else { 3841edb306SCy Schubert s = NULL; 3941edb306SCy Schubert } 4041edb306SCy Schubert 4141edb306SCy Schubert if ((w->w_word != field->w_word) || (s == NULL)) { 4241edb306SCy Schubert PRINTF("%s", field->w_word); 4341edb306SCy Schubert } else { 4441edb306SCy Schubert for (t = s; *t != '\0'; t++) { 4541edb306SCy Schubert if (ISALPHA(*t) && ISLOWER(*t)) 4641edb306SCy Schubert *t = TOUPPER(*t); 4741edb306SCy Schubert } 4841edb306SCy Schubert PRINTF("%s", s); 4941edb306SCy Schubert free(s); 5041edb306SCy Schubert } 5141edb306SCy Schubert } 5241edb306SCy Schubert } 5341edb306SCy Schubert } 54