unsigned long ref_id, lock_ref_id;
double offset, delay, precision;
const char *tmp;
- char name[5], cmd[10 + 1], *param;
+ char cmd[10 + 1], *name, *param;
unsigned char ref[5];
SRC_SelectOption sel_option;
lock_ref_id = 0;
sel_option = SRC_SelectNormal;
- if (sscanf(line, "%4s%n", name, &n) != 1) {
+ while (isspace(line[0]))
+ line++;
+ tmp = line;
+ while (line[0] != '\0' && !isspace(line[0]))
+ line++;
+
+ if (line == tmp) {
LOG(LOGS_WARN, LOGF_Configure, "Could not read refclock driver name at line %d", line_number);
return;
}
- line += n;
+
+ name = MallocArray(char, 1 + line - tmp);
+ strncpy(name, tmp, line - tmp);
+ name[line - tmp] = '\0';
while (isspace(line[0]))
line++;
if (line == tmp) {
LOG(LOGS_WARN, LOGF_Configure, "Could not read refclock parameter at line %d", line_number);
+ Free(name);
return;
}
line += n;
}
- strncpy(refclock_sources[i].driver_name, name, 4);
+ refclock_sources[i].driver_name = name;
refclock_sources[i].driver_parameter = param;
refclock_sources[i].driver_poll = dpoll;
refclock_sources[i].poll = poll;
if (n_sources == MAX_RCL_SOURCES)
return 0;
- if (strncmp(params->driver_name, "SHM", 4) == 0) {
+ if (strcmp(params->driver_name, "SHM") == 0) {
inst->driver = &RCL_SHM_driver;
inst->precision = 1e-6;
- } else if (strncmp(params->driver_name, "SOCK", 4) == 0) {
+ } else if (strcmp(params->driver_name, "SOCK") == 0) {
inst->driver = &RCL_SOCK_driver;
inst->precision = 1e-9;
pps_source = 1;
- } else if (strncmp(params->driver_name, "PPS", 4) == 0) {
+ } else if (strcmp(params->driver_name, "PPS") == 0) {
inst->driver = &RCL_PPS_driver;
inst->precision = 1e-9;
pps_source = 1;
#endif
n_sources++;
+ Free(params->driver_name);
+
return 1;
}