author | viric@llimona |
Fri, 16 Jun 2006 18:45:24 +0200 | |
changeset 62 | 39bf7ecd7b21 |
parent 53 | 667cd5966695 |
permissions | -rw-r--r-- |
0 | 1 |
#include "rfc3164.h" |
15
fea6e87812f0
Now everything works - the rfc3164 message parser must be improved.
viric@llimona
parents:
6
diff
changeset
|
2 |
#include <stdio.h> // snprintf |
fea6e87812f0
Now everything works - the rfc3164 message parser must be improved.
viric@llimona
parents:
6
diff
changeset
|
3 |
#include <unistd.h> // write |
fea6e87812f0
Now everything works - the rfc3164 message parser must be improved.
viric@llimona
parents:
6
diff
changeset
|
4 |
#include <string.h> // strlen |
1 | 5 |
|
0 | 6 |
|
6 | 7 |
int process_message(char * restrict buffer) |
0 | 8 |
{ |
6 | 9 |
int i; |
53
667cd5966695
Finer message processing - now only at file and screen output appear '\n'.
viric@llimona
parents:
22
diff
changeset
|
10 |
/* char message[MESSAGE_LENGTH+1]; */ |
0 | 11 |
|
6 | 12 |
for(i=0; i<MESSAGE_LENGTH; i++) |
1 | 13 |
{ |
6 | 14 |
if (buffer[i] == '\n' || buffer[i] == '\0') |
15 |
{ |
|
16 |
buffer[i] = '\0'; |
|
17 |
break; |
|
18 |
} |
|
19 |
else if ((buffer[i] & 128) == 128 ) |
|
20 |
{ |
|
21 |
/* Convertim de 8bits a 7bits */ |
|
22 |
buffer[i] = buffer[i] & ~128; |
|
23 |
} |
|
22
52c1a4d0b565
Added >32 check for the characters to be always printable.
viric@mandarina
parents:
15
diff
changeset
|
24 |
|
52c1a4d0b565
Added >32 check for the characters to be always printable.
viric@mandarina
parents:
15
diff
changeset
|
25 |
/* Han de ser caràcters imprimibles */ |
52c1a4d0b565
Added >32 check for the characters to be always printable.
viric@mandarina
parents:
15
diff
changeset
|
26 |
if (buffer[i] < 32) |
52c1a4d0b565
Added >32 check for the characters to be always printable.
viric@mandarina
parents:
15
diff
changeset
|
27 |
buffer[i] = ' '; |
1 | 28 |
} |
6 | 29 |
if(i == MESSAGE_LENGTH) |
15
fea6e87812f0
Now everything works - the rfc3164 message parser must be improved.
viric@llimona
parents:
6
diff
changeset
|
30 |
buffer[MESSAGE_LENGTH-1] = '\0'; |
6 | 31 |
/* Debug */ |
15
fea6e87812f0
Now everything works - the rfc3164 message parser must be improved.
viric@llimona
parents:
6
diff
changeset
|
32 |
/* fprintf(stderr,"M: %s\n", buffer); */ |
fea6e87812f0
Now everything works - the rfc3164 message parser must be improved.
viric@llimona
parents:
6
diff
changeset
|
33 |
|
53
667cd5966695
Finer message processing - now only at file and screen output appear '\n'.
viric@llimona
parents:
22
diff
changeset
|
34 |
/*snprintf(message, MESSAGE_LENGTH+1,"%s\n", buffer); */ |
667cd5966695
Finer message processing - now only at file and screen output appear '\n'.
viric@llimona
parents:
22
diff
changeset
|
35 |
/* write(1, message, strlen(message)); */ |
6 | 36 |
|
37 |
return i; |
|
0 | 38 |
} |