Only in busybox_httpd/applets: .svn Only in busybox_httpd/arch/i386: .svn Only in busybox_httpd/arch: .svn Only in busybox_httpd/archival/bz: .svn Only in busybox_httpd/archival/libunarchive: .svn Only in busybox_httpd/archival: .svn Only in busybox_httpd: busybox1.11.2 Only in busybox_httpd: .config Only in busybox_httpd: .config_backup Only in busybox_httpd: .config.old Only in busybox_httpd: conf.sh Only in busybox_httpd/console-tools: .svn Only in busybox_httpd/coreutils/libcoreutils: .svn Only in busybox_httpd/coreutils: .svn Only in busybox_httpd/debianutils: .svn Only in busybox_httpd/docs/busybox.net/images: .svn Only in busybox_httpd/docs/busybox.net: .svn Only in busybox_httpd/docs/cgi: .svn Only in busybox_httpd/docs: .svn Only in busybox_httpd/e2fsprogs/old_e2fsprogs/blkid: .svn Only in busybox_httpd/e2fsprogs/old_e2fsprogs/e2p: .svn Only in busybox_httpd/e2fsprogs/old_e2fsprogs/ext2fs: .svn Only in busybox_httpd/e2fsprogs/old_e2fsprogs: .svn Only in busybox_httpd/e2fsprogs/old_e2fsprogs/uuid: .svn Only in busybox_httpd/e2fsprogs: .svn Only in busybox_httpd/editors: .svn Only in busybox_httpd/examples/bootfloppy/etc/init.d: .svn Only in busybox_httpd/examples/bootfloppy/etc: .svn Only in busybox_httpd/examples/bootfloppy: .svn Only in busybox_httpd/examples: .svn Only in busybox_httpd/examples/udhcp: .svn Only in busybox_httpd/findutils: .svn Only in busybox_httpd: gcc.sh Only in busybox_httpd/include: applet_tables.h Only in busybox_httpd/include: autoconf.h Only in busybox_httpd/include: bbconfigopts.h Only in busybox_httpd/include: config Only in busybox_httpd/include: ipc_cgi_ext.h diff -r busybox_httpd/include/libbb.h busybox-1.11.2/include/libbb.h 42,50d41 < < #ifndef ULLONG_MAX < # define ULLONG_MAX 18446744073709551615ULL < #endif < #ifndef LLONG_MAX < # define LLONG_MAX 9223372036854775807LL < # define LLONG_MIN (-LLONG_MAX - 1LL) < #endif < 1408,1547d1398 < < < ///*.........................................................................................*/ < #ifndef __BDEBUGWHERE_BDEBUGINFO__ < #define __BDEBUGWHERE_BDEBUGINFO__ < //begin broadcasting debugging macro. < #include < #include < #include < #include < #include < #include < #include < #include < < #include < #include < #include < #include < #include < #include < #include < #include < #include < < #include < < #if 0 < static char szFilling[48]; < # define BDEBUG_ON < # define BDEBUGWHERE broadcast_debug(__FUNCTION__,__LINE__,__FILE__,"") < # define BDEBUGINFO(fmt,args...) broadcast_debug(__FUNCTION__,__LINE__,__FILE__,fmt,##args) < # define BDEBUG BDEBUGINFO < # define BDEBUGINFO_ARGV(argc,argv) broadcast_debug_showargv(__FUNCTION__,__LINE__,__FILE__,argc,argv) < # define BDEBUGBT broadcast_bt(__FUNCTION__,__LINE__,__FILE__,"") < # define BDEBUGMEM(addr,varname) broadcast_mem(__FUNCTION__,__LINE__,__FILE__,addr,varname) < #else < # define BDEBUGWHERE < # define BDEBUGINFO < # define BDEBUG < # define BDEBUGINFO_ARGV < # define BDEBUGBT < # define BDEBUGMEM < #endif < < < #ifdef BDEBUG_ON < static char* repstr(int len, char cFill) < { < memset(szFilling, cFill, sizeof(szFilling)); < if (len<=0) < szFilling[1]=0; < else if (len < union semun { < int val; /* Value for SETVAL */ < struct semid_ds *buf; /* Buffer for IPC_STAT, IPC_SET */ < unsigned short *array; /* Array for GETALL, SETALL */ < struct seminfo *__buf; /* Buffer for IPC_INFO < (Linux specific) */ < }; < #define SEMAPHORE_KEY ((key_t)0x12345678) < < static int semaphore_p(void) < { < struct sembuf sem_b; < int semid; < int ret; < sem_b.sem_num = 0; < sem_b.sem_op = -1; < sem_b.sem_flg = SEM_UNDO; < semid = semget(SEMAPHORE_KEY,1,0666 | IPC_CREAT); < ret = semop(semid,&sem_b,1); < return ret; < } < < static int semaphore_v(void) < { < struct sembuf sem_b; < int semid; < int ret; < sem_b.sem_num = 0; < sem_b.sem_op = 1; < sem_b.sem_flg = SEM_UNDO; < semid = semget(SEMAPHORE_KEY,1,0666 | IPC_CREAT); < ret = semop(semid,&sem_b,1); < return ret; < } < //信号量 378c341 < static void send_file_and_exit(const char *url, int what, bool bExtedCgi) ATTRIBUTE_NORETURN; --- > static void send_file_and_exit(const char *url, int what) ATTRIBUTE_NORETURN; 984c947 < static void send_headers(int responseNum, char* filename) --- > static void send_headers(int responseNum) 986d948 < BDEBUG("filename: %s", filename); 1019,1031c981,984 < if (filename && 0==strcmp(mime_type,"application/octet-stream")){ < len = sprintf(iobuf, < "HTTP/1.0 %d %s\r\nContent-type: %s\r\n" < "Content-Disposition: attachment; filename=\"%s\";\r\n" < "Date: %s\r\nConnection: close\r\n", < responseNum, responseString, mime_type, filename, tmp_str); < } < else{ < len = sprintf(iobuf, < "HTTP/1.0 %d %s\r\nContent-type: text/html\r\n" < "Date: %s\r\nConnection: close\r\n", < responseNum, responseString, tmp_str); < } --- > len = sprintf(iobuf, > "HTTP/1.0 %d %s\r\nContent-type: %s\r\n" > "Date: %s\r\nConnection: close\r\n", > responseNum, responseString, mime_type, tmp_str); 1057c1010 < return send_file_and_exit(error_page, SEND_BODY,false); --- > return send_file_and_exit(error_page, SEND_BODY); 1093d1045 < BDEBUG("Header:'%s'",iobuf); 1104c1056 < send_headers(responseNum,NULL); --- > send_headers(responseNum); 1134d1085 < BDEBUG("iobuf:'%s'",iobuf); 1319d1269 < //........................................................................................................ 1322,1325d1271 < #include "../include/ipc_cgi_ext.h" < //#include "../../../common.h" < #define MYBUFSIZE 2048 < 1331,1333c1277,1301 < < static void send_cubermctrl_cgi_post_response(char *msg, char* back_to_url) ATTRIBUTE_NORETURN; < static void send_cubermctrl_cgi_post_response(char *msg, char* back_to_url) --- > /* > * Spawn CGI script, forward CGI's stdin/out <=> network > * > * Environment variables are set up and the script is invoked with pipes > * for stdin/stdout. If a POST is being done the script is fed the POST > * data in addition to setting the QUERY_STRING variable (for GETs or POSTs). > * > * Parameters: > * const char *url The requested URL (with leading /). > * int post_len Length of the POST body. > * const char *cookie For set HTTP_COOKIE. > * const char *content_type For set CONTENT_TYPE. > */ > static void send_cgi_and_exit( > const char *url, > const char *request, > int post_len, > const char *cookie, > const char *content_type) ATTRIBUTE_NORETURN; > static void send_cgi_and_exit( > const char *url, > const char *request, > int post_len, > const char *cookie, > const char *content_type) 1335,1338c1303,1306 < int len = 0; < len += sprintf(iobuf+len, "HTTP/1.0 200 \r\nContent-Type:text/html;\r\nConnection: close\r\n"); < iobuf[len++] = '\r'; < iobuf[len++] = '\n'; --- > struct fd_pair fromCgi; /* CGI -> httpd pipe */ > struct fd_pair toCgi; /* httpd -> CGI pipe */ > char *script; > int pid; 1340,1349c1308,1310 < len += sprintf(iobuf+len, "Upload result\n"); < /* printf("", s); */ < len += sprintf(iobuf+len, "", back_to_url); < len += sprintf(iobuf+len, "

%s. You will automatically redirect to previous page.

