version 1.14, 2018/12/31 09:23:08 |
version 1.15, 2019/03/10 20:49:24 |
|
|
#include <netinet/in.h> |
#include <netinet/in.h> |
|
|
#include <err.h> |
#include <err.h> |
#include <locale.h> |
|
#include <resolv.h> |
#include <resolv.h> |
#include <stdio.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <stdlib.h> |
|
|
|
|
void encode(void); |
void encode(void); |
void base64_encode(void); |
void base64_encode(void); |
static void usage(void); |
static void __dead usage(void); |
|
|
FILE *output; |
FILE *output; |
int mode; |
int mode; |
|
|
pmode = MODE_B64ENCODE; |
pmode = MODE_B64ENCODE; |
} |
} |
|
|
setlocale(LC_ALL, ""); |
|
while ((ch = getopt(argc, argv, optstr[pmode])) != -1) { |
while ((ch = getopt(argc, argv, optstr[pmode])) != -1) { |
switch (ch) { |
switch (ch) { |
case 'm': |
case 'm': |
|
|
case 'o': |
case 'o': |
outfile = optarg; |
outfile = optarg; |
break; |
break; |
case '?': |
|
default: |
default: |
usage(); |
usage(); |
} |
} |
|
|
#define RW (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH) |
#define RW (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH) |
mode = RW & ~umask(RW); |
mode = RW & ~umask(RW); |
break; |
break; |
case 0: |
|
default: |
default: |
usage(); |
usage(); |
} |
} |
|
|
encode(); |
encode(); |
if (ferror(output)) |
if (ferror(output)) |
errx(1, "write error"); |
errx(1, "write error"); |
exit(0); |
return 0; |
} |
} |
|
|
/* ENC is the basic 1 character encoding function to make a char printing */ |
/* ENC is the basic 1 character encoding function to make a char printing */ |
|
|
(void)fprintf(output, "%c\nend\n", ENC('\0')); |
(void)fprintf(output, "%c\nend\n", ENC('\0')); |
} |
} |
|
|
static void |
static void __dead |
usage(void) |
usage(void) |
{ |
{ |
switch (pmode) { |
switch (pmode) { |