예제 #1
0
파일: time.c 프로젝트: Firstyear/ds
char *
get_timestring(time_t *t)
{
    char	*timebuf;

    if ( (timebuf = slapi_ch_malloc(32)) == NULL )
        return("No memory for get_timestring");
    CTIME(t, timebuf, 32);
    timebuf[strlen(timebuf) - 1] = '\0';	/* strip out return */
    return(timebuf);
}
예제 #2
0
static int
prolog_history_hook(orchids_t *ctx, mod_entry_t *mod, void *data, event_t *event)
{
  prolog_history_cfg_t *cfg;
  int		i;
  event_t	*e;
  char		buff[256];

  cfg = (prolog_history_cfg_t *)mod->config;

  for (i = 0; i < cfg->time_fields_nb; i++)
    for (e = event; e; e = e->next)
      if (cfg->time_fields_ids[i] == e->field_id)
      {
	DebugLog(DF_MOD, DS_DEBUG, "Followed time field %i (%s). "
		 "Current Db (%s).\n",
		 cfg->time_fields_ids[i], ctime(&(CTIME(e->value))),
		 ctime(&(SLIST_FIRST(&cfg->history)->time)));

	if (CTIME(e->value) > SLIST_FIRST(&cfg->history)->time)
	{
	  snprintf(buff, 256, "flushall, getall('%s').",
		   SLIST_FIRST(&cfg->history)->odbc_DSN);
	  int ret = pl_execute(buff);
	  DebugLog(DF_MOD, DS_DEBUG, "Update database to odbc %s.\n",
		   (SLIST_FIRST(&cfg->history)->odbc_DSN), ret);
	  if (ret)
	  {
	    SLIST_REMOVE_HEAD(&cfg->history, next);
	    gettimeofday(&cfg->prolog_cfg->last_db_update, NULL);
	  }
	}
	return 0;
      }

  return 0;
}