2 // errors.c - error & help routines
4 // Written by Eryk Vershen
8 * Copyright 1996,1997,1998 by Apple Computer, Inc.
11 * Permission to use, copy, modify, and distribute this software and
12 * its documentation for any purpose and without fee is hereby granted,
13 * provided that the above copyright notice appears in all copies and
14 * that both the copyright notice and this permission notice appear in
15 * supporting documentation.
17 * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
18 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
19 * FOR A PARTICULAR PURPOSE.
21 * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR
22 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
23 * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT,
24 * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
25 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
39 // for va_start(), etc.
67 extern const char * const sys_errlist
[];
72 // Forward declarations
80 init_program_name(char **argv
)
82 #if defined(__linux__) || defined(__unix__)
83 if ((program_name
= strrchr(argv
[0], '/')) != (char *)NULL
) {
86 program_name
= argv
[0];
89 program_name
= "pdisk";
97 printf("\t%s [-h|--help]\n", program_name
);
98 printf("\t%s [-v|--version]\n", program_name
);
100 printf("\t%s [-l|--list [name]] [...]\n", program_name
);
102 printf("\t%s [-l|--list] name [...]\n", program_name
);
104 printf("\t%s [-r|--readonly] name ...\n", program_name
);
105 printf("\t%s [-i|--interactive]\n", program_name
);
106 printf("\t%s name [...]\n", program_name
);
108 {"debug", no_argument, 0, 'd'},
109 {"abbr", no_argument, 0, 'a'},
110 {"fs", no_argument, 0, 'f'},
111 {"logical", no_argument, 0, kLogicalOption},
112 {"compute_size", no_argument, 0, 'c'},
118 usage(const char *kind
)
120 error(-1, "bad usage - %s\n", kind
);
126 // Print a message on standard error and exit with value.
127 // Values in the range of system error numbers will add
128 // the perror(3) message.
131 fatal(int value
, const char *fmt
, ...)
135 fprintf(stderr
, "%s: ", program_name
);
137 vfprintf(stderr
, fmt
, ap
);
140 #if defined(__linux__) || defined(NeXT) || defined(__unix__)
141 if (value
> 0 && value
< sys_nerr
) {
142 fprintf(stderr
, " (%s)\n", sys_errlist
[value
]);
144 fprintf(stderr
, "\n");
147 fprintf(stderr
, "\n");
148 printf("Processing stopped: Choose 'Quit' from the file menu to quit.\n\n");
155 // Print a message on standard error.
156 // Values in the range of system error numbers will add
157 // the perror(3) message.
160 error(int value
, const char *fmt
, ...)
164 fprintf(stderr
, "%s: ", program_name
);
166 vfprintf(stderr
, fmt
, ap
);
169 #if defined(__linux__) || defined(NeXT) || defined(__unix__)
170 if (value
> 0 && value
< sys_nerr
) {
171 fprintf(stderr
, " (%s)\n", sys_errlist
[value
]);
173 fprintf(stderr
, "\n");
176 fprintf(stderr
, "\n");