Advertisement
captmicro

min webserver header

Oct 28th, 2012
410
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.45 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2.  
  3. #pragma comment(lib, "ws2_32.lib")
  4. #include <winsock2.h>
  5. #include <WS2tcpip.h>
  6.  
  7. #include <windows.h>
  8. #include <stdio.h>
  9.  
  10. #pragma comment(lib, "lua51.lib")
  11. extern "C"
  12. {
  13. #include "lua.h"
  14. #include "lauxlib.h"
  15. #include "lualib.h"
  16. }
  17.  
  18. #define LUA_FUNCTION(name) static int name(lua_State *L)
  19.  
  20. #define MAX_CONNECTIONS 32
  21. #define BUFFER_SIZE 1024
  22.  
  23. #define halloc(size) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size)
  24. #define hfree(ptr) HeapFree(GetProcessHeap(), 0, ptr);
  25.  
  26. #define B 1
  27. #define KB B * 1024
  28. #define MB KB * 1024
  29. #define GB MB * 1024
  30.  
  31. #define LUA_PRINTBUFFER_SIZE MB
  32. #define HTTP_DEFAULT_FILE "/index.html"
  33. #define HTTP_VER "HTTP/1.1 %s\r\n"
  34. #define HTTP_DATE "%a, %d %b %Y %I:%M:%S %Z\r\n"
  35. #define HTTP_SERVER "Server: microserver\r\n"
  36. #define HTTP_CACHECONTROL "Cache-Control: no-cache\r\n"
  37. #define HTTP_KEEPALIVE "Keep-Alive: timeout=15, max=800\r\n"
  38. #define HTTP_CONNECTION "Connection: Keep-Alive\r\n"
  39. #define HTTP_CONTENTTYPE "Content-Type: %s\r\n\r\n"
  40. #define HTTP_404_CONTENT "<html>\n<head>\n\t<title>Error! 404 Not Found</title>\n<head>\n<body>\n\t<h1 style=\"text-align:center\">Error! 404 Not Found</h1>\n</body>\n</html>"
  41.  
  42. int main(int argc, char *aargv[]);
  43.  
  44. void parsesendGET(SOCKET *cs, char *request);
  45.  
  46. char *ParseLuaTags(char *html);
  47. LUA_FUNCTION(l_print);
  48.  
  49. void ProfileSection2str(char *sec);
  50. int lstrcmpn(char *str1, char *str2, int size);
  51. int lstrcnt(char *str1, char chr);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement