support (support.c / support.h), originally created by Guy Carpenter (Oct 1989) and expanded by John Hughes Clarke and Jonathan Beaudoin, is the foundational C utility library included by nearly every source file in the Ocean Mapping Group codebase. It provides:
Replaces the first occurrence of search in filename with replace (or deletes search if replace == NULL). Powers -swap_dirs in mos2.
word_tolower
char *word_tolower(char *str)
Converts str to lowercase in-place and returns str.
3. Numeric, Angle & File-List Parsing
Function
Signature
Description
strtoint / strtodbl
int strtoint(char *s) / double strtodbl(char *s)
Parses an integer or double from s; sets error_val = error_val_str_not_used if trailing non-numeric characters remain.
fieldtoint / fieldtodbl
int fieldtoint(char *s, int len) / double fieldtodbl(char *s, int len)
Parses a fixed-width ASCII column of length len into an int or double.
strtoangle
double strtoangle(char *s)
Parses geographic angles into signed decimal degrees; accepts whole degrees (nnn), decimal degrees (nnn.ddd), degrees/minutes (nnn'mm.mm or nnn^mm.mm), and trailing hemisphere suffixes (N/E positive, S/W negative).
check_error
error_type check_error(void)
Returns and clears error_val after strtoint/strtodbl/strtoangle.
rounddown / roundup / roundupforce
double rounddown(double n, double mod)
Rounds n down or up to an exact multiple of mod.
getc_line / getc_line_jb / getc_line_vlength
int getc_line(FILE *file, char *string, int printit)
Reads a newline-terminated line from file (with dynamic OMG_Buffer growth in getc_line_vlength).
load_inputfiles_from_list
int load_inputfiles_from_list(char *name, char *allnames[], int *totin)
Reads a text file list (-xyzlist), skips blank lines and # comments, prepends the list fileβs directory path to relative entries, and appends valid file paths into allnames[].