My favorites | Sign in
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes    
 
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/*
* Anon@elhacker.net
* file2bits
*/

#include"file2bits.h"

int main(int argc, char *argv[]) {
char *input,*baseoutput,*ext,*config;
unsigned char iflag,sflag,oflag,eflag,rflag,cflag,verbose;
int size,len,count,c,bytes;
if(argc == 1) {
error_info();
}
iflag = 0;
sflag = 0;
oflag = 0;
eflag = 0;
rflag = 0;
verbose = 0;
ext = NULL;
while ((c = getopt (argc, argv, "i:s:o:h?e:vrc:")) != -1) {
switch(c) {
case 'i':
if(optarg == NULL) {
error_info();
}
len = strlen(optarg);
input = (char*)calloc(len,sizeof(char)+1);
memcpy(input,optarg,len);
iflag =1;
break;
case 's':
if(optarg == NULL) {
error_info();
}
size =(int) strtol(optarg,NULL,10);
if(errno == EINVAL) {
fprintf(stderr,"strtol(): %s\n",strerror(errno));
error_info();
_exit(0);
}
sflag = 1;
break;
case 'o':
if(optarg == NULL) {
error_info();
}
len = strlen(optarg);
baseoutput = (char*)calloc(len,sizeof(char)+1);
memcpy(baseoutput,optarg,len);
oflag = 1;
break;
case 'e':
if(optarg == NULL) {
error_info();
}
len = strlen(optarg);
ext = (char*)calloc(len,sizeof(char)+1);
memcpy(ext,optarg,len);
eflag = 1;
break;
case 'v':
verbose = 1;
break;
case 'r':
rflag = 1;
break;
case 'c':
if(optarg == NULL) {
error_info();
}
len = strlen(optarg);
config = (char*)calloc(len,sizeof(char)+1);
memcpy(config,optarg,len);
cflag = 1;
break;
case 'h':
case '?':
error_info();
break;
}
}
if(rflag) {
if(!(cflag))
error_info();
restoreFromFiles(config,verbose);
}
else {
if(!(iflag && oflag && sflag))
error_info();
createFromFile(input,baseoutput,ext,size,verbose);
}
}

Change log

r5 by micro.anonymous on Feb 11, 2010   Diff
I have added the functions in separate
files so you can work comfortably with
them individually
Go to: 
Sign in to write a code review

Older revisions

r4 by micro.anonymous on Feb 7, 2010   Diff
menor issues fixed
r3 by micro.anonymous on Feb 7, 2010   Diff
M    file2bits.c
A    Makefile
A    README
update file2bits.c for  issue 1 
added functionality to verbose and
...
r2 by micro.anonymous on Feb 7, 2010   Diff
archivo inicial
All revisions of this file

File info

Size: 1786 bytes, 95 lines
Powered by Google Project Hosting