Example #1
0
#undef V

static int or_state_validate(or_state_t *state, char **msg);

static int or_state_validate_cb(void *old_options, void *options,
                                void *default_options,
                                int from_setconf, char **msg);

/** Magic value for or_state_t. */
#define OR_STATE_MAGIC 0x57A73f57

/** "Extra" variable in the state that receives lines we can't parse. This
 * lets us preserve options from versions of Tor newer than us. */
static config_var_t state_extra_var = {
  "__extra", CONFIG_TYPE_LINELIST, offsetof(or_state_t, ExtraLines), NULL
  CONF_TEST_MEMBERS(or_state_t, LINELIST, ExtraLines)
};

/** Configuration format for or_state_t. */
static const config_format_t state_format = {
  sizeof(or_state_t),
  OR_STATE_MAGIC,
  offsetof(or_state_t, magic_),
  state_abbrevs_,
  NULL,
  state_vars_,
  or_state_validate_cb,
  &state_extra_var,
};

/** Persistent serialized state. */
Example #2
0
  V(ValidUntil,                 ISOTIME, NULL),

  V(Commit,                     LINELIST, NULL),

  V(SharedRandValues,           LINELIST_V, NULL),
  VAR("SharedRandPreviousValue",LINELIST_S, SharedRandValues, NULL),
  VAR("SharedRandCurrentValue", LINELIST_S, SharedRandValues, NULL),
  END_OF_CONFIG_VARS
};

/* "Extra" variable in the state that receives lines we can't parse. This
 * lets us preserve options from versions of Tor newer than us. */
static config_var_t state_extra_var = {
  "__extra", CONFIG_TYPE_LINELIST,
  offsetof(sr_disk_state_t, ExtraLines), NULL
  CONF_TEST_MEMBERS(sr_disk_state_t, LINELIST, ExtraLines)
};

/* Configuration format of sr_disk_state_t. */
static const config_format_t state_format = {
  sizeof(sr_disk_state_t),
  SR_DISK_STATE_MAGIC,
  offsetof(sr_disk_state_t, magic_),
  NULL,
  NULL,
  state_vars,
  disk_state_validate_cb,
  disk_state_free_cb,
  &state_extra_var,
};