Exemplo n.º 1
0
int fsync_shpref_init(int uid)
{
  shmap_t *h;
  struct stat st;
  char *path;
  char *data;
  shkey_t *key;
  size_t data_len;
  size_t len;
  int err;
  int b_of;

  h = shmap_init();
  if (!h)
    return (SHERR_NOMEM);


  path = shpref_path(uid);
  err = shfs_read_mem(path, &data, &data_len);
  if (!err) { /* file may not have existed. */
    shbuf_t *buff = shbuf_map(data, data_len);
    shmap_load(h, buff);
    free(buff);
  }

  free(key);

  fsync_preferences = h;
  fsync_preferences_data = data;

  return (0);
}
Exemplo n.º 2
0
static shmap_t *get_shlock_map(void)
{
  static shmap_t *_lock_map;

  if (!_lock_map) {
    _lock_map = shmap_init(); 
  }

  return (_lock_map);
}
Exemplo n.º 3
0
char *sexe_event_init(int e_type, const char *e_name)
{
  static char key_str[256];
  sexe_event_t *e;
  shkey_t *key;

  if (!event_map) {
    event_map = shmap_init();
  }

  e = (sexe_event_t *)calloc(1, sizeof(sexe_event_t));
  if (!e)
    return (SHERR_NOMEM);

  e->event_type = e_type;
  strncpy(e->mod_name, e_name, sizeof(e->mod_name) - 1);
  key = shkey_bin(e, sizeof(sexe_event_t));
  memcpy(&e->reg_key, key, sizeof(shkey_t));
  shmap_set_ptr(event_map, key, e);
  strncpy(key_str, shkey_hex(key), sizeof(key_str) - 1);
  shkey_free(&key);

  return (key_str);
}
Exemplo n.º 4
0
shmap_t *shmap_init_custom(shmapfunc_t hash_func)
{
    shmap_t *ht = shmap_init();
    ht->hash_func = hash_func;
    return ht;
}