rasdaman complete source
protos.h
Go to the documentation of this file.
1 /*
2 * This file is part of rasdaman community.
3 *
4 * Rasdaman community is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * Rasdaman community is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with rasdaman community. If not, see <http://www.gnu.org/licenses/>.
16 *
17 * Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann /
18 rasdaman GmbH.
19 *
20 * For more information please see <http://www.rasdaman.org>
21 * or contact Peter Baumann via <baumann@rasdaman.com>.
22 */
23 /*------------------------------------------------------------------------*/
24 /* protos.h - Prototypes of all functions */
25 /*------------------------------------------------------------------------*/
26 /*
27  * RCS:
28  * $RCSfile: protos.h,v $ $Revision: 1.10 $ $State: Exp $
29  * $Locker: $
30  */
31 
32 #ifndef _PROTOS_H
33 #define _PROTOS_H
34 
35 #include "server.h"
36 
37 /*------------------------------------------------------------------------*/
38 /* Protoypes from main.c */
39 /*------------------------------------------------------------------------*/
40 
41 int Exit( int );
42 
43 /* init.c */
44 rc_t Initialize( int, char **, struct ServerBase * );
45 rc_t InitDaemon( int );
46 rc_t InitSocket( int *, struct sockaddr_in *, int );
47 rc_t InitClientSocket( int *, struct sockaddr_in *, char *, int );
48 void SavePId( char * );
49 
50 /* childs.c */
51 rc_t InitChild( struct ClientBase * );
52 pid_t NewChild( struct ChildBase *List, struct FDsets *PDSets, struct ClientBase *Client );
53 void CleanupChild( struct ChildBase *List, struct FDsets *PDSets, pid_t PId );
54 void AddChild( struct ChildBase *List, struct ChildBase *Child );
55 void RemChild( struct ChildBase *List, struct ChildBase *Child );
56 struct ChildBase *GetChild( struct ChildBase *List, pid_t PId );
57 
58 /*------------------------------------------------------------------------*/
59 /* Protoypes from config.c */
60 /*------------------------------------------------------------------------*/
61 
62 rc_t ReadArgs( struct ServerBase *, int, char ** );
63 rc_t ReadConfig( struct ServerBase * );
64 rc_t CheckAndSet( struct ServerBase *, char *, int );
65 rc_t SetServDir( struct ServerBase *, char * );
66 rc_t SetFilename( struct ServerBase *, int, char * );
67 rc_t SetString( struct ServerBase *, int, char * );
68 rc_t ConfigureServer( struct ServerBase * );
69 int GetConfigKey( char * );
70 
71 /*------------------------------------------------------------------------*/
72 /* Protoypes from signals.c */
73 /*------------------------------------------------------------------------*/
74 
75 typedef void(*sighandler)(int);
76 
78 void SigHandler( int );
79 rc_t InitSigHandler( void );
80 
81 /*------------------------------------------------------------------------*/
82 /* Protoypes from logging.c */
83 /*------------------------------------------------------------------------*/
84 
85 rc_t OpenLog( struct Logging *, char *, char *, char * );
86 void CloseLog( struct Logging *Log );
87 void LogMsg( int, int, const char *, ... );
88 void ErrorMsg( int, int, const char *, ... );
89 rc_t LogDate( char *, int );
90 struct tm *Get_GMToffset( int * );
91 
92 /*------------------------------------------------------------------------*/
93 /* Protoypes for communication handling. */
94 /*------------------------------------------------------------------------*/
95 
96 /* http.c */
97 void HandleRequest( struct ClientBase *Client );
98 
99 /* http-doit.c */
100 rc_t Accept( int, struct ClientBase * );
101 void GetRequest( struct ClientBase *Client );
102 void InterpreteRequest( struct ClientBase *Client, struct ToDoArgs *ToDo );
103 int SendRequest( int SockFD, struct HTTPMsg *Request, struct FDsets *RW_Sets );
104 int ReadResponseHead( int SockFD, struct RespInfo *Response, struct FDsets *RW_Sets );
105 int ReadResponseBody( int SockFD, struct RespInfo *Response, struct FDsets *RW_Sets );
106 void SendResponse( struct ClientBase *Client );
107 void CreateRasResponse( struct HTTPMode *Mode, struct ClientBase *Client );
108 void DoMessageBody( struct ClientBase *Client );
109 void InterpretePOSTRequest ( struct ClientBase *Client );
110 void WriteAccessLog( struct ClientBase *Client );
111 
112 
113 /* http-readmsg.c */
114 int ReadHeader( int SockFD, char **Buffer, size_t *BuffSize );
115 char *ReadBody( int SockFD, size_t BuffSize );
116 rc_t ParseReqHeader( struct ReqInfo *Request );
117 rc_t ParseRespHeader( struct RespInfo *Response );
118 char *ParseReqLine( char *Buffer, struct ReqInfo *Request );
119 char *ParseRespLine( char *Buffer, struct RespInfo *Response );
120 char *ParseMsgLine( char *Buffer, int *Key, char **Param );
121 void SplitURL( char *Buffer, struct URLComps *URL );
122 size_t GetContentLength( struct MsgHeader *Ptr );
123 char *GetFieldContent( struct MsgHeader *Ptr, int Field, struct MsgHeader **Next );
124 int GetRealm( char *String );
125 
126 /* http-writemsg.g */
127 rc_t AddField( struct MsgHeader *Ptr, int Field, char *Content );
128 rc_t CreateStatusLine( char *Buffer, size_t *BuffSize, int Code, int Protocol );
129 struct HTTPMsg *CreateHTTPMsg( char *, char *, size_t ); // ???
130 rc_t SendHTTPMsg( int SockFD, struct HTTPMsg *Msg );
131 rc_t FreeHTTPMsg( struct HTTPMsg *Ptr );
132 
133 /* http-error.c */
134 int GetHTTPErrorTableEntry( int Code );
135 rc_t CreateHTTPError( int Code, struct HTTPMode *Mode, struct HTTPMsg *Msg );
136 
137 /* http-methods.c */
138 int HTTP_GetMKey( char * );
139 char *HTTP_GetMethodName( int );
140 
141 /* http-fields.c */
142 int HTTP_GetHKey( char * );
143 char *HTTP_GetFieldName( int );
144 
145 /* http-date.c */
146 rc_t HTTP_Date( char *, size_t );
147 
148 /* http-support.c */
149 rc_t InitClientBase( struct ClientBase * );
150 rc_t InitReqInfo( struct ReqInfo * );
151 rc_t InitRespInfo( struct RespInfo * );
152 void InitHTTPMsg( struct HTTPMsg *Msg );
153 struct MsgHeader *NewMsgHeader( int, char * );
154 struct MsgHeader *AppendMsgHeader( struct MsgHeader *, int, char * );
155 void DeleteMsgHeader( struct MsgHeader * );
156 void PrintReqInfo( struct ReqInfo * );
157 void PrintRespInfo( struct RespInfo * );
158 rc_t CheckSockError( int, int, int );
159 char *CharToBits( char c );
160 
161 
162 
163 /*------------------------------------------------------------------------*/
164 /* Protoypes from support.c */
165 /*------------------------------------------------------------------------*/
166 
167 int Get_OpenMax( void );
168 char *PathAlloc( size_t * );
169 int ReadN( register int, register char *, register int );
170 int WriteN( register int, register char *, register int );
171 int ReadLine( register int, register char *, register int );
172 rc_t ParseString( char *, char *, ... );
173 int SNPrintf( char *, size_t *, const char *, ... );
174 int VSNPrintf( char *, size_t, const char *, va_list );
175 char *StrError( int );
176 char *StrToLower( char * );
177 
178 #endif /* _PROTOS_H not defined */
int HTTP_GetHKey(char *)
int ReadResponseHead(int SockFD, struct RespInfo *Response, struct FDsets *RW_Sets)
rc_t InitSocket(int *, struct sockaddr_in *, int)
rc_t SendHTTPMsg(int SockFD, struct HTTPMsg *Msg)
void WriteAccessLog(struct ClientBase *Client)
void InitHTTPMsg(struct HTTPMsg *Msg)
void SavePId(char *)
void DoMessageBody(struct ClientBase *Client)
int SendRequest(int SockFD, struct HTTPMsg *Request, struct FDsets *RW_Sets)
rc_t ReadArgs(struct ServerBase *, int, char **)
rc_t SetFilename(struct ServerBase *, int, char *)
rc_t Initialize(int, char **, struct ServerBase *)
void InterpreteRequest(struct ClientBase *Client, struct ToDoArgs *ToDo)
rc_t CheckSockError(int, int, int)
int Get_OpenMax(void)
int VSNPrintf(char *, size_t, const char *, va_list)
rc_t HTTP_Date(char *, size_t)
void CloseLog(struct Logging *Log)
rc_t FreeHTTPMsg(struct HTTPMsg *Ptr)
int WriteN(register int, register char *, register int)
int ReadLine(register int, register char *, register int)
sighandler Signal(int, sighandler)
void HandleRequest(struct ClientBase *Client)
char * HTTP_GetFieldName(int)
struct tm * Get_GMToffset(int *)
int ReadN(register int, register char *, register int)
size_t GetContentLength(struct MsgHeader *Ptr)
void PrintRespInfo(struct RespInfo *)
void SigHandler(int)
void SplitURL(char *Buffer, struct URLComps *URL)
rc_t AddField(struct MsgHeader *Ptr, int Field, char *Content)
rc_t OpenLog(struct Logging *, char *, char *, char *)
void AddChild(struct ChildBase *List, struct ChildBase *Child)
void CleanupChild(struct ChildBase *List, struct FDsets *PDSets, pid_t PId)
int ReadHeader(int SockFD, char **Buffer, size_t *BuffSize)
rc_t CreateHTTPError(int Code, struct HTTPMode *Mode, struct HTTPMsg *Msg)
char * ParseReqLine(char *Buffer, struct ReqInfo *Request)
Definition: server.h:163
char * ParseMsgLine(char *Buffer, int *Key, char **Param)
char * PathAlloc(size_t *)
rc_t CreateStatusLine(char *Buffer, size_t *BuffSize, int Code, int Protocol)
int SNPrintf(char *, size_t *, const char *,...)
char * HTTP_GetMethodName(int)
Definition: server.h:132
Definition: http.h:53
Definition: server.h:139
int Exit(int)
rc_t ConfigureServer(struct ServerBase *)
void(* sighandler)(int)
Definition: protos.h:75
struct HTTPMsg * CreateHTTPMsg(char *, char *, size_t)
rc_t ParseRespHeader(struct RespInfo *Response)
rc_t LogDate(char *, int)
int GetConfigKey(char *)
void RemChild(struct ChildBase *List, struct ChildBase *Child)
rc_t SetString(struct ServerBase *, int, char *)
void InterpretePOSTRequest(struct ClientBase *Client)
pid_t PId
Definition: server.h:114
Definition: server.h:81
void DeleteMsgHeader(struct MsgHeader *)
struct ChildBase * GetChild(struct ChildBase *List, pid_t PId)
int rc_t
Definition: types.h:36
Definition: http.h:61
int GetRealm(char *String)
rc_t InitClientSocket(int *, struct sockaddr_in *, char *, int)
rc_t Accept(int, struct ClientBase *)
rc_t InitDaemon(int)
rc_t ParseString(char *, char *,...)
struct MsgHeader * NewMsgHeader(int, char *)
char * ParseRespLine(char *Buffer, struct RespInfo *Response)
rc_t InitRespInfo(struct RespInfo *)
rc_t InitClientBase(struct ClientBase *)
void GetRequest(struct ClientBase *Client)
Definition: server.h:102
rc_t InitChild(struct ClientBase *)
struct MsgHeader * AppendMsgHeader(struct MsgHeader *, int, char *)
char * GetFieldContent(struct MsgHeader *Ptr, int Field, struct MsgHeader **Next)
char * StrToLower(char *)
void PrintReqInfo(struct ReqInfo *)
Definition: server.h:110
int ReadResponseBody(int SockFD, struct RespInfo *Response, struct FDsets *RW_Sets)
char * ReadBody(int SockFD, size_t BuffSize)
void CreateRasResponse(struct HTTPMode *Mode, struct ClientBase *Client)
Definition: http.h:93
Definition: http.h:104
rc_t InitSigHandler(void)
int GetHTTPErrorTableEntry(int Code)
char * StrError(int)
rc_t CheckAndSet(struct ServerBase *, char *, int)
rc_t ParseReqHeader(struct ReqInfo *Request)
void SendResponse(struct ClientBase *Client)
int HTTP_GetMKey(char *)
rc_t InitReqInfo(struct ReqInfo *)
rc_t SetServDir(struct ServerBase *, char *)
char * CharToBits(char c)
void ErrorMsg(int, int, const char *,...)
rc_t ReadConfig(struct ServerBase *)
void LogMsg(int, int, const char *,...)
pid_t NewChild(struct ChildBase *List, struct FDsets *PDSets, struct ClientBase *Client)
Definition: server.h:87
Definition: http.h:120