Back to index

webcit  8.12-dfsg
Defines | Functions
paramhandling.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define sbstr(a)   SBstr(a, sizeof(a) - 1)
#define xbstr(a, b)   (char*) XBstr(a, sizeof(a) - 1, b)
#define lbstr(a)   LBstr(a, sizeof(a) - 1)
#define ibstr(a)   IBstr(a, sizeof(a) - 1)
#define ibcstr(a)   IBstr(a.Key, a.len)
#define havebstr(a)   HaveBstr(a, sizeof(a) - 1)
#define yesbstr(a)   YesBstr(a, sizeof(a) - 1)
#define bstr(a)   (char*) Bstr(a, sizeof(a) - 1)
#define putbstr(a, b)   PutBstr(a, sizeof(a) - 1, b)

Functions

void upload_handler (char *name, char *filename, char *partnum, char *disp, void *content, char *cbtype, char *cbcharset, size_t length, char *encoding, char *cbid, void *userdata)
void ParseURLParams (StrBuf *url)
const StrBuf * SBSTR (const char *key)
const StrBuf * SBstr (const char *key, size_t keylen)
const char * XBstr (const char *key, size_t keylen, size_t *len)
const char * XBSTR (const char *key, size_t *len)
long LBstr (const char *key, size_t keylen)
long LBSTR (const char *key)
int IBstr (const char *key, size_t keylen)
int IBSTR (const char *key)
int HaveBstr (const char *key, size_t keylen)
int HAVEBSTR (const char *key)
int YesBstr (const char *key, size_t keylen)
int YESBSTR (const char *key)
const char * BSTR (const char *key)
const char * Bstr (const char *key, size_t keylen)
void PutBstr (const char *key, long keylen, StrBuf *Value)

Define Documentation

#define bstr (   a)    (char*) Bstr(a, sizeof(a) - 1)

Definition at line 36 of file paramhandling.h.

#define havebstr (   a)    HaveBstr(a, sizeof(a) - 1)

Definition at line 27 of file paramhandling.h.

#define ibcstr (   a)    IBstr(a.Key, a.len)

Definition at line 23 of file paramhandling.h.

#define ibstr (   a)    IBstr(a, sizeof(a) - 1)

Definition at line 22 of file paramhandling.h.

#define lbstr (   a)    LBstr(a, sizeof(a) - 1)

Definition at line 18 of file paramhandling.h.

#define putbstr (   a,
 
)    PutBstr(a, sizeof(a) - 1, b)

Definition at line 40 of file paramhandling.h.

#define sbstr (   a)    SBstr(a, sizeof(a) - 1)

Definition at line 10 of file paramhandling.h.

#define xbstr (   a,
 
)    (char*) XBstr(a, sizeof(a) - 1, b)

Definition at line 14 of file paramhandling.h.

#define yesbstr (   a)    YesBstr(a, sizeof(a) - 1)

Definition at line 31 of file paramhandling.h.


Function Documentation

const char* BSTR ( const char *  key)

Definition at line 159 of file paramhandling.c.

{
       void *U;

       if ((WC->Hdr->urlstrings != NULL) &&
           GetHash(WC->Hdr->urlstrings, key, strlen (key), &U))
              return ChrPtr(((urlcontent *)U)->url_data);
       else   
              return ("");
}

Here is the caller graph for this function:

const char* Bstr ( const char *  key,
size_t  keylen 
)

Definition at line 170 of file paramhandling.c.

{
       void *U;

       if ((WC->Hdr->urlstrings != NULL) && 
           GetHash(WC->Hdr->urlstrings, key, keylen, &U))
              return ChrPtr(((urlcontent *)U)->url_data);
       else   
              return ("");
}

Here is the caller graph for this function:

int HaveBstr ( const char *  key,
size_t  keylen 
)

Definition at line 247 of file paramhandling.c.

{
       void *U;

       if ((WC->Hdr->urlstrings != NULL) && 
           GetHash(WC->Hdr->urlstrings, key, keylen, &U))
              return (StrLength(((urlcontent *)U)->url_data) != 0);
       else   
              return (0);
}

Here is the caller graph for this function:

int HAVEBSTR ( const char *  key)

Definition at line 258 of file paramhandling.c.

{
       void *U;

       if ((WC->Hdr->urlstrings != NULL) && 
           GetHash(WC->Hdr->urlstrings, key, strlen(key), &U))
              return (StrLength(((urlcontent *)U)->url_data) != 0);
       else   
              return (0);
}

Here is the caller graph for this function:

int IBstr ( const char *  key,
size_t  keylen 
)

Definition at line 225 of file paramhandling.c.