", msg); < full_write(STDOUT_FILENO, iobuf, len); < log_and_exit(); < } --- > /* Make a copy. NB: caller guarantees: > * url[0] == '/', url[1] != '/' */ > url = xstrdup(url); 1351,1360c1312,1316 < static void send_cubermctrl_cgi_fileupload_and_exit(char *request, char* content_type) ATTRIBUTE_NORETURN; < static void send_cubermctrl_cgi_fileupload_and_exit(char *request, char* content_type) < { < char *p, *q; < char *path = NULL; < char *szBoundary = NULL; < char filename[256]; < char fullpathname[256]; < char szTail[256]; < int len; --- > /* > * We are mucking with environment _first_ and then vfork/exec, > * this allows us to use vfork safely. Parent doesn't care about > * these environment changes anyway. > */ 1361a1318,1321 > /* Check for [dirs/]script.cgi/PATH_INFO */ > script = (char*)url; > while ((script = strchr(script + 1, '/')) != NULL) { > struct stat sb; 1363,1367c1323,1329 < /* get path, that is: where to put file. */ < path = strstr(request,"folder="); < if (NULL==path) { < BDEBUG("syntax error, no folder is found."); < log_and_exit(); --- > *script = '\0'; > if (!is_directory(url + 1, 1, &sb)) { > /* not directory, found script.cgi/PATH_INFO */ > *script = '/'; > break; > } > *script = '/'; /* is directory, find next '/' */ 1369,1373c1331,1336 < path += 7; /* 7 is length of "folder=" */ < path = decodeString(path, 0); < if (access(path,F_OK)) { < BDEBUG("Folder does not exist. ref: '%s'",path); < log_and_exit(); --- > setenv1("PATH_INFO", script); /* set to /PATH_INFO or "" */ > setenv1("REQUEST_METHOD", request); > if (g_query) { > putenv(xasprintf("%s=%s?%s", "REQUEST_URI", url, g_query)); > } else { > setenv1("REQUEST_URI", url); 1375c1338,1339 < BDEBUG("upload file to: %s",path); --- > if (script != NULL) > *script = '\0'; /* cut off /PATH_INFO */ 1377,1381c1341,1344 < /* get boundary */ < szBoundary = strstr(content_type, "boundary="); < if (NULL==szBoundary) { < BDEBUG("Failed to get boundary."); < log_and_exit(); --- > /* SCRIPT_FILENAME is required by PHP in CGI mode */ > if (home_httpd[0] == '/') { > char *fullpath = concat_path_file(home_httpd, url); > setenv1("SCRIPT_FILENAME", fullpath); 1383,1404c1346,1375 < szBoundary += 9; < sprintf(szTail, "%s--%s--%s", "\r\n", szBoundary, "\r\n"); < BDEBUG("boundary: '%s', szTail: '%s'",szBoundary,szTail); < len = 0; < int count = 0; < int nSizeOfTailBoundary = strlen(szTail); < char c; < bool bLeftBoundaryIsFound = false; < bool bSkipContentDisp = false; < bool bSkipContentType = false; < bool bSkipHeadNewline = false; < bool bInContent = false; < FILE *fp = NULL; < while (1) { < < if (hdr_cnt <= 0) { < hdr_cnt = safe_read(STDIN_FILENO, hdr_buf, sizeof(hdr_buf)); < if (hdr_cnt <= 0){ < BDEBUG("hdr_cnt:%d, <=0, break", hdr_cnt); < break; < } < hdr_ptr = hdr_buf; --- > /* set SCRIPT_NAME as full path: /cgi-bin/dirs/script.cgi */ > setenv1("SCRIPT_NAME", url); > /* http://hoohoo.ncsa.uiuc.edu/cgi/env.html: > * QUERY_STRING: The information which follows the ? in the URL > * which referenced this script. This is the query information. > * It should not be decoded in any fashion. This variable > * should always be set when there is query information, > * regardless of command line decoding. */ > /* (Older versions of bbox seem to do some decoding) */ > setenv1("QUERY_STRING", g_query); > putenv((char*)"SERVER_SOFTWARE=busybox httpd/"BB_VER); > putenv((char*)"SERVER_PROTOCOL=HTTP/1.0"); > putenv((char*)"GATEWAY_INTERFACE=CGI/1.1"); > /* Having _separate_ variables for IP and port defeats > * the purpose of having socket abstraction. Which "port" > * are you using on Unix domain socket? > * IOW - REMOTE_PEER="1.2.3.4:56" makes much more sense. > * Oh well... */ > { > char *p = rmt_ip_str ? rmt_ip_str : (char*)""; > char *cp = strrchr(p, ':'); > if (ENABLE_FEATURE_IPV6 && cp && strchr(cp, ']')) > cp = NULL; > if (cp) *cp = '\0'; /* delete :PORT */ > setenv1("REMOTE_ADDR", p); > if (cp) { > *cp = ':'; > #if ENABLE_FEATURE_HTTPD_SET_REMOTE_PORT_TO_ENV > setenv1("REMOTE_PORT", cp + 1); > #endif 1406,1407c1377,1392 < iobuf[count] = c = *hdr_ptr++; < hdr_cnt--; --- > } > setenv1("HTTP_USER_AGENT", user_agent); > if (post_len) > putenv(xasprintf("CONTENT_LENGTH=%d", post_len)); > if (cookie) > setenv1("HTTP_COOKIE", cookie); > if (content_type) > setenv1("CONTENT_TYPE", content_type); > #if ENABLE_FEATURE_HTTPD_BASIC_AUTH > if (remoteuser) { > setenv1("REMOTE_USER", remoteuser); > putenv((char*)"AUTH_TYPE=Basic"); > } > #endif > if (referer) > setenv1("HTTP_REFERER", referer); 1409,1414c1394,1395 < if (false == bInContent ) { < if (bSkipHeadNewline && bLeftBoundaryIsFound && bSkipContentDisp && bSkipContentType) { < bInContent = true; < BDEBUG("bInContent: '%s'", bInContent?"true":"false"); < } < } --- > xpiped_pair(fromCgi); > xpiped_pair(toCgi); 1416,1461c1397,1401 < if ((false == bInContent) && (c == '\n')) { < iobuf[count] = '\0'; < if (false == bSkipHeadNewline) { < if ((1==count && 0x0d == iobuf[0])){ < count = 0; < BDEBUG("0 ************************ bSkipHeadNewline = true"); < if (bLeftBoundaryIsFound){ < bSkipHeadNewline = true; < BDEBUG("1 ************************ bSkipHeadNewline = true"); < } < continue; < } < } < if (false == bLeftBoundaryIsFound) { < // if (0 == strncmp(iobuf, szBoundary, strlen(szBoundary))) < if (strcasestr(iobuf, szBoundary)) < { < bLeftBoundaryIsFound = true; < count = 0; < BDEBUG("2 ************************ bLeftBoundaryIsFound = true;"); < continue; < } < } < if (false == bSkipContentDisp) { < if (strcasestr(iobuf, "content-disposition:")) { < q = strcasestr(iobuf, "filename="); < if (q) { < q += sizeof("filename="); < if ('"' == *q) < q++; < strcpy(filename, q); < /* ie8 发送过来的内容,文件名是c:\path\filename.ext格式 */ < BDEBUG("2.1 ************************ filename: %s", filename); < q = strrchr(filename, '\\'); < if (q) { < q++; < strcpy(filename, q); < BDEBUG("2.2 ************************ filename: %s", filename); < } < q = filename + strlen(filename)-1; < if (('"' == *q) || ('\r' == *q)) < *q = 0; < q = filename + strlen(filename)-1; < if (('"' == *q) || ('\r' == *q)) < *q = 0; < } --- > pid = vfork(); > if (pid < 0) { > /* TODO: log perror? */ > log_and_exit(); > } 1463,1464c1403,1405 < bSkipContentDisp = true; < count = 0; --- > if (!pid) { > /* Child process */ > char *argv[3]; 1466,1476c1407 < /* open fd for writing */ < sprintf(fullpathname, "%s/%s", path, filename); < BDEBUG("3 ************************ filename: %s", fullpathname); < fp = fopen(fullpathname, "w+"); < if (fp == NULL) { < BDEBUG("File open error. '%s'", fullpathname); < log_and_exit(); < } < continue; < } < } --- > xfunc_error_retval = 242; 1478,1485c1409,1416 < if (false == bSkipContentType) { < if (strcasestr(iobuf, "content-type:")) { < BDEBUG("4 ************************ bSkipContentType = true;"); < bSkipContentType = true; < count = 0; < continue; < } < } --- > /* NB: close _first_, then move fds! */ > close(toCgi.wr); > close(fromCgi.rd); > xmove_fd(toCgi.rd, 0); /* replace stdin with the pipe */ > xmove_fd(fromCgi.wr, 1); /* replace stdout with the pipe */ > /* User seeing stderr output can be a security problem. > * If CGI really wants that, it can always do dup itself. */ > /* dup2(1, 2); */ 1487c1418,1426 < iobuf[count] = c; --- > /* Chdiring to script's dir */ > script = strrchr(url, '/'); > if (script != url) { /* paranoia */ > *script = '\0'; > if (chdir(url + 1) != 0) { > bb_perror_msg("chdir %s", url + 1); > goto error_execing_cgi; > } > // not needed: *script = '/'; 1488a1428 > script++; 1489a1430,1432 > /* set argv[0] to name without path */ > argv[0] = script; > argv[1] = NULL; 1491,1495c1434,1436 < if (count < (IOBUF_SIZE - 1)) /* check overflow */ < count++; < < if (bInContent) { < /* now process file-content */ --- > #if ENABLE_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR > { > char *suffix = strrchr(script, '.'); 1497,1523c1438,1446 < /* c is '\n', so c may be one of 2 cases: 1 -- char in file-content, 2 -- new line before boundary */ < if (c == '\n' && count > 1) { < /* if '\n' is not the first char in iobuf, and there is not boundary in iobuf, < * then write chars before it to file. < */ < if ((count >= nSizeOfTailBoundary) && < (0==strncmp(iobuf, szTail, nSizeOfTailBoundary))) { < /* finished */ < fclose(fp); < system("sync"); < BDEBUG("fclose."); < bInContent = false; < break; < } < else { < /* write chars before "c and its prev" to file */ < if ((count >= 2) && (0x0d==iobuf[count-2]) && (0x0a==iobuf[count-1])) { < //char tmp[512]; < if (count-2 > 0) < fwrite(iobuf, 1, count-2, fp); < //memset(tmp, 0, sizeof(tmp)); < //snprintf(tmp, sizeof(tmp), "%s", iobuf); < BDEBUG("write %d chars, 0x0d 0x0a moved to head of iobuf", count-2); < //BDEBUG("szTail: '%s'", szTail); < count = 0; < iobuf[count++] = 0x0d; < iobuf[count++] = 0x0a; --- > if (suffix) { > Htaccess *cur; > for (cur = script_i; cur; cur = cur->next) { > if (strcmp(cur->before_colon + 1, suffix) == 0) { > /* found interpreter name */ > argv[0] = cur->after_colon; > argv[1] = script; > argv[2] = NULL; > break; 1525,1528d1447 < // else { < // fwrite(iobuf, 1, count, fp); < // count = 0; < // } 1531,1537d1449 < else if (count >= (IOBUF_SIZE-2)) { < /* 这里需要用IOBUF_SIZE-2, 因为上面对c=='\n'分支的处理不完全,会存在用IOBUF_SIZE-1话 < * ,可能出现count不能++而iobuf被覆盖1个字节的问题。*/ < fwrite(iobuf, 1, count, fp); < BDEBUG("write %d chars",count); < count = 0; < } 1539,1571c1451,1457 < } < < /* done. */ < sprintf(fullpathname, "/cgi-bin/cubermctrl.cgi?id=2&cmd=BROWSE&folder=%s", path); < send_cubermctrl_cgi_post_response("File upload successed", fullpathname); < //log_and_exit(); < } < < #define HDD_MOUNT_ROOT "/tmp/hdd/volumes/" < #define HDD_FILES_LINK "dev_hdd" < #define USB_MOUNT_ROOT "/tmp/usbmounts/" < #define USB_FILES_LINK "dev_usb" < #define INTERNAL_HDD_BROWSE_PATH "/tmp/ramfs/volumes/HDD:" < #define M3UFILEDEFAULTPATH INTERNAL_HDD_BROWSE_PATH < #define INTERNAL_FIRST_PARTITION_NAME "HDD1" < #define IDE_HDD_MOUNT_POINT "/usr/local/etc/hdd/volumes" < #define MUSICM3UFILENAME "/m3u.Music" < #define VIDEOM3UFILENAME "/m3u.Video" < #define PICTUREM3UFILENAME "/m3u.Picture" < #define ALL3UFILENAME "/m3u.All" < #define M3UINFOFILE "/m3u.info" < #define M3UTYPE_MOVIE 1 < #define M3UTYPE_MUSIC 2 < #define M3UTYPE_PICTURE 3 < < #define SBCS 0x00 < #define UTF16_LE 0x01 < #define UTF16_BE 0x02 < #define UTF8 0x03 < char tmpbuf[1024]; < < char *ufgets(char *s, int size, FILE *stream, char charset) { < int i = 0; --- > #endif > /* restore default signal dispositions for CGI process */ > bb_signals(0 > | (1 << SIGCHLD) > | (1 << SIGPIPE) > | (1 << SIGHUP) > , SIG_DFL); 1573,1578c1459,1469 < if(charset != UTF16_LE && charset != UTF16_BE) < return fgets(s, size, stream); < else { < while(i < size-2) { < if(fread((void *)(s+i), 2, sizeof(char), stream) <= 0) < break; --- > /* _NOT_ execvp. We do not search PATH. argv[0] is a filename > * without any dir components and will only match a file > * in the current directory */ > execv(argv[0], argv); > if (verbose) > bb_perror_msg("exec %s", argv[0]); > error_execing_cgi: > /* send to stdout > * (we are CGI here, our stdout is pumped to the net) */ > send_headers_and_exit(HTTP_NOT_FOUND); > } /* end child */ 1580c1471 < i+=2; --- > /* Parent process */ 1582,1590c1473,1474 < if(charset == UTF16_LE < && s[i-2] == '\n' < && s[i-1] == 0) < break; < else if(charset == UTF16_BE < && s[i-1] == '\n' < && s[i-2] == 0) < break; < } --- > /* Restore variables possibly changed by child */ > xfunc_error_retval = 0; 1592,1599c1476,1479 < if(i != 0) { < s[i] = 0; < s[i+1] = 0; < return s; < } < else < return NULL; < } --- > /* Pump data */ > close(fromCgi.wr); > close(toCgi.rd); > cgi_io_loop_and_exit(fromCgi.rd, toCgi.wr, post_len); 1602,1615c1482 < bool IsMoreThanOnePartitionOfHdd(void) < { < char path [512] = {0}; < struct stat64 info; < < sprintf (path, "%s/HDD2", IDE_HDD_MOUNT_POINT); < < if (stat64 (path, &info) != 0 && errno == ENOENT) < { < return false; < } < < return true; < } --- > #endif /* FEATURE_HTTPD_CGI */ 1617,4650c1484,1491 < char* m3ufile_url(char* m3ufile) < { < memset(tmpbuf, 0, sizeof(tmpbuf)); < char hdd_label[256]; < char hdd_mount_point[256]; < char *p = strchr(m3ufile, '/'); < if (p) { < memset(hdd_label, 0, sizeof(hdd_label)); < if (p - m3ufile < sizeof(hdd_label)) { < strncpy(hdd_label, m3ufile, p - m3ufile); < } < snprintf(hdd_mount_point, sizeof(hdd_mount_point), "%s%s", "/tmp/ramfs/volumes/", hdd_label); < if (-1 != readlink(hdd_mount_point, hdd_label, sizeof(hdd_label))) { < char *q = strrchr(hdd_label, '/'); < if (q) { < q++; < snprintf(tmpbuf, sizeof(tmpbuf), "/%s/%s%s", HDD_FILES_LINK, q, p++); < } < } < } < return tmpbuf; < } < < static send_cubermctrl_cgi_m3uadd_and_exit(char* cmd, char *m3ufile) ATTRIBUTE_NORETURN; < static send_cubermctrl_cgi_m3uadd_and_exit(char* cmd, char *m3ufile) < { < char m3ufilename[512]; < char m3ufilename_m[512]; < char m3ufilename_v[512]; < char m3ufilename_p[512]; < char m3ufilename_a[512]; < char m3uinfofile[512]; < char sztmp[1024]; < char *item = strstr(cmd,"file="); < FILE *fp; < if (NULL==item) < log_and_exit(); < < item += 5; /* len of "file=" */ < /* get full-path filename of m3u */ < if(IsMoreThanOnePartitionOfHdd() == false) < { < sprintf(m3ufilename,"%s%s",M3UFILEDEFAULTPATH, m3ufile); < sprintf(m3uinfofile,"%s%s",M3UFILEDEFAULTPATH, M3UINFOFILE); < sprintf(m3ufilename_m,"%s%s",M3UFILEDEFAULTPATH, MUSICM3UFILENAME); < sprintf(m3ufilename_v,"%s%s",M3UFILEDEFAULTPATH, VIDEOM3UFILENAME); < sprintf(m3ufilename_p,"%s%s",M3UFILEDEFAULTPATH, PICTUREM3UFILENAME); < sprintf(m3ufilename_a,"%s%s",M3UFILEDEFAULTPATH, ALL3UFILENAME); < } < else < { < sprintf(m3ufilename,"%s/%s/%s",M3UFILEDEFAULTPATH,INTERNAL_FIRST_PARTITION_NAME,m3ufile); < sprintf(m3uinfofile,"%s/%s/%s",M3UFILEDEFAULTPATH,INTERNAL_FIRST_PARTITION_NAME,M3UINFOFILE); < sprintf(m3ufilename_m,"%s/%s/%s",M3UFILEDEFAULTPATH,INTERNAL_FIRST_PARTITION_NAME,MUSICM3UFILENAME); < sprintf(m3ufilename_v,"%s/%s/%s",M3UFILEDEFAULTPATH,INTERNAL_FIRST_PARTITION_NAME,VIDEOM3UFILENAME); < sprintf(m3ufilename_p,"%s/%s/%s",M3UFILEDEFAULTPATH,INTERNAL_FIRST_PARTITION_NAME,PICTUREM3UFILENAME); < sprintf(m3ufilename_a,"%s/%s/%s",M3UFILEDEFAULTPATH,INTERNAL_FIRST_PARTITION_NAME,ALL3UFILENAME); < } < < if((fp = fopen(m3ufilename, "a+")) != NULL) < { < < decodeString(item, 0); < fputs(item, fp); < fputs("\n", fp); < fclose(fp); < sync(); < } < < //music number < if(access(m3ufilename_m, F_OK)) < sprintf(sztmp, "echo \"0\" > %s", m3uinfofile); < else < sprintf(sztmp, "wc -l %s | cut -d '/' -f1 | sed -e \"s/ //g\" > %s", m3ufilename_m, m3uinfofile); < system(sztmp); < < //video number < if(access(m3ufilename_v, F_OK)) < sprintf(sztmp, "echo \"0\" >> %s", m3uinfofile); < else < sprintf(sztmp, "wc -l %s | cut -d '/' -f1 | sed -e \"s/ //g\" >> %s", m3ufilename_v, m3uinfofile); < system(sztmp); < < //picture number < if(access(m3ufilename_p, F_OK)) < sprintf(sztmp, "echo \"0\" >> %s", m3uinfofile); < else < sprintf(sztmp, "wc -l %s | cut -d '/' -f1 | sed -e \"s/ //g\" >> %s", m3ufilename_p, m3uinfofile); < system(sztmp); < < //all number < if(access(m3ufilename_a, F_OK)) < sprintf(sztmp, "echo \"0\" >> %s", m3uinfofile); < else < sprintf(sztmp, "wc -l %s | cut -d '/' -f1 | sed -e \"s/ //g\" >> %s", m3ufilename_a, m3uinfofile); < system(sztmp); < < #if 0 < sprintf(sztmp, "wc -l %s | cut -d '/' -f1 | sed -e \"s/ //g\" > %s", m3ufilename_m, m3uinfofile); < system(sztmp); < sprintf(sztmp, "wc -l %s | cut -d '/' -f1 | sed -e \"s/ //g\" >> %s", m3ufilename_v, m3uinfofile); < system(sztmp); < sprintf(sztmp, "wc -l %s | cut -d '/' -f1 | sed -e \"s/ //g\" >> %s", m3ufilename_p, m3uinfofile); < system(sztmp); < sprintf(sztmp, "wc -l %s | cut -d '/' -f1 | sed -e \"s/ //g\" >> %s", m3ufilename_a, m3uinfofile); < system(sztmp); < #endif < //m3u.info文件的第一行~第4行,分别是对应的Music,Video,Picture对应的playlist的文件的数量 < // < #if 0 < FILE *fpinfo; < int playlistnum[4]; < char szline[128]; < bool bfgetsok = true; < memset(playlistnum, 0, sizeof(playlistnum)); < if((fpinfo = fopen(m3uinfofile, "a+")) != NULL) < { < // line 1 -- Music < if (fgets(szline, sizeof(szline), fpinfo)){ < playlistnum[0] = atoi(szline); < } < else < bfgetsok = false; < // line 2 -- Video < if (bfgetsok && fgets(szline, sizeof(szline), fpinfo)){ < playlistnum[1] = atoi(szline); < } < else < bfgetsok = false; < // line 3 -- Photo < if (bfgetsok && fgets(szline, sizeof(szline), fpinfo)){ < playlistnum[2] = atoi(szline); < } < else < bfgetsok = false; < // line 4 -- All < if (bfgetsok && fgets(szline, sizeof(szline), fpinfo)){ < playlistnum[3] = atoi(szline); < } < < if (0==strcmp(m3ufile, MUSICM3UFILENAME)) { < playlistnum[0]++; < } < else if (0==strcmp(m3ufile, VIDEOM3UFILENAME)) { < playlistnum[1]++; < } < else if (0==strcmp(m3ufile, PICTUREM3UFILENAME)) { < playlistnum[2]++; < } < < sprintf(szline, "%1d\n%1d\n%1d\n%1d\n", playlistnum[0],playlistnum[1],playlistnum[2],playlistnum[3]); < fclose(fpinfo); < fpinfo = fopen(m3uinfofile, "w"); < fwrite(szline, 1, strlen(szline), fpinfo); < fclose(fpinfo); < sync(); < } < #endif < < int len = 0; < len += sprintf(iobuf+len, "HTTP/1.0 200 \r\nContent-Type:text/html;\r\nConnection: close\r\n"); < iobuf[len++] = '\r'; < iobuf[len++] = '\n'; < len += sprintf(iobuf+len, "\n"); < len += sprintf(iobuf+len, ""); < full_write(STDOUT_FILENO, iobuf, len); < < log_and_exit(); < } < < static void send_cubermctrl_cgi_m3udel_and_exit( < char* cmd, char *m3ufile, char* title, char* m3utype) ATTRIBUTE_NORETURN; < static void send_cubermctrl_cgi_m3udel_and_exit( < char* cmd, char *m3ufile, char* title, char* m3utype) < { < < char m3ufilename[512]; < char m3ufilename_tmp[512]; < decodeString(cmd, 0); < char *item = strstr(cmd, "file="); < if (item) < item += 5; /* len of "file=" */ < < /* get full-path filename of m3u */ < if(IsMoreThanOnePartitionOfHdd() == false) < { < sprintf(m3ufilename,"%s%s",M3UFILEDEFAULTPATH,m3ufile); < } < else < { < sprintf(m3ufilename,"%s/%s/%s",M3UFILEDEFAULTPATH,INTERNAL_FIRST_PARTITION_NAME,m3ufile); < } < < sprintf(m3ufilename_tmp, "%s_tmp", m3ufilename); < BDEBUG("m3ufilename: %s", m3ufilename); < static const char RFC1123FMT[] ALIGN1 = "%a, %d %b %Y %H:%M:%S GMT"; < const char *mime_type; < unsigned i; < time_t timer = time(0); < char tmp_str[80]; < int len; < < /* error message is HTML */ < mime_type = found_mime_type; < < /* emit the current date */ < strftime(tmp_str, sizeof(tmp_str), RFC1123FMT, gmtime(&timer)); < /* 1/3: send head */ < len = sprintf(iobuf, < "HTTP/1.0 200 \r\nContent-type: %s\r\n" < "Date: %s\r\nConnection: close\r\n", < "text/html"/*mime_type*/, tmp_str); < iobuf[len++] = '\r'; < iobuf[len++] = '\n'; < len += sprintf(iobuf + len, < "devices browse" < "" < "\n" < "\n" < "%s
\n", title); < if (full_write(STDOUT_FILENO, iobuf, len) != len) { < if (verbose > 1) < bb_perror_msg("error"); < log_and_exit(); < } < < < /* read file and display ervery line */ < FILE *fp; < FILE *fp_tmp; < char textbuffer[512]; < < if((fp_tmp = fopen(m3ufilename_tmp, "w+")) != NULL) { < BDEBUG("create file '%s' failed.", m3ufilename_tmp); < } < < if((fp = fopen(m3ufilename, "r")) != NULL) < { < //@TODO: detect UTF16 BOM here ... < char charset = UTF8; < char buffer[2]; < fread(buffer, 2, sizeof(char), fp); < if((buffer[0] & 0xff) == 0xFF && (buffer[1] & 0xff) == 0xFE) < charset = UTF16_LE; < else if((buffer[0] & 0xff) == 0xFE && (buffer[1] & 0xff) == 0xFF) < charset = UTF16_BE; < < if(charset == UTF8) < rewind(fp); < < int line=1;//Add by ray for issue 0010814,1 for /../ < < while(ufgets(textbuffer, 512-1, fp, charset) != NULL) < { < if(charset != UTF8) < { < char convert_buffer[512]={0}; < //charset_convert_cgi(charset, UTF8, textbuffer, convert_buffer, 512); < strncpy(textbuffer, convert_buffer, 512-1); < } < < if(textbuffer[0] != '#' && textbuffer[0] != '\n' && textbuffer[0] != 0) < { < if (textbuffer[strlen(textbuffer)-2] == 0x0D && textbuffer[strlen(textbuffer)-1] == 0x0A) < textbuffer[strlen(textbuffer)-2] = 0; < else if(textbuffer[strlen(textbuffer)-2] != 0x0D && textbuffer[strlen(textbuffer)-1] == 0x0A) < textbuffer[strlen(textbuffer)-1] = 0; < } < < if (0 != strcmp(textbuffer, item)) { < len=sprintf(iobuf, "‹" < "Del%s
\n" < , m3utype, textbuffer, m3ufile_url(textbuffer), textbuffer); < if (full_write(STDOUT_FILENO, iobuf, len) != len) { < if (verbose > 1) < bb_perror_msg("error"); < log_and_exit(); < } < fputs(textbuffer, fp_tmp); < fputs("\n", fp_tmp); < } < else < { < BDEBUG("delete: '%s'", item); < } < } < fclose(fp); < if (fp_tmp) < fclose(fp_tmp); < sprintf(textbuffer, "mv -f %s %s", m3ufilename_tmp, m3ufilename); < system(textbuffer); < sync(); < } < < < /* 3/3: send tail */ < len = sprintf(iobuf, "\n"); < if (full_write(STDOUT_FILENO, iobuf, len) != len) { < if (verbose > 1) < bb_perror_msg("error"); < log_and_exit(); < } < < < char m3ufilename_m[512]; < char m3ufilename_v[512]; < char m3ufilename_p[512]; < char m3ufilename_a[512]; < char m3uinfofile[512]; < char sztmp[1024]; < < /* get full-path filename of m3u */ < if(IsMoreThanOnePartitionOfHdd() == false) < { < sprintf(m3uinfofile,"%s%s",M3UFILEDEFAULTPATH, M3UINFOFILE); < sprintf(m3ufilename_m,"%s%s",M3UFILEDEFAULTPATH, MUSICM3UFILENAME); < sprintf(m3ufilename_v,"%s%s",M3UFILEDEFAULTPATH, VIDEOM3UFILENAME); < sprintf(m3ufilename_p,"%s%s",M3UFILEDEFAULTPATH, PICTUREM3UFILENAME); < sprintf(m3ufilename_a,"%s%s",M3UFILEDEFAULTPATH, ALL3UFILENAME); < } < else < { < sprintf(m3uinfofile,"%s/%s/%s",M3UFILEDEFAULTPATH,INTERNAL_FIRST_PARTITION_NAME,M3UINFOFILE); < sprintf(m3ufilename_m,"%s/%s/%s",M3UFILEDEFAULTPATH,INTERNAL_FIRST_PARTITION_NAME,MUSICM3UFILENAME); < sprintf(m3ufilename_v,"%s/%s/%s",M3UFILEDEFAULTPATH,INTERNAL_FIRST_PARTITION_NAME,VIDEOM3UFILENAME); < sprintf(m3ufilename_p,"%s/%s/%s",M3UFILEDEFAULTPATH,INTERNAL_FIRST_PARTITION_NAME,PICTUREM3UFILENAME); < sprintf(m3ufilename_a,"%s/%s/%s",M3UFILEDEFAULTPATH,INTERNAL_FIRST_PARTITION_NAME,ALL3UFILENAME); < } < < < //music number < if(access(m3ufilename_m, F_OK)) < sprintf(sztmp, "echo \"0\" > %s", m3uinfofile); < else < sprintf(sztmp, "wc -l %s | cut -d '/' -f1 | sed -e \"s/ //g\" > %s", m3ufilename_m, m3uinfofile); < system(sztmp); < < //video number < if(access(m3ufilename_v, F_OK)) < sprintf(sztmp, "echo \"0\" >> %s", m3uinfofile); < else < sprintf(sztmp, "wc -l %s | cut -d '/' -f1 | sed -e \"s/ //g\" >> %s", m3ufilename_v, m3uinfofile); < system(sztmp); < < //picture number < if(access(m3ufilename_p, F_OK)) < sprintf(sztmp, "echo \"0\" >> %s", m3uinfofile); < else < sprintf(sztmp, "wc -l %s | cut -d '/' -f1 | sed -e \"s/ //g\" >> %s", m3ufilename_p, m3uinfofile); < system(sztmp); < < //all number < if(access(m3ufilename_a, F_OK)) < sprintf(sztmp, "echo \"0\" >> %s", m3uinfofile); < else < sprintf(sztmp, "wc -l %s | cut -d '/' -f1 | sed -e \"s/ //g\" >> %s", m3ufilename_a, m3uinfofile); < system(sztmp); < < } < < static void send_iPhone_cgi_m3udel_and_exit( < char* cmd, char *m3ufile, char* title, char* m3utype) ATTRIBUTE_NORETURN; < static void send_iPhone_cgi_m3udel_and_exit( < char* cmd, char *m3ufile, char* title, char* m3utype) < { < < char m3ufilename[512]; < char m3ufilename_tmp[512]; < decodeString(cmd, 0); < char *item = strstr(cmd, "file="); < if (item) < item += 5; /* len of "file=" */ < < /* get full-path filename of m3u */ < if(IsMoreThanOnePartitionOfHdd() == false) < { < sprintf(m3ufilename,"%s%s",M3UFILEDEFAULTPATH,m3ufile); < } < else < { < sprintf(m3ufilename,"%s/%s/%s",M3UFILEDEFAULTPATH,INTERNAL_FIRST_PARTITION_NAME,m3ufile); < } < < sprintf(m3ufilename_tmp, "%s_tmp", m3ufilename); < BDEBUG("m3ufilename: %s", m3ufilename); < static const char RFC1123FMT[] ALIGN1 = "%a, %d %b %Y %H:%M:%S GMT"; < const char *mime_type; < unsigned i; < time_t timer = time(0); < char tmp_str[80]; < int len; < char image[24]; < if(strstr(title,"Movie Playlist")) strcpy(image,"i/v_list.png"); < if(strstr(title,"Music Playlist")) strcpy(image,"i/a_list.png"); < if(strstr(title,"Picture Playlist")) strcpy(image,"i/i_list.png"); < < /* error message is HTML */ < mime_type = found_mime_type; < < /* emit the current date */ < strftime(tmp_str, sizeof(tmp_str), RFC1123FMT, gmtime(&timer)); < /* 1/3: send head */ < len = sprintf(iobuf, < "HTTP/1.0 200 \r\nContent-type: text/html\r\n" < "Date: %s\r\nConnection: close\r\n" < , tmp_str); < iobuf[len++] = '\r'; < iobuf[len++] = '\n'; < len += sprintf(iobuf + len, < "playlist\n" < "\n" < "\n" < "\n" < "\n" < "\n" < "\n" < "\n" < "
\n" < "\n" < "\n" < "\n" < "\n" < "\n" < "\n" < ,image,title); < if (full_write(STDOUT_FILENO, iobuf, len) != len) { < if (verbose > 1) < bb_perror_msg("error"); < log_and_exit(); < } < < < /* read file and display ervery line */ < FILE *fp; < FILE *fp_tmp; < char textbuffer[512]; < < if((fp_tmp = fopen(m3ufilename_tmp, "w+")) != NULL) { < BDEBUG("create file '%s' failed.", m3ufilename_tmp); < } < < if((fp = fopen(m3ufilename, "r")) != NULL) < { < //@TODO: detect UTF16 BOM here ... < char charset = UTF8; < char buffer[2]; < fread(buffer, 2, sizeof(char), fp); < if((buffer[0] & 0xff) == 0xFF && (buffer[1] & 0xff) == 0xFE) < charset = UTF16_LE; < else if((buffer[0] & 0xff) == 0xFE && (buffer[1] & 0xff) == 0xFF) < charset = UTF16_BE; < < if(charset == UTF8) < rewind(fp); < < int line=1;//Add by ray for issue 0010814,1 for /../ < < while(ufgets(textbuffer, 512-1, fp, charset) != NULL) < { < if(charset != UTF8) < { < char convert_buffer[512]={0}; < //charset_convert_cgi(charset, UTF8, textbuffer, convert_buffer, 512); < strncpy(textbuffer, convert_buffer, 512-1); < } < < if(textbuffer[0] != '#' && textbuffer[0] != '\n' && textbuffer[0] != 0) < { < if (textbuffer[strlen(textbuffer)-2] == 0x0D && textbuffer[strlen(textbuffer)-1] == 0x0A) < textbuffer[strlen(textbuffer)-2] = 0; < else if(textbuffer[strlen(textbuffer)-2] != 0x0D && textbuffer[strlen(textbuffer)-1] == 0x0A) < textbuffer[strlen(textbuffer)-1] = 0; < } < < if (0 != strcmp(textbuffer, item)) { < < char image_icon[24]; < if(strstr(m3utype,"MOVIE")) strcpy(image_icon,"i/cgi_video.png"); < if(strstr(m3utype,"MUSIC")) strcpy(image_icon,"i/cgi_audio.png"); < if(strstr(m3utype,"PICTURE")) strcpy(image_icon,"i/cgi_image.png"); < /* iPhone < len=sprintf(iobuf, "

