how to transform the structure of language "C" in Purebasic

Just starting out? Need help? Post your questions and find answers here.
siesit
User
User
Posts: 12
Joined: Fri Aug 21, 2009 8:40 am
Location: rus
Contact:

how to transform the structure of language "C" in Purebasic

Post by siesit »

how to transform the structure of language "C" in "Purebasic"?
Many thanks for help

Code: Select all

typedef struct FCGX_Stream {
    unsigned char *rdNext;    /* reader: first valid byte
                               * writer: equals stop */
    unsigned char *wrNext;    /* writer: first free byte
                               * reader: equals stop */
    unsigned char *stop;      /* reader: last valid byte + 1
                               * writer: last free byte + 1 */
    unsigned char *stopUnget; /* reader: first byte of current buffer
                               * fragment, for ungetc
                               * writer: undefined */
    int isReader;
    int isClosed;
    int wasFCloseCalled;
    int FCGI_errno;                /* error status */
    void (*fillBuffProc) (struct FCGX_Stream *stream);
    void (*emptyBuffProc) (struct FCGX_Stream *stream, int doClose);
    void *data;
} FCGX_Stream;

/*
 * An environment (as defined by environ(7)): A NULL-terminated array
 * of strings, each string having the form name=value.
 */
typedef char **FCGX_ParamArray;

/*
 * FCGX_Request Flags
 *
 * Setting FCGI_FAIL_ACCEPT_ON_INTR prevents FCGX_Accept() from
 * restarting upon being interrupted.
 */
#define FCGI_FAIL_ACCEPT_ON_INTR	1

/*
 * FCGX_Request -- State associated with a request.
 *
 * Its exposed for API simplicity, I expect parts of it to change!
 */
typedef struct FCGX_Request {
    int requestId;            /* valid if isBeginProcessed */
    int role;
    FCGX_Stream *in;
    FCGX_Stream *out;
    FCGX_Stream *err;
	char **envp;

	/* Don't use anything below here */

    struct Params *paramsPtr;
    int ipcFd;               /* < 0 means no connection */
    int isBeginProcessed;     /* FCGI_BEGIN_REQUEST seen */
    int keepConnection;       /* don't close ipcFd at end of request */
    int appStatus;
    int nWriters;             /* number of open writers (0..2) */
	int flags;
	int listen_sock;
} FCGX_Request;
site created by purebasic work-flow-Initiative
siesit
User
User
Posts: 12
Joined: Fri Aug 21, 2009 8:40 am
Location: rus
Contact:

Re: how to transform the structure of language "C" in Pureba

Post by siesit »

tried to do so:
though not sure what is right ...
in the comments pointed out that he was unable to translate

Code: Select all

FCGI_FAIL_ACCEPT_ON_INTR.l=1

;typedef char **FCGX_ParamArray;

Structure FCGX_Stream
*rdNext.c
*wrNext.c
*stop.c
*stopUnget.c
isReader.l
isClosed.l
wasFCloseCalled.l
FCGI_errno.l;                /* error status */
;     void (*fillBuffProc) (struct FCGX_Stream *stream);
;     void (*emptyBuffProc) (struct FCGX_Stream *stream, int doClose);
;     void *Data;
EndStructure

Structure FCGX_Request
    requestId.l;            /* valid if isBeginProcessed */
    role.l;
     *in.FCGX_Stream;
     *out.FCGX_Stream;
     *err.FCGX_Stream;
     *envp.c
;   char **envp;
;/* Don't use anything below here */
;   struct Params *paramsPtr;
    ipcFd.l;               /* < 0 means no connection */
    isBeginProcessed.l;     /* FCGI_BEGIN_REQUEST seen */
    keepConnection.l;       /* don't close ipcFd at end of request */
    appStatus.l;
    nWriters.l;             /* number of open writers (0..2) */
    flags.l;
    listen_sock.l;
EndStructure

Request.FCGX_Request
site created by purebasic work-flow-Initiative
User avatar
Shield
Addict
Addict
Posts: 1021
Joined: Fri Jan 21, 2011 8:25 am
Location: 'stralia!
Contact:

Re: how to transform the structure of language "C" in Pureba

Post by Shield »

Code: Select all

;     void (*emptyBuffProc) (struct FCGX_Stream *stream, int doClose);
Try using prototypes for this, e.g.

Code: Select all

Prototype.i pt_emptyBuffProc(*stream.FCGX_Stream, doClose.i)

Code: Select all

void *Data;
That's just a regular pointer, use *Data.
Same goes with char **envp which is a pointer to a pointer (array)...still a pointer though. ;)
So use *envp.

Code: Select all

struct Params *paramsPtr;
Seems to be a pointer to a structure called Params, so just using *paramsPtr should do the trick.

Code: Select all

typedef char **FCGX_ParamArray;
That just means that FCGX_ParamArray is the same as a pointer to a pointer to a char (usually used to represent arrays),
so just replace any FCGX_ParamArray with .i (or no type since it's a pointer).


Sorry for the brief explanations, don't have much time at the moment but wanted to help out a bit. :)
Image
Blog: Why Does It Suck? (http://whydoesitsuck.com/)
"You can disagree with me as much as you want, but during this talk, by definition, anybody who disagrees is stupid and ugly."
- Linus Torvalds
Post Reply