Made DPU accept -c in order to output to stdout

pull/11/head
silverwizard 5 years ago
parent a1184bd3fb
commit 11380315ae
  1. 18
      dpu.c

18
dpu.c

@ -7,11 +7,15 @@
int main (int argc, char **argv){ int main (int argc, char **argv){
char name[FILENAME_MAX]; char name[FILENAME_MAX];
FILE *bob,*joe,*moe; FILE *bob,*joe,*moe;
int thing, factor, arg; int out, thing, factor, arg, modifier;
int modifier; out = 0;
factor=0; factor=0;
while((modifier=getopt(argc,argv,"0123456789"))+1){ while((modifier=getopt(argc,argv,"0123456789c"))+1){
switch(modifier){ switch(modifier){
case 'c':
joe = stdout;
out = 1;
break;
case '0': case '1': case '2': case '3': case '4': case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9': case '5': case '6': case '7': case '8': case '9':
factor=factor*10+modifier-'0'; factor=factor*10+modifier-'0';
@ -45,9 +49,11 @@ int main (int argc, char **argv){
fputs("NO YOU FOOL, A REAL ONE!\n",stderr); fputs("NO YOU FOOL, A REAL ONE!\n",stderr);
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if((joe = fopen(name,"w"))==NULL){ if(!out){
fputs("Ummm, you seem to have an unwritable file or directory or something silly called the output file, this is dumb. Please stop.\n",stderr); if((joe = fopen(name,"w"))==NULL){
return EXIT_FAILURE; fputs("Ummm, you seem to have an unwritable file or directory or something silly called the output file, this is dumb. Please stop.\n",stderr);
return EXIT_FAILURE;
}
} }
if((moe = fopen("/dev/urandom","r"))==NULL){ if((moe = fopen("/dev/urandom","r"))==NULL){
fputs("So, you aren't random enough. Annoying.\n",stderr); fputs("So, you aren't random enough. Annoying.\n",stderr);

Loading…
Cancel
Save