Annotation of 43BSDReno/usr.bin/hexdump/odsyntax.c, revision 1.1

1.1     ! root        1: /*-
        !             2:  * Copyright (c) 1990 The Regents of the University of California.
        !             3:  * All rights reserved.
        !             4:  *
        !             5:  * Redistribution and use in source and binary forms are permitted
        !             6:  * provided that: (1) source distributions retain this entire copyright
        !             7:  * notice and comment, and (2) distributions including binaries display
        !             8:  * the following acknowledgement:  ``This product includes software
        !             9:  * developed by the University of California, Berkeley and its contributors''
        !            10:  * in the documentation or other materials provided with the distribution
        !            11:  * and in all advertising materials mentioning features or use of this
        !            12:  * software. Neither the name of the University nor the names of its
        !            13:  * contributors may be used to endorse or promote products derived
        !            14:  * from this software without specific prior written permission.
        !            15:  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
        !            16:  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
        !            17:  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
        !            18:  */
        !            19: 
        !            20: #ifndef lint
        !            21: static char sccsid[] = "@(#)odsyntax.c 5.2 (Berkeley) 5/25/90";
        !            22: #endif /* not lint */
        !            23: 
        !            24: #include <sys/types.h>
        !            25: #include <stdio.h>
        !            26: #include "hexdump.h"
        !            27: 
        !            28: int deprecated;
        !            29: 
        !            30: oldsyntax(argc, argvp)
        !            31:        int argc;
        !            32:        char ***argvp;
        !            33: {
        !            34:        extern enum _vflag vflag;
        !            35:        extern FS *fshead;
        !            36:        extern char *optarg;
        !            37:        extern int length, optind;
        !            38:        int ch, first;
        !            39:        char **argv;
        !            40: 
        !            41:        deprecated = 1;
        !            42:        first = 0;
        !            43:        argv = *argvp;
        !            44:        while ((ch = getopt(argc, argv, "aBbcDdeFfHhIiLlOoPpswvXx")) != EOF)
        !            45:                switch (ch) {
        !            46:                case 'a':
        !            47:                        if (!first++) {
        !            48:                                add("\"%07.7_Ao\n\"");
        !            49:                                add("\"%07.7_ao  \"");
        !            50:                        } else
        !            51:                                add("\"         \"");
        !            52:                        add("16/1 \"%3_u \" \"\\n\"");
        !            53:                        break;
        !            54:                case 'B':
        !            55:                case 'o':
        !            56:                        if (!first++) {
        !            57:                                add("\"%07.7_Ao\n\"");
        !            58:                                add("\"%07.7_ao  \"");
        !            59:                        } else
        !            60:                                add("\"         \"");
        !            61:                        add("8/2 \" %06o \" \"\\n\"");
        !            62:                        break;
        !            63:                case 'b':
        !            64:                        if (!first++) {
        !            65:                                add("\"%07.7_Ao\n\"");
        !            66:                                add("\"%07.7_ao  \"");
        !            67:                        } else
        !            68:                                add("\"         \"");
        !            69:                        add("16/1 \"%03o \" \"\\n\"");
        !            70:                        break;
        !            71:                case 'c':
        !            72:                        if (!first++) {
        !            73:                                add("\"%07.7_Ao\n\"");
        !            74:                                add("\"%07.7_ao  \"");
        !            75:                        } else
        !            76:                                add("\"         \"");
        !            77:                        add("16/1 \"%3_c \" \"\\n\"");
        !            78:                        break;
        !            79:                case 'd':
        !            80:                        if (!first++) {
        !            81:                                add("\"%07.7_Ao\n\"");
        !            82:                                add("\"%07.7_ao  \"");
        !            83:                        } else
        !            84:                                add("\"         \"");
        !            85:                        add("8/2 \"  %05u \" \"\\n\"");
        !            86:                        break;
        !            87:                case 'D':
        !            88:                        if (!first++) {
        !            89:                                add("\"%07.7_Ao\n\"");
        !            90:                                add("\"%07.7_ao  \"");
        !            91:                        } else
        !            92:                                add("\"         \"");
        !            93:                        add("4/4 \"     %010u \" \"\\n\"");
        !            94:                        break;
        !            95:                case 'e':               /* undocumented in od */
        !            96:                case 'F':
        !            97:                        if (!first++) {
        !            98:                                add("\"%07.7_Ao\n\"");
        !            99:                                add("\"%07.7_ao  \"");
        !           100:                        } else
        !           101:                                add("\"         \"");
        !           102:                        add("2/8 \"          %21.14e \" \"\\n\"");
        !           103:                        break;
        !           104:                        
        !           105:                case 'f':
        !           106:                        if (!first++) {
        !           107:                                add("\"%07.7_Ao\n\"");
        !           108:                                add("\"%07.7_ao  \"");
        !           109:                        } else
        !           110:                                add("\"         \"");
        !           111:                        add("4/4 \" %14.7e \" \"\\n\"");
        !           112:                        break;
        !           113:                case 'H':
        !           114:                case 'X':
        !           115:                        if (!first++) {
        !           116:                                add("\"%07.7_Ao\n\"");
        !           117:                                add("\"%07.7_ao  \"");
        !           118:                        } else
        !           119:                                add("\"         \"");
        !           120:                        add("4/4 \"       %08x \" \"\\n\"");
        !           121:                        break;
        !           122:                case 'h':
        !           123:                case 'x':
        !           124:                        if (!first++) {
        !           125:                                add("\"%07.7_Ao\n\"");
        !           126:                                add("\"%07.7_ao  \"");
        !           127:                        } else
        !           128:                                add("\"         \"");
        !           129:                        add("8/2 \"   %04x \" \"\\n\"");
        !           130:                        break;
        !           131:                case 'I':
        !           132:                case 'L':
        !           133:                case 'l':
        !           134:                        if (!first++) {
        !           135:                                add("\"%07.7_Ao\n\"");
        !           136:                                add("\"%07.7_ao  \"");
        !           137:                        } else
        !           138:                                add("\"         \"");
        !           139:                        add("4/4 \"    %11d \" \"\\n\"");
        !           140:                        break;
        !           141:                case 'i':
        !           142:                        if (!first++) {
        !           143:                                add("\"%07.7_Ao\n\"");
        !           144:                                add("\"%07.7_ao  \"");
        !           145:                        } else
        !           146:                                add("\"         \"");
        !           147:                        add("8/2 \" %6d \" \"\\n\"");
        !           148:                        break;
        !           149:                case 'O':
        !           150:                        if (!first++) {
        !           151:                                add("\"%07.7_Ao\n\"");
        !           152:                                add("\"%07.7_ao  \"");
        !           153:                        } else
        !           154:                                add("\"         \"");
        !           155:                        add("4/4 \"    %011o \" \"\\n\"");
        !           156:                        break;
        !           157:                case 'v':
        !           158:                        vflag = ALL;
        !           159:                        break;
        !           160:                case 'P':
        !           161:                case 'p':
        !           162:                case 's':
        !           163:                case 'w':
        !           164:                case '?':
        !           165:                default:
        !           166:                        (void)fprintf(stderr,
        !           167:                            "od: od(1) has been deprecated for hexdump(1).\n");
        !           168:                        if (ch != '?')
        !           169:                                (void)fprintf(stderr,
        !           170: "od: hexdump(1) compatibility doesn't support the -%c option%s\n",
        !           171:                                    ch, ch == 's' ? "; see strings(1)." : ".");
        !           172:                        usage();
        !           173:                }
        !           174: 
        !           175:        if (!fshead) {
        !           176:                add("\"%07.7_Ao\n\"");
        !           177:                add("\"%07.7_ao  \" 8/2 \"%06o \" \"\\n\"");
        !           178:        }
        !           179: 
        !           180:        *argvp += optind;
        !           181: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.