| 31 | //------------------------------------------------------------------------- |
| 32 | |
| 33 | static void |
| 34 | initialize_record(const RecordElement *record, void *) |
| 35 | { |
| 36 | RecInt tempInt = 0; |
| 37 | RecFloat tempFloat = 0.0; |
| 38 | RecCounter tempCounter = 0; |
| 39 | |
| 40 | RecUpdateT update; |
| 41 | RecCheckT check; |
| 42 | RecAccessT access; |
| 43 | RecT type; |
| 44 | |
| 45 | // Less typing ... |
| 46 | type = record->type; |
| 47 | update = record->update; |
| 48 | check = record->check; |
| 49 | access = record->access; |
| 50 | |
| 51 | if (REC_TYPE_IS_CONFIG(type)) { |
| 52 | const char *value = RecConfigOverrideFromEnvironment(record->name, record->value); |
| 53 | RecData data = {0}; |
| 54 | RecSourceT source = value == record->value ? REC_SOURCE_DEFAULT : REC_SOURCE_ENV; |
| 55 | |
| 56 | // If you specify a consistency check, you have to specify a regex expression. We abort here |
| 57 | // so that this breaks QA completely. |
| 58 | if (record->check != RECC_NULL && record->regex == nullptr) { |
| 59 | ink_fatal("%s has a consistency check but no regular expression", record->name); |
| 60 | } |
| 61 | |
| 62 | RecDataSetFromString(record->value_type, &data, value); |
| 63 | RecErrT reg_status{REC_ERR_FAIL}; |
| 64 | switch (record->value_type) { |
| 65 | case RECD_INT: |
| 66 | reg_status = RecRegisterConfigInt(type, record->name, data.rec_int, update, check, record->regex, source, access); |
| 67 | break; |
| 68 | |
| 69 | case RECD_FLOAT: |
| 70 | reg_status = RecRegisterConfigFloat(type, record->name, data.rec_float, update, check, record->regex, source, access); |
| 71 | break; |
| 72 | |
| 73 | case RECD_STRING: |
| 74 | reg_status = RecRegisterConfigString(type, record->name, data.rec_string, update, check, record->regex, source, access); |
| 75 | break; |
| 76 | |
| 77 | case RECD_COUNTER: |
| 78 | reg_status = RecRegisterConfigCounter(type, record->name, data.rec_counter, update, check, record->regex, source, access); |
| 79 | break; |
| 80 | |
| 81 | default: |
| 82 | ink_assert(true); |
| 83 | break; |
| 84 | } // switch |
| 85 | |
| 86 | if (reg_status != REC_ERR_OKAY) { |
| 87 | ink_fatal("%s cannot be registered. Please check the logs.", record->name); |
| 88 | } |
| 89 | |
| 90 | RecDataZero(record->value_type, &data); |
nothing calls this directly
no test coverage detected