%s

\n" < "\n" < "
 (Del)%s
\n" < , m3utype, textbuffer, m3ufile_url(textbuffer), textbuffer); < */ < len=sprintf(iobuf, "\n" < "

DEL\n" < "

%s\n" < "\n" < "\n" < , m3utype, textbuffer, m3ufile_url(textbuffer), textbuffer,image_icon); < if (full_write(STDOUT_FILENO, iobuf, len) != len) { < if (verbose > 1) < bb_perror_msg("error"); < log_and_exit(); < } < fputs(textbuffer, fp_tmp); < fputs("\n", fp_tmp); < } < else < { < BDEBUG("delete: '%s'", item); < } < } < fclose(fp); < if (fp_tmp) < fclose(fp_tmp); < sprintf(textbuffer, "mv -f %s %s", m3ufilename_tmp, m3ufilename); < system(textbuffer); < sync(); < } < < < /* 3/3: send tail */ < len = sprintf(iobuf, "

\n"); < if (full_write(STDOUT_FILENO, iobuf, len) != len) { < if (verbose > 1) < bb_perror_msg("error"); < log_and_exit(); < } < < < char m3ufilename_m[512]; < char m3ufilename_v[512]; < char m3ufilename_p[512]; < char m3ufilename_a[512]; < char m3uinfofile[512]; < char sztmp[1024]; < < /* get full-path filename of m3u */ < if(IsMoreThanOnePartitionOfHdd() == false) < { < sprintf(m3uinfofile,"%s%s",M3UFILEDEFAULTPATH, M3UINFOFILE); < sprintf(m3ufilename_m,"%s%s",M3UFILEDEFAULTPATH, MUSICM3UFILENAME); < sprintf(m3ufilename_v,"%s%s",M3UFILEDEFAULTPATH, VIDEOM3UFILENAME); < sprintf(m3ufilename_p,"%s%s",M3UFILEDEFAULTPATH, PICTUREM3UFILENAME); < sprintf(m3ufilename_a,"%s%s",M3UFILEDEFAULTPATH, ALL3UFILENAME); < } < else < { < sprintf(m3uinfofile,"%s/%s/%s",M3UFILEDEFAULTPATH,INTERNAL_FIRST_PARTITION_NAME,M3UINFOFILE); < sprintf(m3ufilename_m,"%s/%s/%s",M3UFILEDEFAULTPATH,INTERNAL_FIRST_PARTITION_NAME,MUSICM3UFILENAME); < sprintf(m3ufilename_v,"%s/%s/%s",M3UFILEDEFAULTPATH,INTERNAL_FIRST_PARTITION_NAME,VIDEOM3UFILENAME); < sprintf(m3ufilename_p,"%s/%s/%s",M3UFILEDEFAULTPATH,INTERNAL_FIRST_PARTITION_NAME,PICTUREM3UFILENAME); < sprintf(m3ufilename_a,"%s/%s/%s",M3UFILEDEFAULTPATH,INTERNAL_FIRST_PARTITION_NAME,ALL3UFILENAME); < } < < < //music number < if(access(m3ufilename_m, F_OK)) < sprintf(sztmp, "echo \"0\" > %s", m3uinfofile); < else < sprintf(sztmp, "wc -l %s | cut -d '/' -f1 | sed -e \"s/ //g\" > %s", m3ufilename_m, m3uinfofile); < system(sztmp); < < //video number < if(access(m3ufilename_v, F_OK)) < sprintf(sztmp, "echo \"0\" >> %s", m3uinfofile); < else < sprintf(sztmp, "wc -l %s | cut -d '/' -f1 | sed -e \"s/ //g\" >> %s", m3ufilename_v, m3uinfofile); < system(sztmp); < < //picture number < if(access(m3ufilename_p, F_OK)) < sprintf(sztmp, "echo \"0\" >> %s", m3uinfofile); < else < sprintf(sztmp, "wc -l %s | cut -d '/' -f1 | sed -e \"s/ //g\" >> %s", m3ufilename_p, m3uinfofile); < system(sztmp); < < //all number < if(access(m3ufilename_a, F_OK)) < sprintf(sztmp, "echo \"0\" >> %s", m3uinfofile); < else < sprintf(sztmp, "wc -l %s | cut -d '/' -f1 | sed -e \"s/ //g\" >> %s", m3ufilename_a, m3uinfofile); < system(sztmp); < } < < < < < < < < static void send_cubermctrl_cgi_moviem3u_and_exit( < char *m3ufile, char* title, char* m3utype) ATTRIBUTE_NORETURN; < static void send_cubermctrl_cgi_moviem3u_and_exit( < char *m3ufile, char* title, char* m3utype) < { < char m3ufilename[512]; < < /* get full-path filename of m3u */ < if(IsMoreThanOnePartitionOfHdd() == false) < { < < sprintf(m3ufilename,"%s%s",M3UFILEDEFAULTPATH,m3ufile); < } < else < { < sprintf(m3ufilename,"%s/%s/%s",M3UFILEDEFAULTPATH,INTERNAL_FIRST_PARTITION_NAME,m3ufile); < } < < BDEBUG("m3ufilename: %s", m3ufilename); < < static const char RFC1123FMT[] ALIGN1 = "%a, %d %b %Y %H:%M:%S GMT"; < const char *mime_type; < unsigned i; < time_t timer = time(0); < char tmp_str[80]; < int len; < < /* error message is HTML */ < mime_type = found_mime_type; < < /* emit the current date */ < strftime(tmp_str, sizeof(tmp_str), RFC1123FMT, gmtime(&timer)); < /* 1/3: send head */ < len = sprintf(iobuf, < "HTTP/1.0 200 \r\nContent-type: %s\r\n" < "Date: %s\r\nConnection: close\r\n", < "text/html"/*mime_type*/, tmp_str); < iobuf[len++] = '\r'; < iobuf[len++] = '\n'; < len += sprintf(iobuf + len, < "devices browse\n" < "\n" < "%s
\n",title); < if (full_write(STDOUT_FILENO, iobuf, len) != len) { < if (verbose > 1) < bb_perror_msg("error"); < log_and_exit(); < } < < < /* read file and display ervery line */ < FILE *fp; < char textbuffer[512]; < < if((fp = fopen(m3ufilename, "r")) != NULL) < { < //@TODO: detect UTF16 BOM here ... < char charset = UTF8; < char buffer[2]; < fread(buffer, 2, sizeof(char), fp); < if((buffer[0] & 0xff) == 0xFF && (buffer[1] & 0xff) == 0xFE) < charset = UTF16_LE; < else if((buffer[0] & 0xff) == 0xFE && (buffer[1] & 0xff) == 0xFF) < charset = UTF16_BE; < < if(charset == UTF8) < rewind(fp); < < int line=1;//Add by ray for issue 0010814,1 for /../ < < while(ufgets(textbuffer, 512-1, fp, charset) != NULL) < { < if(charset != UTF8) < { < char convert_buffer[512]={0}; < //charset_convert_cgi(charset, UTF8, textbuffer, convert_buffer, 512); < strncpy(textbuffer, convert_buffer, 512-1); < } < < if(textbuffer[0] != '#' && textbuffer[0] != '\n' && textbuffer[0] != 0) < { < if (textbuffer[strlen(textbuffer)-2] == 0x0D && textbuffer[strlen(textbuffer)-1] == 0x0A) < textbuffer[strlen(textbuffer)-2] = 0; < else if(textbuffer[strlen(textbuffer)-2] != 0x0D && textbuffer[strlen(textbuffer)-1] == 0x0A) < textbuffer[strlen(textbuffer)-1] = 0; < } < < len=sprintf(iobuf, "‹" < "Del%s
\n" < , m3utype, textbuffer, m3ufile_url(textbuffer), textbuffer); < if (full_write(STDOUT_FILENO, iobuf, len) != len) { < if (verbose > 1) < bb_perror_msg("error"); < log_and_exit(); < } < } < fclose(fp); < } < < /* 3/3: send tail */ < len = sprintf(iobuf, "\n"); < if (full_write(STDOUT_FILENO, iobuf, len) != len) { < if (verbose > 1) < bb_perror_msg("error"); < log_and_exit(); < } < < } < < static void send_iPhone_cgi_moviem3u_and_exit( < char *m3ufile, char* title, char* m3utype) ATTRIBUTE_NORETURN; < static void send_iPhone_cgi_moviem3u_and_exit( < char *m3ufile, char* title, char* m3utype) < { < char m3ufilename[512]; < < /* get full-path filename of m3u */ < if(IsMoreThanOnePartitionOfHdd() == false) < { < < sprintf(m3ufilename,"%s%s",M3UFILEDEFAULTPATH,m3ufile); < } < else < { < sprintf(m3ufilename,"%s/%s/%s",M3UFILEDEFAULTPATH,INTERNAL_FIRST_PARTITION_NAME,m3ufile); < } < < BDEBUG("m3ufilename: %s", m3ufilename); < < static const char RFC1123FMT[] ALIGN1 = "%a, %d %b %Y %H:%M:%S GMT"; < const char *mime_type; < unsigned i; < time_t timer = time(0); < char tmp_str[80]; < int len; < char image[24]; < if(strstr(title,"Movie Playlist")) strcpy(image,"i/v_list.png"); < if(strstr(title,"Music Playlist")) strcpy(image,"i/a_list.png"); < if(strstr(title,"Picture Playlist")) strcpy(image,"i/i_list.png"); < /* error message is HTML */ < mime_type = found_mime_type; < < /* emit the current date */ < strftime(tmp_str, sizeof(tmp_str), RFC1123FMT, gmtime(&timer)); < < /* 1/3: send head */ < len = sprintf(iobuf, < "HTTP/1.0 200 \r\nContent-type: text/html\r\n" < "Date: %s\r\nConnection: close\r\n" < , tmp_str); < iobuf[len++] = '\r'; < iobuf[len++] = '\n'; < len += sprintf(iobuf + len, < "playlist\n" < "\n" < "\n" < "\n" < "\n" < "\n" < "\n" < "\n" < "
\n" < "\n" < "\n" < "\n" < "\n" < "\n" < "\n" < ,image,title); < < < if (full_write(STDOUT_FILENO, iobuf, len) != len) { < if (verbose > 1) < bb_perror_msg("error"); < log_and_exit(); < } < < < /* read file and display ervery line */ < FILE *fp; < char textbuffer[512]; < < if((fp = fopen(m3ufilename, "r")) != NULL) < { < //@TODO: detect UTF16 BOM here ... < char charset = UTF8; < char buffer[2]; < fread(buffer, 2, sizeof(char), fp); < if((buffer[0] & 0xff) == 0xFF && (buffer[1] & 0xff) == 0xFE) < charset = UTF16_LE; < else if((buffer[0] & 0xff) == 0xFE && (buffer[1] & 0xff) == 0xFF) < charset = UTF16_BE; < < if(charset == UTF8) < rewind(fp); < < int line=1;//Add by ray for issue 0010814,1 for /../ < < while(ufgets(textbuffer, 512-1, fp, charset) != NULL) < { < if(charset != UTF8) < { < char convert_buffer[512]={0}; < //charset_convert_cgi(charset, UTF8, textbuffer, convert_buffer, 512); < strncpy(textbuffer, convert_buffer, 512-1); < } < < if(textbuffer[0] != '#' && textbuffer[0] != '\n' && textbuffer[0] != 0) < { < if (textbuffer[strlen(textbuffer)-2] == 0x0D && textbuffer[strlen(textbuffer)-1] == 0x0A) < textbuffer[strlen(textbuffer)-2] = 0; < else if(textbuffer[strlen(textbuffer)-2] != 0x0D && textbuffer[strlen(textbuffer)-1] == 0x0A) < textbuffer[strlen(textbuffer)-1] = 0; < } < < // len=sprintf(iobuf, "‹" < // "Del%s
\n" < // , m3utype, textbuffer, m3ufile_url(textbuffer), textbuffer); < /* < len=sprintf(iobuf, "

