VC++ To PureBasic No

Windows specific forum
Rascal
User
User
Posts: 30
Joined: Mon Sep 17, 2007 11:06 pm

VC++ To PureBasic No

Post by Rascal »

Code: Select all

#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <httpfilt.h>

BOOL WINAPI __stdcall GetFilterVersion(HTTP_FILTER_VERSION *pVer)
{
  pVer->dwFlags = SF_NOTIFY_PREPROC_HEADERS| SF_NOTIFY_URL_MAP | SF_NOTIFY_SEND_RAW_DATA;         
  pVer->dwFilterVersion=HTTP_FILTER_REVISION; 
  strcpy(pVer->lpszFilterDesc, ("Chehw's HTTP Filter Sample"));//, SF_MAX_FILTER_DESC_LEN);
  return TRUE;
}

DWORD WINAPI __stdcall HttpFilterProc(HTTP_FILTER_CONTEXT *pfc, DWORD NotificationType, void *pvNotification)
{
    PHTTP_FILTER_URL_MAP pURLMap; 
    PHTTP_FILTER_PREPROC_HEADERS pPreHeaders;
    char * pszPhysPath;
    switch(NotificationType)
    {
    case SF_NOTIFY_PREPROC_HEADERS:
        pPreHeaders=(PHTTP_FILTER_PREPROC_HEADERS)pvNotification;
        pfc->ServerSupportFunction(pfc, SF_REQ_SEND_RESPONSE_HEADER, "200 OK", 
            (ULONG_PTR)"Content-type: text/html\r\n\r\n"
                       "<html><h1>Hello World!</h1></html>", 0);
        pfc->ServerSupportFunction(pfc, SF_REQ_DISABLE_NOTIFICATIONS, NULL,
            SF_NOTIFY_URL_MAP |    SF_NOTIFY_SEND_RAW_DATA, 0);
        return SF_STATUS_REQ_FINISHED;
    default:
        break;
    }
    return SF_STATUS_REQ_NEXT_NOTIFICATION; 
}

Code: Select all

#SF_MAX_FILTER_DESC_LEN          = 257
#SF_STATUS_REQ_NEXT_NOTIFICATION = $8000002
#HTTP_FILTER_REVISION            = $00040000
#SF_NOTIFY_READ_RAW_DATA         = 32768
#SF_NOTIFY_PREPROC_HEADERS       = 16384
#SF_NOTIFY_URL_MAP               = 4096
#SF_NOTIFY_AUTHENTICATION        = 8192
#SF_NOTIFY_AUTH_COMPLETE         = 67108864
#SF_NOTIFY_ACCESS_DENIED         = 2048
#SF_NOTIFY_SEND_RESPONSE         = 64
#SF_NOTIFY_SEND_RAW_DATA         = 1024
#SF_NOTIFY_END_OF_REQUEST        = 128
#SF_NOTIFY_LOG                   = 512
#SF_NOTIFY_END_OF_NET_SESSION    = 256
#SF_NOTIFY_ORDER_LOW             = 131072
#SF_NOTIFY_ORDER_MEDIUM          = 262144
#SF_NOTIFY_ORDER_HIGH            = 524288
#SF_NOTIFY_ORDER_DEFAULT         = #SF_NOTIFY_ORDER_LOW
#SF_NOTIFY_SECURE_PORT           = 1
#SF_NOTIFY_NONSECURE_PORT        = 2
#SF_REQ_SEND_RESPONSE_HEADER     = 0
#SF_REQ_DISABLE_NOTIFICATIONS    = 8
#SF_STATUS_REQ_FINISHED          = 134217728
#SF_NOTIFY_ORDER_DEFAULT         = #SF_NOTIFY_ORDER_LOW
#HSE_REQ_END_RESERVED            = 1000 
#HSE_REQ_SEND_RESPONSE_HEADER_EX = #HSE_REQ_END_RESERVED+16 

