-
Notifications
You must be signed in to change notification settings - Fork 0
/
moomooencode.orig.c
70 lines (61 loc) · 1.76 KB
/
moomooencode.orig.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/***************** START OF MOOMOOENCODE.C ************************/
/*
* moomooencode.c by Sean O'Gara ([email protected]) 7/1/94.
*
* This program encodes a binary file into "MoO mOo moo MOO MOo ... "
* where the data in the file is used to determine the cases of the letters.
* The file can be decoded by moomoodecode.
*
* Usage: moomooencode expansion-file-name
*
* The program takes the input file from std. input and sends the encoded
* result to std. output. expansion-file-name is the name the file will
* get when it is moomoodecoded.
*/
#include <stdio.h>
#include <string.h>
void moosend(char c);
main(int argc, char *argv[])
{
char *exname;
int i, l, c;
if (argc != 2) {
fprintf(stderr,"\nUsage: %s expansion-file-name\n\n",argv[0]);
fprintf(stderr,"This program takes the input file from std. input\n");
fprintf(stderr,"and sends the encoded result to std. output.\n");
fprintf(stderr,"expansion-file-name is the name the file will get\n");
fprintf(stderr,"when it is moomoodecoded.\n");
return;
}
exname = argv[1];
moosend(0); /* version/format identifier -- change when extensions added */
l = strlen(exname);
for (i=0;i<l;i++) moosend(exname[i]);
moosend(0);
while ((c = fgetc(stdin)) != EOF) {
moosend(c);
}
printf("\n");
}
void moosend(char c)
{
static cpos = 0;
char *lomoo = "moo";
char *himoo = "MOO";
int mpos, i;
int line_len = 74;
for (i=0;i<8;i++) {
mpos = cpos++ % 4;
if (mpos == 3) {
fputc(' ',stdout);
++cpos;
mpos = 0;
}
fputc((c & 128) ? himoo[mpos] : lomoo[mpos],stdout);
c = c << 1;
if (cpos > line_len) {
printf("\n");
cpos = 0;
}
}
}