View | Details | Raw Unified | Return to bug 25278 | Differences between
and this patch

Collapse All | Expand All

(-)bs.c (-51 / +44 lines)
Lines 9-22 Link Here
9
 * $FreeBSD: src/games/bs/bs.c,v 1.9 2000/02/21 03:07:31 billf Exp $
9
 * $FreeBSD: src/games/bs/bs.c,v 1.9 2000/02/21 03:07:31 billf Exp $
10
 */
10
 */
11
11
12
#include <assert.h>
13
#include <ctype.h>
12
#include <ncurses.h>
14
#include <ncurses.h>
13
#include <signal.h>
15
#include <signal.h>
14
#include <ctype.h>
15
#include <assert.h>
16
#include <stdlib.h>
16
#include <stdlib.h>
17
#include <unistd.h>
18
#include <time.h>
19
#include <string.h>
17
#include <string.h>
18
#include <sysexits.h>
19
#include <time.h>
20
#include <unistd.h>
20
21
21
#ifndef A_UNDERLINE	/* BSD curses */
22
#ifndef A_UNDERLINE	/* BSD curses */
22
#define	beep()	write(1,"\007",1);
23
#define	beep()	write(1,"\007",1);
Lines 1110-1167 Link Here
1110
    return(sgetc("YN") == 'Y');
1111
    return(sgetc("YN") == 'Y');
1111
}
1112
}
1112
1113
1113
static void do_options(c,op)
1114
static void usage()
1114
int c;
1115
char *op[];
1116
{
1115
{
1117
    int i;
1118
1116
1119
    if (c > 1)
1117
    (void) fprintf(stderr, "Usage: bs [-s | -b] [-c]\n"
1120
    {
1118
			   "\tWhere the options are:\n"
1121
	for (i=1; i<c; i++)
1119
			   "\t-s : play a salvo game\n"
1122
	{
1120
			   "\t-b : play a blitz game\n"
1123
	    switch(op[i][0])
1121
			   "\t-c : ships may be adjacent\n");
1124
	    {
1122
    exit(EX_USAGE);
1125
	    default:
1123
}
1126
	    case '?':
1124
1127
		(void) fprintf(stderr, "Usage: battle [-s | -b] [-c]\n");
1125
static void do_options(argc,argv)
1128
		(void) fprintf(stderr, "\tWhere the options are:\n");
1126
int argc;
1129
		(void) fprintf(stderr, "\t-s : play a salvo game\n");
1127
char *argv[];
1130
		(void) fprintf(stderr, "\t-b : play a blitz game\n");
1128
{
1131
		(void) fprintf(stderr, "\t-c : ships may be adjacent\n");
1129
    int c;
1132
		exit(1);
1130
1133
		break;
1131
    while ((c = getopt(argc, argv, "bcs")) != -1) {
1134
	    case '-':
1132
	switch (c) {
1135
		switch(op[i][1])
1133
	case 'b':
1136
		{
1134
		if (salvo == 1) {
1137
		case 'b':
1135
		    (void) fprintf(stderr,
1136
			    "Bad Arg: -b and -s are mutually exclusive\n");
1137
		    exit(EX_USAGE);
1138
		} else {
1138
		    blitz = 1;
1139
		    blitz = 1;
1139
		    if (salvo == 1)
1140
		}
1140
		    {
1141
                break;
1141
			(void) fprintf(stderr,
1142
        case 'c':
1142
				"Bad Arg: -b and -s are mutually exclusive\n");
1143
		closepack = 1;
1143
			exit(1);
1144
                break;
1144
		    }
1145
        case 's':
1145
		    break;
1146
		if (blitz == 1) {
1146
		case 's':
1147
		    salvo = 1;
1148
		    if (blitz == 1)
1149
		    {
1150
			(void) fprintf(stderr,
1151
				"Bad Arg: -s and -b are mutually exclusive\n");
1152
			exit(1);
1153
		    }
1154
		    break;
1155
		case 'c':
1156
		    closepack = 1;
1157
		    break;
1158
		default:
1159
		    (void) fprintf(stderr,
1147
		    (void) fprintf(stderr,
1160
			    "Bad arg: type \"%s ?\" for usage message\n", op[0]);
1148
			    "Bad Arg: -s and -b are mutually exclusive\n");
1161
		    exit(1);
1149
		    exit(EX_USAGE);
1150
		} else {
1151
		    salvo = 1;
1162
		}
1152
		}
1163
	    }
1153
                break;
1164
	}
1154
        case '?':
1155
        default:
1156
                usage();
1157
        }
1165
    }
1158
    }
1166
}
1159
}

Return to bug 25278