Changeset 22873 in vbox
- Timestamp:
- Sep 9, 2009 6:38:18 PM (15 years ago)
- Location:
- trunk/src/VBox/Devices/Network/slirp
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/slirp/debug.c
r19838 r22873 194 194 QSOCKET_FOREACH(so, so_next, tcp) 195 195 /* { */ 196 n = sprintf(buff, "tcp[%s]", so->so_tcpcb?tcpstates[so->so_tcpcb->t_state]:"NONE");196 n = RTStrPrintf(buff, sizeof(buff), "tcp[%s]", so->so_tcpcb?tcpstates[so->so_tcpcb->t_state]:"NONE"); 197 197 while (n < 17) 198 198 buff[n++] = ' '; … … 208 208 QSOCKET_FOREACH(so, so_next, udp) 209 209 /* { */ 210 n = sprintf(buff, "udp[%d sec]", (so->so_expire - curtime) / 1000);210 n = RTStrPrintf(buff, sizeof(buff), "udp[%d sec]", (so->so_expire - curtime) / 1000); 211 211 while (n < 17) 212 212 buff[n++] = ' '; -
trunk/src/VBox/Devices/Network/slirp/debug.h
r20306 r22873 18 18 19 19 #include <VBox/log.h> 20 /* we've excluded stdio.h */ 21 # define FILE void 20 22 21 23 #ifdef LOG_ENABLED -
trunk/src/VBox/Devices/Network/slirp/libalias/alias_ftp.c
r22452 r22873 676 676 if (ftp_message_type == FTP_PORT_COMMAND) { 677 677 /* Generate PORT command string. */ 678 #ifndef VBOX 678 679 sprintf(stemp, "PORT %d,%d,%d,%d,%d,%d\r\n", 679 680 a1, a2, a3, a4, p1, p2); 681 #else 682 RTStrPrintf(stemp, sizeof(stemp), "PORT %d,%d,%d,%d,%d,%d\r\n", 683 a1, a2, a3, a4, p1, p2); 684 #endif 680 685 } else { 681 686 /* Generate 227 reply string. */ 687 #ifndef VBOX 682 688 sprintf(stemp, 683 689 "227 Entering Passive Mode (%d,%d,%d,%d,%d,%d)\r\n", 684 690 a1, a2, a3, a4, p1, p2); 691 #else 692 RTStrPrintf(stemp, sizeof(stemp), 693 "227 Entering Passive Mode (%d,%d,%d,%d,%d,%d)\r\n", 694 a1, a2, a3, a4, p1, p2); 695 #endif 685 696 } 686 697 break; 687 698 case FTP_EPRT_COMMAND: 688 699 /* Generate EPRT command string. */ 700 #ifndef VBOX 689 701 sprintf(stemp, "EPRT |1|%d.%d.%d.%d|%d|\r\n", 690 702 a1, a2, a3, a4, ntohs(alias_port)); 703 #else 704 RTStrPrintf(stemp, sizeof(stemp), "EPRT |1|%d.%d.%d.%d|%d|\r\n", 705 a1, a2, a3, a4, ntohs(alias_port)); 706 #endif 691 707 break; 692 708 case FTP_229_REPLY: 693 709 /* Generate 229 reply string. */ 710 #ifndef VBOX 694 711 sprintf(stemp, "229 Entering Extended Passive Mode (|||%d|)\r\n", 695 712 ntohs(alias_port)); 713 #else 714 RTStrPrintf(stemp, sizeof(stemp), "229 Entering Extended Passive Mode (|||%d|)\r\n", 715 ntohs(alias_port)); 716 #endif 696 717 break; 697 718 } -
trunk/src/VBox/Devices/Network/slirp/slirp.c
r22857 r22873 7 7 #include <VBox/pdmdrv.h> 8 8 #include <iprt/assert.h> 9 #include <iprt/file.h> 9 10 #ifndef RT_OS_WINDOWS 10 11 # include <sys/ioctl.h> … … 331 332 #else /* !RT_OS_WINDOWS */ 332 333 334 static int RTFileGets(RTFILE File, void *pvBuf, size_t cbBufSize, size_t *pcbRead) 335 { 336 size_t cbRead; 337 char bTest; 338 int rc = VERR_NO_MEMORY; 339 char *pu8Buf = (char *)pvBuf; 340 *pcbRead = 0; 341 while( RT_SUCCESS(rc = RTFileRead(File, &bTest, 1, &cbRead)) 342 && (pu8Buf - (char *)pvBuf) < cbBufSize) 343 { 344 if (cbRead == 0) 345 return VERR_EOF; 346 if (bTest == '\r' || bTest == '\n') 347 { 348 *pu8Buf = 0; 349 return VINF_SUCCESS; 350 } 351 *pu8Buf = bTest; 352 pu8Buf++; 353 (*pcbRead)++; 354 } 355 return rc; 356 } 333 357 static int get_dns_addr_domain(PNATState pData, bool fVerbose, 334 358 struct in_addr *pdns_addr, … … 337 361 char buff[512]; 338 362 char buff2[256]; 339 FILE *f = NULL;363 RTFILE f; 340 364 int found = 0; 341 365 struct in_addr tmp_addr; 366 int rc; 367 size_t bytes; 342 368 343 369 #ifdef RT_OS_OS2 … … 346 372 if (etc) 347 373 { 348 snprintf(buff, sizeof(buff), "%s/RESOLV2", etc);349 f = fopen(buff, "rt");350 } 351 if ( !f)352 { 353 snprintf(buff, sizeof(buff), "%s/RESOLV2", _PATH_ETC);354 f = fopen(buff, "rt");355 } 356 if ( !f)357 { 358 snprintf(buff, sizeof(buff), "%s/resolv.conf", _PATH_ETC);359 f = fopen(buff, "rt");374 RTStrmPrintf(buff, sizeof(buff), "%s/RESOLV2", etc); 375 rc = RTFileOpen(&f, buff, RTFILE_O_READ); 376 } 377 if (RT_FAILURE(rc)) 378 { 379 RTStrmPrintf(buff, sizeof(buff), "%s/RESOLV2", _PATH_ETC); 380 rc = RTFileOpen(&f, buff, RTFILE_O_READ); 381 } 382 if (RT_FAILURE(rc)) 383 { 384 RTStrmPrintf(buff, sizeof(buff), "%s/resolv.conf", _PATH_ETC); 385 rc = RTFileOpen(&f, buff, RTFILE_O_READ); 360 386 } 361 387 #else 362 # ifndef DEBUG_vvl363 f = fopen("/etc/resolv.conf", "r");364 # else388 # ifndef DEBUG_vvl 389 rc = RTFileOpen(&f, "/etc/resolv.conf", RTFILE_O_READ); 390 # else 365 391 char *home = getenv("HOME"); 366 snprintf(buff, sizeof(buff), "%s/resolv.conf", home);367 f = fopen(buff, "r");368 if ( f != NULL)392 RTStrPrintf(buff, sizeof(buff), "%s/resolv.conf", home); 393 rc = RTFileOpen(&f, buff, RTFILE_O_READ); 394 if (RT_SUCCESS(rc)) 369 395 { 370 396 Log(("NAT: DNS we're using %s\n", buff)); … … 372 398 else 373 399 { 374 f = fopen("/etc/resolv.conf", "r");400 rc = RTFileOpen(&f, "/etc/resolv.conf", RTFILE_O_READ); 375 401 Log(("NAT: DNS we're using %s\n", buff)); 376 402 } 377 # endif378 #endif 379 if ( !f)403 # endif 404 #endif 405 if (RT_FAILURE(rc)) 380 406 return -1; 381 407 … … 383 409 *ppszDomain = NULL; 384 410 Log(("nat: DNS Servers:\n")); 385 while (fgets(buff, 512, f) != NULL) 411 while ( RT_SUCCESS(rc = RTFileGets(f, buff, 512, &bytes)) 412 && rc != VERR_EOF) 386 413 { 387 414 struct dns_entry *da = NULL; … … 434 461 } 435 462 } 436 fclose(f);463 RTFileClose(f); 437 464 if (!found) 438 465 return -1; -
trunk/src/VBox/Devices/Network/slirp/slirp.h
r22843 r22873 128 128 #endif 129 129 130 #include <stdio.h>131 130 #include <errno.h> 131 132 132 133 133 #ifndef HAVE_MEMMOVE … … 343 343 }; 344 344 AssertCompileSize(struct ethhdr, 14); 345 346 /* 347 * (vvl) externing of sscanf. 348 */ 349 int sscanf(const char *s, const char *format, ...); 350 345 351 #if defined(VBOX_SLIRP_ALIAS) 346 352 … … 367 373 368 374 # define strncasecmp RTStrNICmp 369 375 # define stderr NULL 376 # define stdout NULL 370 377 # ifdef DEBUG 371 378 # define LIBALIAS_DEBUG -
trunk/src/VBox/Devices/Network/slirp/tftp.c
r15875 r22873 137 137 138 138 tp->tp_op = htons(TFTP_OACK); 139 n += sprintf((char *)tp->x.tp_buf + n, "%s", key) + 1;140 n += sprintf((char *)tp->x.tp_buf + n, "%u", value) + 1;139 n += RTStrPrintf((char *)tp->x.tp_buf + n, M_FREEROOM(m), "%s", key) + 1; 140 n += RTStrPrintf((char *)tp->x.tp_buf + n, M_FREEROOM(m), "%u", value) + 1; 141 141 142 142 saddr.sin_addr = recv_tp->ip.ip_dst;
Note:
See TracChangeset
for help on using the changeset viewer.