00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
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
00031
00032
00033 #define MAXPATHNAME 512
00034 #define MAXPLATNAME 32
00035
00036 #define SHORTSTRLEN 128
00037 #define MAXSTRLEN 1024
00038 #define MSLEN 1024
00039 #define LONGSTRLEN 4096
00040
00041 #define SUCCESS 1
00042 #define FAILURE 0
00043
00044 #define TRUE 1
00045 #define FALSE 0
00046
00047 #define DEBUGCHECK 0
00048 #define DEBUGON 1
00049 #define DEBUGOFF 2
00050
00051
00052
00053
00054
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
00092
00093
00094
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
00106
00107
00108
00109
00110
00111 #define getdebug() set_debug(DEBUGCHECK)
00112 #define setdebug(state) set_debug(state)
00113
00114
00115
00116 #endif