%s

\n" < "\n" < "
 (Del)%s
\n" < , m3utype, textbuffer, m3ufile_url(textbuffer), textbuffer); < */ < char image_icon[24]; < if(strstr(m3utype,"MOVIE")) strcpy(image_icon,"i/cgi_video.png"); < if(strstr(m3utype,"MUSIC")) strcpy(image_icon,"i/cgi_audio.png"); < if(strstr(m3utype,"PICTURE")) strcpy(image_icon,"i/cgi_image.png"); < < < len=sprintf(iobuf, "\n" < "

DEL\n" < "

%s\n" < "\n" < "\n" < , m3utype, textbuffer, m3ufile_url(textbuffer), textbuffer,image_icon); < < if (full_write(STDOUT_FILENO, iobuf, len) != len) { < if (verbose > 1) < bb_perror_msg("error"); < log_and_exit(); < } < } < fclose(fp); < } < < /* 3/3: send tail */ < len = sprintf(iobuf, "\n"); < if (full_write(STDOUT_FILENO, iobuf, len) != len) { < if (verbose > 1) < bb_perror_msg("error"); < log_and_exit(); < } < < } < < < < static void send_cubermctrl_cgi_filebrowse_and_exit( < char* request) ATTRIBUTE_NORETURN; < static void send_cubermctrl_cgi_filebrowse_and_exit( < char* request) < { < typedef struct _tagTABLESUFFIX < { < char *type; < char *suffix; < char *image; < char *tip; < }TABLESUFFIX; < < static TABLESUFFIX tableSuffix[]= < { < {"ADDM3UMUSIC","aac","cgi_audio.png","Add to music playlist"}, < {"ADDM3UMUSIC","flac","cgi_audio.png","Add to music playlist"}, < {"ADDM3UMUSIC","mp3","cgi_audio.png","Add to music playlist"}, < {"ADDM3UMUSIC","m4a","cgi_audio.png","Add to music playlist"}, < {"ADDM3UMUSIC","mp2","cgi_audio.png","Add to music playlist"}, < {"ADDM3UMUSIC","ogg","cgi_audio.png","Add to music playlist"}, < {"ADDM3UMUSIC","wav","cgi_audio.png","Add to music playlist"}, < {"ADDM3UMUSIC","wma","cgi_audio.png","Add to music playlist"}, < {"ADDM3UMUSIC","mka","cgi_audio.png","Add to music playlist"}, < < {"ADDM3UMOVIE","avi","cgi_video.png","Add to movie playlist"}, < {"ADDM3UMOVIE","asf","cgi_video.png","Add to movie playlist"}, < {"ADDM3UMOVIE","dat","cgi_video.png","Add to movie playlist"}, < {"ADDM3UMOVIE","divx","cgi_video.png","Add to movie playlist"}, < {"ADDM3UMOVIE","flv","cgi_video.png","Add to movie playlist"}, < {"ADDM3UMOVIE","iso","cgi_video.png","Add to movie playlist"}, < {"ADDM3UMOVIE","ifo","cgi_video.png","Add to movie playlist"}, < {"ADDM3UMOVIE","lnk","cgi_video.png","Add to movie playlist"}, < {"ADDM3UMOVIE","mkv","cgi_video.png","Add to movie playlist"}, < {"ADDM3UMOVIE","mks","cgi_video.png","Add to movie playlist"}, < {"ADDM3UMOVIE","m2ts","cgi_video.png","Add to movie playlist"}, < {"ADDM3UMOVIE","mts","cgi_video.png","Add to movie playlist"}, < {"ADDM3UMOVIE","mov","cgi_video.png","Add to movie playlist"}, < {"ADDM3UMOVIE","mpg","cgi_video.png","Add to movie playlist"}, < {"ADDM3UMOVIE","mpeg","cgi_video.png","Add to movie playlist"}, < {"ADDM3UMOVIE","mp4","cgi_video.png","Add to movie playlist"}, < {"ADDM3UMOVIE","m2v","cgi_video.png","Add to movie playlist"}, < {"ADDM3UMOVIE","m4v","cgi_video.png","Add to movie playlist"}, < {"ADDM3UMOVIE","rm","cgi_video.png","Add to movie playlist"}, < {"ADDM3UMOVIE","rmvb","cgi_video.png","Add to movie playlist"}, < {"ADDM3UMOVIE","ts","cgi_video.png","Add to movie playlist"}, < {"ADDM3UMOVIE","tsp","cgi_video.png","Add to movie playlist"}, < {"ADDM3UMOVIE","tp","cgi_video.png","Add to movie playlist"}, < {"ADDM3UMOVIE","trp","cgi_video.png","Add to movie playlist"}, < {"ADDM3UMOVIE","vob","cgi_video.png","Add to movie playlist"}, < {"ADDM3UMOVIE","wmv","cgi_video.png","Add to movie playlist"}, < < {"ADDM3UPICTURE","bmp","cgi_image.png","Add to picture playlist"}, < {"ADDM3UPICTURE","gif","cgi_image.png","Add to picture playlist"}, < {"ADDM3UPICTURE","jpg","cgi_image.png","Add to picture playlist"}, < {"ADDM3UPICTURE","jpeg","cgi_image.png","Add to picture playlist"}, < {"ADDM3UPICTURE","png","cgi_image.png","Add to picture playlist"}, < {"ADDM3UPICTURE","tif","cgi_image.png","Add to picture playlist"}, < }; < < static const char RFC1123FMT[] ALIGN1 = "%a, %d %b %Y %H:%M:%S GMT"; < < const char *mime_type; < unsigned i; < time_t timer = time(0); < char tmp_str[80]; < int len; < < /* error message is HTML */ < mime_type = found_mime_type; < < /* emit the current date */ < strftime(tmp_str, sizeof(tmp_str), RFC1123FMT, gmtime(&timer)); < /* 1/3: send head */ < len = sprintf(iobuf, < "HTTP/1.0 200 \r\nContent-type: %s\r\n" < "Date: %s\r\nConnection: close\r\n", < "text/html"/*mime_type*/, tmp_str); < iobuf[len++] = '\r'; < iobuf[len++] = '\n'; < len += sprintf(iobuf + len, < "devices browse\n" < "\n" < "\n"); < if (full_write(STDOUT_FILENO, iobuf, len) != len) { < if (verbose > 1) < bb_perror_msg("error"); < log_and_exit(); < } < < < /* 2/3: send body */ < DIR *pdir; < struct dirent *pent; < char subpath[2048]; < char szMsg[512]; < < char *path = strstr(request,"folder="); < if (NULL==path){ < BDEBUG("syntax error, no folder is found."); < log_and_exit(); < } < path += 7; // 7 is length of "folder=" < < path = decodeString(path, 0); < if(access(path,F_OK)) < { < BDEBUG("Folder does not exist."); < log_and_exit(); < } < < bool bIsHDD = false; < if (0==strncmp(path,USB_MOUNT_ROOT,strlen(USB_MOUNT_ROOT))) < bIsHDD = false; < else < bIsHDD = true; < char *pathfordisp = bIsHDD ? path+strlen(HDD_MOUNT_ROOT) : path+strlen(USB_MOUNT_ROOT); < int m = pathfordisp - path + 1; < int n = 0; < len = 0; < char *q1 = pathfordisp; < char *q2 = q1; < char sztmp1[1024]; < char sztmp2[256]; < while (q1-path" < "%s/", sztmp1, sztmp2); < q2 = q1+1; < < } < else if (q1 - path == strlen(path) - 1) { < snprintf(sztmp2, q1-q2+2, "%s", q2); < len += sprintf(subpath+len, "%s", sztmp2); < q2 = q1+1; < } < q1++; < } < < sprintf(sztmp1, < "

" < "     Upload a file to the above folder: " < "" < "
" < ,path); < < < /* 2.1/3: send path in body */ < len = sprintf(iobuf, "

" < "" < "" < " %s

%s
\n 1) < bb_perror_msg("error"); < log_and_exit(); < } < < < /* 2.2 / 3: scan directory, list folder in this directory first */ < pdir = opendir(path); < if (!pdir) < { < BDEBUG("Error to opendir"); < log_and_exit(); < } < < while ((pent = readdir(pdir)) != NULL) < { < struct stat fstat; < if (strcmp(pent->d_name, ".") == 0 || strcmp(pent->d_name, "..") == 0) < continue; < memset(subpath, 0, sizeof(subpath)); < strcpy(subpath, path); < if (subpath[strlen(subpath)-1] != '/') < strcat(subpath, "/"); < if(strlen(subpath) + strlen(pent->d_name) >= sizeof(subpath)) < continue; < strcat(subpath, pent->d_name); < int ret=stat(subpath, &fstat); < < if (-1==ret){ < switch (errno){ < case EACCES: < sprintf(szMsg,"Search permission is denied"); < case EBADF: < sprintf(szMsg,"fd is bad."); < case EFAULT: < sprintf(szMsg,"Bad address."); < case ELOOP: < sprintf(szMsg,"Too many symbolic links encountered while traversing the path."); < case ENAMETOOLONG: < sprintf(szMsg,"File name too long."); < case ENOENT: < sprintf(szMsg,"A component of the path path does not exist, or the path is empty"); < case ENOMEM: < sprintf(szMsg,"Out of memory (i.e., kernel memory)."); < case ENOTDIR: < sprintf(szMsg,"A component of the path is not a directory."); < case EOVERFLOW: < sprintf(szMsg,"(stat()) path refers to a file whose size cannot be represented in the type off_t."); < } < BDEBUG("o-o-o-o-o-o-o-o [%s]:%s",subpath,szMsg); < break; < } < < //cbFunc(subpath, fstat, script); < len = 0; < if (S_ISDIR(fstat.st_mode)) { < char ch = *(subpath + strlen(path)+1); < if ('.' == ch) continue; < //len += sprintf(iobuf, "\n"); < len += sprintf(iobuf, "\n"); < len += sprintf(iobuf + len, "\n" < "\n", < "Beige", subpath, subpath + strlen(path)+1); < len += sprintf(iobuf + len, ""); < len += sprintf(iobuf + len, "\n"); < } < else { < continue; < } < < if (full_write(STDOUT_FILENO, iobuf, len) != len) { < if (verbose > 1) < bb_perror_msg("error"); < log_and_exit(); < } < < } < closedir(pdir); < < /* 2.3 / 3: scan directory, list files in this directory */ < pdir = opendir(path); < if (!pdir) < { < BDEBUG("Error to opendir"); < log_and_exit(); < } < < while ((pent = readdir(pdir)) != NULL) < { < struct stat fstat; < if (strcmp(pent->d_name, ".") == 0 || strcmp(pent->d_name, "..") == 0) < continue; < memset(subpath, 0, sizeof(subpath)); < strcpy(subpath, path); < if (subpath[strlen(subpath)-1] != '/') < strcat(subpath, "/"); < if(strlen(subpath) + strlen(pent->d_name) >= sizeof(subpath)) < continue; < strcat(subpath, pent->d_name); < int ret=stat(subpath, &fstat); < < if (-1==ret){ < switch (errno){ < case EACCES: < sprintf(szMsg,"Search permission is denied"); < case EBADF: < sprintf(szMsg,"fd is bad."); < case EFAULT: < sprintf(szMsg,"Bad address."); < case ELOOP: < sprintf(szMsg,"Too many symbolic links encountered while traversing the path."); < case ENAMETOOLONG: < sprintf(szMsg,"File name too long."); < case ENOENT: < sprintf(szMsg,"A component of the path path does not exist, or the path is empty"); < case ENOMEM: < sprintf(szMsg,"Out of memory (i.e., kernel memory)."); < case ENOTDIR: < sprintf(szMsg,"A component of the path is not a directory."); < case EOVERFLOW: < sprintf(szMsg,"(stat()) path refers to a file whose size cannot be represented in the type off_t."); < } < BDEBUG("o-o-o-o-o-o-o-o [%s]:%s",subpath,szMsg); < break; < } < < //cbFunc(subpath, fstat, script); < len = 0; < /* files */ < if (S_ISREG(fstat.st_mode)) { < char ch = *(subpath + strlen(path)+1); < if ('.' == ch) continue; < < char *m3utype = NULL; < char *m3uimage = NULL; < char *tip = NULL; < char *ext = strrchr(subpath + strlen(path) + 1, '.'); < if (ext) { < ext ++; < for (int j = 0; j < sizeof(tableSuffix) / sizeof(tableSuffix[0]); j++) { < if (0==strcasecmp(ext, tableSuffix[j].suffix)) { < m3utype = tableSuffix[j].type; < m3uimage = tableSuffix[j].image; < tip = tableSuffix[j].tip; < break; < } < } < } < len += sprintf(iobuf, "\n"); < len += sprintf(iobuf + len, "\n" < "\n", < m3utype?"Azure":"Beige", bIsHDD ? HDD_FILES_LINK : USB_FILES_LINK, < subpath+strlen(bIsHDD ? HDD_MOUNT_ROOT : USB_MOUNT_ROOT), < subpath + strlen(path)+1); < if (m3utype && bIsHDD) { < char m3ufile[512]; < char *prefix = "/tmp/hdd/volumes/HDD1"; < char *q = strstr(subpath, prefix); < memset(m3ufile, 0, sizeof(m3ufile)); < if (q) { < sprintf(m3ufile, "HDD:%s", subpath + strlen(prefix)); < decodeString(m3ufile, 0); < } < < len += sprintf(iobuf + len, "", < m3utype, m3ufile, m3uimage, tip); < } < else { < len += sprintf(iobuf + len, ""); < } < len += sprintf(iobuf + len, "\n"); < } < else { < continue; < } < < if (full_write(STDOUT_FILENO, iobuf, len) != len) { < if (verbose > 1) < bb_perror_msg("error"); < log_and_exit(); < } < < } < closedir(pdir); < < < < /* 3/3: send tail */ < len = sprintf(iobuf, "
%s
   %s" < "
\n"); < if (full_write(STDOUT_FILENO, iobuf, len) != len) { < if (verbose > 1) < bb_perror_msg("error"); < log_and_exit(); < } < < } < < static void send_iPhone_cgi_filebrowse_and_exit( < char* request) ATTRIBUTE_NORETURN; < static void send_iPhone_cgi_filebrowse_and_exit( < char* request) < { < typedef struct _tagTABLESUFFIX < { < char *type; < char *suffix; < char *image; < char *tip; < }TABLESUFFIX; < < static TABLESUFFIX tableSuffix[]= < { < {"ADDM3UMUSIC","aac","cgi_audio.png","Add to music playlist"}, < {"ADDM3UMUSIC","flac","cgi_audio.png","Add to music playlist"}, < {"ADDM3UMUSIC","mp3","cgi_audio.png","Add to music playlist"}, < {"ADDM3UMUSIC","m4a","cgi_audio.png","Add to music playlist"}, < {"ADDM3UMUSIC","mp2","cgi_audio.png","Add to music playlist"}, < {"ADDM3UMUSIC","ogg","cgi_audio.png","Add to music playlist"}, < {"ADDM3UMUSIC","wav","cgi_audio.png","Add to music playlist"}, < {"ADDM3UMUSIC","wma","cgi_audio.png","Add to music playlist"}, < {"ADDM3UMUSIC","mka","cgi_audio.png","Add to music playlist"}, < < {"ADDM3UMOVIE","avi","cgi_video.png","Add to movie playlist"}, < {"ADDM3UMOVIE","asf","cgi_video.png","Add to movie playlist"}, < {"ADDM3UMOVIE","dat","cgi_video.png","Add to movie playlist"}, < {"ADDM3UMOVIE","divx","cgi_video.png","Add to movie playlist"}, < {"ADDM3UMOVIE","flv","cgi_video.png","Add to movie playlist"}, < {"ADDM3UMOVIE","iso","cgi_video.png","Add to movie playlist"}, < {"ADDM3UMOVIE","ifo","cgi_video.png","Add to movie playlist"}, < {"ADDM3UMOVIE","lnk","cgi_video.png","Add to movie playlist"}, < {"ADDM3UMOVIE","mkv","cgi_video.png","Add to movie playlist"}, < {"ADDM3UMOVIE","mks","cgi_video.png","Add to movie playlist"}, < {"ADDM3UMOVIE","m2ts","cgi_video.png","Add to movie playlist"}, < {"ADDM3UMOVIE","mts","cgi_video.png","Add to movie playlist"}, < {"ADDM3UMOVIE","mov","cgi_video.png","Add to movie playlist"}, < {"ADDM3UMOVIE","mpg","cgi_video.png","Add to movie playlist"}, < {"ADDM3UMOVIE","mpeg","cgi_video.png","Add to movie playlist"}, < {"ADDM3UMOVIE","mp4","cgi_video.png","Add to movie playlist"}, < {"ADDM3UMOVIE","m2v","cgi_video.png","Add to movie playlist"}, < {"ADDM3UMOVIE","m4v","cgi_video.png","Add to movie playlist"}, < {"ADDM3UMOVIE","rm","cgi_video.png","Add to movie playlist"}, < {"ADDM3UMOVIE","rmvb","cgi_video.png","Add to movie playlist"}, < {"ADDM3UMOVIE","ts","cgi_video.png","Add to movie playlist"}, < {"ADDM3UMOVIE","tsp","cgi_video.png","Add to movie playlist"}, < {"ADDM3UMOVIE","tp","cgi_video.png","Add to movie playlist"}, < {"ADDM3UMOVIE","trp","cgi_video.png","Add to movie playlist"}, < {"ADDM3UMOVIE","vob","cgi_video.png","Add to movie playlist"}, < {"ADDM3UMOVIE","wmv","cgi_video.png","Add to movie playlist"}, < < {"ADDM3UPICTURE","bmp","cgi_image.png","Add to picture playlist"}, < {"ADDM3UPICTURE","gif","cgi_image.png","Add to picture playlist"}, < {"ADDM3UPICTURE","jpg","cgi_image.png","Add to picture playlist"}, < {"ADDM3UPICTURE","jpeg","cgi_image.png","Add to picture playlist"}, < {"ADDM3UPICTURE","png","cgi_image.png","Add to picture playlist"}, < {"ADDM3UPICTURE","tif","cgi_image.png","Add to picture playlist"}, < }; < < static const char RFC1123FMT[] ALIGN1 = "%a, %d %b %Y %H:%M:%S GMT"; < < const char *mime_type; < unsigned i; < time_t timer = time(0); < char tmp_str[80]; < int len; < < /* error message is HTML */ < mime_type = found_mime_type; < < /* emit the current date */ < strftime(tmp_str, sizeof(tmp_str), RFC1123FMT, gmtime(&timer)); < /* 1/3: send head */ < len = sprintf(iobuf, < "HTTP/1.0 200 \r\nContent-type: %s\r\n" < "Date: %s\r\nConnection: close\r\n", < "text/html"/*mime_type*/, tmp_str); < iobuf[len++] = '\r'; < iobuf[len++] = '\n'; < len += sprintf(iobuf + len, < "devices browse\n" < "\n" < "\n" < "\n" < "\n" < "\n" < "\n" < "\n"); < if (full_write(STDOUT_FILENO, iobuf, len) != len) { < if (verbose > 1) < bb_perror_msg("error"); < log_and_exit(); < } < < < /* 2/3: send body */ < DIR *pdir; < struct dirent *pent; < char subpath[2048]; < char szMsg[512]; < < char *path = strstr(request,"folder="); < if (NULL==path){ < BDEBUG("syntax error, no folder is found."); < log_and_exit(); < } < path += 7; // 7 is length of "folder=" < < path = decodeString(path, 0); < if(access(path,F_OK)) < { < BDEBUG("Folder does not exist."); < log_and_exit(); < } < < bool bIsHDD = false; < if (0==strncmp(path,USB_MOUNT_ROOT,strlen(USB_MOUNT_ROOT))) < bIsHDD = false; < else < bIsHDD = true; < char *pathfordisp = bIsHDD ? path+strlen(HDD_MOUNT_ROOT) : path+strlen(USB_MOUNT_ROOT); < int m = pathfordisp - path + 1; < int n = 0; < len = 0; < char *q1 = pathfordisp; < char *q2 = q1; < char sztmp1[1024]; < char sztmp2[256]; < while (q1-path" < "%s/", sztmp1, sztmp2); < q2 = q1+1; < < } < else if (q1 - path == strlen(path) - 1) { < snprintf(sztmp2, q1-q2+2, "%s", q2); < len += sprintf(subpath+len, "%s", sztmp2); < q2 = q1+1; < } < q1++; < } < < sprintf(sztmp1, < < "
" < "
" < < ,path); < < /* 2.1/3: send path in body */ < < len = sprintf(iobuf, "
\n" < "\n" < "\n" < "\n" < "\n" < "\n" < "\n" < "%s\n" < ,(bIsHDD?"i/harddisk.png":"i/removable.png"), subpath, (bIsHDD?"":""),""); < < < < < if (full_write(STDOUT_FILENO, iobuf, len) != len) { < if (verbose > 1) < bb_perror_msg("error"); < log_and_exit(); < } < < < /* 2.2 / 3: scan directory, list folder in this directory first */ < pdir = opendir(path); < if (!pdir) < { < BDEBUG("Error to opendir"); < log_and_exit(); < } < < while ((pent = readdir(pdir)) != NULL) < { < struct stat fstat; < if (strcmp(pent->d_name, ".") == 0 || strcmp(pent->d_name, "..") == 0) < continue; < memset(subpath, 0, sizeof(subpath)); < strcpy(subpath, path); < if (subpath[strlen(subpath)-1] != '/') < strcat(subpath, "/"); < if(strlen(subpath) + strlen(pent->d_name) >= sizeof(subpath)) < continue; < strcat(subpath, pent->d_name); < int ret=stat(subpath, &fstat); < < if (-1==ret){ < switch (errno){ < case EACCES: < sprintf(szMsg,"Search permission is denied"); < case EBADF: < sprintf(szMsg,"fd is bad."); < case EFAULT: < sprintf(szMsg,"Bad address."); < case ELOOP: < sprintf(szMsg,"Too many symbolic links encountered while traversing the path."); < case ENAMETOOLONG: < sprintf(szMsg,"File name too long."); < case ENOENT: < sprintf(szMsg,"A component of the path path does not exist, or the path is empty"); < case ENOMEM: < sprintf(szMsg,"Out of memory (i.e., kernel memory)."); < case ENOTDIR: < sprintf(szMsg,"A component of the path is not a directory."); < case EOVERFLOW: < sprintf(szMsg,"(stat()) path refers to a file whose size cannot be represented in the type off_t."); < } < BDEBUG("o-o-o-o-o-o-o-o [%s]:%s",subpath,szMsg); < break; < } < < //cbFunc(subpath, fstat, script); < len = 0; < if (S_ISDIR(fstat.st_mode)) { < char ch = *(subpath + strlen(path)+1); < char timebuf[26]; < struct stat buf; < < stat (subpath,&buf); < < if ('.' == ch) continue; < //len += sprintf(iobuf, "\n"); < < len += sprintf(iobuf, "\n"); < len += sprintf(iobuf + len, "\n" < "\n" < , subpath, subpath + strlen(path)+1); < len += sprintf(iobuf + len, ""); < len += sprintf(iobuf + len, "\n"); < < } < else { < continue; < } < < if (full_write(STDOUT_FILENO, iobuf, len) != len) { < if (verbose > 1) < bb_perror_msg("error"); < log_and_exit(); < } < < } < closedir(pdir); < < /* 2.3 / 3: scan directory, list files in this directory */ < pdir = opendir(path); < if (!pdir) < { < BDEBUG("Error to opendir"); < log_and_exit(); < } < < while ((pent = readdir(pdir)) != NULL) < { < struct stat fstat; < if (strcmp(pent->d_name, ".") == 0 || strcmp(pent->d_name, "..") == 0) < continue; < memset(subpath, 0, sizeof(subpath)); < strcpy(subpath, path); < if (subpath[strlen(subpath)-1] != '/') < strcat(subpath, "/"); < if(strlen(subpath) + strlen(pent->d_name) >= sizeof(subpath)) < continue; < strcat(subpath, pent->d_name); < int ret=stat(subpath, &fstat); < < if (-1==ret){ < switch (errno){ < case EACCES: < sprintf(szMsg,"Search permission is denied"); < case EBADF: < sprintf(szMsg,"fd is bad."); < case EFAULT: < sprintf(szMsg,"Bad address."); < case ELOOP: < sprintf(szMsg,"Too many symbolic links encountered while traversing the path."); < case ENAMETOOLONG: < sprintf(szMsg,"File name too long."); < case ENOENT: < sprintf(szMsg,"A component of the path path does not exist, or the path is empty"); < case ENOMEM: < sprintf(szMsg,"Out of memory (i.e., kernel memory)."); < case ENOTDIR: < sprintf(szMsg,"A component of the path is not a directory."); < case EOVERFLOW: < sprintf(szMsg,"(stat()) path refers to a file whose size cannot be represented in the type off_t."); < } < BDEBUG("o-o-o-o-o-o-o-o [%s]:%s",subpath,szMsg); < break; < } < < //cbFunc(subpath, fstat, script); < len = 0; < /* files */ < if (S_ISREG(fstat.st_mode)) { < char ch = *(subpath + strlen(path)+1); < if ('.' == ch) continue; < < char *m3utype = NULL; < char *m3uimage = NULL; < char *tip = NULL; < char *ext = strrchr(subpath + strlen(path) + 1, '.'); < if (ext) { < ext ++; < for (int j = 0; j < sizeof(tableSuffix) / sizeof(tableSuffix[0]); j++) { < if (0==strcasecmp(ext, tableSuffix[j].suffix)) { < m3utype = tableSuffix[j].type; < m3uimage = tableSuffix[j].image; < tip = tableSuffix[j].tip; < break; < } < } < } < len += sprintf(iobuf, "\n"); < len += sprintf(iobuf + len, "\n" < "\n", < < < subpath + strlen(path)+1); < if (m3utype && bIsHDD) { < char m3ufile[512]; < char *prefix = "/tmp/hdd/volumes/HDD1"; < char *q = strstr(subpath, prefix); < memset(m3ufile, 0, sizeof(m3ufile)); < if (q) { < sprintf(m3ufile, "HDD:%s", subpath + strlen(prefix)); < decodeString(m3ufile, 0); < } < < len += sprintf(iobuf + len, "" < , m3uimage,tip,m3utype, m3ufile); < < } < else { < len += sprintf(iobuf + len, ""); < } < len += sprintf(iobuf + len, "\n"); < } < else { < continue; < } < < if (full_write(STDOUT_FILENO, iobuf, len) != len) { < if (verbose > 1) < bb_perror_msg("error"); < log_and_exit(); < } < < } < closedir(pdir); < < < < /* 3/3: send tail */ < len = sprintf(iobuf, "
%s
%s
%s
\n"); < if (full_write(STDOUT_FILENO, iobuf, len) != len) { < if (verbose > 1) < bb_perror_msg("error"); < log_and_exit(); < } < < } < < < < < < < < < < < static void send_cubermctrl_cgi_setup_and_exit(char ext_cmd, char* param, int cgiPID) ATTRIBUTE_NORETURN; < static void send_cubermctrl_cgi_setup_and_exit(char ext_cmd, char* param, int cgiPID) < { < /* send request to DvdPlayer */ < cgi_extmsg msg; < char* ext_param = strstr(param, "cmd="); < if (!ext_param) < log_and_exit(); < ext_param += 4; < CGI_EXT_MsgClear(); < CGI_EXT_MsgSetCmd(&msg, ext_cmd); < CGI_EXT_MsgSetBuf(&msg, ext_param, true); < if (CGI_EXT_MsgSnd(&msg, cgiPID, 2) != RET_CGI_EXT_OK) < BDEBUGINFO("----CGI Controller: Cannot send msg."); < < static const char RFC1123FMT[] ALIGN1 = "%a, %d %b %Y %H:%M:%S GMT"; < < const char *mime_type; < unsigned i; < time_t timer = time(0); < char tmp_str[80]; < int len = 0; < cgi_extmsg rcvmsg; < int serverID = -1; < < /* error message is HTML */ < mime_type = found_mime_type; < < /* emit the current date */ < strftime(tmp_str, sizeof(tmp_str), RFC1123FMT, gmtime(&timer)); < < /* send http-head */ < < len = sprintf(iobuf, < "HTTP/1.0 200 \r\nContent-type: %s\r\n" < "Date: %s\r\nConnection: close\r\n", < "text/html"/*mime_type*/, tmp_str); < < < iobuf[len++] = '\r'; < iobuf[len++] = '\n'; < len += sprintf(iobuf + len, < "setup system\n" < ); < < if (DEBUG) < fprintf(stderr, "headers: '%s'\n", iobuf); < if (full_write(STDOUT_FILENO, iobuf, len) != len) { < if (verbose > 1) < bb_perror_msg("error"); < log_and_exit(); < } < < /* send content */ < BDEBUGWHERE; < len = 0; < while (1) { < BDEBUGWHERE; < if( CGI_EXT_MsgRcv(&rcvmsg, cgiPID, &serverID) != RET_CGI_EXT_OK) < log_and_exit(); < if (serverID != 2) < log_and_exit(); < if (CGI_EXT_MsgGetCmd(&rcvmsg) != ext_cmd) < { < log_and_exit(); < } < < BDEBUGWHERE; < len = sprintf(iobuf,"%s",CGI_EXT_MsgGetBuf(&rcvmsg)); < if (full_write(STDOUT_FILENO, iobuf, len) != len) { < if (verbose > 1) < bb_perror_msg("error"); < log_and_exit(); < } < < if (CGI_EXT_MsgGetBuf_isFinished(&rcvmsg)) < break; < } < < BDEBUGWHERE; < len = sprintf(iobuf, "\n"); < if (DEBUG) < fprintf(stderr, "headers: '%s'\n", iobuf); < if (full_write(STDOUT_FILENO, iobuf, len) != len) { < if (verbose > 1) < bb_perror_msg("error"); < log_and_exit(); < } < } < < static void send_cubermctrl_cgi_timerrecord_disp_and_exit( < int cgiPID) ATTRIBUTE_NORETURN; < static void send_cubermctrl_cgi_timerrecord_disp_and_exit( < int cgiPID) < { < < static const char RFC1123FMT[] ALIGN1 = "%a, %d %b %Y %H:%M:%S GMT"; < < const char *mime_type; < unsigned i; < time_t timer = time(0); < char tmp_str[80]; < int len = 0; < cgi_extmsg rcvmsg; < int serverID = -1; < < /* error message is HTML */ < mime_type = found_mime_type; < < /* emit the current date */ < strftime(tmp_str, sizeof(tmp_str), RFC1123FMT, gmtime(&timer)); < < /* send http-head */ < < len = sprintf(iobuf, < "HTTP/1.0 200 \r\nContent-type: text/html\r\n" < "Date: %s\r\nConnection: close\r\n" < , tmp_str); < < < iobuf[len++] = '\r'; < iobuf[len++] = '\n'; < len += sprintf(iobuf + len, < "devices browse" < "\n" < "\n" < ); < < if (DEBUG) < fprintf(stderr, "headers: '%s'\n", iobuf); < if (full_write(STDOUT_FILENO, iobuf, len) != len) { < if (verbose > 1) < bb_perror_msg("error"); < log_and_exit(); < } < < /* send content */ < BDEBUGWHERE; < len = 0; < while (1) { < BDEBUGWHERE; < if( CGI_EXT_MsgRcv(&rcvmsg, cgiPID, &serverID) != RET_CGI_EXT_OK) < log_and_exit(); < if (serverID != 2) < log_and_exit(); < if (CGI_EXT_MsgGetCmd(&rcvmsg) != CGI_EXT_TIMERRECORD_SCHEDULE) < { < log_and_exit(); < } < < BDEBUGWHERE; < len = sprintf(iobuf,"%s",CGI_EXT_MsgGetBuf(&rcvmsg)); < if (full_write(STDOUT_FILENO, iobuf, len) != len) { < if (verbose > 1) < bb_perror_msg("error"); < log_and_exit(); < } < < if (CGI_EXT_MsgGetBuf_isFinished(&rcvmsg)) < break; < } < < BDEBUGWHERE; < len = sprintf(iobuf, "\n"); < if (DEBUG) < fprintf(stderr, "headers: '%s'\n", iobuf); < if (full_write(STDOUT_FILENO, iobuf, len) != len) { < if (verbose > 1) < bb_perror_msg("error"); < log_and_exit(); < } < } < < static void send_iPhone_cgi_timerrecord_disp_and_exit( < int cgiPID) ATTRIBUTE_NORETURN; < static void send_iPhone_cgi_timerrecord_disp_and_exit( < int cgiPID) < { < < static const char RFC1123FMT[] ALIGN1 = "%a, %d %b %Y %H:%M:%S GMT"; < < const char *mime_type; < unsigned i; < time_t timer = time(0); < char tmp_str[80]; < int len = 0; < cgi_extmsg rcvmsg; < int serverID = -1; < < /* error message is HTML */ < mime_type = found_mime_type; < < /* emit the current date */ < strftime(tmp_str, sizeof(tmp_str), RFC1123FMT, gmtime(&timer)); < < /* send http-head */ < < len = sprintf(iobuf, < "HTTP/1.0 200 \r\nContent-type: %s\r\n" < "Date: %s\r\nConnection: close\r\n", < "text/html"/*mime_type*/, tmp_str); < < < iobuf[len++] = '\r'; < iobuf[len++] = '\n'; < < len += sprintf(iobuf + len, < "devices browse" < "\n" < "\n" < "\n" < "\n" < "\n" < < "\n" < ); < < if (DEBUG) < fprintf(stderr, "headers: '%s'\n", iobuf); < if (full_write(STDOUT_FILENO, iobuf, len) != len) { < if (verbose > 1) < bb_perror_msg("error"); < log_and_exit(); < } < < /* send content */ < BDEBUGWHERE; < len = 0; < while (1) { < BDEBUGWHERE; < if( CGI_EXT_MsgRcv(&rcvmsg, cgiPID, &serverID) != RET_CGI_EXT_OK) < log_and_exit(); < if (serverID != 2) < log_and_exit(); < if (CGI_EXT_MsgGetCmd(&rcvmsg) != CGI_IPHONE_TIMERRECORD_SCHEDULE) < { < log_and_exit(); < } < < BDEBUGWHERE; < len = sprintf(iobuf,"%s",CGI_EXT_MsgGetBuf(&rcvmsg)); < if (full_write(STDOUT_FILENO, iobuf, len) != len) { < if (verbose > 1) < bb_perror_msg("error"); < log_and_exit(); < } < < if (CGI_EXT_MsgGetBuf_isFinished(&rcvmsg)) < break; < } < < BDEBUGWHERE; < len = sprintf(iobuf, "\n"); < if (DEBUG) < fprintf(stderr, "headers: '%s'\n", iobuf); < if (full_write(STDOUT_FILENO, iobuf, len) != len) { < if (verbose > 1) < bb_perror_msg("error"); < log_and_exit(); < } < } < < < < < < < static void send_cubermctrl_cgi_devicestatus_and_exit( < int cgiPID) ATTRIBUTE_NORETURN; < static void send_cubermctrl_cgi_devicestatus_and_exit( < int cgiPID) < { < < static const char RFC1123FMT[] ALIGN1 = "%a, %d %b %Y %H:%M:%S GMT"; < < const char *mime_type; < unsigned i; < time_t timer = time(0); < char tmp_str[80]; < int len; < cgi_extmsg rcvmsg; < int serverID = -1; < char devinfo[1024*16]; < < < len = 0; < while (lendevices browse\n" < "%s\n\n",devinfo); < if (DEBUG) < fprintf(stderr, "headers: '%s'\n", iobuf); < if (full_write(STDOUT_FILENO, iobuf, len) != len) { < if (verbose > 1) < bb_perror_msg("error"); < log_and_exit(); < } < < < } < < < static void send_iPhone_cgi_devicestatus_and_exit( < int cgiPID) ATTRIBUTE_NORETURN; < static void send_iPhone_cgi_devicestatus_and_exit( < int cgiPID) < { < < static const char RFC1123FMT[] ALIGN1 = "%a, %d %b %Y %H:%M:%S GMT"; < < const char *mime_type; < unsigned i; < time_t timer = time(0); < char tmp_str[80]; < int len; < cgi_extmsg rcvmsg; < int serverID = -1; < char devinfo[1024*16]; < < < len = 0; < while (lendevices browse\n" < "%s\n\n", devinfo); < < if (DEBUG) < fprintf(stderr, "headers: '%s'\n", iobuf); < if (full_write(STDOUT_FILENO, iobuf, len) != len) { < if (verbose > 1) < bb_perror_msg("error"); < log_and_exit(); < } < < < } < < < < static void send_cubermctrl_cgi_and_exit( < const char *url, < const char *request, < int post_len, < const char *cookie, < const char *content_type) ATTRIBUTE_NORETURN; < static void send_cubermctrl_cgi_and_exit( < const char *url, < const char *request, < int post_len, < const char *cookie, < const char *content_type) < { < if (!g_query) < log_and_exit(); < < cgi_extmsg msg; < int cgiPID = (int) getpid(); < char *pID; < char ext_id; < char ext_cmd=0; < char *ext_param; < < BDEBUG("url: '%s'\nrequest: '%s'\ng_query: '%s'",url,request,g_query); < < pID = strstr(g_query,"id="); < if (!pID) < log_and_exit(); < pID += 3; //point to char after "id=" < ext_id = *pID; //get id < < < if(CGI_EXT_MsgInit() != RET_CGI_EXT_OK) < { < printf("Cannot connect to Venus.\n"); < log_and_exit(); < } < < < /* remote control */ < switch (ext_id) { < case '1': < { < ext_cmd = CGI_EXT_REMOTE_CONTROL; < ext_param = strstr(pID, "cmd="); < if (!ext_param) < log_and_exit(); < ext_param += 4; < CGI_EXT_MsgClear(); < CGI_EXT_MsgSetCmd(&msg, ext_cmd); < CGI_EXT_MsgSetBuf(&msg, ext_param, true); < if (CGI_EXT_MsgSnd(&msg, cgiPID, 2) != RET_CGI_EXT_OK) < BDEBUGINFO("----CGI Controller: Cannot send msg."); < /* response is needed, otherwise safari will retry more 2 times. */ < < int len = 0; < len += sprintf(iobuf+len, "HTTP/1.0 200 \r\nContent-Type:text/html;\r\nConnection: close\r\n"); < iobuf[len++] = '\r'; < iobuf[len++] = '\n'; < len += sprintf(iobuf+len, "\n"); < len += sprintf(iobuf+len, ""); < full_write(STDOUT_FILENO, iobuf, len); < } < break; < /* download/upload, playlist */ < case '2': < { < ext_cmd = CGI_EXT_DEVICE_FILETRANSMIT; < ext_param = strstr(pID, "cmd="); < if (!ext_param) < log_and_exit(); < ext_param += 4; < < /* partition list */ < if (0==strncmp(ext_param,"IPHONE_DEVICES",14)){ < CGI_EXT_MsgClear(); < CGI_EXT_MsgSetCmd(&msg, ext_cmd); < CGI_EXT_MsgSetBuf(&msg, ext_param,true); < if (CGI_EXT_MsgSnd(&msg, cgiPID, 2) != RET_CGI_EXT_OK) < BDEBUGINFO("----CGI Controller: Cannot send msg."); < < send_iPhone_cgi_devicestatus_and_exit(cgiPID); < } < else if (0==strncmp(ext_param,"DEVICES",7)){ < CGI_EXT_MsgClear(); < CGI_EXT_MsgSetCmd(&msg, ext_cmd); < CGI_EXT_MsgSetBuf(&msg, ext_param,true); < if (CGI_EXT_MsgSnd(&msg, cgiPID, 2) != RET_CGI_EXT_OK) < BDEBUGINFO("----CGI Controller: Cannot send msg."); < < send_cubermctrl_cgi_devicestatus_and_exit(cgiPID); < } < /* browse */ < else if (0==strncmp(ext_param, "BROWSE", 6)){ < send_cubermctrl_cgi_filebrowse_and_exit(ext_param); < } < /* playlist */ < else if (0==strncmp(ext_param, "MOVIEM3U", 8)) { < send_cubermctrl_cgi_moviem3u_and_exit(VIDEOM3UFILENAME, "Movie Playlist", "MOVIE"); < } < else if (0==strncmp(ext_param, "MUSICM3U", 8)) { < send_cubermctrl_cgi_moviem3u_and_exit(MUSICM3UFILENAME, "Music Playlist", "MUSIC"); < } < else if (0==strncmp(ext_param, "PICTUREM3U", 10)) { < send_cubermctrl_cgi_moviem3u_and_exit(PICTUREM3UFILENAME, "Picture Playlist", "PICTURE"); < } < /* del items of playlist */ < else if (0==strncmp(ext_param, "DELMOVIEM3U", 11)) { < send_cubermctrl_cgi_m3udel_and_exit(ext_param, VIDEOM3UFILENAME, "Movie Playlist", "MOVIE"); < } < else if (0==strncmp(ext_param, "DELMUSICM3U", 11)) { < send_cubermctrl_cgi_m3udel_and_exit(ext_param, MUSICM3UFILENAME, "Music Playlist", "MUSIC"); < } < else if (0==strncmp(ext_param, "DELPICTUREM3U", 13)) { < send_cubermctrl_cgi_m3udel_and_exit(ext_param, PICTUREM3UFILENAME, "Picture Playlist", "PICTURE"); < } < /* add item to playlist */ < else if (0==strncmp(ext_param, "ADDM3UMOVIE", 11)) { < send_cubermctrl_cgi_m3uadd_and_exit(ext_param, VIDEOM3UFILENAME); < } < else if (0==strncmp(ext_param, "ADDM3UMUSIC", 11)) { < send_cubermctrl_cgi_m3uadd_and_exit(ext_param, MUSICM3UFILENAME); < } < else if (0==strncmp(ext_param, "ADDM3UPICTURE", 13)) { < send_cubermctrl_cgi_m3uadd_and_exit(ext_param, PICTUREM3UFILENAME); < } < /* download was departed, we create a link in www folder which linked to < device partition. < */ < else if (0==strncmp(ext_param, "DOWNLOAD", 8)){ < ext_param = decodeString(ext_param,0); < char *filename = strstr(ext_param, "folder="); < if (!filename) < log_and_exit(); < filename += 7; // move to char after "folder=" < send_file_and_exit(filename, SEND_HEADERS_AND_BODY, true); < } < /* upload */ < else if (0==strncmp(ext_param, "UPLOAD", 6)){ < send_cubermctrl_cgi_fileupload_and_exit(ext_param, content_type); < } < } < break; < /* timer record */ < case '3': < { < ext_cmd = CGI_EXT_TIMERRECORD_SCHEDULE; < ext_param = strstr(pID, "cmd="); < if (!ext_param) < log_and_exit(); < ext_param += 4; < CGI_EXT_MsgClear(); < CGI_EXT_MsgSetCmd(&msg, ext_cmd); < CGI_EXT_MsgSetBuf(&msg, ext_param, true); < if (CGI_EXT_MsgSnd(&msg, cgiPID, 2) != RET_CGI_EXT_OK) < BDEBUGINFO("----CGI Controller: Cannot send msg."); < send_cubermctrl_cgi_timerrecord_disp_and_exit(cgiPID); < } < break; < case '4': < ext_cmd = CGI_EXT_SETUP_TV; < send_cubermctrl_cgi_setup_and_exit(ext_cmd, pID, cgiPID); < break; < case '5': < ext_cmd = CGI_EXT_SETUP_AUDIO; < send_cubermctrl_cgi_setup_and_exit(ext_cmd, pID, cgiPID); < break; < case '6': < ext_cmd = CGI_EXT_SETUP_VIDEO; < send_cubermctrl_cgi_setup_and_exit(ext_cmd, pID, cgiPID); < break; < case '7': < ext_cmd = CGI_EXT_SETUP_REC; < send_cubermctrl_cgi_setup_and_exit(ext_cmd, pID, cgiPID); < break; < case '8': < ext_cmd = CGI_EXT_SETUP_NETWORK; < send_cubermctrl_cgi_setup_and_exit(ext_cmd, pID, cgiPID); < break; < case '9': < ext_cmd = CGI_EXT_SETUP_SYSTEM; < send_cubermctrl_cgi_setup_and_exit(ext_cmd, pID, cgiPID); < break; < case 'a': < ext_cmd = CGI_EXT_SETUP_MISC; < send_cubermctrl_cgi_setup_and_exit(ext_cmd, pID, cgiPID); < break; < case 'b': < { < < int len = 0; < if(strstr(user_agent,"iPhone")|| strstr(user_agent,"Mobile")) < { < len += sprintf(iobuf+len, ""); < } < else < { < len += sprintf(iobuf+len, ""); < } < full_write(STDOUT_FILENO, iobuf, len); < } < break; < < case 'c': < { < ext_cmd = CGI_IPHONE_TIMERRECORD_SCHEDULE; < ext_param = strstr(pID, "cmd="); < if (!ext_param) < log_and_exit(); < ext_param += 4; < CGI_EXT_MsgClear(); < CGI_EXT_MsgSetCmd(&msg, ext_cmd); < CGI_EXT_MsgSetBuf(&msg, ext_param, true); < if (CGI_EXT_MsgSnd(&msg, cgiPID, 2) != RET_CGI_EXT_OK) < BDEBUGINFO("----CGI Controller: Cannot send msg."); < send_iPhone_cgi_timerrecord_disp_and_exit(cgiPID); < < } < break; < < case 'd': < { < int semid; < semid = semget(SEMAPHORE_KEY,1,0666 | IPC_CREAT|IPC_EXCL); < if(semid < 0) < { < //sem alreay exist,do nothing < } < else < { < union semun sem_union; < sem_union.val = 1; < int ret = semctl(semid,0,SETVAL,sem_union); < } < < char status[128]; < semaphore_p(); < memset(status,0,128); < memcpy(status,"unknown",strlen("unknown")); < FILE *fp = fopen("/tmp/VenusVFD","r"); < fgets(status, 128, fp); < fclose(fp); < semaphore_v(); < < char VenusVFD[128]=" "); < int len = 0; < len += sprintf(iobuf+len,"%s", VenusVFD); < full_write(STDOUT_FILENO, iobuf, len); < < } < break; < < default: < log_and_exit(); < break; < } < < log_and_exit(); < } < < < < static void send_iPhone_cgi_and_exit( < const char *url, < const char *request, < int post_len, < const char *cookie, < const char *content_type) ATTRIBUTE_NORETURN; < static void send_iPhone_cgi_and_exit( < const char *url, < const char *request, < int post_len, < const char *cookie, < const char *content_type) < { < if (!g_query) < log_and_exit(); < < cgi_extmsg msg; < int cgiPID = (int) getpid(); < char *pID; < char ext_id; < char ext_cmd=0; < char *ext_param; < < BDEBUG("url: '%s'\nrequest: '%s'\ng_query: '%s'",url,request,g_query); < < pID = strstr(g_query,"id="); < if (!pID) < log_and_exit(); < pID += 3; //point to char after "id=" < ext_id = *pID; //get id < < < if(CGI_EXT_MsgInit() != RET_CGI_EXT_OK) < { < printf("Cannot connect to Venus.\n"); < log_and_exit(); < } < < < /* remote control */ < switch (ext_id) { < case '1': < { < ext_cmd = CGI_EXT_REMOTE_CONTROL; < ext_param = strstr(pID, "cmd="); < if (!ext_param) < log_and_exit(); < ext_param += 4; < CGI_EXT_MsgClear(); < CGI_EXT_MsgSetCmd(&msg, ext_cmd); < CGI_EXT_MsgSetBuf(&msg, ext_param, true); < if (CGI_EXT_MsgSnd(&msg, cgiPID, 2) != RET_CGI_EXT_OK) < BDEBUGINFO("----CGI Controller: Cannot send msg."); < < int len = 0; < len += sprintf(iobuf+len, "HTTP/1.0 200 \r\nContent-Type:text/html;\r\nConnection: close\r\n"); < iobuf[len++] = '\r'; < iobuf[len++] = '\n'; < len += sprintf(iobuf+len, "\n"); < len += sprintf(iobuf+len, ""); < full_write(STDOUT_FILENO, iobuf, len); < } < break; < /* download/upload, playlist */ < case '2': < { < ext_cmd = CGI_EXT_DEVICE_FILETRANSMIT; < ext_param = strstr(pID, "cmd="); < if (!ext_param) < log_and_exit(); < ext_param += 4; < < /* partition list */ < if (0==strncmp(ext_param,"IPHONE_DEVICES",14)){ < CGI_EXT_MsgClear(); < CGI_EXT_MsgSetCmd(&msg, ext_cmd); < CGI_EXT_MsgSetBuf(&msg, ext_param,true); < if (CGI_EXT_MsgSnd(&msg, cgiPID, 2) != RET_CGI_EXT_OK) < BDEBUGINFO("----CGI Controller: Cannot send msg."); < < send_iPhone_cgi_devicestatus_and_exit(cgiPID); < } < < else if (0==strncmp(ext_param,"DEVICES",7)){ < CGI_EXT_MsgClear(); < CGI_EXT_MsgSetCmd(&msg, ext_cmd); < CGI_EXT_MsgSetBuf(&msg, ext_param,true); < if (CGI_EXT_MsgSnd(&msg, cgiPID, 2) != RET_CGI_EXT_OK) < BDEBUGINFO("----CGI Controller: Cannot send msg."); < < send_cubermctrl_cgi_devicestatus_and_exit(cgiPID); < } < < < < < /* browse */ < else if (0==strncmp(ext_param, "BROWSE", 6)){ < send_iPhone_cgi_filebrowse_and_exit(ext_param); < } < /* playlist */ < else if (0==strncmp(ext_param, "MOVIEM3U", 8)) { < send_iPhone_cgi_moviem3u_and_exit(VIDEOM3UFILENAME, "Movie Playlist", "MOVIE"); < } < else if (0==strncmp(ext_param, "MUSICM3U", 8)) { < send_iPhone_cgi_moviem3u_and_exit(MUSICM3UFILENAME, "Music Playlist", "MUSIC"); < } < else if (0==strncmp(ext_param, "PICTUREM3U", 10)) { < send_iPhone_cgi_moviem3u_and_exit(PICTUREM3UFILENAME, "Picture Playlist", "PICTURE"); < } < /* del items of playlist */ < else if (0==strncmp(ext_param, "DELMOVIEM3U", 11)) { < send_iPhone_cgi_m3udel_and_exit(ext_param, VIDEOM3UFILENAME, "Movie Playlist", "MOVIE"); < } < else if (0==strncmp(ext_param, "DELMUSICM3U", 11)) { < send_iPhone_cgi_m3udel_and_exit(ext_param, MUSICM3UFILENAME, "Music Playlist", "MUSIC"); < } < else if (0==strncmp(ext_param, "DELPICTUREM3U", 13)) { < send_iPhone_cgi_m3udel_and_exit(ext_param, PICTUREM3UFILENAME, "Picture Playlist", "PICTURE"); < } < /* add item to playlist */ < else if (0==strncmp(ext_param, "ADDM3UMOVIE", 11)) { < send_cubermctrl_cgi_m3uadd_and_exit(ext_param, VIDEOM3UFILENAME); < } < else if (0==strncmp(ext_param, "ADDM3UMUSIC", 11)) { < send_cubermctrl_cgi_m3uadd_and_exit(ext_param, MUSICM3UFILENAME); < } < else if (0==strncmp(ext_param, "ADDM3UPICTURE", 13)) { < send_cubermctrl_cgi_m3uadd_and_exit(ext_param, PICTUREM3UFILENAME); < } < /* download was departed, we create a link in www folder which linked to < device partition. < */ < else if (0==strncmp(ext_param, "DOWNLOAD", 8)){ < ext_param = decodeString(ext_param,0); < char *filename = strstr(ext_param, "folder="); < if (!filename) < log_and_exit(); < filename += 7; // move to char after "folder=" < send_file_and_exit(filename, SEND_HEADERS_AND_BODY, true); < } < /* upload */ < else if (0==strncmp(ext_param, "UPLOAD", 6)){ < send_cubermctrl_cgi_fileupload_and_exit(ext_param, content_type); < } < } < break; < /* timer record */ < < case '3': < { < ext_cmd = CGI_EXT_TIMERRECORD_SCHEDULE; < ext_param = strstr(pID, "cmd="); < if (!ext_param) < log_and_exit(); < ext_param += 4; < CGI_EXT_MsgClear(); < CGI_EXT_MsgSetCmd(&msg, ext_cmd); < CGI_EXT_MsgSetBuf(&msg, ext_param, true); < if (CGI_EXT_MsgSnd(&msg, cgiPID, 2) != RET_CGI_EXT_OK) < BDEBUGINFO("----CGI Controller: Cannot send msg."); < send_cubermctrl_cgi_timerrecord_disp_and_exit(cgiPID); < < < < < } < break; < case '4': < ext_cmd = CGI_EXT_SETUP_TV; < send_cubermctrl_cgi_setup_and_exit(ext_cmd, pID, cgiPID); < break; < case '5': < ext_cmd = CGI_EXT_SETUP_AUDIO; < send_cubermctrl_cgi_setup_and_exit(ext_cmd, pID, cgiPID); < break; < case '6': < ext_cmd = CGI_EXT_SETUP_VIDEO; < send_cubermctrl_cgi_setup_and_exit(ext_cmd, pID, cgiPID); < break; < case '7': < ext_cmd = CGI_EXT_SETUP_REC; < send_cubermctrl_cgi_setup_and_exit(ext_cmd, pID, cgiPID); < break; < case '8': < ext_cmd = CGI_EXT_SETUP_NETWORK; < send_cubermctrl_cgi_setup_and_exit(ext_cmd, pID, cgiPID); < break; < case '9': < ext_cmd = CGI_EXT_SETUP_SYSTEM; < send_cubermctrl_cgi_setup_and_exit(ext_cmd, pID, cgiPID); < break; < case 'a': < ext_cmd = CGI_EXT_SETUP_MISC; < send_cubermctrl_cgi_setup_and_exit(ext_cmd, pID, cgiPID); < break; < case 'b': < { < < int len = 0; < if(strstr(user_agent,"iPhone")||strstr(user_agent,"Mobile")) < { < len += sprintf(iobuf+len, ""); < } < else < { < len += sprintf(iobuf+len, ""); < } < full_write(STDOUT_FILENO, iobuf, len); < } < break; < case 'c': < { < ext_cmd = CGI_IPHONE_TIMERRECORD_SCHEDULE; < ext_param = strstr(pID, "cmd="); < if (!ext_param) < log_and_exit(); < ext_param += 4; < CGI_EXT_MsgClear(); < CGI_EXT_MsgSetCmd(&msg, ext_cmd); < CGI_EXT_MsgSetBuf(&msg, ext_param, true); < if (CGI_EXT_MsgSnd(&msg, cgiPID, 2) != RET_CGI_EXT_OK) < BDEBUGINFO("----CGI Controller: Cannot send msg."); < send_iPhone_cgi_timerrecord_disp_and_exit(cgiPID); < } < break; < < case 'd': < { < int semid; < semid = semget(SEMAPHORE_KEY,1,0666 | IPC_CREAT|IPC_EXCL); < if(semid < 0) < { < //sem alreay exist,do nothing < } < else < { < union semun sem_union; < sem_union.val = 1; < int ret = semctl(semid,0,SETVAL,sem_union); < } < < char status[128]; < semaphore_p(); < memset(status,0,128); < memcpy(status,"unknown",strlen("unknown")); < FILE *fp = fopen("/tmp/VenusVFD","r"); < fgets(status, 128, fp); < fclose(fp); < semaphore_v(); < < char VenusVFD[128]=" "); < int len = 0; < len += sprintf(iobuf+len,"%s", VenusVFD); < full_write(STDOUT_FILENO, iobuf, len); < < } < break; < < default: < log_and_exit(); < break; < } < < log_and_exit(); < } < //......................................................................................... < < /* < * Spawn CGI script, forward CGI's stdin/out <=> network < * < * Environment variables are set up and the script is invoked with pipes < * for stdin/stdout. If a POST is being done the script is fed the POST < * data in addition to setting the QUERY_STRING variable (for GETs or POSTs). < * < * Parameters: < * const char *url The requested URL (with leading /). < * int post_len Length of the POST body. < * const char *cookie For set HTTP_COOKIE. < * const char *content_type For set CONTENT_TYPE. < */ < static void send_cgi_and_exit( < const char *url, < const char *request, < int post_len, < const char *cookie, < const char *content_type) ATTRIBUTE_NORETURN; < static void send_cgi_and_exit( < const char *url, < const char *request, < int post_len, < const char *cookie, < const char *content_type) < { < struct fd_pair fromCgi; /* CGI -> httpd pipe */ < struct fd_pair toCgi; /* httpd -> CGI pipe */ < char *script; < int pid; < < ///------------- check for SPECIAL cgi name: cubermctrl.cgi ------------------- < if (0!=strcasestr(url, "cubermctrl.cgi")){ < if(strstr(user_agent,"iPhone") || strstr(user_agent,"Mobile") ) < { < send_iPhone_cgi_and_exit(url,request,post_len,cookie,content_type); < } < else < { < send_cubermctrl_cgi_and_exit(url,request,post_len,cookie,content_type); < } < return; < } < ///---------------------------------------------------------------------------- < /* Make a copy. NB: caller guarantees: < * url[0] == '/', url[1] != '/' */ < url = xstrdup(url); < < /* < * We are mucking with environment _first_ and then vfork/exec, < * this allows us to use vfork safely. Parent doesn't care about < * these environment changes anyway. < */ < < /* Check for [dirs/]script.cgi/PATH_INFO */ < script = (char*)url; < while ((script = strchr(script + 1, '/')) != NULL) { < struct stat sb; < < *script = '\0'; < if (!is_directory(url + 1, 1, &sb)) { < /* not directory, found script.cgi/PATH_INFO */ < *script = '/'; < break; < } < *script = '/'; /* is directory, find next '/' */ < } < setenv1("PATH_INFO", script); /* set to /PATH_INFO or "" */ < setenv1("REQUEST_METHOD", request); < if (g_query) { < putenv(xasprintf("%s=%s?%s", "REQUEST_URI", url, g_query)); < } else { < setenv1("REQUEST_URI", url); < } < if (script != NULL) < *script = '\0'; /* cut off /PATH_INFO */ < < /* SCRIPT_FILENAME is required by PHP in CGI mode */ < if (home_httpd[0] == '/') { < char *fullpath = concat_path_file(home_httpd, url); < setenv1("SCRIPT_FILENAME", fullpath); < } < /* set SCRIPT_NAME as full path: /cgi-bin/dirs/script.cgi */ < setenv1("SCRIPT_NAME", url); < /* http://hoohoo.ncsa.uiuc.edu/cgi/env.html: < * QUERY_STRING: The information which follows the ? in the URL < * which referenced this script. This is the query information. < * It should not be decoded in any fashion. This variable < * should always be set when there is query information, < * regardless of command line decoding. */ < /* (Older versions of bbox seem to do some decoding) */ < setenv1("QUERY_STRING", g_query); < putenv((char*)"SERVER_SOFTWARE=busybox httpd/"BB_VER); < putenv((char*)"SERVER_PROTOCOL=HTTP/1.0"); < putenv((char*)"GATEWAY_INTERFACE=CGI/1.1"); < /* Having _separate_ variables for IP and port defeats < * the purpose of having socket abstraction. Which "port" < * are you using on Unix domain socket? < * IOW - REMOTE_PEER="1.2.3.4:56" makes much more sense. < * Oh well... */ < { < char *p = rmt_ip_str ? rmt_ip_str : (char*)""; < char *cp = strrchr(p, ':'); < if (ENABLE_FEATURE_IPV6 && cp && strchr(cp, ']')) < cp = NULL; < if (cp) *cp = '\0'; /* delete :PORT */ < setenv1("REMOTE_ADDR", p); < if (cp) { < *cp = ':'; < #if ENABLE_FEATURE_HTTPD_SET_REMOTE_PORT_TO_ENV < setenv1("REMOTE_PORT", cp + 1); < #endif < } < } < setenv1("HTTP_USER_AGENT", user_agent); < if (post_len) < putenv(xasprintf("CONTENT_LENGTH=%d", post_len)); < if (cookie) < setenv1("HTTP_COOKIE", cookie); < if (content_type) < setenv1("CONTENT_TYPE", content_type); < #if ENABLE_FEATURE_HTTPD_BASIC_AUTH < if (remoteuser) { < setenv1("REMOTE_USER", remoteuser); < putenv((char*)"AUTH_TYPE=Basic"); < } < #endif < if (referer) < setenv1("HTTP_REFERER", referer); < < //.............................. < BDEBUG( "setenv ********************* :\n" < "\tPATH_INFO=%s\n" "\tREQUEST_METHOD=%s\n" "\tREQUEST_URI=%s\n" < "\tSCRIPT_FILENAME=%s\n" "\tSCRIPT_NAME=%s\n" "\tQUERY_STRING=%s\n" < "\tSERVER_SOFTWARE=%s\n" "\tSERVER_PROTOCOL=%s\n" "\tGATEWAY_INTERFACE=%s\n" < "\tREMOTE_ADDR=%s\n" "\tREMOTE_PORT=%s\n" "\tHTTP_USER_AGENT=%s\n" < "\tHTTP_ACCEPT=%s\n" "\tHTTP_ACCEPT_LANGUAGE=%s\n" "\tCONTENT_LENGTH=%s\n" < "\tHTTP_COOKIE=%s\n" "\tCONTENT_TYPE=%s\n" "\tREMOTE_USER=%s\n" < "\tAUTH_TYPE=%s\n" "\tHTTP_REFERER=%s\n" "\tHTTP_HOST=%s\n" < ,getenv("PATH_INFO"),getenv("REQUEST_METHOD"),getenv("REQUEST_URI") < ,getenv("SCRIPT_FILENAME") ,getenv("SCRIPT_NAME") ,getenv("QUERY_STRING") < ,getenv("SERVER_SOFTWARE") ,getenv("SERVER_PROTOCOL") ,getenv("GATEWAY_INTERFACE") < ,getenv("REMOTE_ADDR") ,getenv("REMOTE_PORT") ,getenv("HTTP_USER_AGENT") < ,getenv("HTTP_ACCEPT") ,getenv("HTTP_ACCEPT_LANGUAGE") ,getenv("CONTENT_LENGTH") < ,getenv("HTTP_COOKIE") ,getenv("CONTENT_TYPE") ,getenv("REMOTE_USER") < ,getenv("AUTH_TYPE") ,getenv("HTTP_REFERER") ,getenv("HTTP_HOST") < ); < //............................... < < xpiped_pair(fromCgi); < xpiped_pair(toCgi); < < pid = vfork(); < if (pid < 0) { < /* TODO: log perror? */ < log_and_exit(); < } < < if (!pid) { < /* Child process */ < char *argv[3]; < < xfunc_error_retval = 242; < < /* NB: close _first_, then move fds! */ < close(toCgi.wr); < close(fromCgi.rd); < xmove_fd(toCgi.rd, 0); /* replace stdin with the pipe */ < xmove_fd(fromCgi.wr, 1); /* replace stdout with the pipe */ < /* User seeing stderr output can be a security problem. < * If CGI really wants that, it can always do dup itself. */ < /* dup2(1, 2); */ < < /* Chdiring to script's dir */ < script = strrchr(url, '/'); < if (script != url) { /* paranoia */ < *script = '\0'; < if (chdir(url + 1) != 0) { < bb_perror_msg("chdir %s", url + 1); < goto error_execing_cgi; < } < // not needed: *script = '/'; < } < script++; < < /* set argv[0] to name without path */ < argv[0] = script; < argv[1] = NULL; < < #if ENABLE_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR < { < char *suffix = strrchr(script, '.'); < < if (suffix) { < Htaccess *cur; < for (cur = script_i; cur; cur = cur->next) { < if (strcmp(cur->before_colon + 1, suffix) == 0) { < /* found interpreter name */ < argv[0] = cur->after_colon; < argv[1] = script; < argv[2] = NULL; < break; < } < } < } < } < #endif < /* restore default signal dispositions for CGI process */ < bb_signals(0 < | (1 << SIGCHLD) < | (1 << SIGPIPE) < | (1 << SIGHUP) < , SIG_DFL); < < /* _NOT_ execvp. We do not search PATH. argv[0] is a filename < * without any dir components and will only match a file < * in the current directory */ < execv(argv[0], argv); < if (verbose) < bb_perror_msg("exec %s", argv[0]); < error_execing_cgi: < /* send to stdout < * (we are CGI here, our stdout is pumped to the net) */ < send_headers_and_exit(HTTP_NOT_FOUND); < } /* end child */ < < /* Parent process */ < < /* Restore variables possibly changed by child */ < xfunc_error_retval = 0; < < /* Pump data */ < close(fromCgi.wr); < close(toCgi.rd); < cgi_io_loop_and_exit(fromCgi.rd, toCgi.wr, post_len); < } < < #endif /* FEATURE_HTTPD_CGI */ < < /* < * Send a file response to a HTTP request, and exit < * < * Parameters: < * const char *url The requested URL (with leading /). < * what What to send (headers/body/both). < */ < static void send_file_and_exit(const char *url, int what, bool bExtedCgi) --- > /* > * Send a file response to a HTTP request, and exit > * > * Parameters: > * const char *url The requested URL (with leading /). > * what What to send (headers/body/both). > */ > static void send_file_and_exit(const char *url, int what) 4653c1494 < /* Warning: shorter equivalent suffix in one line must be first */ --- > /* Warning: shorter equivalent suffix in one line must be first */ 4663c1504 < ".mpe.mpeg.mpg", "video/mpeg", --- > ".mpe.mpeg", "video/mpeg", 4665c1506 < ".mp3.wma", "audio/mpeg", --- > ".mp3", "audio/mpeg", 4683d1523 < BDEBUG("url: %s",url); 4696,4704c1536,1542 < if (false==bExtedCgi){ < for (table = suffixTable; *table; table += 2) { < try_suffix = strcasestr(table[0], suffix); /* modified to strcasestr by fengyh */ < if (try_suffix) { < try_suffix += strlen(suffix); < if (*try_suffix == '\0' || *try_suffix == '.') { < found_mime_type = table[1]; < break; < } --- > for (table = suffixTable; *table; table += 2) { > try_suffix = strstr(table[0], suffix); > if (try_suffix) { > try_suffix += strlen(suffix); > if (*try_suffix == '\0' || *try_suffix == '.') { > found_mime_type = table[1]; > break; 4720c1558 < url, found_mime_type); --- > url, found_mime_type); 4742,4743c1580,1581 < || lseek(f, range_start, SEEK_SET) != range_start < ) { --- > || lseek(f, range_start, SEEK_SET) != range_start > ) { 4748c1586 < send_headers(HTTP_PARTIAL_CONTENT,NULL); --- > send_headers(HTTP_PARTIAL_CONTENT); 4754,4760d1591 < char *filename = strrchr(url,'/'); < if (filename){ < filename++; < } < else{ < filename = url; < } 4762c1593 < send_headers(HTTP_OK, filename); --- > send_headers(HTTP_OK); 4770c1601 < count = sendfile(1, f, &offset, sz); --- > count = sendfile(1, f, &offset, sz); 4780c1611 < fallback: --- > fallback: 4785c1616 < n = full_write(STDOUT_FILENO, iobuf, count); --- > n = full_write(STDOUT_FILENO, iobuf, count); 4789,4790c1620,1621 < if (!range_len) < break; --- > if (!range_len) > break; 4793c1624 < fin: --- > fin: 4807,4817c1638,1648 < "checkPermIP: '%s' ? '%u.%u.%u.%u/%u.%u.%u.%u'\n", < rmt_ip_str, < (unsigned char)(cur->ip >> 24), < (unsigned char)(cur->ip >> 16), < (unsigned char)(cur->ip >> 8), < (unsigned char)(cur->ip), < (unsigned char)(cur->mask >> 24), < (unsigned char)(cur->mask >> 16), < (unsigned char)(cur->mask >> 8), < (unsigned char)(cur->mask) < ); --- > "checkPermIP: '%s' ? '%u.%u.%u.%u/%u.%u.%u.%u'\n", > rmt_ip_str, > (unsigned char)(cur->ip >> 24), > (unsigned char)(cur->ip >> 16), > (unsigned char)(cur->ip >> 8), > (unsigned char)(cur->ip), > (unsigned char)(cur->mask >> 24), > (unsigned char)(cur->mask >> 16), > (unsigned char)(cur->mask >> 8), > (unsigned char)(cur->mask) > ); 4858,4860c1689,1691 < && (strncmp(dir_prefix, path, len) != 0 < || (path[len] != '/' && path[len] != '\0')) < ) { --- > && (strncmp(dir_prefix, path, len) != 0 > || (path[len] != '/' && path[len] != '\0')) > ) { 4872,4873c1703,1704 < && md5_passwd[3] == '$' && md5_passwd[4] < ) { --- > && md5_passwd[3] == '$' && md5_passwd[4] > ) { 4885,4886c1716,1717 < user_and_passwd + user_len_p1 /* cleartext pwd from user */, < md5_passwd /*salt */, 1 /* cleanup */); --- > user_and_passwd + user_len_p1 /* cleartext pwd from user */, > md5_passwd /*salt */, 1 /* cleanup */); 4897c1728 < set_remoteuser_var: --- > set_remoteuser_var: 4973,4975c1804,1806 < && fromAddr->u.sin6.sin6_addr.s6_addr32[0] == 0 < && fromAddr->u.sin6.sin6_addr.s6_addr32[1] == 0 < && ntohl(fromAddr->u.sin6.sin6_addr.s6_addr32[2]) == 0xffff) --- > && fromAddr->u.sin6.sin6_addr.s6_addr32[0] == 0 > && fromAddr->u.sin6.sin6_addr.s6_addr32[1] == 0 > && ntohl(fromAddr->u.sin6.sin6_addr.s6_addr32[2]) == 0xffff) 4998,5002c1829 < //urlp = strpbrk(iobuf, " \t"); < urlp = strchr(iobuf, ' '); < if (NULL==urlp) < urlp = strchr(iobuf, '\t'); < --- > urlp = strpbrk(iobuf, " \t"); 5027c1854 < tptr = strchrnul(urlp, ' '); --- > tptr = strchrnul(urlp, ' '); 5080c1907 < continue; --- > continue; 5150c1977 < && prequest != request_HEAD --- > && prequest != request_HEAD 5152c1979 < ) { --- > ) { 5313c2140 < (prequest != request_HEAD ? SEND_HEADERS_AND_BODY : SEND_HEADERS) --- > (prequest != request_HEAD ? SEND_HEADERS_AND_BODY : SEND_HEADERS) 5315c2142 < SEND_HEADERS_AND_BODY --- > SEND_HEADERS_AND_BODY 5317,5318c2144 < , false < ); --- > ); 5444,5447c2270,2273 < USE_FEATURE_HTTPD_BASIC_AUTH( r_opt_realm ,) < USE_FEATURE_HTTPD_AUTH_MD5( m_opt_md5 ,) < USE_FEATURE_HTTPD_SETUID( u_opt_setuid ,) < p_opt_port , --- > USE_FEATURE_HTTPD_BASIC_AUTH( r_opt_realm ,) > USE_FEATURE_HTTPD_AUTH_MD5( m_opt_md5 ,) > USE_FEATURE_HTTPD_SETUID( u_opt_setuid ,) > p_opt_port , 5472,5474c2298,2300 < USE_FEATURE_HTTPD_SETUID(const char *s_ugid = NULL;) < USE_FEATURE_HTTPD_SETUID(struct bb_uidgid_t ugid;) < USE_FEATURE_HTTPD_AUTH_MD5(const char *pass;) --- > USE_FEATURE_HTTPD_SETUID(const char *s_ugid = NULL;) > USE_FEATURE_HTTPD_SETUID(struct bb_uidgid_t ugid;) > USE_FEATURE_HTTPD_AUTH_MD5(const char *pass;) 5476c2302 < INIT_G(); --- > INIT_G(); 5502c2328 < ); --- > ); 5523c2349 < "name '%s'", s_ugid); --- > "name '%s'", s_ugid); 5563,5564c2389,2390 < // if (!(opt & OPT_INETD)) < // setenv_long("SERVER_PORT", ???); --- > // if (!(opt & OPT_INETD)) > // setenv_long("SERVER_PORT", ???); diff -r busybox_httpd/networking/httpd_post_upload.txt busybox-1.11.2/networking/httpd_post_upload.txt 61d60 < saved to $file 77d75 < it should be to save file to $file Only in busybox_httpd/networking/libiproute: .svn Only in busybox_httpd/networking: .svn Only in busybox_httpd/networking: test.c Only in busybox_httpd/networking/udhcp: .svn Only in busybox_httpd: nul Only in busybox_httpd/printutils: .svn Only in busybox_httpd/procps: .svn Only in busybox_httpd/runit: .svn Only in busybox_httpd/scripts/basic: docproc Only in busybox_httpd/scripts/basic: fixdep Only in busybox_httpd/scripts/basic: split-include Only in busybox_httpd/scripts/basic: .svn Only in busybox_httpd/scripts/kconfig: conf Only in busybox_httpd/scripts/kconfig: lex.zconf.c Only in busybox_httpd/scripts/kconfig/lxdialog: lxdialog Only in busybox_httpd/scripts/kconfig/lxdialog: .svn Only in busybox_httpd/scripts/kconfig: mconf Only in busybox_httpd/scripts/kconfig: .svn Only in busybox_httpd/scripts/kconfig: zconf.hash.c Only in busybox_httpd/scripts/kconfig: zconf.tab.c Only in busybox_httpd/scripts: .svn Only in busybox_httpd/selinux: .svn Only in busybox_httpd/shell/ash_test/ash-alias: .svn Only in busybox_httpd/shell/ash_test/ash-arith: .svn Only in busybox_httpd/shell/ash_test/ash-heredoc: .svn Only in busybox_httpd/shell/ash_test/ash-invert: .svn Only in busybox_httpd/shell/ash_test/ash-quoting: .svn Only in busybox_httpd/shell/ash_test/ash-read: .svn Only in busybox_httpd/shell/ash_test/ash-redir: .svn Only in busybox_httpd/shell/ash_test/ash-signals: .svn Only in busybox_httpd/shell/ash_test/ash-vars: .svn Only in busybox_httpd/shell/ash_test: .svn Only in busybox_httpd/shell/hush_test/hush-bugs: .svn Only in busybox_httpd/shell/hush_test/hush-glob: .svn Only in busybox_httpd/shell/hush_test/hush-misc: .svn Only in busybox_httpd/shell/hush_test/hush-parsing: .svn Only in busybox_httpd/shell/hush_test/hush-psubst: .svn Only in busybox_httpd/shell/hush_test/hush-vars: .svn Only in busybox_httpd/shell/hush_test/hush-z_slow: .svn Only in busybox_httpd/shell/hush_test: .svn Only in busybox_httpd/shell/msh_test/msh-bugs: .svn Only in busybox_httpd/shell/msh_test/msh-execution: .svn Only in busybox_httpd/shell/msh_test/msh-misc: .svn Only in busybox_httpd/shell/msh_test/msh-parsing: .svn Only in busybox_httpd/shell/msh_test/msh-vars: .svn Only in busybox_httpd/shell/msh_test: .svn Only in busybox_httpd/shell: .svn Only in busybox_httpd: .svn Only in busybox_httpd/sysklogd: .svn Only in busybox_httpd/testsuite/basename: .svn Only in busybox_httpd/testsuite/bunzip2: .svn Only in busybox_httpd/testsuite/cat: .svn Only in busybox_httpd/testsuite/cmp: .svn Only in busybox_httpd/testsuite/cp: .svn Only in busybox_httpd/testsuite/cut: .svn Only in busybox_httpd/testsuite/date: .svn Only in busybox_httpd/testsuite/dd: .svn Only in busybox_httpd/testsuite/dirname: .svn Only in busybox_httpd/testsuite/du: .svn Only in busybox_httpd/testsuite/echo: .svn Only in busybox_httpd/testsuite/expand: .svn Only in busybox_httpd/testsuite/expr: .svn Only in busybox_httpd/testsuite/false: .svn Only in busybox_httpd/testsuite/find: .svn Only in busybox_httpd/testsuite/gunzip: .svn Only in busybox_httpd/testsuite/gzip: .svn Only in busybox_httpd/testsuite/head: .svn Only in busybox_httpd/testsuite/hostid: .svn Only in busybox_httpd/testsuite/hostname: .svn Only in busybox_httpd/testsuite/id: .svn Only in busybox_httpd/testsuite/ln: .svn Only in busybox_httpd/testsuite/ls: .svn Only in busybox_httpd/testsuite/md5sum: .svn Only in busybox_httpd/testsuite/mkdir: .svn Only in busybox_httpd/testsuite/msh: .svn Only in busybox_httpd/testsuite/mv: .svn Only in busybox_httpd/testsuite/pwd: .svn Only in busybox_httpd/testsuite/rm: .svn Only in busybox_httpd/testsuite/rmdir: .svn Only in busybox_httpd/testsuite/strings: .svn Only in busybox_httpd/testsuite: .svn Only in busybox_httpd/testsuite/tail: .svn Only in busybox_httpd/testsuite/tar: .svn Only in busybox_httpd/testsuite/tee: .svn Only in busybox_httpd/testsuite/touch: .svn Only in busybox_httpd/testsuite/tr: .svn Only in busybox_httpd/testsuite/true: .svn Only in busybox_httpd/testsuite/unexpand: .svn Only in busybox_httpd/testsuite/uptime: .svn Only in busybox_httpd/testsuite/wc: .svn Only in busybox_httpd/testsuite/wget: .svn Only in busybox_httpd/testsuite/which: .svn Only in busybox_httpd/testsuite/xargs: .svn diff -r busybox_httpd/util-linux/fdisk.c busybox-1.11.2/util-linux/fdisk.c 2307c2307 < printf("No free sectors available:%lu %lu\n", start, limit); --- > printf("No free sectors available\n"); Only in busybox_httpd/util-linux: .svn Only in busybox_httpd/util-linux/volume_id: .svn