|
|
1.1 ! root 1: /********************************************************************* ! 2: * COPYRIGHT NOTICE * ! 3: ********************************************************************** ! 4: * This software is copyright (C) 1982 by Pavel Curtis * ! 5: * * ! 6: * Permission is granted to reproduce and distribute * ! 7: * this file by any means so long as no fee is charged * ! 8: * above a nominal handling fee and so long as this * ! 9: * notice is always included in the copies. * ! 10: * * ! 11: * Other rights are reserved except as explicitly granted * ! 12: * by written permission of the author. * ! 13: * Pavel Curtis * ! 14: * Computer Science Dept. * ! 15: * 405 Upson Hall * ! 16: * Cornell University * ! 17: * Ithaca, NY 14853 * ! 18: * * ! 19: * Ph- (607) 256-4934 * ! 20: * * ! 21: * Pavel.Cornell@Udel-Relay (ARPAnet) * ! 22: * decvax!cornell!pavel (UUCPnet) * ! 23: *********************************************************************/ ! 24: ! 25: /* ! 26: * dump.c - dump the contents of a compiled terminfo file in a ! 27: * human-readable format. ! 28: * ! 29: * $Log: dump.c,v $ ! 30: * Revision 1.10 93/04/12 14:13:14 bin ! 31: * Udo: third color update ! 32: * ! 33: * Revision 1.4 92/06/02 12:04:49 bin ! 34: * *** empty log message *** ! 35: * ! 36: * Revision 1.2 92/04/13 14:36:41 bin ! 37: * update by vlad ! 38: * ! 39: * Revision 2.2 91/07/28 14:03:30 munk ! 40: * Made the large arrays static ! 41: ! 42: * Revision 2.1 82/10/25 14:46:20 pavel ! 43: * Added Copyright Notice ! 44: * ! 45: * Revision 2.0 82/10/24 15:17:29 pavel ! 46: * Beta-one Test Release ! 47: * ! 48: * Revision 1.3 82/08/23 22:30:18 pavel ! 49: * The REAL Alpha-one Release Version ! 50: * ! 51: * Revision 1.2 82/08/19 19:12:50 pavel ! 52: * Alpha Test Release One ! 53: * ! 54: * Revision 1.1 82/08/12 18:39:19 pavel ! 55: * Initial revision ! 56: * ! 57: * ! 58: */ ! 59: ! 60: #ifdef RCSHDR ! 61: static char RCSid[] = ! 62: "$Header: /src386/usr/lib/ncurses/RCS/dump.c,v 1.10 93/04/12 14:13:14 bin Exp Locker: bin $"; ! 63: #endif ! 64: ! 65: #include "compiler.h" ! 66: #include "term.h" ! 67: ! 68: extern char *BoolNames[BOOLCOUNT], *NumNames[NUMCOUNT], *StrNames[STRCOUNT]; ! 69: struct term _first_term; ! 70: ! 71: ! 72: main(argc, argv) ! 73: int argc; ! 74: char *argv[]; ! 75: { ! 76: int i, j; ! 77: int cur_column; ! 78: static char buffer[1024]; ! 79: ! 80: for (j=1; j < argc; j++) ! 81: { ! 82: if (read_entry(argv[j], &_first_term) < 0) ! 83: { ! 84: fprintf(stderr, "read_entry bombed on %s\n", argv[j]); ! 85: abort(); ! 86: } ! 87: ! 88: printf("%s,\n", _first_term.term_names); ! 89: putchar('\t'); ! 90: cur_column = 9; ! 91: ! 92: for (i=0; i < BOOLCOUNT; i++) ! 93: { ! 94: if (_first_term.Booleans[i] == TRUE) ! 95: { ! 96: if (cur_column > 9 ! 97: && cur_column + strlen(BoolNames[i]) + 2 > 79) ! 98: { ! 99: printf("\n\t"); ! 100: cur_column = 9; ! 101: } ! 102: printf("%s, ", BoolNames[i]); ! 103: cur_column += strlen(BoolNames[i]) + 2; ! 104: } ! 105: } ! 106: ! 107: for (i=0; i < NUMCOUNT; i++) ! 108: { ! 109: if (_first_term.Numbers[i] != -1) ! 110: { ! 111: if (cur_column > 9 ! 112: && cur_column + strlen(NumNames[i]) + 5 > 79) ! 113: { ! 114: printf("\n\t"); ! 115: cur_column = 9; ! 116: } ! 117: printf("%s#%d, ", NumNames[i], _first_term.Numbers[i]); ! 118: cur_column += strlen(NumNames[i]) + 5; ! 119: } ! 120: } ! 121: ! 122: for (i=0; i < STRCOUNT; i++) ! 123: { ! 124: if (_first_term.Strings[i]) ! 125: { ! 126: sprintf(buffer, "%s=%s, ", StrNames[i], ! 127: _first_term.Strings[i]); ! 128: expand(buffer); ! 129: if (cur_column > 9 && cur_column + strlen(buffer) > 79) ! 130: { ! 131: printf("\n\t"); ! 132: cur_column = 9; ! 133: } ! 134: printf("%s", buffer); ! 135: cur_column += strlen(buffer); ! 136: } ! 137: } ! 138: ! 139: putchar('\n'); ! 140: } ! 141: } ! 142: ! 143: ! 144: typedef unsigned char uchar; ! 145: ! 146: expand(str) ! 147: uchar *str; ! 148: { ! 149: char *strcpy(); ! 150: static char buffer[1024]; ! 151: int bufp; ! 152: uchar *ptr; ! 153: ! 154: bufp = 0; ! 155: ptr = str; ! 156: while (*str) ! 157: { ! 158: if (*str < ' ') { ! 159: if (*str == 0x1B) { ! 160: buffer[bufp++] = '\\'; ! 161: buffer[bufp++] = 'E'; ! 162: } else { ! 163: buffer[bufp++] = '^'; ! 164: buffer[bufp++] = *str + '@'; ! 165: } ! 166: } else ! 167: if (*str < '\177') ! 168: buffer[bufp++] = *str; ! 169: else ! 170: { ! 171: sprintf(&buffer[bufp], "\\%03o", *str); ! 172: bufp += 4; ! 173: } ! 174: ! 175: str++; ! 176: } ! 177: ! 178: buffer[bufp] = '\0'; ! 179: strcpy((char *) ptr, buffer); ! 180: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.