-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
52 lines (44 loc) · 893 Bytes
/
main.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
/*
* File: main.c
* for uunyaencode
*
* Author: yuki
*
* Created on 2012/04/21, 11:43
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "consts.h"
/*
*
*/
int main(int argc, char** argv) {
FILE *fi ;
FILE *fo ;
char ic ;
char iw ;
int i ;
int outcount ;
fi = stdin ;
fo = stdout ;
outcount = 0 ;
while (1)
{
ic = fgetc(fi);
if ( feof(fi) ) break ;
for ( i = 0 ; i < 8 ; i ++ )
{
iw = ic & 1 ; ic = ic >> 1 ;
if ( iw == 0 ) fputs( ENCODESTRING_UU , fo ) ;
else fputs( ENCODESTRING_NYA , fo ) ;
outcount ++ ;
if ( outcount == LINEMAX )
{
fputs( "\n" , fo );
outcount = 0 ;
}
}
}
return (EXIT_SUCCESS);
}