⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 webpage.c

📁 TI公司C6000系列DSP(DM642)进行网络视频电话通讯源代码
💻 C
字号:
//--------------------------------------------------------------------------
// IP Stack Client Demo
//--------------------------------------------------------------------------
// webpage.c
//
// Web page and CGI function
//
// Author: Michael A. Denio
// Copyright 2000, 2001 by Texas Instruments Inc.
//-------------------------------------------------------------------------
#include <std.h>
#include <sys.h>
#include <sem.h>
#include <tsk.h>
#include "c:\ti\c6000\ndk\inc\netmain.h"
#include "thrControl.h"

#pragma DATA_SECTION(DEFAULT, "OBJMEM");
#include "webdata\default.c"
#pragma DATA_SECTION(TIBUG, "OBJMEM");
#include "webdata\tibug.c"
#pragma DATA_SECTION(JAVA1, "OBJMEM");
#include "webdata\java1.c"
#pragma DATA_SECTION(JAVA2, "OBJMEM");
#include "webdata\java2.c"

static int cgiConfig(int htmlSock, int ContentLength, char *pArgs );

extern char *cgiParseVars(char PostIn[], int *pParseIndex );


void AddWebFiles(void)
{
    efs_createfile("index.html", DEFAULT_SIZE, DEFAULT);
    efs_createfile("tibug.jpg", TIBUG_SIZE, TIBUG);
    efs_createfile("easyCam.class", JAVA1_SIZE, JAVA1);
    efs_createfile("easyCam$1.class", JAVA2_SIZE, JAVA2);
    efs_createfile("cfgquality.cgi", 0, (UINT8*)cgiConfig);
}

void RemoveWebFiles(void)
{
    efs_destroyfile("index.html");
    efs_destroyfile("tibug.jpg");
    efs_destroyfile("cfgquality.cgi");
    efs_destroyfile("easyCam.class");
    efs_destroyfile("easyCam$1.class");
}


#define html(str) httpSendClientStr(htmlSock, (char *)str)


//
// cgiConfig()
//
static int cgiConfig(int htmlSock, int ContentLength, char *pArgs )
{
    char    *qualstr = 0;
    char    *buffer, *key, *value;
    int     len,quality;
    int     parseIndex;

    // CGI Functions can now support URI arguments as well if the
    // pArgs pointer is not NULL, and the ContentLength were zero,
    // we could parse the arguments off of pArgs instead.

    // First, allocate a buffer for the request
    buffer = (char*) mmBulkAlloc( ContentLength + 1 );
    if ( !buffer )
        goto ERROR;

    // Now read the data from the client
    len = recv( htmlSock, buffer, ContentLength, MSG_WAITALL );
    if ( len < 1 )
        goto ERROR;

    // Setup to parse the post data
    parseIndex = 0;
    buffer[ContentLength] = '\0';

    // Process request variables until there are none left
    do
    {
        key   = cgiParseVars( buffer, &parseIndex );
        value = cgiParseVars( buffer, &parseIndex );

        if( !strcmp("quality", key) )
            qualstr = value;
    } while ( parseIndex != -1 );

    //
    // Output the data we read in...
    //

    httpSendStatusLine(htmlSock, HTTP_OK, CONTENT_TYPE_HTML);
    // CRLF before entity
    html( CRLF );

    //
    // Generate response
    //

    // If the password is incorrect or missing, generate an error
    if( qualstr )
    {
        quality = 0;
        while( *qualstr )
            quality = quality * 10 + (*qualstr++ - '0');
        if( quality > 0 && quality <= 100 )
            thrControlSet( 1, quality );
    }

    // Send back the same default page
    send( htmlSock, DEFAULT, DEFAULT_SIZE, 0 );

ERROR:
    if( buffer )
        mmBulkFree( buffer );

    return( 1 );
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -