comparison src/readsock.c @ 15:f671821d8222

code beautifying; 0 -> \0 if appropriate
author meillo@marmaro.de
date Thu, 06 Nov 2008 09:18:38 +0100
parents 26e34ae9a3e3
children 3654c502a4df
comparison
equal deleted inserted replaced
14:a8f3424347dc 15:f671821d8222
14 You should have received a copy of the GNU General Public License 14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software 15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */ 17 */
18 18
19 /*#include "masqmail.h"*/
20 #include <signal.h> 19 #include <signal.h>
21 #include <stdio.h> 20 #include <stdio.h>
22 #include <stdlib.h> 21 #include <stdlib.h>
23 #include <setjmp.h> 22 #include <setjmp.h>
24 #include <unistd.h> 23 #include <unistd.h>
25 #include <ctype.h> 24 #include <ctype.h>
25
26 #include "readsock.h" 26 #include "readsock.h"
27 /*#include "masqmail.h"*/
27 28
28 jmp_buf jmp_timeout; 29 jmp_buf jmp_timeout;
29 30
30 static void 31 static void
31 sig_timeout_handler(int sig) 32 sig_timeout_handler(int sig)
78 while ((c != '\n') && (c != EOF) && (p < buf_len - 1)) { 79 while ((c != '\n') && (c != EOF) && (p < buf_len - 1)) {
79 buf[p++] = c; 80 buf[p++] = c;
80 c = fgetc(in); 81 c = fgetc(in);
81 } 82 }
82 83
83 buf[p] = 0; 84 buf[p] = '\0';
84 85
85 if (c == EOF) 86 if (c == EOF)
86 return -1; 87 return -1;
87 else if (p >= buf_len) { 88 else if (p >= buf_len) {
88 ungetc(c, in); 89 ungetc(c, in);
89 return -2; 90 return -2;
90 } 91 }
91 92
92 buf[p++] = c; /* \n */ 93 buf[p++] = c; /* \n */
93 buf[p] = 0; 94 buf[p] = '\0';
94 95
95 return p; 96 return p;
96 } 97 }
97 98
98 int 99 int
175 buf = *pbuf; 176 buf = *pbuf;
176 /* here we are sure that buf[p-1] == '\n' */ 177 /* here we are sure that buf[p-1] == '\n' */
177 if (flags & READSOCKL_CVT_CRLF) { 178 if (flags & READSOCKL_CVT_CRLF) {
178 if ((buf[p - 2] == '\r') && (buf[p - 1] == '\n')) { 179 if ((buf[p - 2] == '\r') && (buf[p - 1] == '\n')) {
179 buf[p - 2] = '\n'; 180 buf[p - 2] = '\n';
180 buf[p - 1] = 0; 181 buf[p - 1] = '\0';
181 p--; 182 p--;
182 } 183 }
183 } 184 }
184 } 185 }
185 return p; 186 return p;