diff --git a/Makefile b/Makefile index ff2a3f4..d71ad1c 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,11 @@ CFLAGS = -g -Wall -Wextra -Werror -objects = main.o input.o output.o encode.o +objects = main.o input.o encode.o b64 : $(objects) cc -o b64 $(objects) main.o input.o : input.h -main.o output.o : output.h main.o encode.o : encode.h .PHONY : clean diff --git a/main.c b/main.c index bedae82..9cb544c 100644 --- a/main.c +++ b/main.c @@ -1,7 +1,6 @@ #include #include #include "input.h" -#include "output.h" #include "encode.h" #define OBUFSIZE 4 @@ -13,12 +12,11 @@ unsigned char sbuf[SBUFSIZE]; int main(int argc, char *argv[]) { - int c, n, l; - int dec, url, hlp, wrp; + int c, n, dec, url, hlp; char *prog = *argv; FILE *in, *out; - dec = url = hlp = wrp = 0; + dec = url = hlp = 0; while (--argc > 0 && (*++argv)[0] == '-') while ((c = *++argv[0])) switch (c) { @@ -31,16 +29,13 @@ main(int argc, char *argv[]) case 'h': hlp = 1; break; - case 'w': - wrp = 1; - break; default: fprintf(stderr, "%s: illegal option %c\n", prog, c); exit(EXIT_FAILURE); break; } if (hlp) { - fprintf(stdout, "Usage: %s -duhw infile outfile\n", prog); + fprintf(stdout, "Usage: %s -d -h infile outfile\n", prog); } else { if (argc >= 1 && (in = fopen(*argv, "r")) == NULL) { fprintf(stderr, "%s: can't open %s\n", prog, *argv); @@ -57,16 +52,10 @@ main(int argc, char *argv[]) } } else { while ((n = getocts((argc >= 1) ? in : stdin, obuf, OBUFSIZE))) { - if (wrp) { - n = encode(obuf, n, sbuf, url); - l = printw((argc == 2) ? out : stdout, sbuf, n); - } else { - encode(obuf, n, sbuf, url); - fprintf((argc == 2) ? out : stdout, "%s", sbuf); - } + encode(obuf, n, sbuf, url); + fprintf((argc == 2) ? out : stdout, "%s", sbuf); } - if (!wrp || l != '\n') - fprintf((argc == 2) ? out : stdout, "\n"); + fprintf((argc == 2) ? out : stdout, "\n"); } if (in) fclose(in); diff --git a/output.c b/output.c deleted file mode 100644 index d5c1a3a..0000000 --- a/output.c +++ /dev/null @@ -1,19 +0,0 @@ -#include "output.h" - -#define WRAPCOL 76 - -char -printw(FILE *fp, unsigned char *s, int slen) -{ - static int col; - int c; - - while (slen--) { - fputc((c = *s++), fp); - ++col; - if (!(col %= WRAPCOL)) - fputc((c = '\n'), fp); - } - - return c; -} diff --git a/output.h b/output.h deleted file mode 100644 index 8135e20..0000000 --- a/output.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef HEADER_OUTPUT -#define HEADER_OUTPUT - -#include - -char -printw(FILE *fp, unsigned char *s, int slen); - -#endif