|
ocssw
V2022
|
Go to the source code of this file.
Macros | |
| #define | EARTH_CIRCUMFERENCE 40075016.6856 |
| #define | BAD_FLT -32767.0 |
| #define | BAD_INT -32767 |
| #define | BAD_UINT 65535 |
| #define | BAD_BYTE -128 |
| #define | BAD_UBYTE 255 |
Functions | |
| int | endianess (void) |
| void | parse_file_name (const char *inpath, char *outpath) |
| int | swapc_bytes (char *in, int nbyte, int ntime) |
| int | swapc_bytes2 (const char *in, char *out, int nbyte, int ntime) |
| size_t | fread_swap (int little_endian, void *ptr, size_t size, size_t nmemb, FILE *stream) |
| size_t | fwrite_swap (int little_endian, const void *ptr, size_t size, size_t nmemb, FILE *stream) |
| void | spline (float[], float[], int, float, float, float[]) |
| void | splint (float[], float[], float[], int, float, float *) |
| void | lspline (float xin[], float yin[], int32_t nin, float xout[], float yout[], int32_t nout) |
| float | linterp (float xin[], float yin[], int32_t nin, float xout) |
| float | bioBandShift (float xin[], float yin[], float chl, int32_t nin, float xout) |
| int32_t | filesize_ (const char *filename) |
| int32_t | filesize (const char *filename) |
| int | getlut_file (char *lut_file, short *rlut, short *glut, short *blut) |
| char * | lowcase (char *instr) |
| char * | upcase (char *instr) |
| int | isValidInt (const char *str) |
| void * | allocateMemory (size_t numBytes, const char *name) |
| void | trimBlanks (char *str) |
| char * | trimBlanksDup (const char *str) |
| int | getFileFormatIndex (const char *str) |
| const char * | getFileFormatName (const char *str) |
| const char * | getFileFormatExtension (const char *str) |
| char * | replace_ocroots (const char *inStr) |
| double | str2resolution (char const *resolutionStr) |
| const char * | resolution2str (double resolution) |
| double | resolution2degrees (double resolution) |
| double | degrees2resolution (double degrees) |
| int32_t | resolve2binRows (const char *resolve) |
| double | resolve2resolution (const char *resolve) |
Variables | |
| int | want_verbose |
Detailed Description
This is a bunch of useful general utilities.
Definition in file genutils.h.
Macro Definition Documentation
◆ BAD_BYTE
| #define BAD_BYTE -128 |
Definition at line 25 of file genutils.h.
◆ BAD_FLT
| #define BAD_FLT -32767.0 |
Define a few useful BAD values
Definition at line 22 of file genutils.h.
◆ BAD_INT
| #define BAD_INT -32767 |
Definition at line 23 of file genutils.h.
◆ BAD_UBYTE
| #define BAD_UBYTE 255 |
Definition at line 26 of file genutils.h.
◆ BAD_UINT
| #define BAD_UINT 65535 |
Definition at line 24 of file genutils.h.
◆ EARTH_CIRCUMFERENCE
| #define EARTH_CIRCUMFERENCE 40075016.6856 |
Definition at line 10 of file genutils.h.
Function Documentation
◆ allocateMemory()
| void* allocateMemory | ( | size_t | numBytes, |
| const char * | name | ||
| ) |
Definition at line 7 of file allocateMemory.c.
◆ bioBandShift()
| float bioBandShift | ( | float | xin[], |
| float | yin[], | ||
| float | chl, | ||
| int32_t | nin, | ||
| float | xout | ||
| ) |
◆ degrees2resolution()
| double degrees2resolution | ( | double | degrees | ) |
Pixel resolution degrees to meters.
- Parameters
-
degrees resolution in degrees
- Returns
- double in meters
Definition at line 93 of file resolution_utils.cpp.
◆ endianess()
| int endianess | ( | void | ) |
determine endianess
Is this machine little endian
- Returns
- 0 for BIG_ENDIAN machines, 1 for LITTLE_ENDIAN mahcines
Determines if the host calling this routine is a big or little endian machine.
- Returns
- A 0 for BIG_ENDIAN machines, 1 for LITTLE_ENDIAN mahcines.
Definition at line 10 of file endianess.c.
◆ filesize()
| int32_t filesize | ( | const char * | filename | ) |
Definition at line 8 of file filesize.c.
◆ filesize_()
| int32_t filesize_ | ( | const char * | filename | ) |
Definition at line 19 of file filesize.c.
◆ fread_swap()
| size_t fread_swap | ( | int | little_endian, |
| void * | ptr, | ||
| size_t | size, | ||
| size_t | nmemb, | ||
| FILE * | stream | ||
| ) |
read a binary file and swap bytes if necessary
- Parameters
-
little_endian set to 0 for big endian files, 1 for little endian files ptr memory to read into size size of object to read in bytes nmemb number of objects to read stream file to read from
- Returns
- number of objects read
Definition at line 4 of file fread_swap.c.
◆ fwrite_swap()
| size_t fwrite_swap | ( | int | little_endian, |
| const void * | ptr, | ||
| size_t | size, | ||
| size_t | nmemb, | ||
| FILE * | stream | ||
| ) |
write a binary file and swap bytes if necessary
- Parameters
-
little_endian set to 0 for big endian files, 1 for little endian files ptr memory to write size size of object to write in bytes nmemb number of objects to write stream file to write to
- Returns
- number of objects written
Definition at line 15 of file fread_swap.c.
◆ getFileFormatExtension()
convert the input string to the file format extension. Input string can be index, name or extension Formats are defined in $OCDATAROOT/common/file_formats.txt
- Parameters
-
str input string
- Returns
- pointer to internal string holding the file format extension
Definition at line 221 of file fileFormatUtils.c.
◆ getFileFormatIndex()
| int getFileFormatIndex | ( | const char * | str | ) |
convert the input string to the file format index. Input string can be index, name or extension Formats are defined in $OCDATAROOT/common/file_formats.txt
- Parameters
-
str input string
- Returns
- index associated with the file format
Definition at line 188 of file fileFormatUtils.c.
◆ getFileFormatName()
convert the input string to the normalized file format name. Input string can be index, name or extension Formats are defined in $OCDATAROOT/common/file_formats.txt
- Parameters
-
str input string
- Returns
- pointer to internal string holding the normalized format string, or NULL
Definition at line 205 of file fileFormatUtils.c.
◆ getlut_file()
| int getlut_file | ( | char * | lut_file, |
| short * | rlut, | ||
| short * | glut, | ||
| short * | blut | ||
| ) |
Definition at line 8 of file getlut_file.c.
◆ isValidInt()
| int isValidInt | ( | const char * | str | ) |
check if a string is a valid integer
- Parameters
-
str string to check
- Returns
- 1 if valid int, 0 if not
Definition at line 9 of file isValidInt.c.
◆ linterp()
| float linterp | ( | float | xin[], |
| float | yin[], | ||
| int32_t | nin, | ||
| float | xout | ||
| ) |
◆ lowcase()
◆ lspline()
| void lspline | ( | float | xin[], |
| float | yin[], | ||
| int32_t | nin, | ||
| float | xout[], | ||
| float | yout[], | ||
| int32_t | nout | ||
| ) |
◆ parse_file_name()
| void parse_file_name | ( | const char * | inpath, |
| char * | outpath | ||
| ) |
This function parses a path name. It removes extra /'s, translates any environment variables, translates ~users, and also handles "." and ".."
- Parameters
-
inpath file name to be translated outpath pointer to enough space for the translated file path
Definition at line 23 of file parse_file_name.c.
◆ replace_ocroots()
| char* replace_ocroots | ( | const char * | inStr | ) |
allocate a new string with environment variable names substituted for the values for: OCVARROOT, OCDATAROOT and OCSSWROOT
- Parameters
-
inStr string to do substitutions on
- Returns
- sanitized string that must be freed by the caller.
Definition at line 37 of file replace_ocroots.cpp.
◆ resolution2degrees()
| double resolution2degrees | ( | double | resolution | ) |
Pixel resolution meters to degrees.
- Parameters
-
resolution in meters
- Returns
- double in degrees
Definition at line 89 of file resolution_utils.cpp.
◆ resolution2str()
| const char* resolution2str | ( | double | resolution | ) |
Pixel resolution meters to string.
- Parameters
-
resolution in meters
- Returns
- const char* resolution as a string with units
Definition at line 84 of file resolution_utils.cpp.
◆ resolve2binRows()
| int32_t resolve2binRows | ( | const char * | resolve | ) |
convert l2bin style resolve string to number line in L3bin file
- Parameters
-
resolve l2bin style string
- Returns
- int32_t number of lines in L3bin file
Definition at line 145 of file resolution_utils.cpp.
◆ resolve2resolution()
| double resolve2resolution | ( | const char * | resolve | ) |
convert l2bin style resolve string to pixel resolution in meters
- Parameters
-
resolve l2bin style string
- Returns
- double resolution in meters
Definition at line 152 of file resolution_utils.cpp.
◆ spline()
| void spline | ( | float | [], |
| float | [], | ||
| int | , | ||
| float | , | ||
| float | , | ||
| float | [] | ||
| ) |
Definition at line 35 of file nr_spline.c.
◆ splint()
| void splint | ( | float | [], |
| float | [], | ||
| float | [], | ||
| int | , | ||
| float | , | ||
| float * | |||
| ) |
Definition at line 78 of file nr_spline.c.
◆ str2resolution()
| double str2resolution | ( | char const * | resolutionStr | ) |
Pixel resolution string to meters.
- Parameters
-
resolutionStr resolution string
- Returns
- double in meters
Definition at line 79 of file resolution_utils.cpp.
◆ swapc_bytes()
| int swapc_bytes | ( | char * | in, |
| int | nbyte, | ||
| int | ntime | ||
| ) |
Swap bytes in place
- Parameters
-
in pointer to memory to byte swap nbyte size of object to reverse ntime number of objects to swap
- Returns
- 0 always
Definition at line 4 of file swapc_bytes.c.
◆ swapc_bytes2()
| int swapc_bytes2 | ( | const char * | in, |
| char * | out, | ||
| int | nbyte, | ||
| int | ntime | ||
| ) |
Swap bytes from in to out. in and out should not be overlapping memory
- Parameters
-
in pointer to source memory to byte swap out pointer to destination memory nbyte size of object to reverse ntime number of objects to swap
- Returns
- 0 always
Definition at line 24 of file swapc_bytes.c.
◆ trimBlanks()
| void trimBlanks | ( | char * | str | ) |
trim white space off of beginning and end of string.
- Parameters
-
str string to modify
Definition at line 10 of file trimBlanks.c.
◆ trimBlanksDup()
| char* trimBlanksDup | ( | const char * | str | ) |
Allocate a string without beginning and ending white space.
- Parameters
-
str string to use as source (left unmodified)
- Returns
- pointer to newly allocated string without whitespace on ends
Definition at line 58 of file trimBlanks.c.
◆ upcase()
Variable Documentation
◆ want_verbose
| int want_verbose |
Do we want to print out extra info to stdout
Definition at line 3 of file genutils_globals.c.


