1 /************************************************************************
2 qDecoder - Web Application Interface for C/C++ http://www.qDecoder.org
3
4 Copyright (C) 2001 The qDecoder Project.
5 Copyright (C) 1999,2000 Hongik Internet, Inc.
6 Copyright (C) 1998 Nobreak Technologies, Inc.
7 Copyright (C) 1996,1997 Seung-young Kim.
8
9 This library is free software; you can redistribute it and/or
10 modify it under the terms of the GNU Lesser General Public
11 License as published by the Free Software Foundation; either
12 version 2.1 of the License, or (at your option) any later version.
13
14 This library is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Lesser General Public License for more details.
18
19 You should have received a copy of the GNU Lesser General Public
20 License along with this library; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22
23 Copyright Disclaimer:
24 Hongik Internet, Inc., hereby disclaims all copyright interest.
25 President, Christopher Roh, 6 April 2000
26
27 Nobreak Technologies, Inc., hereby disclaims all copyright interest.
28 President, Yoon Cho, 6 April 2000
29
30 Seung-young Kim, hereby disclaims all copyright interest.
31 Author, Seung-young Kim, 6 April 2000
32 ************************************************************************/
33
34 #include "qDecoder.h"
35 #include "qInternal.h"
36
37
38 /**********************************************
39 ** Usage : qFreeAll();
40 ** Do : De-allocate all reserved memories.
41 **********************************************/
42 void qFreeAll(void) {
43 qFree();
44 qSessionFree();
45 qAwkClose();
46 }
47
48 /**********************************************
49 ** Usage : qReset();
50 ** Do : Reset all static flags and de-allocate
51 ** all reserved memories.
52 **********************************************/
53 void qReset(void) {
54 qFreeAll();
55
56 /* reset static variables */
57 qErrorLog(NULL);
58 qErrorContact(NULL);
59 qResetContentFlag();
60 }
61
62 /**********************************************
63 ** Usage : qUniqueID();
64 ** Return: Unique string depend on client.
65 ** Do : Generate unique id for each connection.
66 **********************************************/
67 char *qUniqueID(void) {
68 char parm[256];
69 static char uniqid[16 * 2 + 1];
70
71 #ifdef _WIN32
72 struct tm *envtime;
73 envtime = qGetTime();
74 sprintf(parm, "%04d%02d%02d%02d%02d%02d-%s:%s", envtime->tm_year, envtime->tm_mon, envtime->tm_mday, envtime->tm_hour, envtime->tm_min, envtime->tm_sec , qGetenvDefault("", "REMOTE_ADDR"), qGetenvDefault("", "REMOTE_PORT"));
75 #else
76 struct timeval tv;
77 gettimeofday(&tv, NULL);
78 sprintf(parm, "%ld.%ld-%s:%s", tv.tv_sec, tv.tv_usec, qGetenvDefault("", "REMOTE_ADDR"), qGetenvDefault("", "REMOTE_PORT"));
79 #endif
80
81 strcpy(uniqid, qMD5Str(parm));
82
83 return uniqid;
84 }