{
       void *U;

       if ((WC->Hdr->urlstrings != NULL) && 
           GetHash(WC->Hdr->urlstrings, key, keylen, &U))
              return StrTol(((urlcontent *)U)->url_data);
       else   
              return (0);
}
int IBSTR ( const char *  key)

Definition at line 236 of file paramhandling.c.

{
       void *U;

       if ((WC->Hdr->urlstrings != NULL) && 
           GetHash(WC->Hdr->urlstrings, key, strlen(key), &U))
              return StrToi(((urlcontent *)U)->url_data);
       else   
              return (0);
}

Here is the caller graph for this function:

long LBstr ( const char *  key,
size_t  keylen 
)

Definition at line 203 of file paramhandling.c.

{
       void *U;

       if ((WC->Hdr->urlstrings != NULL) && 
           GetHash(WC->Hdr->urlstrings, key, keylen, &U))
              return StrTol(((urlcontent *)U)->url_data);
       else   
              return (0);
}

Here is the caller graph for this function:

long LBSTR ( const char *  key)

Definition at line 214 of file paramhandling.c.

{
       void *U;

       if ((WC->Hdr->urlstrings != NULL) && 
           GetHash(WC->Hdr->urlstrings, key, strlen(key), &U))
              return StrTol(((urlcontent *)U)->url_data);
       else   
              return (0);
}

Here is the caller graph for this function:

void ParseURLParams ( StrBuf *  url)

Definition at line 28 of file paramhandling.c.

