这个网页上用cgi,javascript,html,c写的,其实我自己比较了解到是html,其次是javascript,对于c书到时看过几片了,但要编程感觉还是不够,cgi以前都没听说过,是最近才看到电子书,现在公司给了我他们以前做的web的程序,看到自己云里雾里的,网上cgi的资料也少,对于c写的cgi,太少了,所以很少棘手,请大家帮忙,分析下程序.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "cgi.h"
typedef unsigned char BYTE;
#define Ver1 2
#define Ver2 2
//#define Protocol_Length 174
char *Get_Val[100];
char first_str[]="Audio_Output_Model";
char second_str[]="Audio_Bit";
char third_str[]="Audio_Type";
char fourth_str[]="Audio_Layer";
char fifth_str[]="Audio_sampling_rate";
char seps[]="=&";
int ret,recvDataLength;
int Length,DesUserID,UserNameLength;
int cgi_audio_stream_type,cgi_audio_layer,cgi_audio_bit_rate,cgi_audio_sampling_rate,cgi_audio_channel;
int t_audio_stream_type,t_audio_layer,t_audio_bit_rate,t_audio_sampling_rate,t_audio_channel;
int road;
int wt;
char str1[]="r1";//路数
char str2[]="r2";
char str3[]="r3";
char str4[]="r4";
char str5[]="w1";
char str6[]="w2";
char str7[]="w3";
char str8[]="w4";
int cgi_init();
int cgi_out(char *buf,int buflen);
int cgi_recv(char *buf);
int cgi_free();
int net_get_err_info(int err_code,char *ret_val);
int Send_Terminal_Audio(int audio_stream_type,int audio_layer,int audio_bit_rate,int audio_sampling_rate,int audio_channel)
{
//printf("%d",road);
if ((road!=1)&&(road!=2)&&(road!=3)&&(road!=4))
{
unsigned char buf[2000];
int i,sum;
i=NoSetTerminal();
buf[0]=0xfb;
buf[1]=((sizeof(pro_Terminal)+17)/256) & 0xff;
buf[2]=(sizeof(pro_Terminal)+17) & 0xff;
buf[3]=0x0c;
buf[4]=0x02;
buf[5]=0;
buf[6]=0;
buf[7]=0;
buf[8]=0;
buf[9]=0;
buf[10]=0;
buf[11]=0;
buf[12]=0;
buf[13]=Ver1;
buf[14]=Ver2;
road=wt;
if (audio_stream_type!=0)
{
pro_Terminal.aud_coding_standard_status[wt-1]=0x01;
pro_Terminal.aud_coding_standard[wt-1]=audio_stream_type;
}
if (audio_layer!=0)
{
pro_Terminal.aud_layer_status[wt-1]=0x01;
pro_Terminal.aud_layer[wt-1]=audio_layer;
}
if (audio_bit_rate!=0)
{
pro_Terminal.aud_bit_rate_status[wt-1]=0x01;
pro_Terminal.aud_bit_rate[wt-1][0]=(((audio_bit_rate/256)/256)/256) & 0xff;
pro_Terminal.aud_bit_rate[wt-1][1]=((audio_bit_rate/256)/256) & 0xff;
pro_Terminal.aud_bit_rate[wt-1][2]=(audio_bit_rate/256) & 0xff;
pro_Terminal.aud_bit_rate[wt-1][3]=audio_bit_rate & 0xff;
}
if (audio_sampling_rate!=0)
{
pro_Terminal.aud_sampling_rate_status[wt-1]=0x01;
pro_Terminal.aud_sampling_rate[wt-1]=audio_sampling_rate;