Mercurial > repos > ktnyt > gembassy
comparison GEMBASSY-1.0.3/gsoap/extras/ckdb.c @ 0:8300eb051bea draft
Initial upload
author | ktnyt |
---|---|
date | Fri, 26 Jun 2015 05:19:29 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:8300eb051bea |
---|---|
1 /* | |
2 ckdb.c | |
3 | |
4 HTTP cookie database manager. | |
5 | |
6 The contents of this file are subject to the gSOAP Public License | |
7 Version 1.0 (the "License"); you may not use this file except in | |
8 compliance with the License. You may obtain a copy of the License at | |
9 http://www.cs.fsu.edu/~engelen/soaplicense.html Software distributed | |
10 under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY | |
11 OF ANY KIND, either express or implied. See the License for the | |
12 specific language governing rights and limitations under the License. | |
13 | |
14 The Initial Developer of the Original Code is Robert A. van Engelen. | |
15 Copyright (C) 2000-2002 Robert A. van Engelen. All Rights Reserved. | |
16 | |
17 1. Compile ckdb.h: | |
18 soapcpp2 -cpckdb ckdb.h | |
19 2. Compile ckdb.c: | |
20 gcc -DWITH_COOKIES -DWITH_NOGLOBAL -c ckdb.c | |
21 3. Compile and link with main program, e.g. ckdbtest.c: | |
22 soapcpp2 -c ckdbtest.h | |
23 gcc -DWITH_COOKIES ckdbtest.c ckdb.o stdsoap2.c soapC.c soapClient.c | |
24 | |
25 */ | |
26 | |
27 #include <sys/stat.h> | |
28 #include "stdsoap2.h" | |
29 #define WITH_NOGLOBAL | |
30 #undef SOAP_FMAC3 | |
31 #define SOAP_FMAC3 static | |
32 #include "ckdbC.c" | |
33 | |
34 int soap_save_cookies(struct soap *soap, const char *pathname) | |
35 { int socket = soap->socket; | |
36 int sendfd = soap->sendfd; | |
37 soap_begin(soap); | |
38 soap->socket = -1; /* make sure plain I/O is used */ | |
39 soap->sendfd = open(pathname, O_CREAT|O_TRUNC|O_WRONLY, S_IREAD|S_IWRITE); | |
40 if (soap->sendfd >= 0) | |
41 { soap_serialize_cookie(soap, (struct cookie*)soap->cookies); | |
42 soap_begin_send(soap); | |
43 soap_put_cookie(soap, (struct cookie*)soap->cookies, "jar", NULL); | |
44 soap_end_send(soap); | |
45 close(soap->sendfd); | |
46 soap->socket = socket; | |
47 soap->sendfd = sendfd; | |
48 return SOAP_OK; | |
49 } | |
50 soap->socket = socket; | |
51 soap->sendfd = sendfd; | |
52 return SOAP_EOF; | |
53 } | |
54 | |
55 int soap_load_cookies(struct soap *soap, const char *pathname) | |
56 { int socket = soap->socket; | |
57 int recvfd = soap->recvfd; | |
58 soap_begin(soap); | |
59 soap->socket = -1; /* make sure plain I/O is used */ | |
60 soap->recvfd = open(pathname, O_RDONLY); | |
61 if (soap->recvfd >= 0) | |
62 { if (soap_begin_recv(soap)) | |
63 { close(soap->recvfd); | |
64 soap->socket = socket; | |
65 soap->recvfd = recvfd; | |
66 return soap->error; | |
67 } | |
68 soap->cookies = (struct soap_cookie*)soap_get_cookie(soap, NULL, "jar", NULL); | |
69 if (!soap->cookies && soap->error) | |
70 { close(soap->recvfd); | |
71 soap->socket = socket; | |
72 soap->recvfd = recvfd; | |
73 return soap->error; | |
74 } | |
75 if (soap_end_recv(soap)) | |
76 { close(soap->recvfd); | |
77 soap->socket = socket; | |
78 soap->recvfd = recvfd; | |
79 return soap->error; | |
80 } | |
81 close(soap->recvfd); | |
82 soap->socket = socket; | |
83 soap->recvfd = recvfd; | |
84 return SOAP_OK; | |
85 } | |
86 soap->socket = socket; | |
87 soap->recvfd = recvfd; | |
88 return SOAP_EOF; | |
89 } |