/* ** Copyright (c) 2002 D. Richard Hipp ** ** 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 library; if not, write to the ** Free Software Foundation, Inc., 59 Temple Place - Suite 330, ** Boston, MA 02111-1307, USA. ** ** Author contact information: ** drh@hwaci.com ** http://www.hwaci.com/drh/ ** ******************************************************************************* */ #include "config.h" #include #include #include "history.h" /* ** These are some functions that are commonly used by all SCM modules */ /* ** Make sure the given file or directory is contained in the ** FILE table of the database. */ void insert_file(const char *zName, int cn){ int i; char *zBase, *zDir; char *zToFree; int isDir = 0; int nLen; int isNewer; if( zName==0 || zName[0]==0 ) return; zToFree = zDir = mprintf("%s", zName); if( zDir==0 ) return; /* Subversion will pass directories too so we need to detect those early on. */ nLen = strlen(zDir)-1; if( zDir[nLen]=='/' ){ zDir[nLen--] = 0; isDir = 1; } while( zDir && zDir[0] ){ for(i=nLen; i>0 && zDir[i]!='/'; i--){} if( i==0 ){ zBase = zDir; zDir = ""; }else{ zDir[i] = 0; zBase = &zDir[i+1]; } isNewer = db_exists( "SELECT 1 FROM file WHERE dir='%q' AND base='%q' AND lastcn>%d", zDir, zBase, cn ); if( isNewer ) break; db_execute( "REPLACE INTO file(isdir, base, dir, lastcn) " "VALUES(%d,'%q','%q',%d)", isDir, zBase, zDir, cn); isDir = 1; zName = zDir; } free(zToFree); } void update_file_table_with_lastcn(void){ char **az; int i; az = db_query("SELECT MAX(cn),filename FROM filechng GROUP BY filename"); for(i=0; az[i]; i+=2){ insert_file(az[i+1], atoi(az[i])); } db_query_free(az); } /* ** WEBPAGE: /update_file_table ** ** Make sure the FILE table contains every file mentioned in ** FILECHNG with correct lastcn. */ void update_file_table(void){ login_check_credentials(); if( g.okSetup ){ db_execute("BEGIN"); update_file_table_with_lastcn(); db_execute("COMMIT"); } cgi_redirect("index"); } /* ** Convert a struct tm* that represents a moment in UTC into the number ** of seconds in 1970, UTC. */ time_t mkgmtime(struct tm *p){ time_t t; int nDay; int isLeapYr; /* Days in each month: 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 */ static int priorDays[] = { 0, 31, 59, 90,120,151,181,212,243,273,304,334 }; if( p->tm_mon<0 ){ int nYear = (11 - p->tm_mon)/12; p->tm_year -= nYear; p->tm_mon += nYear*12; }else if( p->tm_mon>11 ){ p->tm_year += p->tm_mon/12; p->tm_mon %= 12; } isLeapYr = p->tm_year%4==0 && (p->tm_year%100!=0 || (p->tm_year+300)%400==0); p->tm_yday = priorDays[p->tm_mon] + p->tm_mday - 1; if( isLeapYr && p->tm_mon>1 ) p->tm_yday++; nDay = (p->tm_year-70)*365 + (p->tm_year-69)/4 -p->tm_year/100 + (p->tm_year+300)/400 + p->tm_yday; t = ((nDay*24 + p->tm_hour)*60 + p->tm_min)*60 + p->tm_sec; return t; } /* ** This routine is called to complete the generation of an error ** message in the history_update module. */ void error_finish(int nErr){ if( nErr==0 ) return; @ common_footer(); cgi_reply(); exit(0); } /* ** This routine is called whenever an error situation is encountered. ** It makes sure an appropriate header has been issued. */ void error_init(int *pnErr){ if( *pnErr==0 ){ common_standard_menu(0, 0); cgi_reset_content(); cgi_set_status(200, "OK"); cgi_set_content_type("text/html"); common_header("Error Reading Repository"); @

The following errors occurred while trying to read and @ interpret if( !strcmp(g.scm.zSCM,"cvs") ){ @ the CVSROOT/history file from the CVS repository. }else{ @ the %h(g.scm.zName) repository. } @ This indicates a problem in the installation of CVSTrac. Please save @ this page and contact your system administrator.

@