C:/fscan/HTTPCore/CallBack.cpp

Go to the documentation of this file.
00001 
00007 #include "CallBack.h"
00008 #include <stdio.h>
00009 #include <stdlib.h>
00010 
00011 
00012 
00013 typedef struct _cb_list{
00014     unsigned int cbType;
00015     HTTP_IO_REQUEST_CALLBACK cb;   
00016 } CB_LIST, *PCB_LIST;
00017 
00018 static PCB_LIST CBList=    NULL;
00019 static unsigned int CBItems=   0;
00020 
00021 /**********************************************************************************************************************/
00023 
00030 /**********************************************************************************************************************/
00031 void RegisterHTTPCallBack(unsigned int cbType, HTTP_IO_REQUEST_CALLBACK cb)
00032 {
00033         CBList=(PCB_LIST)realloc(CBList,sizeof(CB_LIST)*++CBItems);
00034     CBList[CBItems-1].cbType=cbType;
00035     CBList[CBItems-1].cb=cb;
00036 }
00037 /**********************************************************************************************************************/
00039 
00045 /**********************************************************************************************************************/
00046 int  RemoveHTTPCallBack(unsigned int cbType, HTTP_IO_REQUEST_CALLBACK cb){
00047     unsigned int ret=0;
00048     for (unsigned int i=0;i<CBItems;i++)
00049     {
00050         if ( (cb==NULL) || (CBList[i].cb == cb ) )
00051         {
00052             if (CBList[i].cbType & cbType)
00053             {
00054                 CBList[i].cb=NULL;
00055                 ret++;
00056             }
00057         }
00058     }
00059     if (ret==CBItems) 
00060     {
00061         free(CBList);
00062         CBList=NULL;
00063         CBItems=0;
00064     }
00065     return(ret);
00066 }
00067 /**********************************************************************************************************************/
00069 
00077 /**********************************************************************************************************************/
00078 int DoCallBack(int cbType,HTTPHANDLE HTTPHandle,PHTTP_DATA *request,PHTTP_DATA *response)
00079 {
00080     unsigned int i;
00081     int ret;
00082     for (i=0; i<CBItems;i++)
00083     {
00084         if ( (CBList[i].cbType & cbType) && (CBList[i].cb) )
00085         {
00086             ret=CBList[i].cb (
00087                 cbType,
00088                 HTTPHandle,
00089                                 request,
00090                                 response);
00091             if (ret & CBRET_STATUS_NEXT_CB_BLOCK)
00092                 break;
00093             if (ret & CBRET_STATUS_CANCEL_REQUEST)
00094             {
00095                 return(CBRET_STATUS_CANCEL_REQUEST);
00096             }
00097         }
00098     }     
00099     return( CBRET_STATUS_NEXT_CB_CONTINUE );
00100 }
00101 /**********************************************************************************************************************/

Generated on Sun Jan 18 00:32:03 2009 for Fast HTTP Vulnerability Scanner by  doxygen 1.5.4