/********************************************************************* * Copyright 2014, UCAR/Unidata * See netcdf/COPYRIGHT file for copying and redistribution conditions. *********************************************************************/ #include "config.h" #include #include #include /* General rule try to avoid any obscure string functions. We currently use - strcasecmp - strchr - strndup - strlen */ #undef DEBUG /* Define the legal leading key characters */ #define KEYCHARS1 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789$_." /*forward*/ static const char* ncsettings_text; static char** lines; static int nlines; static char* dup; static char** map = NULL; /*forward*/ static void parse(); static int parseline(const char* line, int keypos); static int iskeyline(const char* line); static void preprocess(); const char* nc_settings(const char* key) { char** mapp; if(map == NULL) parse(); for(mapp=map;*mapp != NULL;mapp+=2) { /* Note this assumes that no key is a prefix of another */ if(strcasecmp(*mapp,key)==0) { return mapp[1]; } } return NULL; } const char** nc_settings_all() { if(map == NULL) parse(); return (const char**)map; } const char* nc_settings_text() { return ncsettings_text; } static void parse() { int i,keypos; int nkeys; const char** line; preprocess(); nkeys = 0; /* Count # of key lines */ for(i=0;i