Back to index

webcit  8.12-dfsg
Functions | Variables
webserver.h File Reference

Go to the source code of this file.

Functions

int ClientGetLine (ParsedHttpHdrs *Hdr, StrBuf *Target)
int client_read_to (ParsedHttpHdrs *Hdr, StrBuf *Target, int bytes, int timeout)
void wc_backtrace (void)
void ShutDownWebcit (void)
void shutdown_ssl (void)

Variables

char * static_dirs [PATH_MAX]
 Web representation.
int ndirs
char socket_dir [PATH_MAX]
char * default_landing_page

Function Documentation

int client_read_to ( ParsedHttpHdrs Hdr,
StrBuf *  Target,
int  bytes,
int  timeout 
)

Definition at line 661 of file tcp_sockets.c.

{
       const char *Error;
       int retval = 0;

#ifdef HAVE_OPENSSL
       if (is_https) {
              long bufremain = 0;
              long baselen;

              baselen = StrLength(Target);

              if (Hdr->Pos == NULL)
                     Hdr->Pos = ChrPtr(Hdr->ReadBuf);

              if (StrLength(Hdr->ReadBuf) > 0)
              {
                     bufremain = StrLength(Hdr->ReadBuf) - (Hdr->Pos - ChrPtr(Hdr->ReadBuf));
                     
                     if (bytes < bufremain)
                            bufremain = bytes;
                     StrBufAppendBufPlain(Target, Hdr->Pos, bufremain, 0);
                     StrBufCutLeft(Hdr->ReadBuf, bufremain);
              }

              if (bytes > bufremain) 
              {
                     while ((StrLength(Hdr->ReadBuf) + StrLength(Target) < bytes + baselen) &&
                            (retval >= 0))
                            retval = client_read_sslbuffer(Hdr->ReadBuf, timeout);
                     if (retval >= 0) {
                            StrBufAppendBuf(Target, Hdr->ReadBuf, 0); /* todo: Buf > bytes? */
                            return 1;
                     }
                     else {
                            syslog(2, "client_read_ssl() failed\n");
                            return -1;
                     }
              }
              else 
                     return 1;
       }
#endif

       retval = StrBufReadBLOBBuffered(Target, 
                                   Hdr->ReadBuf, 
                                   &Hdr->Pos, 
                                   &Hdr->http_sock, 
                                   1, 
                                   bytes,
                                   O_TERM,
                                   &Error);
       if (retval < 0) {
              syslog(2, "client_read() failed: %s\n",
                     Error);
              wc_backtrace();
              return retval;
       }

       return 1;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int ClientGetLine ( ParsedHttpHdrs Hdr,
StrBuf *  Target 
)

Definition at line 439 of file tcp_sockets.c.

{
       const char *Error;
#ifdef HAVE_OPENSSL
       const char *pch, *pchs;
       int rlen, len, retval = 0;

       if (is_https) {
              int ntries = 0;
              if (StrLength(Hdr->ReadBuf) > 0)
              {
                     pchs = ChrPtr(Hdr->ReadBuf);
                     pch = strchr(pchs, '\n');
                     if (pch != NULL) {
                            rlen = 0;
                            len = pch - pchs;
                            if (len > 0 && (*(pch - 1) == '\r') )
                                   rlen ++;
                            StrBufSub(Target, Hdr->ReadBuf, 0, len - rlen);
                            StrBufCutLeft(Hdr->ReadBuf, len + 1);
                            return len - rlen;
                     }
              }

              while (retval == 0) { 
                            pch = NULL;
                            pchs = ChrPtr(Hdr->ReadBuf);
                            if (*pchs != '\0')
                                   pch = strchr(pchs, '\n');
                            if (pch == NULL) {
                                   retval = client_read_sslbuffer(Hdr->ReadBuf, SLEEPING);
                                   pchs = ChrPtr(Hdr->ReadBuf);
                                   pch = strchr(pchs, '\n');
                                   if (pch == NULL)
                                          retval = 0;
                            }
                            if (retval == 0) {
                                   sleeeeeeeeeep(1);
                                   ntries ++;
                            }
                            if (ntries > 10)
                                   return 0;
              }
              if ((retval > 0) && (pch != NULL)) {
                     rlen = 0;
                     len = pch - pchs;
                     if (len > 0 && (*(pch - 1) == '\r') )
                            rlen ++;
                     StrBufSub(Target, Hdr->ReadBuf, 0, len - rlen);
                     StrBufCutLeft(Hdr->ReadBuf, len + 1);
                     return len - rlen;

              }
              else 
                     return -1;
       }
       else 
#endif
              return StrBufTCP_read_buffered_line_fast(Target, 
                                                  Hdr->ReadBuf,
                                                  &Hdr->Pos,
                                                  &Hdr->http_sock,
                                                  5,
                                                  1,
                                                  &Error);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void shutdown_ssl ( void  )

Here is the caller graph for this function:

void ShutDownWebcit ( void  )

Definition at line 135 of file sysdep.c.

{
       free_zone_directory ();
       icaltimezone_release_zone_tab ();
       icalmemory_free_ring ();
       ShutDownLibCitadel ();
       shutdown_modules ();
#ifdef HAVE_OPENSSL
       if (is_https) {
              shutdown_ssl();
       }
#endif
}

Here is the call graph for this function:

Here is the caller graph for this function:

void wc_backtrace ( void  )

Definition at line 543 of file sysdep.c.

{
#ifdef HAVE_BACKTRACE
       void *stack_frames[50];
       size_t size, i;
       char **strings;


       size = backtrace(stack_frames, sizeof(stack_frames) / sizeof(void*));
       strings = backtrace_symbols(stack_frames, size);
       for (i = 0; i < size; i++) {
              if (strings != NULL)
                     syslog(1, "%s\n", strings[i]);
              else
                     syslog(1, "%p\n", stack_frames[i]);
       }
       free(strings);
#endif
}

Here is the caller graph for this function:


Variable Documentation

Definition at line 26 of file webserver.c.

int ndirs
char socket_dir[PATH_MAX]

Definition at line 41 of file test_main.c.

char* static_dirs[PATH_MAX]

Web representation.

Definition at line 90 of file sysdep.c.