aboutsummaryrefslogtreecommitdiff
path: root/networking/httpd.c
diff options
context:
space:
mode:
authormjn3 <mjn3@69ca8d6d-28ef-0310-b511-8ec308f3f277>2003-03-19 09:13:01 +0000
committermjn3 <mjn3@69ca8d6d-28ef-0310-b511-8ec308f3f277>2003-03-19 09:13:01 +0000
commite901c15d890dbbdce4c086963cb1513653fc46b5 (patch)
treea318d0f03aa076c74b576ea45dc543a5669e8e91 /networking/httpd.c
parent40758c00616c3b2c85d83eb4afdeb04b1f65c9f1 (diff)
downloadbusybox-w32-e901c15d890dbbdce4c086963cb1513653fc46b5.tar.gz
busybox-w32-e901c15d890dbbdce4c086963cb1513653fc46b5.tar.bz2
busybox-w32-e901c15d890dbbdce4c086963cb1513653fc46b5.zip
Major coreutils update.
git-svn-id: svn://busybox.net/trunk/busybox@6751 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'networking/httpd.c')
-rw-r--r--networking/httpd.c58
1 files changed, 29 insertions, 29 deletions
diff --git a/networking/httpd.c b/networking/httpd.c
index fb37224cf..e62168d38 100644
--- a/networking/httpd.c
+++ b/networking/httpd.c
@@ -178,12 +178,12 @@ static const char home[] = "/www";
178#define CONFIG_FEATURE_HTTPD_RELOAD_CONFIG_SIGHUP 178#define CONFIG_FEATURE_HTTPD_RELOAD_CONFIG_SIGHUP
179 179
180/* require from libbb.a for linking */ 180/* require from libbb.a for linking */
181const char *applet_name = "httpd"; 181const char *bb_applet_name = "httpd";
182 182
183void show_usage(void) 183void bb_show_usage(void)
184{ 184{
185 fprintf(stderr, "Usage: %s [-p <port>] [-c configFile] [-d/-e <string>] " 185 fprintf(stderr, "Usage: %s [-p <port>] [-c configFile] [-d/-e <string>] "
186 "[-r realm] [-u user]\n", applet_name); 186 "[-r realm] [-u user]\n", bb_applet_name);
187 exit(1); 187 exit(1);
188} 188}
189#endif 189#endif
@@ -395,7 +395,7 @@ static int conf_sort(const void *p1, const void *p2)
395 } 395 }
396#ifdef DEBUG 396#ifdef DEBUG
397 if(!test) 397 if(!test)
398 error_msg_and_die("sort: can`t found compares!"); 398 bb_error_msg_and_die("sort: can`t found compares!");
399#endif 399#endif
400 return test; 400 return test;
401} 401}
@@ -423,7 +423,7 @@ static void parse_conf(const char *path, int flag)
423 cf = p0 = alloca(strlen(path) + sizeof(httpd_conf) + 2); 423 cf = p0 = alloca(strlen(path) + sizeof(httpd_conf) + 2);
424 if(p0 == NULL) { 424 if(p0 == NULL) {
425 if(flag == FIRST_PARSE) 425 if(flag == FIRST_PARSE)
426 error_msg_and_die(memory_exhausted); 426 bb_error_msg_and_die(bb_msg_memory_exhausted);
427 return; 427 return;
428 } 428 }
429 sprintf(p0, "%s/%s", path, httpd_conf); 429 sprintf(p0, "%s/%s", path, httpd_conf);
@@ -433,7 +433,7 @@ static void parse_conf(const char *path, int flag)
433 if(flag != FIRST_PARSE) 433 if(flag != FIRST_PARSE)
434 return; /* subdir config not found */ 434 return; /* subdir config not found */
435 if(p0 == NULL) /* if -c option gived */ 435 if(p0 == NULL) /* if -c option gived */
436 perror_msg_and_die("%s", cf); 436 bb_perror_msg_and_die("%s", cf);
437 p0 = NULL; 437 p0 = NULL;
438 cf = httpd_conf; /* set -c ./httpd_conf */ 438 cf = httpd_conf; /* set -c ./httpd_conf */
439 } 439 }
@@ -543,7 +543,7 @@ static void parse_conf(const char *path, int flag)
543 pcur = alloca((n + 1) * sizeof(Htaccess *)); 543 pcur = alloca((n + 1) * sizeof(Htaccess *));
544 if(pcur == NULL) { 544 if(pcur == NULL) {
545 if(flag == FIRST_PARSE) 545 if(flag == FIRST_PARSE)
546 error_msg_and_die(memory_exhausted); 546 bb_error_msg_and_die(bb_msg_memory_exhausted);
547 return; 547 return;
548 } 548 }
549 n = 0; 549 n = 0;
@@ -557,7 +557,7 @@ static void parse_conf(const char *path, int flag)
557 config->Httpd_conf_parsed = *pcur; 557 config->Httpd_conf_parsed = *pcur;
558 for(cur = *pcur; cur; cur = cur->next) { 558 for(cur = *pcur; cur; cur = cur->next) {
559#ifdef DEBUG 559#ifdef DEBUG
560 error_msg("%s: %s:%s", cf, cur->before_colon, cur->after_colon); 560 bb_error_msg("%s: %s:%s", cf, cur->before_colon, cur->after_colon);
561#endif 561#endif
562 cur->next = *++pcur; 562 cur->next = *++pcur;
563 } 563 }
@@ -829,10 +829,10 @@ static int openServer(void)
829 listen(fd, 9); 829 listen(fd, 9);
830 signal(SIGCHLD, SIG_IGN); /* prevent zombie (defunct) processes */ 830 signal(SIGCHLD, SIG_IGN); /* prevent zombie (defunct) processes */
831 } else { 831 } else {
832 perror_msg_and_die("bind"); 832 bb_perror_msg_and_die("bind");
833 } 833 }
834 } else { 834 } else {
835 perror_msg_and_die("create socket"); 835 bb_perror_msg_and_die("create socket");
836 } 836 }
837 return fd; 837 return fd;
838} 838}
@@ -905,7 +905,7 @@ static int sendHeaders(HttpResponseNum responseNum)
905#ifdef DEBUG 905#ifdef DEBUG
906 if (config->debugHttpd) fprintf(stderr, "Headers: '%s'", buf); 906 if (config->debugHttpd) fprintf(stderr, "Headers: '%s'", buf);
907#endif 907#endif
908 return full_write(a_c_w, buf, len); 908 return bb_full_write(a_c_w, buf, len);
909} 909}
910 910
911/**************************************************************************** 911/****************************************************************************
@@ -1105,7 +1105,7 @@ static int sendCgi(const char *url,
1105 outFd = toCgi[1]; 1105 outFd = toCgi[1];
1106 close(fromCgi[1]); 1106 close(fromCgi[1]);
1107 close(toCgi[0]); 1107 close(toCgi[0]);
1108 if (body) full_write(outFd, body, bodyLen); 1108 if (body) bb_full_write(outFd, body, bodyLen);
1109 close(outFd); 1109 close(outFd);
1110 1110
1111 while (1) { 1111 while (1) {
@@ -1129,9 +1129,9 @@ static int sendCgi(const char *url,
1129#ifdef DEBUG 1129#ifdef DEBUG
1130 if (config->debugHttpd) { 1130 if (config->debugHttpd) {
1131 if (WIFEXITED(status)) 1131 if (WIFEXITED(status))
1132 error_msg("piped has exited with status=%d", WEXITSTATUS(status)); 1132 bb_error_msg("piped has exited with status=%d", WEXITSTATUS(status));
1133 if (WIFSIGNALED(status)) 1133 if (WIFSIGNALED(status))
1134 error_msg("piped has exited with signal=%d", WTERMSIG(status)); 1134 bb_error_msg("piped has exited with signal=%d", WTERMSIG(status));
1135 } 1135 }
1136#endif 1136#endif
1137 pid = -1; 1137 pid = -1;
@@ -1141,7 +1141,7 @@ static int sendCgi(const char *url,
1141 int s = a_c_w; 1141 int s = a_c_w;
1142 1142
1143 // There is something to read 1143 // There is something to read
1144 count = full_read(inFd, buf, sizeof(buf)-1); 1144 count = bb_full_read(inFd, buf, sizeof(buf)-1);
1145 // If a read returns 0 at this point then some type of error has 1145 // If a read returns 0 at this point then some type of error has
1146 // occurred. Bail now. 1146 // occurred. Bail now.
1147 if (count == 0) break; 1147 if (count == 0) break;
@@ -1149,14 +1149,14 @@ static int sendCgi(const char *url,
1149 if (firstLine) { 1149 if (firstLine) {
1150 /* check to see if the user script added headers */ 1150 /* check to see if the user script added headers */
1151 if (strncmp(buf, "HTTP/1.0 200 OK\n", 4) != 0) { 1151 if (strncmp(buf, "HTTP/1.0 200 OK\n", 4) != 0) {
1152 full_write(s, "HTTP/1.0 200 OK\n", 16); 1152 bb_full_write(s, "HTTP/1.0 200 OK\n", 16);
1153 } 1153 }
1154 if (strstr(buf, "ontent-") == 0) { 1154 if (strstr(buf, "ontent-") == 0) {
1155 full_write(s, "Content-type: text/plain\n\n", 26); 1155 bb_full_write(s, "Content-type: text/plain\n\n", 26);
1156 } 1156 }
1157 firstLine=0; 1157 firstLine=0;
1158 } 1158 }
1159 full_write(s, buf, count); 1159 bb_full_write(s, buf, count);
1160#ifdef DEBUG 1160#ifdef DEBUG
1161 if (config->debugHttpd) 1161 if (config->debugHttpd)
1162 fprintf(stderr, "cgi read %d bytes\n", count); 1162 fprintf(stderr, "cgi read %d bytes\n", count);
@@ -1223,14 +1223,14 @@ static int sendFile(const char *url, char *buf)
1223 int count; 1223 int count;
1224 1224
1225 sendHeaders(HTTP_OK); 1225 sendHeaders(HTTP_OK);
1226 while ((count = full_read(f, buf, MAX_MEMORY_BUFF)) > 0) { 1226 while ((count = bb_full_read(f, buf, MAX_MEMORY_BUFF)) > 0) {
1227 full_write(a_c_w, buf, count); 1227 bb_full_write(a_c_w, buf, count);
1228 } 1228 }
1229 close(f); 1229 close(f);
1230 } else { 1230 } else {
1231#ifdef DEBUG 1231#ifdef DEBUG
1232 if (config->debugHttpd) 1232 if (config->debugHttpd)
1233 perror_msg("Unable to open '%s'", url); 1233 bb_perror_msg("Unable to open '%s'", url);
1234#endif 1234#endif
1235 sendHeaders(HTTP_NOT_FOUND); 1235 sendHeaders(HTTP_NOT_FOUND);
1236 } 1236 }
@@ -1399,7 +1399,7 @@ BAD_REQUEST:
1399 but CGI script can`t be a directory */ 1399 but CGI script can`t be a directory */
1400 } 1400 }
1401 1401
1402 /* algorithm stolen from libbb simplify_path(), 1402 /* algorithm stolen from libbb bb_simplify_path(),
1403 but don`t strdup and reducing trailing slash */ 1403 but don`t strdup and reducing trailing slash */
1404 purl = test = url; 1404 purl = test = url;
1405 1405
@@ -1517,7 +1517,7 @@ FORBIDDEN: /* protect listing /cgi-bin */
1517 if (length > 0) { 1517 if (length > 0) {
1518 body = malloc(length + 1); 1518 body = malloc(length + 1);
1519 if (body) { 1519 if (body) {
1520 length = full_read(a_c_r, body, length); 1520 length = bb_full_read(a_c_r, body, length);
1521 if(length < 0) // closed 1521 if(length < 0) // closed
1522 length = 0; 1522 length = 0;
1523 body[length] = 0; // always null terminate for safety 1523 body[length] = 0; // always null terminate for safety
@@ -1629,7 +1629,7 @@ static int miniHttpd(int server)
1629 config->port = ntohs(fromAddr.sin_port); 1629 config->port = ntohs(fromAddr.sin_port);
1630#ifdef DEBUG 1630#ifdef DEBUG
1631 if (config->debugHttpd) { 1631 if (config->debugHttpd) {
1632 error_msg("connection from IP=%s, port %u\n", 1632 bb_error_msg("connection from IP=%s, port %u\n",
1633 config->rmt_ip, config->port); 1633 config->rmt_ip, config->port);
1634 } 1634 }
1635#endif 1635#endif
@@ -1748,7 +1748,7 @@ int httpd_main(int argc, char *argv[])
1748 case 'p': 1748 case 'p':
1749 config->port = atoi(optarg); 1749 config->port = atoi(optarg);
1750 if(config->port <= 0 || config->port > 0xffff) 1750 if(config->port <= 0 || config->port > 0xffff)
1751 error_msg_and_die("invalid %s for -p", optarg); 1751 bb_error_msg_and_die("invalid %s for -p", optarg);
1752 break; 1752 break;
1753#endif 1753#endif
1754#ifdef CONFIG_FEATURE_HTTPD_DECODE_URL_STR 1754#ifdef CONFIG_FEATURE_HTTPD_DECODE_URL_STR
@@ -1780,13 +1780,13 @@ int httpd_main(int argc, char *argv[])
1780 break; 1780 break;
1781#endif 1781#endif
1782 default: 1782 default:
1783 error_msg("%s", httpdVersion); 1783 bb_error_msg("%s", httpdVersion);
1784 show_usage(); 1784 bb_show_usage();
1785 } 1785 }
1786 } 1786 }
1787 1787
1788 if(chdir(home_httpd)) { 1788 if(chdir(home_httpd)) {
1789 perror_msg_and_die("can`t chdir to %s", home_httpd); 1789 bb_perror_msg_and_die("can`t chdir to %s", home_httpd);
1790 } 1790 }
1791#ifndef CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY 1791#ifndef CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY
1792 server = openServer(); 1792 server = openServer();
@@ -1809,7 +1809,7 @@ int httpd_main(int argc, char *argv[])
1809#ifndef CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY 1809#ifndef CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY
1810 if (!config->debugHttpd) { 1810 if (!config->debugHttpd) {
1811 if (daemon(1, 0) < 0) /* don`t change curent directory */ 1811 if (daemon(1, 0) < 0) /* don`t change curent directory */
1812 perror_msg_and_die("daemon"); 1812 bb_perror_msg_and_die("daemon");
1813 } 1813 }
1814 return miniHttpd(server); 1814 return miniHttpd(server);
1815#else 1815#else