Changeset 272 for trunk/src/sh_mail.c
- Timestamp:
- Jan 27, 2010, 10:52:20 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/sh_mail.c
r252 r272 947 947 948 948 static time_t time_wait = 300; 949 static void report_smtp (char * reply); 949 950 950 951 static FILE * sh_mail_start_conn (struct alias * ma_address, … … 1113 1114 if (0 != is_numeric(sh.host.name)) 1114 1115 { 1115 TPT(( 0, FIL__, __LINE__, _("msg=<HELO [%s]>%c%c"),1116 sh.host.name, 13, 10));1116 sl_snprintf(error_msg, sizeof(error_msg), "HELO [%s]", 1117 sh.host.name); 1117 1118 } 1118 1119 else 1119 1120 { 1120 TPT(( 0, FIL__, __LINE__, _("msg=<HELO %s>%c%c"), 1121 sh.host.name, 13, 10)); 1122 } 1121 sl_snprintf(error_msg, sizeof(error_msg), "HELO %s", 1122 sh.host.name); 1123 } 1124 report_smtp(error_msg); 1125 1123 1126 if (0 != is_numeric(sh.host.name)) 1124 1127 fprintf(connFile, _("HELO [%s]%c%c"), sh.host.name, 13, 10); … … 1152 1155 } 1153 1156 1154 TPT(( 0, FIL__, __LINE__, _("msg=<MAIL FROM:<%s>>%c%c"), 1155 this_address, 13, 10)); 1157 sl_snprintf(error_msg, sizeof(error_msg), "MAIL FROM:<%s>", 1158 this_address); 1159 report_smtp(error_msg); 1156 1160 1157 1161 (void) fflush(connFile); … … 1175 1179 if (aFlag == 0) 1176 1180 { 1177 TPT(( 0, FIL__, __LINE__, _("msg=<RCPT TO:<%s>>%c%c"), 1178 address, 13, 10)); 1181 sl_snprintf(error_msg, sizeof(error_msg), "RCPT TO:<%s>", 1182 address); 1183 report_smtp(error_msg); 1179 1184 1180 1185 (void) fflush(connFile); … … 1210 1215 ++address_num; 1211 1216 1212 TPT(( 0, FIL__, __LINE__, _("msg=<RCPT TO:<%s>>%c%c"), 1213 sh_string_str(ma_address->recipient), 13, 10)); 1217 sl_snprintf(error_msg, sizeof(error_msg), "RCPT TO:<%s>", 1218 sh_string_str(ma_address->recipient)); 1219 report_smtp(error_msg); 1214 1220 1215 1221 (void) fflush(connFile); … … 1241 1247 /* Send the message 1242 1248 */ 1243 TPT(( 0, FIL__, __LINE__, _("msg=<DATA>%c%c"), 13, 10));1249 report_smtp(_("DATA")); 1244 1250 1245 1251 (void) fflush(connFile); … … 1273 1279 TPT(( 0, FIL__, __LINE__, _("msg=<From: <%s>%c%cTo: <%s>%c%cDate: %s>%c%c"), 1274 1280 this_address, 13, 10, address, 13, 10, my_tbuf, 13, 10)); 1281 1282 report_smtp(_("sending data..")); 1275 1283 1276 1284 (void) fflush(connFile); … … 1299 1307 time_wait = 300; 1300 1308 1309 report_smtp(_(".")); 1310 1301 1311 (void) fflush(connFile); 1302 1312 fprintf(connFile, _("%c%c.%c%c"), 13, 10, 13, 10); 1303 1313 (void) fflush(connFile); 1304 1305 TPT(( 0, FIL__, __LINE__, _("msg=<message end written>\n")));1306 1314 1307 1315 if (0 != sh_mail_wait(250, fd)) … … 1332 1340 * 1333 1341 */ 1342 extern int flag_err_debug; 1343 1344 static void report_smtp (char * reply) 1345 { 1346 char * tmp; 1347 1348 if (flag_err_debug == SL_TRUE) 1349 { 1350 tmp = sh_util_safe_name_keepspace(reply); 1351 1352 sh_error_handle (SH_ERR_ALL, FIL__, __LINE__, 0, MSG_E_SUBGEN, 1353 tmp, 1354 _("report_smtp") ); 1355 SH_FREE(tmp); 1356 } 1357 return; 1358 } 1359 1334 1360 1335 1361 static int sh_mail_wait(int code, int ma_socket) … … 1339 1365 char c; 1340 1366 1341 char errmsg[128]; 1367 char errmsg[194]; 1368 char reply[128]; 1369 unsigned int ireply = 0; 1342 1370 1343 1371 enum { … … 1357 1385 */ 1358 1386 1359 rcode = 0; 1360 state = WAIT_CODE_START; 1387 rcode = 0; 1388 state = WAIT_CODE_START; 1389 reply[0] = '\0'; 1361 1390 1362 1391 while (sl_read_timeout_fd (ma_socket, &c, 1, time_wait, SL_FALSE) > 0) { 1392 1393 if (ireply < (sizeof(reply) - 1)) 1394 { 1395 if (c != '\n' && c != '\r') 1396 { 1397 reply[ireply] = c; 1398 ++ireply; 1399 reply[ireply] = '\0'; 1400 } 1401 } 1363 1402 1364 1403 g = (int) c; … … 1379 1418 if (0 != isspace(g)) 1380 1419 break; /* Skip white space */ 1381 if (0 == isdigit(g)) 1382 return 0; /* No leading number */ 1420 if (0 == isdigit(g)) 1421 { 1422 report_smtp(reply); 1423 SL_RETURN( 0, _("mail_wait")); /* No leading number */ 1424 } 1383 1425 rcode = g-(int)'0'; /* convert to number */ 1384 1426 state = WAIT_CODE; … … 1411 1453 if (g != 1) 1412 1454 { 1455 char * tmp = sh_util_safe_name_keepspace(reply); 1413 1456 sl_snprintf(errmsg, sizeof(errmsg), 1414 _("Bad response (%d), expected %d"), rcode, code); 1457 _("Bad response (%s), expected %d"), tmp, code); 1458 SH_FREE(tmp); 1415 1459 1416 1460 sh_error_handle((-1), FIL__, __LINE__, 0, MSG_E_NET, 1417 1461 errmsg, _("sh_mail_wait"), 1418 1462 _("mail"), _("SMTP server")); 1463 } 1464 else 1465 { 1466 report_smtp(reply); 1419 1467 } 1420 1468 waited_time = time(NULL) - waited_time; … … 1438 1486 1439 1487 TPT((0, FIL__, __LINE__, _("msg=<mail_wait: bad>\n"))); 1488 report_smtp(reply); 1440 1489 SL_RETURN( 0, _("mail_wait")); 1441 1490 … … 1446 1495 1447 1496 /* Failed, EOF or error on socket */ 1497 report_smtp(reply); 1448 1498 SL_RETURN( 0, _("mail_wait")); 1449 1499 }
Note:
See TracChangeset
for help on using the changeset viewer.