PostGIS  3.4.0dev-r@@SVN_REVISION@@

◆ is_format_valid()

static int is_format_valid ( const char *  format)
static

Definition at line 198 of file lwgeom_out_marc21.c.

198  {
199 
200  char *int_part;
201  char *dec_part = strchr(format, '.');
202  if(!dec_part) dec_part = strchr(format, ',');
203 
204  if(!dec_part) {
205 
206  if (strcmp(format, "hdddmmss") && strcmp(format, "dddmmss")) {
207 
208  return LW_FALSE;
209 
210  }
211 
212  } else {
213 
214  if(strlen(dec_part)<2) return LW_FALSE;
215 
216  int_part = palloc(sizeof(char)*strlen(format));
217  memcpy(int_part, &format[0], strlen(format) - strlen(dec_part));
218  int_part[strlen(format) - strlen(dec_part)]='\0';
219 
220  if (strcmp(int_part,"hddd") && strcmp(int_part,"ddd") &&
221  strcmp(int_part,"hdddmm") && strcmp(int_part,"dddmm") &&
222  strcmp(int_part,"hdddmmss") && strcmp(int_part,"dddmmss")) {
223 
224  pfree(int_part);
225  return LW_FALSE;
226 
227  }
228 
229  for (size_t i = 1; i < strlen(dec_part); i++) {
230 
231  if(dec_part[i]!=int_part[strlen(int_part)-1]) {
232 
233  pfree(int_part);
234  return LW_FALSE;
235  }
236  }
237 
238  pfree(int_part);
239 
240  }
241 
242  return LW_TRUE;
243 
244 }
#define LW_FALSE
Definition: liblwgeom.h:94
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:93

References LW_FALSE, and LW_TRUE.

Referenced by lwgeom_to_marc21().

Here is the caller graph for this function: