GNU libmicrohttpd  0.9.29
internal.h
Go to the documentation of this file.
1 /*
2  This file is part of libmicrospdy
3  Copyright Copyright (C) 2012 Andrey Uzunov
4 
5  This program is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 
25 #ifndef INTERNAL_H_H
26 #define INTERNAL_H_H
27 
28 #include "platform.h"
29 #include "platform_interface.h"
30 #include "microspdy.h"
31 
36 #define SPDYF_BUFFER_SIZE 8192
37 
42 #define SPDYF_INITIAL_WINDOW_SIZE 65536
43 
50 #define SPDYF_NUM_SENT_FRAMES_AT_ONCE 10
51 
52 
57 
58 
62 extern void *spdyf_panic_cls;
63 
64 
70 #define SPDYF_PANIC(msg) \
71  spdyf_panic (spdyf_panic_cls, __FILE__, __LINE__, msg)
72 
73 
80 #define SPDYF_ASSERT(expr, msg) \
81  if(!(expr)){\
82  SPDYF_PANIC(msg);\
83  abort();\
84  }
85 
86 
93 #if HAVE_BIG_ENDIAN
94 #define HTON24(n) n
95 #else
96 #define HTON24(n) (((((uint32_t)(n) & 0xFF)) << 16)\
97  | (((uint32_t)(n) & 0xFF00))\
98  | ((((uint32_t)(n) & 0xFF0000)) >> 16))
99 #endif
100 
101 
108 #if HAVE_BIG_ENDIAN
109 #define NTOH24(n) n
110 #else
111 #define NTOH24(n) (((((uint32_t)(n) & 0xFF)) << 16)\
112  | (((uint32_t)(n) & 0xFF00))\
113  | ((((uint32_t)(n) & 0xFF0000)) >> 16))
114 #endif
115 
116 
123 #if HAVE_BIG_ENDIAN
124 #define NTOH31(n) n
125 #else
126 #define NTOH31(n) (((((uint32_t)(n) & 0x7F)) << 24) | \
127  ((((uint32_t)(n) & 0xFF00)) << 8) | \
128  ((((uint32_t)(n) & 0xFF0000)) >> 8) | \
129  ((((uint32_t)(n) & 0xFF000000)) >> 24))
130 #endif
131 
132 
139 #if HAVE_BIG_ENDIAN
140 #define HTON31(n) n
141 #else
142 #define HTON31(n) (((((uint32_t)(n) & 0xFF)) << 24) | \
143  ((((uint32_t)(n) & 0xFF00)) << 8) | \
144  ((((uint32_t)(n) & 0xFF0000)) >> 8) | \
145  ((((uint32_t)(n) & 0x7F000000)) >> 24))
146 #endif
147 
148 
155 #define SPDYF_DEBUG(fmt, ...) do { \
156  fprintf (stdout, "%s\n%u: ",__FILE__, __LINE__);\
157  fprintf(stdout,fmt,##__VA_ARGS__);\
158  fprintf(stdout,"\n");\
159  fflush(stdout); } while (0)
160 
161 
168 #define SPDYF_PRINT_STREAM(strm, size) do { \
169  int ___i;\
170  for(___i=0;___i<size;___i++){\
171  fprintf(stdout,"%x ",*((uint8_t *) strm + ___i));\
172  fflush(stdout);\
173  }\
174  fprintf(stdout,"\n");\
175  } while (0)
176 
177 
183 #define SPDYF_SIGINT(msg) do { \
184  fprintf(stdout,"%i : %s\n", __LINE__,__FILE__);\
185  fprintf(stdout,msg);\
186  fprintf(stdout,"\n");\
187  fflush(stdout);\
188  raise(SIGINT); } while (0)
189 
190 
196 unsigned long long
198 
199 #endif
internal platform abstraction functions
public interface to libmicrospdy
SPDY_PanicCallback spdyf_panic
Definition: daemon.c:58
platform-specific includes for libmicrohttpd
unsigned long long SPDYF_monotonic_time(void)
Definition: internal.c:30
void(* SPDY_PanicCallback)(void *cls, const char *file, unsigned int line, const char *reason)
Definition: microspdy.h:592
void * spdyf_panic_cls
Definition: daemon.c:64