|
|
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.1 92/03/13 10:21:08 bin ! 31: * Initial revision ! 32: * ! 33: * Revision 2.2 91/07/28 14:03:30 munk ! 34: * Made the large arrays static ! 35: ! 36: * Revision 2.1 82/10/25 14:46:20 pavel ! 37: * Added Copyright Notice ! 38: * ! 39: * Revision 2.0 82/10/24 15:17:29 pavel ! 40: * Beta-one Test Release ! 41: * ! 42: * Revision 1.3 82/08/23 22:30:18 pavel ! 43: * The REAL Alpha-one Release Version ! 44: * ! 45: * Revision 1.2 82/08/19 19:12:50 pavel ! 46: * Alpha Test Release One ! 47: * ! 48: * Revision 1.1 82/08/12 18:39:19 pavel ! 49: * Initial revision ! 50: * ! 51: * ! 52: */ ! 53: ! 54: #ifndef COHERENT ! 55: static char RCSid[] = ! 56: "$Header: /src386/usr/bin/infocmp/RCS/dump.c,v 1.1 92/03/13 10:21:08 bin Exp $"; ! 57: #endif ! 58: ! 59: #include "compiler.h" ! 60: #include "term.h" ! 61: ! 62: extern char *BoolNames[BOOLCOUNT], *NumNames[NUMCOUNT], *StrNames[STRCOUNT]; ! 63: ! 64: ! 65: main(argc, argv) ! 66: int argc; ! 67: char *argv[]; ! 68: { ! 69: int i, j; ! 70: int cur_column; ! 71: static char buffer[1024]; ! 72: ! 73: for (j=1; j < argc; j++) ! 74: { ! 75: if (read_entry(argv[j], &_first_term) < 0) ! 76: { ! 77: fprintf(stderr, "read_entry bombed on %s\n", argv[j]); ! 78: abort(); ! 79: } ! 80: ! 81: printf("%s,\n", _first_term.term_names); ! 82: putchar('\t'); ! 83: cur_column = 9; ! 84: ! 85: for (i=0; i < BOOLCOUNT; i++) ! 86: { ! 87: if (_first_term.Booleans[i] == TRUE) ! 88: { ! 89: if (cur_column > 9 ! 90: && cur_column + strlen(BoolNames[i]) + 2 > 79) ! 91: { ! 92: printf("\n\t"); ! 93: cur_column = 9; ! 94: } ! 95: printf("%s, ", BoolNames[i]); ! 96: cur_column += strlen(BoolNames[i]) + 2; ! 97: } ! 98: } ! 99: ! 100: for (i=0; i < NUMCOUNT; i++) ! 101: { ! 102: if (_first_term.Numbers[i] != -1) ! 103: { ! 104: if (cur_column > 9 ! 105: && cur_column + strlen(NumNames[i]) + 5 > 79) ! 106: { ! 107: printf("\n\t"); ! 108: cur_column = 9; ! 109: } ! 110: printf("%s#%d, ", NumNames[i], _first_term.Numbers[i]); ! 111: cur_column += strlen(NumNames[i]) + 5; ! 112: } ! 113: } ! 114: ! 115: for (i=0; i < STRCOUNT; i++) ! 116: { ! 117: if (_first_term.Strings[i]) ! 118: { ! 119: sprintf(buffer, "%s=%s, ", StrNames[i], ! 120: _first_term.Strings[i]); ! 121: expand(buffer); ! 122: if (cur_column > 9 && cur_column + strlen(buffer) > 79) ! 123: { ! 124: printf("\n\t"); ! 125: cur_column = 9; ! 126: } ! 127: printf("%s", buffer); ! 128: cur_column += strlen(buffer); ! 129: } ! 130: } ! 131: ! 132: putchar('\n'); ! 133: } ! 134: } ! 135: ! 136: ! 137: typedef unsigned char uchar; ! 138: ! 139: expand(str) ! 140: uchar *str; ! 141: { ! 142: static char buffer[1024]; ! 143: int bufp; ! 144: uchar *ptr; ! 145: ! 146: bufp = 0; ! 147: ptr = str; ! 148: while (*str) ! 149: { ! 150: if (*str < ' ') { ! 151: if (*str == 0x1B) { ! 152: buffer[bufp++] = '\\'; ! 153: buffer[bufp++] = 'E'; ! 154: } else { ! 155: buffer[bufp++] = '^'; ! 156: buffer[bufp++] = *str + '@'; ! 157: } ! 158: } else ! 159: if (*str < '\177') ! 160: buffer[bufp++] = *str; ! 161: else ! 162: { ! 163: sprintf(&buffer[bufp], "\\%03o", *str); ! 164: bufp += 4; ! 165: } ! 166: ! 167: str++; ! 168: } ! 169: ! 170: buffer[bufp] = '\0'; ! 171: strcpy(ptr, buffer); ! 172: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.