147 lines
3.8 KiB
C
147 lines
3.8 KiB
C
#include <stdio.h>
|
||
#include <stdlib.h>
|
||
#include <fcntl.h>
|
||
#include <string.h>
|
||
#include <unistd.h>
|
||
|
||
//SRC_IP=192.168.0.202&DST_IP=192.168.0.201&VIDEO_PORT=8090&SERIAL_PORT=20001%2C20002&BAUD_RATE=115200&VIDEO_RATE=8000&AUDIO_PORT=1350
|
||
|
||
|
||
void url_decode(char *dest, const char *src) {
|
||
size_t i = 0, j = 0;
|
||
while (src[i] != '\0') {
|
||
if (src[i] == '%' && src[i+1] != '\0' && src[i+2] != '\0') {
|
||
// 解析 % 后的两位十六进制数(如 %3A → 0x3A → ':')
|
||
char hex[3] = {src[i+1], src[i+2], '\0'};
|
||
dest[j++] = (char)strtol(hex, NULL, 16); // 十六进制转字符
|
||
i += 3; // 跳过 %XX
|
||
} else if (src[i] == '+') {
|
||
dest[j++] = ' '; // URL 中 '+' 对应空格
|
||
i++;
|
||
} else {
|
||
dest[j++] = src[i++]; // 普通字符直接复制
|
||
}
|
||
}
|
||
dest[j] = '\0'; // 字符串结束符
|
||
}
|
||
|
||
int main(void){
|
||
int len;
|
||
char *lenstr,poststr[20];
|
||
char m[10],n[10];
|
||
int fd_fs;
|
||
|
||
|
||
char src_ip[50];
|
||
char dst_ip[200];
|
||
char dst_ip1[200];
|
||
char dns_ip[200];
|
||
char dns_ip1[200];
|
||
char gateway[200];
|
||
char gateway1[200];
|
||
char video_port[200];
|
||
char video_port1[200];
|
||
char ip[80];
|
||
char ip_pre[80];
|
||
|
||
char rtsp1_1_pre[120];
|
||
char rtsp1_1[120];
|
||
char rtsp1_2_pre[120];
|
||
char rtsp1_2[120];
|
||
char rtsp1_3_pre[120];
|
||
char rtsp1_3[120];
|
||
char rtsp1_4_pre[120];
|
||
char rtsp1_4[120];
|
||
|
||
char rtsp2_pre[120];
|
||
char rtsp2[120];
|
||
char rtsp3_pre[120];
|
||
char rtsp3[120];
|
||
char rtsp4_pre[120];
|
||
char rtsp4[120];
|
||
char rtsp5_pre[120];
|
||
char rtsp5[120];
|
||
|
||
char serial_port_tx[50];
|
||
char serial_port_rx[50];
|
||
char baud_rate[50];
|
||
char video_rate[50];
|
||
char audio_port[50];
|
||
char switch_port[50];
|
||
char video_source[50];
|
||
char cpe_5g[50];
|
||
|
||
fd_fs = open("/root/ceshi.txt", O_RDWR | O_CREAT);
|
||
|
||
|
||
printf("Content-Type:text/html\n\n");
|
||
printf("\n");
|
||
printf("\n\n\n");
|
||
printf("\n");
|
||
printf("\n");
|
||
lenstr=getenv("QUERY_STRING");
|
||
|
||
printf("%s\n",lenstr);
|
||
|
||
if(lenstr){
|
||
sscanf(lenstr,"%[^&]&%[^&]&%[^&]&%[^&]&%[^&]&%[^&]&%[^&]&%[^&]&%[^&]",ip_pre,rtsp1_1_pre,rtsp1_2_pre,rtsp1_3_pre,rtsp1_4_pre,rtsp2_pre,rtsp3_pre,rtsp4_pre,rtsp5_pre);
|
||
//sscanf(lenstr,"%[^&]&%[^&]&%[^&]&%[^&]&%[^&]&%[^&]&%[^&]&%[^&]&%[^&]&%[^&]",src_ip,dst_ip,dns_ip,gateway,video_port,serial_port_tx,serial_port_rx,baud_rate,video_rate,audio_port);
|
||
|
||
printf("sscan\n");
|
||
printf("%s\n",ip_pre);
|
||
printf("%s\n",rtsp1_1_pre);
|
||
printf("%s\n",rtsp1_2_pre);
|
||
printf("%s\n",rtsp1_3_pre);
|
||
printf("%s\n",rtsp1_4_pre);
|
||
printf("%s\n",rtsp2_pre);
|
||
printf("%s\n",rtsp3_pre);
|
||
printf("%s\n",rtsp4_pre);
|
||
printf("%s\n",rtsp5_pre);
|
||
}
|
||
#if 1
|
||
url_decode(ip,ip_pre);
|
||
url_decode(rtsp1_1,rtsp1_1_pre);
|
||
url_decode(rtsp1_2,rtsp1_2_pre);
|
||
url_decode(rtsp1_3,rtsp1_3_pre);
|
||
url_decode(rtsp1_4,rtsp1_4_pre);
|
||
url_decode(rtsp2,rtsp2_pre);
|
||
url_decode(rtsp3,rtsp3_pre);
|
||
url_decode(rtsp4,rtsp4_pre);
|
||
url_decode(rtsp5,rtsp5_pre);
|
||
if(fd_fs > 0){
|
||
//write(fd_fs,src_ip,strlen(src_ip));
|
||
//write(fd_fs," [\n",3);
|
||
|
||
write(fd_fs,ip,strlen(ip));
|
||
write(fd_fs," \n",2);
|
||
write(fd_fs,rtsp1_1,strlen(rtsp1_1));
|
||
write(fd_fs," \n",2);
|
||
write(fd_fs,rtsp1_2,strlen(rtsp1_2));
|
||
write(fd_fs," \n",2);
|
||
write(fd_fs,rtsp1_3,strlen(rtsp1_3));
|
||
write(fd_fs," \n",2);
|
||
write(fd_fs,rtsp1_4,strlen(rtsp1_4));
|
||
write(fd_fs," \n",2);
|
||
write(fd_fs,rtsp2,strlen(rtsp2));
|
||
write(fd_fs," \n",2);
|
||
write(fd_fs,rtsp3,strlen(rtsp3));
|
||
write(fd_fs," \n",2);
|
||
write(fd_fs,rtsp4,strlen(rtsp4));
|
||
write(fd_fs," \n",2);
|
||
write(fd_fs,rtsp5,strlen(rtsp5));
|
||
write(fd_fs," \n",2);
|
||
#if 0
|
||
write(fd_fs,switch_port,strlen(switch_port));
|
||
write(fd_fs," [\n",3);
|
||
write(fd_fs,video_source,strlen(video_source));
|
||
write(fd_fs," [\n",3);
|
||
write(fd_fs,cpe_5g,strlen(cpe_5g));
|
||
write(fd_fs," [\n",3);
|
||
#endif
|
||
|
||
system("cp /root/ceshi.txt /root/ConfigParameter.txt");
|
||
system("sync");
|
||
}
|
||
#endif
|
||
}
|