version 1.8, 2008/07/05 20:59:42 |
version 1.9, 2008/07/29 18:25:28 |
|
|
|
|
void encode(void); |
void encode(void); |
void base64_encode(void); |
void base64_encode(void); |
static void usage(int); |
static void usage(void); |
|
|
FILE *output; |
FILE *output; |
int mode; |
int mode; |
char **av; |
char **av; |
|
|
/* |
enum program_mode { |
* program modes |
MODE_ENCODE, |
*/ |
MODE_B64ENCODE |
#define MODE_ENCODE 0 |
} pmode; |
#define MODE_B64ENCODE 1 |
|
|
|
int |
int |
main(int argc, char *argv[]) |
main(int argc, char *argv[]) |
{ |
{ |
struct stat sb; |
struct stat sb; |
int base64, ch, mode; |
int base64, ch; |
char *outfile; |
char *outfile; |
extern char *__progname; |
extern char *__progname; |
static const char *optstr[2] = { |
static const char *optstr[2] = { |
|
|
"o:" |
"o:" |
}; |
}; |
|
|
base64 = mode = 0; |
base64 = 0; |
outfile = NULL; |
outfile = NULL; |
|
|
|
pmode = MODE_ENCODE; |
if (strcmp(__progname, "b64encode") == 0) { |
if (strcmp(__progname, "b64encode") == 0) { |
base64 = 1; |
base64 = 1; |
mode = MODE_B64ENCODE; |
pmode = MODE_B64ENCODE; |
} |
} |
|
|
setlocale(LC_ALL, ""); |
setlocale(LC_ALL, ""); |
while ((ch = getopt(argc, argv, optstr[mode])) != -1) { |
while ((ch = getopt(argc, argv, optstr[pmode])) != -1) { |
switch (ch) { |
switch (ch) { |
case 'm': |
case 'm': |
base64 = 1; |
base64 = 1; |
|
|
break; |
break; |
case '?': |
case '?': |
default: |
default: |
usage(mode); |
usage(); |
} |
} |
} |
} |
argv += optind; |
argv += optind; |
|
|
break; |
break; |
case 0: |
case 0: |
default: |
default: |
usage(mode); |
usage(); |
} |
} |
|
|
av = argv; |
av = argv; |
|
|
} |
} |
|
|
static void |
static void |
usage(int mode) |
usage(void) |
{ |
{ |
switch (mode) { |
switch (pmode) { |
case MODE_ENCODE: |
case MODE_ENCODE: |
(void)fprintf(stderr, |
(void)fprintf(stderr, |
"usage: uuencode [-m] [-o output_file] [file] name\n"); |
"usage: uuencode [-m] [-o output_file] [file] name\n"); |