Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-17 07:51:37

0001 /*
0002    Copyright 2000-2003 Virginia Commonwealth University
0003 
0004 
0005    Advisory:
0006 1. The authors make no claim of accuracy of the information in these files or the 
0007    results derived from use of these files.
0008 2. You are not allowed to re-distribute these files or the information contained within.
0009 3. This methods and information contained in these files was interpreted by the authors 
0010    from various sources.  It is the users sole responsibility to verify the accuracy 
0011    of these files.  
0012 4. If you find a error within these files, we ask that you to contact the authors 
0013    and the distributor of these files.
0014 5. We ask that you acknowledge the source of these files in publications that use results
0015    derived from the input 
0016 
0017    Please contact us if you have any questions 
0018 */
0019 /* Header File for General Utilities for CPP programs
0020     File Created:
0021         18-December-1995: Combined ok_check.cpp and some open_file
0022     Modification History:
0023          09-feb-1996: JVS: add pprintf
0024        07-Nov-1996: JVS: FAIL_SAFE definition changed, NULL=0
0025        06-Jan-1998: JVS: Add array_read
0026        07-May-1998: JVS: add myerrno
0027        11-Sept-1998: JVS: add max, min definitions
0028       // 28-Oct-1998: PJK: added MAX_NUM_FIELDS for output_path in case_info.h
0029       03-Dec-1998: JVS: Add #ifndef UTILITIES_H_INCLUDED to ensure single inclusion of the file
0030                         All comments "c" compliant
0031        02-Mar-1999: JVS: Add eprintf_mode
0032        Dec 3, 1999: JVS: Add check_byte_order
0033        April 24, 2001: JVS: Add cp
0034        August 24, 2001: JVS: Change OK from 1 to 0...so exit(OK) is unix standard normal...
0035        Feb 10, 2005: JVS:Add writeLittleEndianBinaryFile()
0036        April 21, 2005: JVS: Add readBinaryDataFromFile()
0037 */
0038 #ifndef UTILITIES_H_INCLUDED
0039 #define UTILITIES_H_INCLUDED
0040 
0041 #define OK     0
0042 #define ERROR -1
0043 #define FAIL  -1
0044 #define ON     1
0045 #define OFF    0
0046 #define FAIL_SAFE -999        /* used to be NULL**JVS 11/7/96** */
0047 #define MAX_STR_LEN 512       /* maximum length of a string */
0048 #define MAX_BUFFER_SIZE 16384 /* maximum number of characters in the output buffer */
0049 #define STR_NULL   ((char) 0)
0050 /* #define MAX_NUM_FIELDS 100 */
0051 #ifndef N_DATA
0052 #define N_DATA 4096 /* maximum number of datapoints */
0053 #endif
0054 #ifdef MAIN
0055 int myerrno = OK;
0056 #else
0057 extern int myerrno;
0058 #endif
0059 #ifdef MAIN
0060 int eprintf_mode = ON;
0061 #else
0062 extern int eprintf_mode;
0063 #endif
0064 #ifndef MAIN
0065 extern /* create global pbuffer */
0066 #endif          
0067 char *pbuffer;  /* pointer to buffer for output of run info for failures */
0068 
0069 #ifndef ENDIAN_H_INCLUDED
0070 #define ENDIAN_H_INCLUDED
0071 
0072 
0073 /* Definitions for byte order, according to significance of bytes, from low
0074    addresses to high addresses.  The value is what you get by putting '4'
0075    in the most significant byte, '3' in the second most significant byte,
0076    '2' in the second least significant byte, and '1' in the least
0077    significant byte.  */
0078 
0079 #define __LITTLE_ENDIAN 1234
0080 #define __BIG_ENDIAN    4321
0081 #define __PDP_ENDIAN    3412
0082 
0083 //(MACG) endian macros defined in macOS 15, silent -Wmacro-redefined warning
0084 #if !defined(LITTLE_ENDIAN) && defined(__LITTLE_ENDIAN)
0085   #define LITTLE_ENDIAN   __LITTLE_ENDIAN
0086 #endif
0087 #if !defined(BIG_ENDIAN) && defined(__BIG_ENDIAN)
0088   #define BIG_ENDIAN      __BIG_ENDIAN
0089 #endif
0090 #if !defined(PDP_ENDIAN) && defined(__PDP_ENDIAN)
0091   #define PDP_ENDIAN      __PDP_ENDIAN
0092 #endif
0093 //(MACG) --- end of changes
0094 #define UNKNOWN_ENDIAN  0000
0095 
0096 #endif  /* endian.h */
0097 
0098 /* #define max and min */
0099 /* (MACG) using min and max functions through algorithm c++ library
0100 #ifndef MINMAX_DEFINED
0101 #define MINMAX_DEFINED
0102 #define min(a,b)    (((a) < (b)) ? (a) : (b))
0103 #define max(a,b)    (((a) > (b)) ? (a) : (b))
0104 //#define __max       max
0105 //#define __min       min
0106 #endif (MACG)*/ /*MINMAX_DEFINED */
0107 
0108 /* *************************************************************************** */
0109 float reverse_float_byte_order(float xold);
0110 short reverse_short_byte_order(short xold);
0111 int reverse_int_byte_order(int xold);
0112 int advance(char *istr, int *sval, int len);
0113 int check_byte_order(void);
0114 int clean_name(char *tmp_path, char *opath);
0115 int clean_name(char *);
0116 int copy(char *SourceFile, char *DestinationFile);
0117 //(MACG) int eprintf(char *fmt, ... );
0118 int eprintf(const char *fmt, ... );
0119 int ok_check(void);
0120 int ok_checks(char *string);
0121 //(MACG) FILE *open_file(char *filename,char *extension, char *access);
0122 FILE *open_file(char *filename,const char *extension,const char *access);
0123 int pprintf(char *fmt, ... );
0124 int latex_string(char *string, char *nstring);
0125 void print_runtime_info(int argc, char *argv[]);
0126 void allocate_pbuffer(void);
0127 float interpolate(float xh, float xl, float xm, float yh, float yl);
0128 int array_read(FILE *istrm, float *array, int max_array);
0129 int array_read(char *in_string, float *array, int max_array);
0130 int view_errors(void);
0131 int writeBigEndianBinaryFile(char *doseFileName,  int nDoseArray, float *doseArray);
0132 int writeLittleEndianBinaryFile(char *doseFileName,  int nDoseArray, float *doseArray);
0133 int writeBinaryFile(char *doseFileName, int nDoseArray, float *doseArray, int swab_flag);
0134 int writeBinaryDataToFile(FILE *outputStream, int nArray, float *array, int swab_flag);
0135 int readBinaryDataFromFile(FILE *iStream, int nItemsToRead, float **arrayToRead, int swab_flag);
0136 int readBinaryDataFromFile(FILE *iStream, int nItemsToRead, float *inputArray, int swab_flag);
0137 // RCN added 
0138 int fget_c_string(char *string, int Max_Str_Len, FILE *fspec);
0139 int get_string(FILE *fspec, char *string);
0140 #endif