internal.c
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00027 #include "internal.h"
00028
00029 #if HAVE_MESSAGES
00030
00033 char *
00034 MHD_state_to_string (enum MHD_CONNECTION_STATE state)
00035 {
00036 switch (state)
00037 {
00038 case MHD_CONNECTION_INIT:
00039 return "connection init";
00040 case MHD_CONNECTION_URL_RECEIVED:
00041 return "connection url received";
00042 case MHD_CONNECTION_HEADER_PART_RECEIVED:
00043 return "header partially received";
00044 case MHD_CONNECTION_HEADERS_RECEIVED:
00045 return "headers received";
00046 case MHD_CONNECTION_HEADERS_PROCESSED:
00047 return "headers processed";
00048 case MHD_CONNECTION_CONTINUE_SENDING:
00049 return "continue sending";
00050 case MHD_CONNECTION_CONTINUE_SENT:
00051 return "continue sent";
00052 case MHD_CONNECTION_BODY_RECEIVED:
00053 return "body received";
00054 case MHD_CONNECTION_FOOTER_PART_RECEIVED:
00055 return "footer partially received";
00056 case MHD_CONNECTION_FOOTERS_RECEIVED:
00057 return "footers received";
00058 case MHD_CONNECTION_HEADERS_SENDING:
00059 return "headers sending";
00060 case MHD_CONNECTION_HEADERS_SENT:
00061 return "headers sent";
00062 case MHD_CONNECTION_NORMAL_BODY_READY:
00063 return "normal body ready";
00064 case MHD_CONNECTION_NORMAL_BODY_UNREADY:
00065 return "normal body unready";
00066 case MHD_CONNECTION_CHUNKED_BODY_READY:
00067 return "chunked body ready";
00068 case MHD_CONNECTION_CHUNKED_BODY_UNREADY:
00069 return "chunked body unready";
00070 case MHD_CONNECTION_BODY_SENT:
00071 return "body sent";
00072 case MHD_CONNECTION_FOOTERS_SENDING:
00073 return "footers sending";
00074 case MHD_CONNECTION_FOOTERS_SENT:
00075 return "footers sent";
00076 case MHD_CONNECTION_CLOSED:
00077 return "closed";
00078 case MHD_TLS_CONNECTION_INIT:
00079 return "secure connection init";
00080 case MHD_TLS_HELLO_REQUEST:
00081 return "secure hello request";
00082 case MHD_TLS_HANDSHAKE_FAILED:
00083 return "secure handshake failed";
00084 case MHD_TLS_HANDSHAKE_COMPLETE:
00085 return "secure handshake _complete";
00086 default:
00087 return "unrecognized connection state";
00088 }
00089 }
00090 #endif
00091
00092 #if HAVE_MESSAGES
00093
00097 void
00098 MHD_DLOG (const struct MHD_Daemon *daemon, const char *format, ...)
00099 {
00100 va_list va;
00101
00102 if ((daemon->options & MHD_USE_DEBUG) == 0)
00103 return;
00104 va_start (va, format);
00105 daemon->custom_error_log (daemon->custom_error_log_cls, format, va);
00106 va_end (va);
00107 }
00108 #endif
00109
00110 void
00111 MHD_tls_log_func (int level, const char *str)
00112 {
00113 #ifdef HAVE_MESSAGES
00114 FPRINTF (stderr, "|<%d>| %s", level, str);
00115 #endif
00116 }
00117
00121 size_t
00122 MHD_http_unescape (char *val)
00123 {
00124 char *rpos = val;
00125 char *wpos = val;
00126 unsigned int num;
00127
00128 while ('\0' != *rpos)
00129 {
00130 switch (*rpos)
00131 {
00132 case '+':
00133 *wpos = ' ';
00134 wpos++;
00135 rpos++;
00136 break;
00137 case '%':
00138 if ( (1 == SSCANF (&rpos[1],
00139 "%2x", &num)) ||
00140 (1 == SSCANF (&rpos[1],
00141 "%2X", &num)) )
00142 {
00143 *wpos = (unsigned char) num;
00144 wpos++;
00145 rpos += 3;
00146 break;
00147 }
00148
00149 default:
00150 *wpos = *rpos;
00151 wpos++;
00152 rpos++;
00153 }
00154 }
00155 *wpos = '\0';
00156 return wpos - val;
00157 }
00158
00159