[BACK]Return to mksubr CVS log [TXT][DIR] Up to [local] / src / usr.bin / kdump

Annotation of src/usr.bin/kdump/mksubr, Revision 1.11

1.1       otto        1: #!/bin/sh
1.11    ! guenther    2: # $OpenBSD: mksubr,v 1.10 2012/04/12 12:33:04 deraadt Exp $
1.1       otto        3: #
                      4: # Copyright (c) 2006 David Kirchner <dpk@dpk.net>
                      5: #
                      6: # Permission to use, copy, modify, and distribute this software for any
                      7: # purpose with or without fee is hereby granted, provided that the above
                      8: # copyright notice and this permission notice appear in all copies.
                      9: #
                     10: # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
                     11: # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
                     12: # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
                     13: # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
                     14: # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
                     15: # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
                     16: # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
                     17: #
                     18: # $FreeBSD: src/usr.bin/kdump/mksubr,v 1.17 2011/06/06 19:00:38 dchagin Exp $
                     19: #
                     20: # Generates kdump_subr.c
                     21: # mkioctls is a special-purpose script, and works fine as it is
                     22: # now, so it remains independent. The idea behind how it generates
                     23: # its list was heavily borrowed here.
                     24: #
                     25: # Some functions here are automatically generated. This can mean
                     26: # the user will see unusual kdump output or errors while building
                     27: # if the underlying .h files are changed significantly.
                     28: #
                     29: # Key:
                     30: # AUTO: Completely auto-generated with either the "or" or the "switch"
                     31: # method.
                     32: # AUTO - Special: Generated automatically, but with some extra commands
                     33: # that the auto_*_type() functions are inappropriate for.
                     34: # MANUAL: Manually entered and must therefore be manually updated.
                     35:
                     36: set -e
                     37:
                     38: LC_ALL=C; export LC_ALL
                     39:
                     40: if [ -z "$1" ]
                     41: then
                     42:        echo "usage: sh $0 include-dir"
                     43:        exit 1
                     44: fi
                     45: include_dir=$1
                     46:
                     47: #
                     48: # Automatically generates a C function that will print out the
                     49: # numeric input as a pipe-delimited string of the appropriate
                     50: # #define keys. ex:
                     51: # S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH
                     52: # The XOR is necessary to prevent including the "0"-value in every
                     53: # line.
                     54: #
                     55: auto_or_type () {
                     56:        local name grep file
                     57:        name=$1
                     58:        grep=$2
                     59:        file=$3
                     60:
                     61:        cat <<_EOF_
                     62: /* AUTO */
                     63: void
                     64: $name (int arg)
                     65: {
                     66:        int     or = 0;
                     67:        printf("%#x<", arg);
                     68: _EOF_
                     69:        egrep "^#[[:space:]]*define[[:space:]]+"${grep}"[[:space:]]*" \
                     70:                $include_dir/$file | \
                     71:        awk '{ for (i = 1; i <= NF; i++) \
                     72:                if ($i ~ /define/) \
                     73:                        break; \
                     74:                ++i; \
                     75:                printf "\tif(!((arg>0)^((%s)>0)))\n\t\tif_print_or(arg, %s, or);\n", $i, $i }'
                     76: cat <<_EOF_
                     77:        printf(">");
                     78:        if (or == 0)
                     79:                (void)printf("<invalid>%ld", (long)arg);
                     80: }
                     81:
                     82: _EOF_
                     83: }
                     84:
                     85: #
1.8       guenther   86: # Like auto_or_type(), but a zero value is valid and prints as "0<>"
                     87: #
                     88: auto_orz_type () {
                     89:        local name grep file
                     90:        name=$1
                     91:        grep=$2
                     92:        file=$3
                     93:
                     94:        cat <<_EOF_
                     95: /* AUTO */
                     96: void
                     97: $name (int arg)
                     98: {
                     99:        int     or = 0;
                    100:        if (arg == 0) {
                    101:                printf("0<>");
                    102:                return;
                    103:        }
                    104:        printf("%#x<", arg);
                    105: _EOF_
                    106:        egrep "^#[[:space:]]*define[[:space:]]+"${grep}"[[:space:]]*" \
                    107:                $include_dir/$file | \
                    108:        awk '{ for (i = 1; i <= NF; i++) \
                    109:                if ($i ~ /define/) \
                    110:                        break; \
                    111:                ++i; \
                    112:                printf "\tif(!((arg>0)^((%s)>0)))\n\t\tif_print_or(arg, %s, or);\n", $i, $i }'
                    113: cat <<_EOF_
                    114:        printf(">");
                    115:        if (or == 0)
                    116:                (void)printf("<invalid>%ld", (long)arg);
                    117: }
                    118:
                    119: _EOF_
                    120: }
                    121:
                    122: #
