Exemplo n.º 1
0
static void message(const char *profile, const char *fmt, ...)
{
  static char *previous = 0;
  static struct timeval zen;
  static const struct timeval tmo = { 0, 100 * 1000 };
  struct timeval now, dif;
  int gap = 0;

  getmonotime(&now);
  timersub(&now, &zen, &dif);
  if( timercmp(&tmo, &dif, <) )
  {
    zen = now;
    gap = 1;
  }

  if( !xstrsame(previous, profile) )
  {
    xstrset(&previous, profile);
    gap = 1;
  }
  if( gap ) printf("\n");

  va_list va;
  va_start(va, fmt);
  vprintf(fmt, va);
  va_end(va);
}
Exemplo n.º 2
0
static const char *current_(const char *profile, const char *key)
{
  static const char general[] = "general";

  /* - - - - - - - - - - - - - - - - - - - *
   * profile lookup order:
   * 1. config: "override"
   * 2. custom: caller provided
   * 3. config: caller provided
   * 4. custom: "general"
   * 5. config: "general"
   * 6. config: "fallback"
   * - - - - - - - - - - - - - - - - - - - */

  const char *res = 0;

  if( (res = override_(key)) )
  {
    // have override value
    goto cleanup;
  }

  if( !xstrnull(res = custom_(profile, key)) )
  {
    // have non-empty custom value for requested profile
    goto cleanup;
  }

  if( (res = config_(profile, key)) )
  {
    // have non-empty default value for requested profile
    goto cleanup;
  }

  if( !xstrsame(profile, general) )
  {
    if( !xstrnull(res = custom_(general, key)) )
    {
      // have non-empty custom value for general profile
      goto cleanup;
    }
    if( (res = config_(general, key)) )
    {
      // have non-empty default value for general profile
      goto cleanup;
    }
  }

  // use the fallback value
  res = fallback_(key);

cleanup:

  return res;
}
Exemplo n.º 3
0
int
inisec_compare(const inisec_t *self, const char *name)
{
  return xstrsame(self->is_name, name);
}
Exemplo n.º 4
0
int
inival_compare(const inival_t *self, const char *key)
{
  return xstrsame(self->iv_key, key);
}