/*************************************************************************** * Copyright (C) 2004 by root * * root@bu1wks2682 * * * * 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. * ***************************************************************************/ #include void CreateIndex (char *table,char *index_name,char *field,MYSQL *mysql) { char bufi[200],sqlt[300],*cp; int i; if (index_name==NULL) { cp=bufi; sprintf(bufi,"%s_%s",table,field); for (i=strlen(table); imysql && stmt->mysql->server_version) fprintf(stdout," [MySQL-%s]\n",stmt->mysql->server_version); else fprintf(stdout," [MySQL]\n "); fprintf(stdout,"[%d] %s\n",mysql_stmt_errno(stmt),mysql_stmt_error(stmt)); } else if (msg) fprintf(stderr, " [MySQL] %s\n", msg); } int Mysql_Execute (MYSQL_STMT *stmt,char *text) {int error; if ((error=mysql_execute(stmt))) print_st_error(stmt, text); return error; } int Mysql_Fetch (MYSQL_STMT *stmt,char *text) { int error; if ((error = mysql_fetch(stmt))!=MYSQL_NO_DATA) { if (error) print_st_error(stmt,text); } return error; } void NuTo (MYSQL_BIND *my_bind,struct my_nu *my_null,int from,int to) { for (;fromyear=tm.tm_year; rd->month=tm.tm_mon+1; rd->day=tm.tm_mday; } int CompSdat (MYSQL_TIME *tol,MYSQL_TIME *ig) { long l1,l2; l1=tol->year*10000+tol->month*100+tol->day; l2=ig->year*10000+ig->month*100+ig->day; if (l1==l2) return 0; return ((l1>l2) ? 1:-1); } int Days (MYSQL_TIME *tol,MYSQL_TIME *ig) { int j,nap=0; MYSQL_TIME seg; unsigned char bmo[sizeof(mon) / sizeof(mon[0])]; memcpy(bmo,mon,sizeof(bmo)); if (CompSdat(tol,ig)>0) return 0; if (tol->yearyear) { if (tol->year&3) bmo[2]=28; nap=bmo[tol->month]-tol->day+1; for (j=tol->month+1; j<13; j++) nap+=bmo[j]; for (j=tol->year+1; jyear; j++) nap+=(j&3) ? 365:366; seg.year=ig->year;seg.month=seg.day=1; } else seg=*tol; if (seg.monthmonth) { bmo[2]=(ig->year&3) ? 28:29; nap+=bmo[seg.month]-seg.day+1; for (j=seg.month+1; jmonth; j++) nap+=bmo[j]; seg.day=1; } nap+=ig->day-seg.day; return nap; } /* utils end */