-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpaghe.c
120 lines (113 loc) · 4.43 KB
/
paghe.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
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#ifndef LINT
static char sccs_id[] = "Module @(#)paghe.c Version 1.2 Date 00/02/21 Hour 11:53:39";
#endif
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#define S_MOVCON 1
#define S_SIPMOV 2
#define TRPACG 3
#define DBSEP '|'
main(int argc,char *argv[])
{
char i_file[256];
char o_file[256];
char tmp[256];
char c;
signed int fd = 0;
unsigned short tipo = TRPACG,lunghezza = 149;
signed short inx,inx1;
FILE *fdout;
strcpy(i_file,"/usr/apri/fls/si/1/TRPACG.D");
strcpy(o_file,"/usr/users/PAG/TRPACG.unl");
if((fd = open(i_file,O_RDONLY)) == -1) {
sprintf(tmp,"Can't open file %s reason",i_file);
perror(tmp);
exit(1);
}
if((fdout = fopen(o_file,"w")) == (FILE *)NULL) {
sprintf(tmp,"Can't open file %s reason",o_file);
perror(tmp);
close(fd);
exit(1);
}
memset(tmp,'\0',sizeof(tmp));
inx1 = inx = 0;
while(read(fd,&c,1) > 0) {
tmp[inx1] = c;
switch(tipo) {
case S_MOVCON:
if(inx == lunghezza) {
inx1++;
tmp[inx1] = DBSEP;
inx1++;
tmp[inx1] = '\n';
inx1++;
tmp[inx1] = '\0';
fprintf(fdout,"%s",tmp);
inx1 = inx = -1;
}
if(inx == 4 || inx == 16 || inx == 29 ||
inx == 30 || inx == 42 || inx == 47 ||
inx == 52 || inx == 54 || inx == 58 ||
inx == 59 || inx == 60 || inx == 64 ||
inx == 65 || inx == 68 || inx == 69 ||
inx == 73 || inx == 75 || inx == 76 ||
inx == 79) {
inx1++;
tmp[inx1] = DBSEP;
}
break;
case S_SIPMOV:
if(inx == lunghezza) {
inx1++;
tmp[inx1] = DBSEP;
inx1++;
tmp[inx1] = '\n';
inx1++;
tmp[inx1] = '\0';
fprintf(fdout,"%s",tmp);
inx1 = inx = -1;
}
if(inx == 4 || inx == 16 || inx == 29 ||
inx == 30 || inx == 42 || inx == 47 ||
inx == 52 || inx == 54 || inx == 58 ||
inx == 59 || inx == 60 || inx == 64 ||
inx == 65 || inx == 68 || inx == 69 ||
inx == 73 || inx == 75 || inx == 76 ||
inx == 79) {
inx1++;
tmp[inx1] = DBSEP;
}
break;
case TRPACG:
if(inx == lunghezza) {
inx1++;
tmp[inx1] = DBSEP;
inx1++;
tmp[inx1] = '\n';
inx1++;
tmp[inx1] = '\0';
fprintf(fdout,"%s",tmp);
inx1 = inx = -1;
}
if(inx == 0 || inx == 6 || inx == 8 ||
inx == 12 || inx == 14 || inx == 26 ||
inx == 38 || inx == 51 || inx == 63 ||
inx == 64 || inx == 67 || inx == 72 ||
inx == 92 || inx == 94 || inx == 99 ||
inx == 103 || inx == 109 || inx == 112 ||
inx == 113 || inx == 114 || inx == 133 )
{
inx1++;
tmp[inx1] = DBSEP;
}
break;
}
inx++;
inx1++;
}
close(fd);
fclose(fdout);
exit(0);
}