home *** CD-ROM | disk | FTP | other *** search
- /* (C) Tim Graves 20th April 1994
- This code is supplied AS IS. no warrantee either expressed or implied
- is provided. This code may be freeley modified and modified as long as my
- origional authorship is acknowledged.
-
- Tim Graves
- Sun Microsystems
-
- */
- /* this file contains the excludelist for the backup subsystem, it is used to
- remove files from the backup */
- /* it can also be used by the restore sub system as the format of the path
- names are different, i.e. m:\wrd\tim.wrd and wrd/tim.wrd, note the path
- separator is different */
- #include <stdio.h>
- #include "psion.h"
- #include "psbackupexclude.h"
- #include <ctype.h>
- #include <string.h>
- extern int debugcall ;
- static char vsn[]="@(#) psbackupexclude.c 3.3@(#)" ;
- /* the structures to hold the exclude entries */
- struct excludestruct * exclude;
- initexclude()
- {
- if (debugcall >= EXCLUDECALLDEBUG)
- fprintf(stderr, "CALL: initexclude()\n") ;
- exclude == NULL ;
- }
-
- setupexclude (path)
- char * path ;
- {
- struct excludestruct * current;
- if (debugcall >= EXCLUDECALLDEBUG)
- fprintf(stderr, "CALL: setupexclude (path = %s)\n",path) ;
- current = exclude ;
- /* first of all does the exclude already ? if so ignore it */
- while (current != NULL)
- {
- if (strcmp(current->path, path) == 0)
- {
- return ;
- }
- current = current->nextexclude ;
- }
- /* we've got here and not found a exclude, install at the end
- of the list */
- return (newexclude(path)) ;
- }
- removeexclude (path)
- char * path ;
- {
- struct excludestruct * current, *prev;
- if (debugcall >= EXCLUDECALLDEBUG)
- fprintf(stderr, "CALL: removeexclude (path = %s)\n",path) ;
- if (exclude == NULL)
- return(OK) ;
- current = exclude ;
- /* check if the exclude is the first in the list */
- if (strcmp(exclude->path, path) == 0)
- {
- /* make sure we have a start pointer */
- exclude = exclude->nextexclude ;
- /* free the path pointer */
- free (current->path) ;
- /* free the structure */
- free(current) ;
- return(OK) ;
- }
- prev = exclude ;
- while (current != NULL)
- {
- if (strcmp(current->path, path) == 0)
- {
- /* remove from the list */
- prev->nextexclude = current->nextexclude ;
- /* free the path pointer */
- free (current -> path) ;
- /* free the structure */
- free (current);
- return (OK);
- }
- /* next item on the list */
- prev = current ;
- current = current->nextexclude ;
- }
- }
-
- /* install a exclude into list */
- installexclude (path, current)
- struct excludestruct *current ;
- char * path ;
- {
- if (debugcall >= EXCLUDECALLDEBUG)
- fprintf(stderr, "CALL: installexclude (path = %s, current = (OMITED))\n",path) ;
- /* lets do the setup */
- current->path = (char *) calloc(1, strlen(path) +1) ; /* length plus the \0 */
- strcpy(current->path, path) ;
- return (OK) ;
- }
-
- /* newexclude, create a exclude add it to the list then fill it */
- newexclude(path)
- char * path ;
- {
- struct excludestruct *new ;
- if (debugcall >= EXCLUDECALLDEBUG)
- fprintf(stderr, "CALL: newexclude (path = %s, )\n",path) ;
- new = (struct excludestruct *) calloc (1, sizeof (struct excludestruct)) ;
- /* add it to the head of the list */
- new->nextexclude = exclude ;
- exclude = new ;
- /* create the exclude */
- return (installexclude(path, exclude));
- }
- /* print each item in the exclude list */
- printexclude()
- {
- struct excludestruct *current ;
- if (debugcall >= EXCLUDECALLDEBUG)
- fprintf(stderr, "CALL: printexclude ()\n") ;
- /* initialise to the head of the list */
- current = exclude ;
- if (exclude == NULL)
- {
- printf("No backup excludes currently installed\n") ;
- return(OK) ;
- }
- printf("Current installed backup excludes\n") ;
- /* run through the list */
- while (current != NULL)
- {
- printf("%s\n", current->path) ;
- /* next item on the list */
- current = current->nextexclude ;
- }
- }
-
-
- /* if the exclude is set return TRUE, otherwise return FALSE */
- findexclude(path)
- char * path ;
- {
- struct excludestruct * current;
- if (debugcall >= EXCLUDECALLDEBUG)
- fprintf(stderr, "CALL: findexclude (path = %s)\n",path) ;
- current = exclude ;
- /* lets doit */
- while (current != NULL)
- {
- if (strcmp(current->path, path) == 0)
- {
- return (TRUE) ;
- }
- current = current->nextexclude ;
- }
- /* we've got here and not found a exclude return FALSE*/
- return (FALSE) ;
- }
-