{
       const char *aptr, *bptr, *eptr, *up;
       int len, keylen;
       urlcontent *u;
       wcsession *WCC = WC;

       if (WCC->Hdr->urlstrings == NULL)
              WCC->Hdr->urlstrings = NewHash(1, NULL);
       eptr = ChrPtr(url) + StrLength(url);
       up = ChrPtr(url);
       while ((up < eptr) && (!IsEmptyStr(up))) {
              aptr = up;
              while ((aptr < eptr) && (*aptr != '\0') && (*aptr != '='))
                     aptr++;
              if (*aptr != '=') {
                     return;
              }
              aptr++;
              bptr = aptr;
              while ((bptr < eptr) && (*bptr != '\0')
                    && (*bptr != '&') && (*bptr != '?') && (*bptr != ' ')) {
                     bptr++;
              }
              keylen = aptr - up - 1; /* -1 -> '=' */
              if(keylen > sizeof(u->url_key)) {
                     syslog(1, "URLkey to long! [%s]", up);
                     continue;
              }

              u = (urlcontent *) malloc(sizeof(urlcontent));
              memcpy(u->url_key, up, keylen);
              u->url_key[keylen] = '\0';
              if (keylen < 0) {
                     syslog(1, "URLkey to long! [%s]", up);
                     free(u);
                     continue;
              }
              
              if (strncmp(u->url_key, "__", 2) != 0)
              {
                     Put(WCC->Hdr->urlstrings, u->url_key, keylen, u, free_url);
                     len = bptr - aptr;
                     u->url_data = NewStrBufPlain(aptr, len);
                     StrBufUnescape(u->url_data, 1);
#ifdef DEBUG_URLSTRINGS
                     syslog(9, "%s = [%d]  %s\n", 
                            u->url_key, 
                            StrLength(u->url_data), 
                            ChrPtr(u->url_data)); 
#endif
              }
              else {
                     len = bptr - aptr;
                     u->url_data = NewStrBufPlain(aptr, len);
                     StrBufUnescape(u->url_data, 1);
                     syslog(1, "REJECTED because of __ is internal only: %s = [%d]  %s\n", 
                            u->url_key, 
                            StrLength(u->url_data), 
                            ChrPtr(u->url_data)); 
                     
                     free_url(u);
              }
              up = bptr;
              ++up;
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void PutBstr ( const char *  key,
long  keylen,
StrBuf *  Value 
)

Definition at line 369 of file paramhandling.c.

{
       urlcontent *u;

       if(keylen > sizeof(u->url_key)) {
              syslog(1, "URLkey to long! [%s]", key);
              FreeStrBuf(&Value);
              return;
       }
       u = (urlcontent*)malloc(sizeof(urlcontent));
       memcpy(u->url_key, key, keylen + 1);
       u->url_data = Value;
       Put(WC->Hdr->urlstrings, u->url_key, keylen, u, free_url);
}

Here is the call graph for this function:

Here is the caller graph for this function:

const StrBuf* SBSTR ( const char *  key)

Definition at line 181 of file paramhandling.c.

{
       void *U;

       if ((WC->Hdr->urlstrings != NULL) &&
           GetHash(WC->Hdr->urlstrings, key, strlen (key), &U))
              return ((urlcontent *)U)->url_data;
       else   
              return NULL;
}

Here is the caller graph for this function:

const StrBuf* SBstr ( const char *  key,
size_t  keylen 
)

Definition at line 192 of file paramhandling.c.

{
       void *U;

       if ((WC->Hdr->urlstrings != NULL) && 
           GetHash(WC->Hdr->urlstrings, key, keylen, &U))
              return ((urlcontent *)U)->url_data;
       else   
              return NULL;
}

Here is the caller graph for this function:

void upload_handler ( char *  name,
char *  filename,
char *  partnum,
char *  disp,
void *  content,
char *  cbtype,
char *  cbcharset,
size_t  length,
char *  encoding,
char *  cbid,
void *  userdata 
)

Definition at line 312 of file paramhandling.c.

{
       wcsession *WCC = WC;
       urlcontent *u;
       long keylen;

#ifdef DEBUG_URLSTRINGS
       syslog(9, "upload_handler() name=%s, type=%s, len=%d", name, cbtype, length);
#endif
       if (WCC->Hdr->urlstrings == NULL)
              WCC->Hdr->urlstrings = NewHash(1, NULL);

       /* Form fields */
       if ( (length > 0) && (IsEmptyStr(cbtype)) ) {
              u = (urlcontent *) malloc(sizeof(urlcontent));
              
              keylen = safestrncpy(u->url_key, name, sizeof(u->url_key));
              u->url_data = NewStrBufPlain(content, length);
              
              if (strncmp(u->url_key, "__", 2) != 0)
              {
                     Put(WCC->Hdr->urlstrings, u->url_key, keylen, u, free_url);
              }
              else {
                     syslog(1, "REJECTED because of __ is internal only: %s = [%d]  %s\n", 
                            u->url_key, 
                            StrLength(u->url_data), 
                            ChrPtr(u->url_data)); 
                     
                     free_url(u);
              }
#ifdef DEBUG_URLSTRINGS
              syslog(9, "Key: <%s> len: [%d] Data: <%s>", 
                     u->url_key, 
                     StrLength(u->url_data), 
                     ChrPtr(u->url_data));
#endif
       }

       /* Uploaded files */
       if ( (length > 0) && (!IsEmptyStr(cbtype)) ) {
              WCC->upload = NewStrBufPlain(content, length);
              WCC->upload_length = length;
              WCC->upload_filename = NewStrBufPlain(filename, -1);
              safestrncpy(WCC->upload_content_type, cbtype, sizeof(WC->upload_content_type));
#ifdef DEBUG_URLSTRINGS
              syslog(9, "File: <%s> len: [%ld]", filename, length);
#endif
              
       }

}

Here is the call graph for this function:

Here is the caller graph for this function:

const char* XBstr ( const char *  key,
size_t  keylen,
size_t *  len 
)

Definition at line 128 of file paramhandling.c.

{
       void *U;

       if ((WC->Hdr->urlstrings != NULL) && 
           GetHash(WC->Hdr->urlstrings, key, keylen, &U)) {
              *len = StrLength(((urlcontent *)U)->url_data);
              return ChrPtr(((urlcontent *)U)->url_data);
       }
       else {
              *len = 0;
              return ("");
       }
}
const char* XBSTR ( const char *  key,
size_t *  len 
)

Definition at line 143 of file paramhandling.c.

{
       void *U;

       if ((WC->Hdr->urlstrings != NULL) &&
           GetHash(WC->Hdr->urlstrings, key, strlen (key), &U)){
              *len = StrLength(((urlcontent *)U)->url_data);
              return ChrPtr(((urlcontent *)U)->url_data);
       }
       else {
              *len = 0;
              return ("");
       }
}
int YesBstr ( const char *  key,
size_t  keylen 
)

Definition at line 270 of file paramhandling.c.

{
       void *U;

       if ((WC->Hdr->urlstrings != NULL) && 
           GetHash(WC->Hdr->urlstrings, key, keylen, &U))
              return strcmp( ChrPtr(((urlcontent *)U)->url_data), "yes") == 0;
       else   
              return (0);
}

Here is the caller graph for this function:

int YESBSTR ( const char *  key)

Definition at line 281 of file paramhandling.c.

{
       void *U;

       if ((WC->Hdr->urlstrings != NULL) && 
           GetHash(WC->Hdr->urlstrings, key, strlen(key), &U))
              return strcmp( ChrPtr(((urlcontent *)U)->url_data), "yes") == 0;
       else   
              return (0);
}

Here is the caller graph for this function: