/* * Concordance Programming Language * Utility to reindex all databases from a log file. * Copyright (C) 2002 Dataflight Software, Inc. * ALL RIGHTS RESERVED. * Dataflight Software and Concordance are registered * trademarks of Dataflight Software, Inc. * * Dataflight Software, Inc. * 2337 Roscomare Road, Suite 11 * Los Angeles, CA 90077 * */ text szUserID = ""; text szPassword = ""; text logFile = ""; /**************************************************************** * Name: main() * * Synopsis: Main entry point for all Concordance CPLs * ****************************************************************/ main() { int fhLog; char logPath[256]; puts(0,0,"Concordance Reindexing Daemon"); closedb(0); /* Get the name of a log file */ if (logFile == "") getfile("Open log file", "*.txt", logFile); /* Loop forever */ while (TRUE) { /* Open log file */ if ((fhLog= open(logFile, "r")) <> EOF) { /* Read a directory and then index all databases in that directory */ while (readln(fhLog, logPath) <> EOF) reindexDaemon(logPath); /* Close log file */ close(fhLog); } } } /**************************************************************** * Name: reindexDaemon() * * Synopsis: Main processing routine for the CPL * ****************************************************************/ reindexDaemon(text directoryPath) { char szFile[256]; int db, i; for (szFile= findfirst(directoryPath + "*.dcb", 0); szFile[0]; szFile = findnext()) { /* Give the user the opportunity to quit */ Message("Press [Esc] to quit now.", FALSE); i = clock() + 3000; while(i > clock()) { if (keypress()) if (getkey() == ESC) exit(); } /* Put a message that we are reindexing */ Message("Reindexing "+directoryPath + szFile, FALSE); /* Reindex the database */ if ((db = opendb(directoryPath + szFile, szUserID, szPassword)) <> EOF) { reindex(db); closedb(db); } } } /* reindexDaemon() */ /**************************************************************** * Name: Message * * Synopsis: Displays error message and waits for key. * ****************************************************************/ Message(text message; int wait) { text screen; int key; cursoroff(); if (wait) screen = save(5,13,8,69); box(5,13,8,69, "3D", MenuColor_); puts(6,14,pad(message,'C',53),MenuColor_); if (wait) { key = getkey(); restore(5,13,screen); } return(asc(upper(chr(key)))); } /* Message() */