Google
Web alhem.net
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

winmain.cpp

Go to the documentation of this file.
00001 00005 /* 00006 Copyright (C) 2004 Anders Hedström (grymse@alhem.net) 00007 00008 This program is free software; you can redistribute it and/or 00009 modify it under the terms of the GNU General Public License 00010 as published by the Free Software Foundation; either version 2 00011 of the License, or (at your option) any later version. 00012 00013 This program is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 GNU General Public License for more details. 00017 00018 You should have received a copy of the GNU General Public License 00019 along with this program; if not, write to the Free Software 00020 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00021 */ 00022 #define STL_USING_MAP 00023 #define STL_USING_STRING 00024 #define STL_USING_VECTOR 00025 #define STL_USING_LIST 00026 #include "stlhelper.h" 00027 #ifdef _WIN32 00028 #pragma warning(disable:4786) 00029 #endif 00030 #include <config-win.h> 00031 #include <mysql.h> 00032 #include <libmysqlwrapped.h> 00033 #include <stdio.h> 00034 #include <windows.h> 00035 #include <shellapi.h> 00036 #include "resource.h" 00037 #include <socket_include.h> 00038 #include <SocketHandler.h> 00039 #include <HttpGetSocket.h> 00040 #include <process.h> 00041 #include "MinderSocket.h" 00042 #include <commctrl.h> 00043 #include "MyErrlog.h" 00044 //#include "Security.h" 00045 00046 #include "MyApp.h" 00047 00048 00049 int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) 00050 { 00051 const char *server_groups[] = {"test_libmysqld_SERVER","embedded","server",NULL}; 00052 /* 00053 const char *server_argv[] = {"main", 00054 "--datadir=.", 00055 "--set-variable=key_buffer_size=32M"}; 00056 int server_argc = sizeof(server_argv) / sizeof(char *); 00057 */ 00058 // 00059 { 00060 int i; 00061 char *argv[10]; 00062 char temp_path[1000]; 00063 ::GetTempPath(1000, temp_path); 00064 00065 for (i = 0; i < 10; i++) 00066 argv[i] = NULL; 00067 00068 argv[0] = new char[100]; 00069 strcpy(argv[0], "fd.exe"); 00070 argv[1] = new char[1000]; 00071 sprintf(argv[1], "--datadir=%s", temp_path); 00072 argv[2] = new char[100]; 00073 strcpy(argv[2], "--language=."); 00074 argv[3] = new char[100]; 00075 strcpy(argv[3], "--skip-innodb"); 00076 argv[4] = new char[100]; 00077 strcpy(argv[4], "--set-variable=key_buffer_size=8M"); 00078 argv[5] = new char[100]; 00079 strcpy(argv[5], "--set-variable=sort_buffer_size=1M"); 00080 00081 int argc = 6; 00082 if (mysql_server_init(argc, argv, (char **)server_groups)) 00083 { 00084 ::MessageBox(NULL, "mysql_server_init() failed", "MySQL", MB_OK); 00085 return -1; 00086 } 00087 00088 // 00089 if (!mysql_thread_safe()) 00090 { 00091 ::MessageBox(NULL, "You are using a non thread safe libmysqld", "Warning", MB_OK); 00092 } 00093 00094 // Database instances get their own scope, not one must live when we call 00095 // mysql_server_end() below 00096 { 00097 MyErrlog log; 00098 { 00099 Database db("fd",&log); 00100 if (!db.Connected()) 00101 { 00102 // Create a temporary Database and create our 'finder' database 00103 Database db("",&log); 00104 Query q(db); 00105 00106 if (!q.Connected()) 00107 { 00108 ::MessageBox(NULL, "Not connected", "Query", MB_OK); 00109 } 00110 00111 q.execute("create database fd"); 00112 q.execute("use fd"); 00113 00114 // database was created, now create tables then exit 00115 q.execute("CREATE TABLE category (" 00116 " num int(11) NOT NULL auto_increment," 00117 " name varchar(255) default NULL," 00118 " PRIMARY KEY (num)" 00119 ") TYPE=MyISAM;"); 00120 00121 q.execute("CREATE TABLE item (" 00122 " num int(11) NOT NULL auto_increment," 00123 " typ enum('File','URL') NOT NULL default 'File'," 00124 " category int(11) NOT NULL default '0'," 00125 " name varchar(255)," 00126 " data mediumtext NOT NULL," 00127 " sz integer," 00128 " sha1 char(40)," 00129 " PRIMARY KEY (num)," 00130 " KEY typ (typ,category)," 00131 " KEY category (category)," 00132 " UNIQUE(sz,sha1)" 00133 ") TYPE=MyISAM;"); 00134 00135 q.execute("CREATE TABLE linkitemtag (" 00136 " item int(11) NOT NULL default '0'," 00137 " tag int(11) NOT NULL default '0'," 00138 " PRIMARY KEY (item,tag)," 00139 " KEY tag (tag)" 00140 ") TYPE=MyISAM;"); 00141 00142 q.execute("CREATE TABLE tag (" 00143 " num int(11) NOT NULL auto_increment," 00144 " name varchar(255) default NULL," 00145 " PRIMARY KEY (num)" 00146 ") TYPE=MyISAM;"); 00147 00148 } // if (!db.Connected) 00149 } 00150 // Start application 00151 { 00152 Database db("fd", &log); 00153 // database update scope 00154 { 00155 Query q(db); 00156 } // end of database update scope 00157 MyApp app(hInstance, hPrevInstance, db); 00158 app.Init(lpCmdLine, nCmdShow); 00159 } 00160 } // scope of mysql connections 00161 mysql_server_end(); 00162 00163 // clean up 00164 for (i = 0; i < 10; i++) 00165 { 00166 if (argv[i]) 00167 delete[] argv[i]; 00168 } 00169 } 00170 00171 return 0; 00172 } 00173 00174

Generated on Thu Feb 10 22:42:34 2005 for Distributed URL Classification Tool by doxygen 1.3.7