| 154 | } |
| 155 | |
| 156 | static int |
| 157 | freebsd_conf_handler(struct ff_config *cfg, const char *section, |
| 158 | const char *name, const char *value) |
| 159 | { |
| 160 | struct ff_freebsd_cfg *newconf, **cur; |
| 161 | newconf = (struct ff_freebsd_cfg *)malloc(sizeof(struct ff_freebsd_cfg)); |
| 162 | if (newconf == NULL) { |
| 163 | fprintf(stderr, "freebsd conf malloc failed\n"); |
| 164 | return 0; |
| 165 | } |
| 166 | |
| 167 | newconf->name = strdup(name); |
| 168 | newconf->str = strdup(value); |
| 169 | |
| 170 | if (strcmp(section, "boot") == 0) { |
| 171 | cur = &cfg->freebsd.boot; |
| 172 | |
| 173 | newconf->value = (void *)newconf->str; |
| 174 | newconf->vlen = strlen(value); |
| 175 | } else if (strcmp(section, "sysctl") == 0) { |
| 176 | cur = &cfg->freebsd.sysctl; |
| 177 | |
| 178 | if (is_integer(value)) { |
| 179 | if (strcmp(name, "kern.ipc.maxsockbuf") == 0) { |
| 180 | long *p = (long *)malloc(sizeof(long)); |
| 181 | *p = atol(value); |
| 182 | newconf->value = (void *)p; |
| 183 | newconf->vlen = sizeof(*p); |
| 184 | } else { |
| 185 | int *p = (int *)malloc(sizeof(int)); |
| 186 | *p = atoi(value); |
| 187 | newconf->value = (void *)p; |
| 188 | newconf->vlen = sizeof(*p); |
| 189 | } |
| 190 | } else { |
| 191 | newconf->value = (void *)newconf->str; |
| 192 | newconf->vlen = strlen(value); |
| 193 | } |
| 194 | } else { |
| 195 | fprintf(stderr, "freebsd conf section[%s] error\n", section); |
| 196 | free(newconf); |
| 197 | return 0; |
| 198 | } |
| 199 | |
| 200 | if (*cur == NULL) { |
| 201 | newconf->next = NULL; |
| 202 | *cur = newconf; |
| 203 | } else { |
| 204 | newconf->next = (*cur)->next; |
| 205 | (*cur)->next = newconf; |
| 206 | } |
| 207 | |
| 208 | return 1; |
| 209 | } |
| 210 | // A recursive binary search function. It returns location of x in |
| 211 | // given array arr[l..r] is present, otherwise -1 |
| 212 | static int |
no test coverage detected