1.1       otto      123: # Automatically generates a C function used when the argument
                    124: # maps to a single, specific #definition
                    125: #
                    126: auto_switch_type () {
                    127:        local name grep file
                    128:        name=$1
                    129:        grep=$2
                    130:        file=$3
                    131:
                    132:        cat <<_EOF_
                    133: /* AUTO */
                    134: void
                    135: $name (int arg)
                    136: {
                    137:        switch (arg) {
                    138: _EOF_
                    139:        egrep "^#[[:space:]]*define[[:space:]]+"${grep}"[[:space:]]*" \
                    140:                $include_dir/$file | \
                    141:        awk '{ for (i = 1; i <= NF; i++) \
                    142:                if ($i ~ /define/) \
                    143:                        break; \
                    144:                ++i; \
                    145:                printf "\tcase %s:\n\t\t(void)printf(\"%s\");\n\t\tbreak;\n", $i, $i }'
                    146: cat <<_EOF_
                    147:        default: /* Should not reach */
                    148:                (void)printf("<invalid=%ld>", (long)arg);
                    149:        }
                    150: }
                    151:
                    152: _EOF_
                    153: }
                    154:
                    155: #
                    156: # Automatically generates a C function used when the argument
                    157: # maps to a #definition
                    158: #
                    159: auto_if_type () {
                    160:        local name grep file
                    161:        name=$1
                    162:        grep=$2
                    163:        file=$3
                    164:
                    165:        cat <<_EOF_
                    166: /* AUTO */
                    167: void
                    168: $name (int arg)
                    169: {
                    170: _EOF_
                    171:        egrep "^#[[:space:]]*define[[:space:]]+"${grep}"[[:space:]]*" \
                    172:                $include_dir/$file | \
                    173:        awk '{ printf "\t"; \
                    174:                if (NR > 1) \
                    175:                        printf "else " ; \
                    176:                printf "if (arg == %s) \n\t\tprintf(\"%s\");\n", $2, $2 }'
                    177: cat <<_EOF_
                    178:        else /* Should not reach */
                    179:                (void)printf("<invalid=%ld>", (long)arg);
                    180: }
                    181:
                    182: _EOF_
                    183: }
                    184:
                    185: # C start
                    186:
                    187: cat <<_EOF_
                    188: #include <stdio.h>
1.2       otto      189: #include <sys/param.h>
1.1       otto      190: #include <sys/fcntl.h>
                    191: #include <sys/stat.h>
                    192: #include <sys/unistd.h>
                    193: #include <sys/mman.h>
                    194: #include <sys/wait.h>
1.2       otto      195: #include <sys/proc.h>
1.1       otto      196: #define _KERNEL
1.2       otto      197: #define COMPAT_43
1.1       otto      198: #include <sys/socket.h>
                    199: #undef _KERNEL
                    200: #include <netinet/in.h>
                    201: #include <sys/param.h>
                    202: #include <sys/mount.h>
                    203: #include <sys/ptrace.h>
                    204: #include <sys/resource.h>
                    205: #include <sys/reboot.h>
                    206: #include <sched.h>
1.2       otto      207: #if 0
1.1       otto      208: #include <sys/linker.h>
                    209: #define _KERNEL
                    210: #include <sys/thr.h>
                    211: #undef _KERNEL
                    212: #include <sys/extattr.h>
                    213: #include <sys/acl.h>
                    214: #include <aio.h>
1.2       otto      215: #endif
1.1       otto      216: #include <sys/sem.h>
                    217: #include <sys/ipc.h>
