sds_util.h

Go to the documentation of this file.
00001 /*******************************************************************************
00002 *
00003 *  COPYRIGHT (C) 2006 Battelle Memorial Institute.  All Rights Reserved.
00004 *
00005 ********************************************************************************
00006 *
00007 *  Author:
00008 *     name:  Brian Ermold
00009 *     phone: (509) 375-2277
00010 *     email: brian.ermold@pnl.gov
00011 *
00012 ********************************************************************************
00013 *
00014 *  RCS INFORMATION:
00015 *    $RCSfile: sds_util.h,v $
00016 *    $Revision: 1.7 $
00017 *    $Locker:  $
00018 *    $Date: 2006/08/04 02:21:28 $
00019 *    $State: ds-dsutil-ingest_lib-1.1-0 $
00020 *
00021 *******************************************************************************/
00022 
00023 #ifndef SDS_UTIL_H
00024 #define SDS_UTIL_H
00025 
00026 #include <stdio.h>
00027 #include <time.h>
00028 
00029 /*******************************************************************************
00030 *  Definitions:
00031 */
00032 
00033 #define MAXPATHNAME    512   /* The maximum length of a path name           */
00034 #define MAXPLATNAME    32    /* The maximum length of a platform name       */
00035 
00036 #define SHORTSTRLEN    128   /* The maximum length of a short string        */
00037 #define MAXSTRLEN      1024  /* The maximum length of a typical string      */
00038 #define MSLEN          1024  /* The maximum length of a typical string      */
00039 #define LONGSTRLEN     4096  /* The maximum length of a long string         */
00040 
00041 #define SUCCESS        1     /* The return value for success                */
00042 #define FAILURE        0     /* The return value for failure                */
00043 
00044 #define TRUE           1     /* The true value for boolean operations       */
00045 #define FALSE          0     /* The false value for boolean operations      */
00046 
00047 #define DEBUGCHECK     0     /* Used by set_debug to check the debug state  */
00048 #define DEBUGON        1     /* Used by set_debug to turn debugging on      */
00049 #define DEBUGOFF       2     /* Used by set_debug to turn debugging off     */
00050 
00051 /* End Definitions */
00052 
00053 /*******************************************************************************
00054 *  Prototypes:
00055 */
00056 
00057 void   print_debug(char *file, int line, char* format, ...);
00058 void   print_error(char *file, int line, char* format, ...);
00059 
00060 int    set_debug(int state);
00061 
00062 int    bin2dec(char *number);
00063 
00064 int    check_file(char *file);
00065 int    check_path(char *path);
00066 int    file_copy(char *src_file, char *dest_file);
00067 int    file_move(char *src_file, char *dest_file);
00068 
00069 int    get_next_line(FILE *fp, char *buf, int buf_size);
00070 int    get_line_count();
00071 
00072 char  *get_collection_home(void);
00073 char  *get_datastream_home(void);
00074 char  *get_hostname(void);
00075 char  *get_log_home(void);
00076 
00077 int    namecompare(const void *s1, const void *s2);
00078 
00079 int    split(char *str, double *val);
00080 
00081 int    days_since1970(int year);
00082 int    days_sinceJan(int month, int year);
00083 int    four_digit_year(int year);
00084 int    get_julian_day(int month, int day, int year);
00085 int    monthnum(char *month);
00086 time_t seconds_since1970(int hourmin, int jday, int year, int seconds);
00087 void   set_date(int jday, int year, int *mon, int *day);
00088 int    validate_time(int hour, int minute, int second);
00089 int    validate_date(int year, int month, int day);
00090 
00091 /* End Prototypes */
00092 
00093 /*******************************************************************************
00094 *  Macros:
00095 */
00096 #define get_debug()    set_debug(DEBUGCHECK)
00097 
00098 #define ISLEAP(y) (y<1900 \
00099                    ? (((y+1900) % 4) == 0 && ((y+1900) % 100) != 0 \
00100                      || ((y+1900) % 400) == 0) \
00101                    : (((y) % 4) == 0 && ((y) % 100) !=0 || ((y) % 400) == 0))
00102 
00103 #define DYSIZE(y) 365 + ISLEAP(y)
00104 
00105 /* End Macros */
00106 
00107 /*******************************************************************************
00108 *  Macros:  For backward compatability with old shared library calls
00109 */
00110 
00111 #define getdebug()        set_debug(DEBUGCHECK)
00112 #define setdebug(state)   set_debug(state)
00113 
00114 /* End Macros */
00115 
00116 #endif /* !SDS_UTIL_H */

Generated on Tue Sep 12 20:12:37 2006 for DSUTIL-INGEST_LIB by doxygen 1.3.5