Deleted Added
full compact
main.c (79987) main.c (92839)
1/*
2 * Copyright (C) 1995 Wolfgang Solfrank
3 * Copyright (c) 1995 Martin Husemann
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 21 unchanged lines hidden (view full) ---

30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33
34#include <sys/cdefs.h>
35#ifndef lint
36__RCSID("$NetBSD: main.c,v 1.10 1997/10/01 02:18:14 enami Exp $");
37static const char rcsid[] =
1/*
2 * Copyright (C) 1995 Wolfgang Solfrank
3 * Copyright (c) 1995 Martin Husemann
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 21 unchanged lines hidden (view full) ---

30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33
34#include <sys/cdefs.h>
35#ifndef lint
36__RCSID("$NetBSD: main.c,v 1.10 1997/10/01 02:18:14 enami Exp $");
37static const char rcsid[] =
38 "$FreeBSD: head/sbin/fsck_msdosfs/main.c 79977 2001-07-19 17:06:08Z obrien $";
38 "$FreeBSD: head/sbin/fsck_msdosfs/main.c 92839 2002-03-20 22:57:10Z imp $";
39#endif /* not lint */
40
41#include <stdlib.h>
42#include <string.h>
43#include <ctype.h>
44#include <stdio.h>
45#include <unistd.h>
46#include <errno.h>
39#endif /* not lint */
40
41#include <stdlib.h>
42#include <string.h>
43#include <ctype.h>
44#include <stdio.h>
45#include <unistd.h>
46#include <errno.h>
47#if __STDC__
48#include <stdarg.h>
47#include <stdarg.h>
49#else
50#include <varargs.h>
51#endif
52
53#include "fsutil.h"
54#include "ext.h"
55
56int alwaysno; /* assume "no" for all questions */
57int alwaysyes; /* assume "yes" for all questions */
58int preen; /* set when preening */
59int rdonly; /* device is opened read only (supersedes above) */
60
48
49#include "fsutil.h"
50#include "ext.h"
51
52int alwaysno; /* assume "no" for all questions */
53int alwaysyes; /* assume "yes" for all questions */
54int preen; /* set when preening */
55int rdonly; /* device is opened read only (supersedes above) */
56
61static void usage __P((void));
62int main __P((int, char **));
57static void usage(void) __dead2;
63
64static void
65usage()
66{
67 errexit("Usage: fsck_msdos [-fnpy] filesystem ... \n");
68}
69
70int
58
59static void
60usage()
61{
62 errexit("Usage: fsck_msdos [-fnpy] filesystem ... \n");
63}
64
65int
71main(argc, argv)
72 int argc;
73 char **argv;
66main(int argc, char **argv)
74{
75 int ret = 0, erg;
76 int ch;
77
78 while ((ch = getopt(argc, argv, "fFnpy")) != -1) {
79 switch (ch) {
80 case 'f':
81 /*

--- 38 unchanged lines hidden (view full) ---

120 }
121
122 return ret;
123}
124
125
126/*VARARGS*/
127int
67{
68 int ret = 0, erg;
69 int ch;
70
71 while ((ch = getopt(argc, argv, "fFnpy")) != -1) {
72 switch (ch) {
73 case 'f':
74 /*

--- 38 unchanged lines hidden (view full) ---

113 }
114
115 return ret;
116}
117
118
119/*VARARGS*/
120int
128#if __STDC__
129ask(int def, const char *fmt, ...)
121ask(int def, const char *fmt, ...)
130#else
131ask(def, fmt, va_alist)
132 int def;
133 char *fmt;
134 va_dcl
135#endif
136{
137 va_list ap;
138
139 char prompt[256];
140 int c;
141
142 if (preen) {
143 if (rdonly)
144 def = 0;
145 if (def)
146 printf("FIXED\n");
147 return def;
148 }
149
122{
123 va_list ap;
124
125 char prompt[256];
126 int c;
127
128 if (preen) {
129 if (rdonly)
130 def = 0;
131 if (def)
132 printf("FIXED\n");
133 return def;
134 }
135
150#if __STDC__
151 va_start(ap, fmt);
136 va_start(ap, fmt);
152#else
153 va_start(ap);
154#endif
155 vsnprintf(prompt, sizeof(prompt), fmt, ap);
156 if (alwaysyes || rdonly) {
157 printf("%s? %s\n", prompt, rdonly ? "no" : "yes");
158 return !rdonly;
159 }
160 do {
161 printf("%s? [yn] ", prompt);
162 fflush(stdout);
163 c = getchar();
164 while (c != '\n' && getchar() != '\n')
165 if (feof(stdin))
166 return 0;
167 } while (c != 'y' && c != 'Y' && c != 'n' && c != 'N');
168 return c == 'y' || c == 'Y';
169}
137 vsnprintf(prompt, sizeof(prompt), fmt, ap);
138 if (alwaysyes || rdonly) {
139 printf("%s? %s\n", prompt, rdonly ? "no" : "yes");
140 return !rdonly;
141 }
142 do {
143 printf("%s? [yn] ", prompt);
144 fflush(stdout);
145 c = getchar();
146 while (c != '\n' && getchar() != '\n')
147 if (feof(stdin))
148 return 0;
149 } while (c != 'y' && c != 'Y' && c != 'n' && c != 'N');
150 return c == 'y' || c == 'Y';
151}