* load_format_config * * parse the user specified fixed width keywords. Currently supported * keywords are: 'preserve_blanks', 'line_delim' and 'null'. any other * unrecognized keyword is treated as a column name (and later on gets * verified as a valid column). */
| 151 | * verified as a valid column). |
| 152 | */ |
| 153 | static void |
| 154 | load_format_config(FormatConfig *format_config, FunctionCallInfo fcinfo) |
| 155 | { |
| 156 | int i; |
| 157 | char *key; |
| 158 | char *val; |
| 159 | int args_num = FORMATTER_GET_NUM_ARGS(fcinfo); |
| 160 | |
| 161 | reset_format_in_config(format_config); |
| 162 | |
| 163 | for (i = 1; i <= args_num; i++) |
| 164 | { |
| 165 | key = FORMATTER_GET_NTH_ARG_KEY(fcinfo, i); |
| 166 | val = FORMATTER_GET_NTH_ARG_VAL(fcinfo, i); |
| 167 | |
| 168 | if ( strcasecmp("preserve_blanks", key) == 0) |
| 169 | { |
| 170 | if ( strcasecmp("on", val) == 0) |
| 171 | { |
| 172 | format_config->preserve_blanks = 1; |
| 173 | } |
| 174 | } |
| 175 | else if ( strcasecmp("line_delim", key) == 0) |
| 176 | { |
| 177 | format_config->line_delimiter = val; |
| 178 | format_config->line_delimiter_length = strlen(val); |
| 179 | } |
| 180 | else if ( strcasecmp("null", key) == 0) |
| 181 | { |
| 182 | format_config->null_value = val; |
| 183 | } |
| 184 | else |
| 185 | { |
| 186 | int size = atoi(val); |
| 187 | format_config->fldNames = lappend(format_config->fldNames, makeString(key)); |
| 188 | format_config->fldSizes = lappend_int(format_config->fldSizes, size); |
| 189 | format_config->fields_tot_size += size; |
| 190 | } |
| 191 | } |
| 192 | } |
| 193 | |
| 194 | /* |
| 195 | * encoding_check_str |
no test coverage detected