home *** CD-ROM | disk | FTP | other *** search
- /* lib.c
-
- */
-
- #include <stdio.h>
- #include <ctype.h>
- #include <errno.h>
- #include "host.h"
-
- #ifndef NULL
- #define NULL 0L
- #endif
-
- char *index();
- char *rindex();
-
- MKDIR( path )
- char * path;
- {
- char * cp = path;
-
- if ( *cp == '\0' )
- return( 0 );
-
- /* see if we need to make any intermediate directories */
- while ( ( cp = index( cp, '/' ) ) != (char *) NULL ) {
- *cp = '\0';
- mkdir( path );
- *cp = '/';
- cp++;
- }
-
- /* make last dir */
- return( mkdir( path ) );
-
- }
-
- CHDIR( path )
- char * path;
- {
- char * cp = path;
-
- if ( *cp == '\0' )
- return( 0 );
-
- MKDIR( path );
-
- /* change to last directory */
- return( chdir( path ) );
-
- }
-
- FILE * FOPEN( name, mode, ftype )
- char * name;
- char * mode;
- char ftype;
- {
-
- char * last;
- FILE * results;
-
- /* are we opening for write or append */
-
- FILEMODE( ftype );
- results = fopen( name, mode );
-
- if ( results != (FILE *) NULL || *mode == 'r' )
- return( results );
-
- /* are we opening in sub-directory */
- last = rindex( name, '/' );
-
- /* lets just verify that all sub-dir's exist */
- if ( last != (char *) NULL ) {
- *last = '\0';
- MKDIR( name );
- *last = '/';
- }
-
- /* now try open again */
- return( fopen( name, mode ));
-
- }
-
- int CREAT( name, mode, ftyp )
- char * name;
- int mode;
- char ftyp;
- {
-
- char * last;
- int results;
-
- /* are we opening for write or append */
- FILEMODE( ftyp );
- results = creat( name, mode );
-
- if ( results != -1 )
- return( results );
-
- /* are we opening in sub-directory */
- last = rindex( name, '/' );
-
- /* lets just verify that all sub-dir's exist */
- if ( last != (char *) NULL ) {
- *last = '\0';
- MKDIR( name );
- *last = '/';
- }
-
- /* now try open again */
- return( creat( name, mode ) );
-
- }
-
- extern FILE *logfile;
- extern int debuglevel;
- extern int remote;
-
- #define MASTER 1
-
-
- int getargs( line, flds )
- char *line;
- char **flds;
- {
- int i = 0;
- char *s;
-
- while ( (*line != '\0') && (*line != '\n') )
- {
- if ( isspace(*line) )
- {
- line++;
- continue;
- }
- *flds++ = line;
- i++;
- while( (isspace(*line) == 0) && (*line != '\0') ) line++;
- if (isspace(*line)) *line++ = '\0';
- }
- return(i);
- }
-
-
-
-