
/* OpenWebSpider
 *
 *  Authors:     Stefano Alimonti AND Stefano Fantin
 *  Version:     0.7
 *  E-Mails:     shen139 [at] openwebspider (dot) org AND stefanofantinguz@yahoo.it
 *
 *
 * 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` (                                               " \
                                "     `id` int(11) NOT NULL auto_increment,                         " \
                                "     `host_id` int(10) unsigned NOT NULL,                          " \
                                "     `hostname` varchar(100) NOT NULL,                             " \
                                "     `page` varchar(255) NOT NULL,                                 " \
                                "     `title` varchar(255) NOT NULL,                                " \
                                "     `text` longtext NOT NULL,                                     " \
                                "     `cache` longblob,                                             " \
                                "     `version` int(11) unsigned NOT NULL default '0',              " \
                                "     `level` int(11) unsigned NOT NULL default '0',                " \
                                "     `rank` int(11) unsigned NOT NULL default '0',                 " \
                                "     `date` varchar(10) NOT NULL,                                  " \
                                "     `time` varchar(10) NOT NULL,                                  " \
                                "     PRIMARY KEY  (`id`)                                      " \
                                "   ) 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*/

