📄 webhttpd.c
字号:
} else { send_template_ini_client_raw(client_socket); sprintf(res,"track set absolute x=%s\nDone\n", x_value); send_template_raw(client_socket, res); } } else { /*error in track action*/ if (cnt[0]->conf.control_html_output) { sprintf(res,"<a href=/%d/track><- back</a>\n", thread); response_client(client_socket, track_error, res); } else response_client(client_socket, track_error_raw, NULL); } } else { /* Y */ setcnt = cnt[thread]; // 1000 is out of range for pwc cnt[thread]->moved = track_center(setcnt, setcnt->video_dev, 1, 1000, atoi(y_value)); if (cnt[thread]->moved) { if (cnt[0]->conf.control_html_output) { send_template_ini_client(client_socket, ini_template); sprintf(res,"track set absolute y=%s<br>\n" "<a href=/%d/track><- back</a>\n", y_value, thread); send_template(client_socket, res); send_template_end_client(client_socket); } else { send_template_ini_client_raw(client_socket); sprintf(res,"track set absolute y=%s\nDone\n", y_value); send_template_raw(client_socket, res); } } else { /*error in track action*/ if (cnt[0]->conf.control_html_output) { sprintf(res,"<a href=/%d/track><- back</a>", thread); response_client(client_socket, track_error, res); } else response_client(client_socket, track_error_raw, NULL); } } return 1; } /* Check Second parameter */ warningkill = sscanf (pointer, "%c%256[a-z]" ,&question, command); if ( ( question != '&' ) || (command[0] == '\0') ){ motion_log(LOG_WARNING, 0, "httpd debug race 4"); if ( strstr(pointer,"&")){ if (cnt[0]->conf.control_html_output) response_client(client_socket, error_value, NULL); else response_client(client_socket, error_value_raw, NULL); } /* no valid syntax */ else{ if (cnt[0]->conf.control_html_output) response_client(client_socket, not_valid_syntax, NULL); else response_client(client_socket, not_valid_syntax_raw, NULL); } return 1; } pointer++; length_uri--; if (!strcmp(command, "pan")){ pointer = pointer + 3; length_uri = length_uri - 3; if ( (pan) || (!tilt) || (X) || (Y) ) { motion_log(LOG_WARNING, 0, "httpd debug race 5"); /* no valid syntax */ if (cnt[0]->conf.control_html_output) response_client(client_socket, not_valid_syntax, NULL); else response_client(client_socket, not_valid_syntax_raw, NULL); return 1; } pan=2; warningkill = sscanf (pointer, "%c%10[-0-9]" ,&question, panvalue); } else if (!strcmp(command, "tilt")) { pointer = pointer + 4; length_uri = length_uri - 4; if ( (tilt) || (!pan) || (X) || (Y) ) { /* no valid syntax */ motion_log(LOG_WARNING, 0, "httpd debug race 6"); if (cnt[0]->conf.control_html_output) response_client(client_socket, not_valid_syntax, NULL); else response_client(client_socket, not_valid_syntax_raw, NULL); return 1; } tilt = 2; warningkill = sscanf (pointer, "%c%10[-0-9]" ,&question, tiltvalue); } else if (!strcmp(command, "x")) { pointer++; length_uri--; if ( (X) || (!Y) || (pan) || (tilt) ) { motion_log(LOG_WARNING, 0, "httpd debug race 7"); /* no valid syntax */ if (cnt[0]->conf.control_html_output) response_client(client_socket, not_valid_syntax, NULL); else response_client(client_socket, not_valid_syntax_raw, NULL); return 1; } X = 2; warningkill = sscanf (pointer, "%c%10[-0-9]" ,&question, x_value); } else if (!strcmp(command, "y")) { pointer++; length_uri--; if ( (Y) || (!X) || (pan) || (tilt) ){ motion_log(LOG_WARNING, 0, "httpd debug race 8"); /* no valid syntax */ if (cnt[0]->conf.control_html_output) response_client(client_socket, not_valid_syntax, NULL); else response_client(client_socket, not_valid_syntax_raw, NULL); return 1; } Y = 2; warningkill = sscanf (pointer, "%c%10[-0-9]" ,&question, y_value); } else { motion_log(LOG_WARNING, 0, "httpd debug race 9"); /* no valid syntax */ if (cnt[0]->conf.control_html_output) response_client(client_socket, not_valid_syntax, NULL); else response_client(client_socket, not_valid_syntax_raw, NULL); return 1; } /* Second value check */ if ( ( warningkill < 2 ) && (question != '=') ) { motion_log(LOG_WARNING, 0, "httpd debug race 10"); /* no valid syntax */ if (cnt[0]->conf.control_html_output) response_client(client_socket, not_valid_syntax, NULL); else response_client(client_socket, not_valid_syntax_raw, NULL); return 1; }else if (( question == '=') && ( warningkill == 1)){ motion_log(LOG_WARNING, 0, "httpd debug race 11"); if (cnt[0]->conf.control_html_output) response_client(client_socket, error_value, NULL); else response_client(client_socket, error_value_raw, NULL); return 1; } if (pan == 2){ pointer = pointer + strlen(panvalue) + 1; length_uri = length_uri - strlen(panvalue) - 1; } else if (tilt == 2){ pointer = pointer + strlen(tiltvalue) + 1; length_uri = length_uri - strlen(tiltvalue) - 1; } else if (X == 2){ pointer = pointer + strlen(x_value) + 1; length_uri = length_uri - strlen(x_value) - 1; } else{ pointer = pointer + strlen(y_value) + 1; length_uri = length_uri - strlen(y_value) - 1; } if (length_uri != 0) { motion_log(LOG_WARNING, 0, "httpd debug race 12"); if (cnt[0]->conf.control_html_output) response_client(client_socket, error_value, NULL); else response_client(client_socket, error_value_raw, NULL); return 1; } /* track set absolute ( x , y )*/ if ( X && Y ) { setcnt = cnt[thread]; cnt[thread]->moved = track_center(setcnt, setcnt->video_dev, 1, atoi(x_value), atoi(y_value)); if (cnt[thread]->moved) { if (cnt[0]->conf.control_html_output){ send_template_ini_client(client_socket, ini_template); sprintf(res,"track set x=%s y=%s<br>\n" "<a href=/%d/track><- back</a>\n", x_value, y_value, thread); send_template(client_socket, res); send_template_end_client(client_socket); } else { send_template_ini_client_raw(client_socket); sprintf(res,"track set x=%s y=%s\nDone\n", x_value, y_value); send_template_raw(client_socket, res); } } else { /*error in track action*/ if (cnt[0]->conf.control_html_output) { sprintf(res,"<a href=/%d/track><- back</a>\n", thread); response_client(client_socket, track_error, res); } else response_client(client_socket, track_error_raw, NULL); } /* track set relative ( pan , tilt )*/ } else { struct coord cent; struct context *relativecnt; /* move pan */ relativecnt = cnt[thread]; cent.width = relativecnt->imgs.width; cent.height = relativecnt->imgs.height; cent.y = 0; cent.x = atoi(panvalue); // Add the number of frame to skip for motion detection cnt[thread]->moved = track_move(relativecnt, relativecnt->video_dev, ¢, &relativecnt->imgs, 1); if (cnt[thread]->moved){ /* move tilt */ relativecnt = cnt[thread]; cent.width = relativecnt->imgs.width; cent.height = relativecnt->imgs.height; cent.x = 0; cent.y = atoi(tiltvalue); SLEEP(1,0); cnt[thread]->moved = track_move(relativecnt, relativecnt->video_dev, ¢, &relativecnt->imgs, 1); if (cnt[thread]->moved){ if (cnt[0]->conf.control_html_output) { send_template_ini_client(client_socket, ini_template); sprintf(res,"track pan=%s tilt=%s<br>\n" "<a href=/%d/track><- back</a>\n", panvalue, tiltvalue, thread); send_template(client_socket, res); send_template_end_client(client_socket); } else { send_template_ini_client_raw(client_socket); sprintf(res,"track pan=%s tilt=%s\nDone\n", panvalue, tiltvalue); send_template_raw(client_socket, res); } return 1; } else{ /*error in track tilt*/ if (cnt[0]->conf.control_html_output) { sprintf(res,"<a href=/%d/track><- back</a>\n", thread); response_client(client_socket, track_error, res); }else response_client(client_socket, track_error_raw, NULL); } } /*error in track pan*/ if (cnt[0]->conf.control_html_output) { sprintf(res,"<a href=/%d/track><- back</a>\n", thread); response_client(client_socket, track_error, res); } else response_client(client_socket, track_error_raw, NULL); } } else if (length_uri == 0) { if (cnt[0]->conf.control_html_output) { send_template_ini_client(client_socket, ini_template); sprintf(res,"<b>Thread %d</b><br>\n" "<form action='set'>\n" "Pan<input type=text name='pan' value=''>\n" "Tilt<input type=text name='tilt' value=''>\n" "<input type=submit value='set relative'>\n" "</form>\n" "<form action='set'>\n" "X<input type=text name='x' value=''>\n" "Y<input type=text name='y' value=''>\n" "<input type=submit value='set absolute'>\n" "</form>\n" "<a href=/%d/track><- back</a>\n", thread, thread); send_template(client_socket, res); send_template_end_client(client_socket); } else { send_template_ini_client_raw(client_socket); sprintf(res,"set needs a pan/tilt or x/y values\n"); send_template_raw(client_socket, res); } } else { /* error not valid command */ if (cnt[0]->conf.control_html_output) response_client(client_socket, not_found_response_valid_command, NULL); else response_client(client_socket, not_found_response_valid_command_raw, NULL); } } else if (!strcmp(command,"status")) { pointer = pointer+6; length_uri = length_uri-6; if (length_uri==0) { if (cnt[0]->conf.control_html_output) { if (cnt[thread]->track.active) sprintf(res,"<b>Thread %d</b><br>track auto enabled<br>\n",thread); else sprintf(res,"<b>Thread %d</b><br>track auto disabled<br>\n",thread); send_template_ini_client(client_socket, ini_template); send_template(client_socket, res); sprintf(res, "<a href=/%d/track><- back</a>\n",thread); send_template(client_socket, res); send_template_end_client(client_socket); } else { if (cnt[thread]->track.active) sprintf(res,"Thread %d\n track auto enabled\nDone\n",thread); else sprintf(res,"Thread %d\n track auto disabled\nDone\n",thread); send_template_ini_client_raw(client_socket); send_template_raw(client_socket, res); } } else { /* error not valid command */ if (cnt[0]->conf.control_html_output) { response_client(client_socket, not_found_response_valid_command, NULL); } else response_client(client_socket, not_found_response_valid_command_raw, NULL); } } else if (!strcmp(command,"auto")) { pointer = pointer + 4; length_uri = length_uri - 4; if ((question == '?') && (length_uri > 0)) { char query[256] = {'\0'}; pointer++; length_uri--; /* value= */ warningkill = sscanf (pointer, "%256[a-z]%c",query,&question); if ((question == '=') && (!strcmp(query,"value")) ) { pointer = pointer + 6; length_uri = length_uri - 6; warningkill = sscanf (pointer, "%256[-0-9a-z]" , command); if ((command!=NULL) && (strlen(command) > 0)) { struct context *autocnt; /* auto value=0|1|status*/ if (!strcmp(command,"status")) { if (cnt[0]->conf.control_html_output) { if (cnt[thread]->track.active) sprintf(res, "<b>Thread %d</b><br>track auto enabled\n", thread); else sprintf(res, "<b>Thread %d</b><br>track auto disabled\n", thread); send_template_ini_client(client_socket, ini_template); send_template(client_socket, res); sprintf(res,"<a href=/%d/track><- back</a>", thread); send_template(client_socket, res); send_template_end_client(client_socket); } else { if (cnt[thread]->track.active) sprintf(res, "Thread %d\n track auto enabled\nDone\n", thread); else sprintf(res, "Thread %d\n track auto disabled\nDone\n", thread); send_template_ini_client_raw(client_socket); send_template_raw(client_socket, res); } } else { int active; active = atoi(command); if (active > -1 && active < 2) { autocnt = cnt[thread]; autocnt->track.active = atoi(command); if (cnt[0]->conf.control_html_output) { send_template_ini_client(client_socket, ini_template); sprintf(res,"track auto %s<br><a href=/%d/track><- back</a>", command,thread); send_template(client_socket, res); send_template_end_client(client_socket); } else { send_template_ini_client_raw(client_socket); sprintf(res,"track auto %s\nDone\n",command); send_template_raw(client_socket, res); } } else { if (cnt[0]->conf.control_html_output) response_client(client_socket, not_found_response_valid_command, NULL); else response_client(client_socket, not_found_response_valid_command_raw, NULL); } } } else { if (cnt[0]->conf.control_html_output) response_client(client_socket, not_found_response_valid_command, NULL); else response_client(client_socket, not_found_response_valid_command_raw, NULL); } } else { if (cnt[0]->conf.control_html_output) response_client(client_socket, not_found_response_valid_command, NULL); else
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -