
/* OpenWebSpider
 *
 *  Author:     Stefano Alimonti aka Shen139
 *  Mail:       shen139 [at] openwebspider (dot) org
 *
 *
 * This file is part of OpenWebSpider
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */

#ifndef __MyMACRO
#define __MyMACRO

/*MACRO*/
#define MIN(a,b)        (a<b)?a:b

#define FREE(x)         if(x)free(x);

#define CREATE_TMP_TABLE(tab)    "CREATE TABLE `%s` ("							        \
                                "		`idpage` int(11) NOT NULL auto_increment,"		\
                                "		`hostname` varchar(100) NOT NULL default '',"	\
                                "		`page` varchar(255) NOT NULL default '',"		\
                                "		`description` varchar(255) NOT NULL default '',"\
                                "		`html` LONGTEXT NOT NULL,"						\
								"       `htmlcache` LONGBLOB,"                          \
                                "		`version` int(11) NOT NULL default '0',"		\
                                "		`level` int(11) NOT NULL default '0', "			\
								"       `rank` int(11) NOT NULL default '0',  "         \
                                "		`date` varchar(10) NOT NULL default '',"		\
                                "		`time` varchar(10) NOT NULL default '',"		\
                                "		PRIMARY KEY  (`idpage`)"						\
                                "	  ) ENGINE=MyISAM CHARSET=utf8 ;",tab


#define ERROR_LOG(msg)	{							\
                        FILE* file;					\
                        time_t long_time;			\
                        struct tm *newtime;			\
                            time( &long_time );		\
                            newtime=localtime(&long_time);	\
                            if((file = fopen("error.log","a"))!=NULL)     \
                            { \
                                fprintf(file,"%i\\%i\\%i %i:%i:%i - %s\n",newtime->tm_mday ,newtime->tm_mon +1, newtime->tm_year +1900,newtime->tm_hour ,newtime->tm_min ,newtime->tm_sec,msg);	\
                                fclose(file);	\
                            }	\
                         }

#define OWS_LOG(msg)	{							\
                        FILE* file;					\
                        time_t long_time;			\
                        struct tm *newtime;			\
                            time( &long_time );		\
                            newtime=localtime(&long_time);	\
                            if((file = fopen("ows_server.log","a"))!=NULL)     \
                            { \
                                fprintf(file,"%i\\%i\\%i %i:%i:%i - %s\n",newtime->tm_mday ,newtime->tm_mon +1, newtime->tm_year +1900,newtime->tm_hour ,newtime->tm_min ,newtime->tm_sec,msg);	\
                                fclose(file);	\
                            }	\
                         }

#endif


/* EOF*/

