# 2.11BSD#431 - /usr/src/games/battlestar/getcom.c

##### Functions

    getcom            X
    getword           X

       1: /*
       2:  * Copyright (c) 1983 Regents of the University of California,
       3:  * All rights reserved.  Redistribution permitted subject to
       4:  * the terms of the Berkeley Software License Agreement.
       5:  */
       6:
       7: #if !defined(lint) && !defined(pdp11)
       8: static char sccsid[] = "@(#)getcom.c	1.3 4/24/85";
       9: #endif
      10:
      11: #include <stdio.h>
      12: #include <ctype.h>
      13:
      14: char *
      15: getcom(buf, size, prompt, error)
      16:     char *buf;
      17:     int size;
      18:     char *prompt, *error;
      19: {
      20:     for (;;) {
      21:         fputs(prompt, stdout);
      22:         if (fgets(buf, size, stdin) == 0) {
      23:             clearerr(stdin);
      24:             continue;
      25:         }
      26:         while (isspace(*buf))
      27:             buf++;
      28:         if (*buf)
      29:             break;
      30:         if (error)
      31:             puts(error);
      32:     }
      33:     return (buf);
      34: }
      35:
      36:
      37: /*
      38:  * shifts to UPPERCASE if flag > 0, lowercase if flag < 0,
      39:  * and leaves it unchanged if flag = 0
      40:  */
      41: char *
      42: getword(buf1, buf2, flag)
      43:     register char *buf1, *buf2;
      44:     register flag;
      45: {
      46:     while (isspace(*buf1))
      47:         buf1++;
      48:     if (*buf1 != ',') {
      49:         if (!*buf1) {
      50:             *buf2 = 0;
      51:             return (0);
      52:         }
      53:         while (*buf1 && !isspace(*buf1) && *buf1 != ',')
      54:             if (flag < 0)
      55:                 if (isupper(*buf1))
      56:                     *buf2++ = tolower(*buf1++);
      57:                 else
      58:                     *buf2++ = *buf1++;
      59:             else if (flag > 0)
      60:                 if (islower(*buf1))
      61:                     *buf2++ = toupper(*buf1++);
      62:                 else
      63:                     *buf2++ = *buf1++;
      64:             else
      65:                 *buf2++ = *buf1++;
      66:     } else
      67:         *buf2++ = *buf1++;
      68:     *buf2 = 0;
      69:     while (isspace(*buf1))
      70:         buf1++;
      71:     return (*buf1 ? buf1 : 0);
      72: }

#### Defined functions

getcom defined in line 14; used 3 times

- in /usr/src/games/battlestar/battlestar.c line 50
- in /usr/src/games/battlestar/com7.c line 34
- in /usr/src/games/battlestar/externs.h line 237

getword defined in line 41; used 3 times

- in /usr/src/games/battlestar/battlestar.c line 53
- in /usr/src/games/battlestar/com7.c line 36
- in /usr/src/games/battlestar/externs.h line 237

#### Defined variables

sccsid defined in line 8; never used

Last modified: 1987-07-31 Generated: 2016-12-26 | Generated by src2html V0.67 page hit count: 1025 |