1.2       otto      218: #if 0
1.1       otto      219: #include <sys/rtprio.h>
1.2       otto      220: #endif
1.1       otto      221: #include <sys/shm.h>
1.2       otto      222: #if 0
1.1       otto      223: #include <nfsserver/nfs.h>
1.2       otto      224: #endif
1.1       otto      225: #include <ufs/ufs/quota.h>
                    226:
                    227: #include "kdump_subr.h"
                    228:
                    229: /*
                    230:  * These are simple support macros. print_or utilizes a variable
                    231:  * defined in the calling function to track whether or not it should
                    232:  * print a logical-OR character ('|') before a string. if_print_or
                    233:  * simply handles the necessary "if" statement used in many lines
                    234:  * of this file.
                    235:  */
                    236: #define print_or(str,orflag) do {                  \\
                    237:        if (orflag) putchar('|'); else orflag = 1; \\
1.8       guenther  238:        printf ("%s", str); }                      \\
1.1       otto      239:        while (0)
                    240: #define if_print_or(i,flag,orflag) do {            \\
                    241:        if ((i & flag) == flag)                    \\
                    242:        print_or(#flag,orflag); }                  \\
                    243:        while (0)
                    244:
                    245: /* MANUAL */
1.2       otto      246: extern const char *const sys_signame[NSIG];
1.1       otto      247: void
                    248: signame (int sig)
                    249: {
                    250:        if (sig > 0 && sig < NSIG)
1.2       otto      251:                (void)printf("SIG%s", sys_signame[sig]);
1.1       otto      252:        else
                    253:                (void)printf("SIG %d", sig);
                    254: }
                    255:
                    256: /* MANUAL */
                    257: void
1.8       guenther  258: sigset (int ss)
                    259: {
                    260:        int     or = 0;
                    261:        int     cnt = 0;
                    262:        int     i;
                    263:
                    264:        for (i = 1; i < NSIG; i++)
                    265:                if (sigismember(&ss, i))
                    266:                        cnt++;
                    267:        if (cnt > (NSIG-1)/2) {
                    268:                ss = ~ss;
                    269:                putchar('~');
                    270:        }
                    271:
                    272:        if (ss == 0) {
                    273:                (void)printf("0<>");
                    274:                return;
                    275:        }
                    276:
                    277:        printf("%#x<", ss);
                    278:        for (i = 1; i < NSIG; i++)
                    279:                if (sigismember(&ss, i)) {
                    280:                        if (or) putchar('|'); else or=1;
                    281:                        signame(i);
                    282:                }
                    283:        printf(">");
                    284: }
                    285:
                    286: /* MANUAL */
                    287: void
1.1       otto      288: semctlname (int cmd)
                    289: {
                    290:        switch (cmd) {
                    291:        case GETNCNT:
                    292:                (void)printf("GETNCNT");
                    293:                break;
                    294:        case GETPID:
                    295:                (void)printf("GETPID");
                    296:                break;
                    297:        case GETVAL:
                    298:                (void)printf("GETVAL");
                    299:                break;
                    300:        case GETALL:
                    301:                (void)printf("GETALL");
                    302:                break;
                    303:        case GETZCNT:
                    304:                (void)printf("GETZCNT");
                    305:                break;
                    306:        case SETVAL:
                    307:                (void)printf("SETVAL");
                    308:                break;
                    309:        case SETALL:
                    310:                (void)printf("SETALL");
                    311:                break;
                    312:        case IPC_RMID:
                    313:                (void)printf("IPC_RMID");
                    314:                break;
                    315:        case IPC_SET:
                    316:                (void)printf("IPC_SET");
                    317:                break;
                    318:        case IPC_STAT:
                    319:                (void)printf("IPC_STAT");
                    320:                break;
                    321:        default: /* Should not reach */
                    322:                (void)printf("<invalid=%ld>", (long)cmd);
                    323:        }
                    324: }
                    325:
                    326: /* MANUAL */
                    327: void
                    328: shmctlname (int cmd) {
                    329:        switch (cmd) {
                    330:        case IPC_RMID:
                    331:                (void)printf("IPC_RMID");
                    332:                break;
                    333:        case IPC_SET:
                    334:                (void)printf("IPC_SET");
                    335:                break;
                    336:        case IPC_STAT:
                    337:                (void)printf("IPC_STAT");
                    338:                break;
                    339:        default: /* Should not reach */
                    340:                (void)printf("<invalid=%ld>", (long)cmd);
                    341:        }
                    342: }
                    343:
                    344: /* MANUAL */
                    345: void
                    346: semgetname (int flag) {
                    347:        int     or = 0;
                    348:        if_print_or(flag, IPC_CREAT, or);
                    349:        if_print_or(flag, IPC_EXCL, or);
                    350:        if_print_or(flag, SEM_R, or);
                    351:        if_print_or(flag, SEM_A, or);
                    352:        if_print_or(flag, (SEM_R>>3), or);
                    353:        if_print_or(flag, (SEM_A>>3), or);
                    354:        if_print_or(flag, (SEM_R>>6), or);
                    355:        if_print_or(flag, (SEM_A>>6), or);
                    356: }
                    357:
                    358: /*
                    359:  * MANUAL
                    360:  *
                    361:  * Only used by SYS_open. Unless O_CREAT is set in flags, the
                    362:  * mode argument is unused (and often bogus and misleading).
                    363:  */
                    364: void
1.4       otto      365: flagsandmodename (int flags, int mode) {
1.1       otto      366:        flagsname (flags);
                    367:        (void)putchar(',');
                    368:        if ((flags & O_CREAT) == O_CREAT) {
                    369:                modename (mode);
                    370:        } else {
                    371:                if (decimal) {
                    372:                        (void)printf("<unused>%ld", (long)mode);
                    373:                } else {
                    374:                        (void)printf("<unused>%#lx", (long)mode);
                    375:                }
                    376:        }
                    377: }
                    378:
                    379: /*
                    380:  * MANUAL
                    381:  *
                    382:  * [g|s]etsockopt's level argument can either be SOL_SOCKET or a value
                    383:  * referring to a line in /etc/protocols . It might be appropriate
                    384:  * to use getprotoent(3) here.
                    385:  */
                    386: void
1.4       otto      387: sockoptlevelname (int level)
1.1       otto      388: {
                    389:        if (level == SOL_SOCKET) {
                    390:                (void)printf("SOL_SOCKET");
                    391:        } else {
                    392:                if (decimal) {
                    393:                        (void)printf("%ld", (long)level);
                    394:                } else {
                    395:                        (void)printf("%#lx", (long)level);
                    396:                }
                    397:        }
                    398: }
                    399:
                    400: _EOF_
                    401:
1.8       guenther  402: auto_orz_type "modename" "S_[A-Z]+[[:space:]]+[0-6]{7}" "sys/stat.h"
1.1       otto      403: auto_or_type "flagsname" "O_[A-Z]+[[:space:]]+0x[0-9A-Fa-f]+" "sys/fcntl.h"
1.8       guenther  404: auto_orz_type "atflagsname" "AT_[A-Z_]+[[:space:]]+0x[0-9A-Fa-f]+" "sys/fcntl.h"
1.3       otto      405: auto_or_type "accessmodename" "[A-Z]_OK[[:space:]]+0?x?[0-9A-Fa-f]+" "sys/unistd.h"
1.1       otto      406: auto_or_type "mmapprotname" "PROT_[A-Z]+[[:space:]]+0x[0-9A-Fa-f]+" "sys/mman.h"
                    407: auto_or_type "mmapflagsname" "MAP_[A-Z]+[[:space:]]+0x[0-9A-Fa-f]+" "sys/mman.h"
1.8       guenther  408: auto_orz_type "wait4optname" "W[A-Z]+[[:space:]]+[0-9]+" "sys/wait.h"
                    409: #auto_or_type "timerflagsname" "TIMER_[A-Z]+[[:space:]]+0x[0-9A-Fa-f]+" "sys/time.h"
1.2       otto      410: #auto_or_type "getfsstatflagsname" "MNT_[A-Z]+[[:space:]]+[1-9][0-9]*" "sys/mount.h"
                    411: #auto_or_type "mountflagsname" "MNT_[A-Z]+[[:space:]]+0x[0-9]+" "sys/mount.h"
                    412: #auto_or_type "rebootoptname" "RB_[A-Z]+[[:space:]]+0x[0-9]+" "sys/reboot.h"
1.3       otto      413: auto_or_type "flockname" "LOCK_[A-Z]+[[:space:]]+0x[0-9]+" "sys/fcntl.h"
1.2       otto      414: #auto_or_type "thrcreateflagsname" "THR_[A-Z]+[[:space:]]+0x[0-9]+" "sys/thr.h"
1.3       otto      415: auto_or_type "mlockallname" "MCL_[A-Z]+[[:space:]]+0x[0-9]+" "sys/mman.h"
1.8       guenther  416: auto_orz_type "shmatname" "SHM_[A-Z]+[[:space:]]+[0-9]{6}" "sys/shm.h"
1.2       otto      417: #auto_or_type "nfssvcname" "NFSSVC_[A-Z]+[[:space:]]+0x[0-9]+" "nfsserver/nfs.h"
                    418: #
1.3       otto      419: auto_switch_type "whencename" "SEEK_[A-Z]+[[:space:]]+[0-9]+" "sys/unistd.h"
                    420: auto_switch_type "rlimitname" "RLIMIT_[A-Z]+[[:space:]]+[0-9]+" "sys/resource.h"
1.2       otto      421: #auto_switch_type "shutdownhowname" "SHUT_[A-Z]+[[:space:]]+[0-9]+" "sys/socket.h"
                    422: #auto_switch_type "prioname" "PRIO_[A-Z]+[[:space:]]+[0-9]" "sys/resource.h"
1.3       otto      423: auto_switch_type "madvisebehavname" "_?MADV_[A-Z]+[[:space:]]+[0-9]+" "sys/mman.h"
                    424: auto_switch_type "msyncflagsname" "MS_[A-Z]+[[:space:]]+0x[0-9]+" "sys/mman.h"
1.11    ! guenther  425: auto_switch_type "clockname" "CLOCK_[A-Z]+[[:space:]]+[0-9]+" "sys/_time.h"
1.2       otto      426: #auto_switch_type "schedpolicyname" "SCHED_[A-Z]+[[:space:]]+[0-9]+" "sched.h"
                    427: #auto_switch_type "kldunloadfflagsname" "LINKER_UNLOAD_[A-Z]+[[:space:]]+[0-9]+" "sys/linker.h"
                    428: #auto_switch_type "extattrctlname" "EXTATTR_NAMESPACE_[A-Z]+[[:space:]]+0x[0-9]+" "sys/extattr.h"
                    429: #auto_switch_type "kldsymcmdname" "KLDSYM_[A-Z]+[[:space:]]+[0-9]+" "sys/linker.h"
                    430: #auto_switch_type "sendfileflagsname" "SF_[A-Z]+[[:space:]]+[0-9]+" "sys/socket.h"
                    431: #auto_switch_type "acltypename" "ACL_TYPE_[A-Z4_]+[[:space:]]+0x[0-9]+" "sys/acl.h"
1.9       guenther  432: auto_orz_type "sigactionflagname" "SA_[A-Z]+[[:space:]]+0x[0-9]+" "sys/signal.h"
1.1       otto      433: auto_switch_type "sigprocmaskhowname" "SIG_[A-Z]+[[:space:]]+[0-9]+" "sys/signal.h"
1.7       deraadt   434: auto_switch_type "sigill_name" "ILL_[A-Z]+[[:space:]]+[0-9]+" "sys/siginfo.h"
                    435: auto_switch_type "sigtrap_name" "TRAP_[A-Z]+[[:space:]]+[0-9]+" "sys/siginfo.h"
                    436: auto_switch_type "sigemt_name" "EMT_[A-Z]+[[:space:]]+[0-9]+" "sys/siginfo.h"
                    437: auto_switch_type "sigfpe_name" "FPE_[A-Z]+[[:space:]]+[0-9]+" "sys/siginfo.h"
                    438: auto_switch_type "sigbus_name" "BUS_[A-Z]+[[:space:]]+[0-9]+" "sys/siginfo.h"
                    439: auto_switch_type "sigsegv_name" "SEGV_[A-Z]+[[:space:]]+[0-9]+" "sys/siginfo.h"
                    440: auto_switch_type "sigchld_name" "CLD_[A-Z]+[[:space:]]+[0-9]+" "sys/siginfo.h"
1.2       otto      441: #auto_switch_type "lio_listioname" "LIO_(NO)?WAIT[[:space:]]+[0-9]+" "aio.h"
1.3       otto      442: auto_switch_type "minheritname" "INHERIT_[A-Z]+[[:space:]]+[0-9]+" "sys/mman.h"
1.2       otto      443: #auto_switch_type "quotactlname" "Q_[A-Z]+[[:space:]]+0x[0-9]+" "ufs/ufs/quota.h"
1.3       otto      444: auto_if_type "sockdomainname" "PF_[[:alnum:]]+[[:space:]]+" "sys/socket.h"
1.5       otto      445: auto_if_type "sockfamilyname" "AF_[[:alnum:]]+[[:space:]]+" "sys/socket.h"
1.3       otto      446: auto_if_type "sockipprotoname" "IPPROTO_[[:alnum:]]+[[:space:]]+" "netinet/in.h"
                    447: auto_switch_type "sockoptname" "SO_[A-Z]+[[:space:]]+0x[0-9]+" "sys/socket.h"
                    448: auto_switch_type "socktypename" "SOCK_[A-Z]+[[:space:]]+[1-9]+[0-9]*" "sys/socket.h"
1.2       otto      449: #auto_switch_type "ptraceopname" "PT_[[:alnum:]_]+[[:space:]]+[0-9]+" "sys/ptrace.h"
1.1       otto      450:
                    451: cat <<_EOF_
                    452: /*
                    453:  * AUTO - Special
                    454:  * F_ is used to specify fcntl commands as well as arguments. Both sets are
                    455:  * grouped in fcntl.h, and this awk script grabs the first group.
                    456:  */
                    457: void
1.4       otto      458: fcntlcmdname (int cmd, int arg)
1.1       otto      459: {
                    460:        switch (cmd) {
                    461: _EOF_
1.6       matthew   462: egrep "^#[[:space:]]*define[[:space:]]+F_[A-Z_]+[[:space:]]+[0-9]+[[:space:]]*" \
1.1       otto      463:        $include_dir/sys/fcntl.h | \
                    464:        awk 'BEGIN { o=0 } { for (i = 1; i <= NF; i++) \
                    465:                if ($i ~ /define/) \
                    466:                        break; \
                    467:                ++i; \
                    468:                if (o <= $(i+1)) \
                    469:                        printf "\tcase %s:\n\t\t(void)printf(\"%s\");\n\t\tbreak;\n", $i, $i; \
                    470:                else \
                    471:                        exit; \
                    472:                o = $(i+1) }'
                    473: cat <<_EOF_
                    474:        default: /* Should not reach */
                    475:                (void)printf("<invalid=%ld>", (long)cmd);
                    476:        }
                    477:        (void)putchar(',');
                    478:        if (cmd == F_GETFD || cmd == F_SETFD) {
                    479:                if (arg == FD_CLOEXEC)
                    480:                        (void)printf("FD_CLOEXEC");
                    481:                else if (arg == 0)
                    482:                        (void)printf("0");
                    483:                else {
                    484:                        if (decimal)
                    485:                                (void)printf("<invalid>%ld", (long)arg);
                    486:                        else
                    487:                                (void)printf("<invalid>%#lx", (long)arg);
                    488:                }
                    489:        } else if (cmd == F_SETFL) {
                    490:                flagsname(arg);
                    491:        } else {
                    492:                if (decimal)
                    493:                        (void)printf("%ld", (long)arg);
                    494:                else
                    495:                        (void)printf("%#lx", (long)arg);
                    496:        }
                    497: }
                    498:
                    499: /*
                    500:  * AUTO - Special
                    501:  *
                    502:  * The send and recv functions have a flags argument which can be
                    503:  * set to 0. There is no corresponding #define. The auto_ functions
                    504:  * detect this as "invalid", which is incorrect here.
                    505:  */
                    506: void
                    507: sendrecvflagsname (int flags)
                    508: {
                    509:        int     or = 0;
                    510:
                    511:        if (flags == 0) {
                    512:                (void)printf("0");
                    513:                return;
                    514:        }
                    515:
                    516:        printf("%#x<", flags);
                    517: _EOF_
                    518: egrep "^#[[:space:]]*define[[:space:]]+MSG_[A-Z]+[[:space:]]+0x[0-9]+[[:space:]]*" $include_dir/sys/socket.h | \
                    519:        awk '{ for (i = 1; i <= NF; i++) \
                    520:                if ($i ~ /define/) \
                    521:                        break; \
                    522:                ++i; \
                    523:                printf "\tif(!((flags>0)^((%s)>0)))\n\t\tif_print_or(flags, %s, or);\n", $i, $i }'
                    524: cat <<_EOF_
                    525:        printf(">");
                    526: }
                    527:
                    528: _EOF_