Structure HTTP_FILTER_VERSION
  dwServerFilterVersion.l
  dwFilterVersion.l
  lpszFilterDesc.b[#SF_MAX_FILTER_DESC_LEN]
  dwFlags.l
EndStructure

Prototype GetServerVariable(ConnID, lpszVariableName.s, *lpvBuffer, *lpdwSizeofBuffer.LONG)
Prototype AddResponseHeaders(ConnID,lpszHeaders.s,dwReserved.s)
Prototype WriteClient(ConnID,*Buffer, *lpdwSizeofBuffer.LONG,dwSync)
Prototype AllocMem(ConnID,cbSize,dwReserved)
Prototype ServerSupportFunction(ConnID, dwServerSupportFunction, *lpvBuffer, *lpdwSizeofBuffer.LONG, *lpdwDataType.LONG)

Structure HTTP_FILTER_CONTEXT
  cbSize.l
  Revision.l
  ServerContext.l
  ulReserved.l
  fIsSecurePort.l
  pFilterContext.l
  GetServerVariable.GetServerVariable
  AddResponseHeaders.AddResponseHeaders 
  WriteClient.WriteClient
  AllocMem.AllocMem 
  ServerSupportFunction.ServerSupportFunction
EndStructure 

Structure HTTP_FILTER_PREPROC_HEADERS
  GetHeader.l
  SetHeader.l
  AddHeader.l
  HttpStatus.l
  dwReserved.l
EndStructure 

Structure HTTP_FILTER_URL_MAP
  pszURL.s
  pszPhysicalPath.s
  cbPathBuff.l
EndStructure 

Declare.l GetFilterVersion(*pVer.HTTP_FILTER_VERSION)
Declare.l HttpFilterProc(*pfc.HTTP_FILTER_CONTEXT,NotificationType,*pvData)

ProcedureDLL.l GetFilterVersion(*pVer.HTTP_FILTER_VERSION)
*pVer\dwFlags = #SF_NOTIFY_PREPROC_HEADERS|#SF_NOTIFY_URL_MAP|#SF_NOTIFY_SEND_RAW_DATA
*pVer\dwFilterVersion = #HTTP_FILTER_REVISION
PokeS(@*pVer\lpszFilterDesc[0],"Chehw's HTTP Filter Sample")
ProcedureReturn #True
EndProcedure

ProcedureDLL.l HttpFilterProc(*pfc.HTTP_FILTER_CONTEXT,NotificationType,*pvData)
pURLMap.HTTP_FILTER_URL_MAP
pPreHeaders.HTTP_FILTER_PREPROC_HEADERS
Select NotificationType
    Case #SF_NOTIFY_PREPROC_HEADERS  
         pPreHeaders = *pvData
         a.s = "Content-type: text/html" + #CRLF$ + #CRLF$ + "<html><h1>Hello World!</h1></html>"
         b.s = "200 OK"
         *pfc\ServerSupportFunction(@*pfc,#SF_REQ_SEND_RESPONSE_HEADER,@b,@a,#Null)
         *pfc\ServerSupportFunction(@*pfc,#SF_REQ_DISABLE_NOTIFICATIONS,#Null,#SF_NOTIFY_URL_MAP|#SF_NOTIFY_SEND_RAW_DATA,#Null)
         ProcedureReturn #SF_STATUS_REQ_FINISHED
EndSelect
ProcedureReturn #SF_STATUS_REQ_NEXT_NOTIFICATION
EndProcedure
inc.
Enthusiast
Enthusiast
Posts: 406
Joined: Thu May 06, 2004 4:28 pm
Location: Cologne/GER

Post by inc. »

?
Whats your purpose?

Maybe some explaining words to your code would give your post the kind of sense it needs to be understood!
Check out OOP support for PB here!
User avatar
Fluid Byte
Addict
Addict
Posts: 2336
Joined: Fri Jul 21, 2006 4:41 am
Location: Berlin, Germany

Post by Fluid Byte »

Are you demented Rascal?
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
LuCiFeR[SD]
666
666
Posts: 1033
Joined: Mon Sep 01, 2003 2:33 pm

Post by LuCiFeR[SD] »

Rascal, There is a new Command in PureBasic that Fred wrote especially for you. it is called:

"ConvertCPPToPB()"

Actually, as you no doubt realised, I am using sarcasm towards you. We do not provide a C++ conversion service here.

It would not surprise me if you are one of our old Chinese freinds under yet another new name... you certainly post in a similar way to how PBChinese and some of his friends used to. But hey, I've been wrong in the past :P

Regardless, just posting a bunch of code, without asking even a simple "Could somebody please help me to convert this code to purebasic" is just damn rude.

Ciao :P
User avatar
djes
Addict
Addict
Posts: 1806
Joined: Sat Feb 19, 2005 2:46 pm
Location: Pas-de-Calais, France

Post by djes »

Maybe he don't speak english...
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

Then he shouldn't be in the English forums? There are French, German, and
even an unofficial Chinese forum that he can visit, if English ain't his thang.

Besides, with literal strings of "Chehw's HTTP Filter Sample" and "Hello world"
in his C sample, then yes, I'd say it's a fair bet he speaks English. And his
username is an English name. And his other posts are all the same: C code
with no explanation.
Post Reply