PostGIS  3.4.0dev-r@@SVN_REVISION@@

◆ option_list_gdal_parse()

void option_list_gdal_parse ( char *  input,
char **  olist 
)

Definition at line 121 of file optionlist.c.

122 {
123  const char *toksep = " ";
124  const char kvsep = '=';
125  const char q2 = '"';
126  const char q1 = '\'';
127  const char notspace = 0x1F;
128 
129  char *key, *val;
130  int in_str = 0;
131  size_t i = 0, sz, input_sz;
132  char *ptr = input;
133 
134  if (!input)
135  lwerror("Option string is null");
136  input_sz = strlen(input);
137 
138  /* Temporarily hide quoted spaces */
139  while(*ptr) {
140  if (*ptr == q2 || *ptr == q1)
141  in_str = !in_str;
142  else if (in_str && *ptr == ' ')
143  *ptr = notspace;
144 
145  ptr++;
146  }
147 
148  /* Tokenize on spaces */
149  for (key = strtok(input, toksep); key; key = strtok(NULL, toksep)) {
150  if (i >= OPTION_LIST_SIZE) return;
151  olist[i++] = key;
152  }
153 
154  /* Check that these are GDAL KEY=VALUE options */
155  sz = i;
156  for (i = 0; i < sz; ++i) {
157  if (i >= OPTION_LIST_SIZE) return;
158  key = olist[i];
159  /* find the key/value separator */
160  val = strchr(key, kvsep);
161  if (!val) {
162  lwerror("Option string entry '%s' lacks separator '%c'", key, kvsep);
163  return;
164  }
165  }
166 
167  /* Unhide quoted space */
168  for (i = 0; i <= input_sz; ++i) {
169  if (input[i] == notspace)
170  input[i] = ' ';
171  }
172 }
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
#define OPTION_LIST_SIZE
Definition: optionlist.h:31

References lwerror(), and OPTION_LIST_SIZE.

Referenced by test_optionlist().

Here is the call graph for this function:
Here is the caller graph for this function: