return edg_wll_Error(ctx,NULL,NULL);
}
- glite_lbu_TimeToDB(from, &from_s);
- glite_lbu_TimeToDB(to, &to_s);
+ glite_lbu_TimeToStr(from, &from_s);
+ glite_lbu_TimeToStr(to, &to_s);
trio_asprintf(&stmt,
"select event,dg_jobid,code,prog,host,u.cert_subj,time_stamp,usec,level,arrived "
case ENOENT: *t = 0;
edg_wll_ResetError(ctx);
break;
- case 0: *t = glite_lbu_DBToTime(time_s);
+ case 0: *t = glite_lbu_StrToTime(time_s);
assert(*t >= 0);
break;
default: break;
static char *time_to_string(time_t t, char **ptr) {
char *s;
- glite_lbu_TimeToDB(t, &s);
+ glite_lbu_TimeToStr(t, &s);
s[strlen(s) - 1] = '\0';
*ptr = s;
static char *to_sql_timeval(edg_wll_JobStat const *stat,int offset)
{
char *out;
- glite_lbu_TimeToDB( ((struct timeval *) (((char *) stat) + offset))->tv_sec, &out );
+ glite_lbu_TimeToStr( ((struct timeval *) (((char *) stat) + offset))->tv_sec, &out );
return out;
}
break;
case EDG_WLL_QUERY_ATTR_TIME:
if (stat->stateEnterTimes)
- glite_lbu_TimeToDB(stat->stateEnterTimes[job_index_cols[i].qrec.attr_id.state+1], &data);
+ glite_lbu_TimeToStr(stat->stateEnterTimes[job_index_cols[i].qrec.attr_id.state+1], &data);
else data = strdup("0");
break;
case EDG_WLL_QUERY_ATTR_RESUBMITTED:
asprintf(&data, "%d", stat->resubmitted);
break;
case EDG_WLL_QUERY_ATTR_STATEENTERTIME:
- glite_lbu_TimeToDB(stat->stateEnterTime.tv_sec, &data);
+ glite_lbu_TimeToStr(stat->stateEnterTime.tv_sec, &data);
break;
case EDG_WLL_QUERY_ATTR_LASTUPDATETIME:
- glite_lbu_TimeToDB(stat->lastUpdateTime.tv_sec, &data);
+ glite_lbu_TimeToStr(stat->lastUpdateTime.tv_sec, &data);
break;
case EDG_WLL_QUERY_ATTR_JDL_ATTR: // This is not the correct way to handle jdl searches.
/* There's no way to index individual JDL attributes */
break;
/* case EDG_WLL_QUERY_ATTR_STATEENTERTIME: /// XXX: Which way of handling this is correct?
if (stat->stateEnterTime)
- glite_lbu_TimeToDB(stat->stateEnterTime, &data);
+ glite_lbu_TimeToStr(stat->stateEnterTime, &data);
else data = strdup("0");
break;
case EDG_WLL_QUERY_ATTR_LASTUPDATETIME:
if (stat->lastUpdateTime)
- glite_lbu_TimeToDB(stat->lastUpdateTime, &data);
+ glite_lbu_TimeToStr(stat->lastUpdateTime, &data);
else data = strdup("0");
break;*/
if (edg_wll_ExecSQL(ctx,jobq,&jobs) < 0) goto err;
while ((ret = edg_wll_FetchRow(ctx,jobs,sizeof(jobc)/sizeof(jobc[0]),NULL,jobc)) > 0) {
- if (now > (expires = glite_lbu_DBToTime(jobc[2]))) {
+ if (now > (expires = glite_lbu_StrToTime(jobc[2]))) {
edg_wll_NotifExpired(ctx,jobc[0]);
glite_common_log(LOG_CATEGORY_LB_SERVER, LOG_PRIORITY_DEBUG, "[%d] NOTIFY:%s expired at %s UTC",
getpid(),jobc[0],asctime(gmtime(&expires)));
*valid = time(NULL) + ctx->notifDuration;
adjust_validity(ctx,valid);
- glite_lbu_TimeToDB(*valid, &time_s);
+ glite_lbu_TimeToStr(*valid, &time_s);
if ( !time_s )
{
edg_wll_SetError(ctx, errno, NULL);
*valid = time(NULL) + ctx->notifDuration;
adjust_validity(ctx,valid);
- glite_lbu_TimeToDB(*valid, &time_s);
+ glite_lbu_TimeToStr(*valid, &time_s);
if ( !time_s )
{
edg_wll_SetError(ctx, errno, "Formating validity time");
*valid = time(NULL) + ctx->notifDuration;
adjust_validity(ctx,valid);
- glite_lbu_TimeToDB(*valid, &time_s);
+ glite_lbu_TimeToStr(*valid, &time_s);
if ( !time_s )
{
edg_wll_SetError(ctx, errno, "Formating validity time");
int expires;
*v2 = 0;
- expires = glite_lbu_DBToTime(v+1);
+ expires = glite_lbu_StrToTime(v+1);
/*
printf("edg_wll_NotifChangeIL(ctx, %s, %s, %d)\n",
nid_s? nid_s: "nid", host, port);
if ( !(nid_s = edg_wll_NotifIdGetUnique(nid)) )
goto cleanup;
- glite_lbu_TimeToDB(now, &time_s);
+ glite_lbu_TimeToStr(now, &time_s);
if ( !time_s )
{
edg_wll_SetError(ctx, errno, NULL);
char *cols[20];
glite_lbu_Statement stmt;
- if (glite_lbu_InitDBContext((glite_lbu_DBContext*) &ctx->dbctx) != 0) {
+ if (glite_lbu_InitDBContext((glite_lbu_DBContext*) &ctx->dbctx, GLITE_LBU_DB_BACKEND_MYSQL) != 0) {
char *ed;
glite_lbu_DBError(ctx->dbctx, NULL, &ed);
case EDG_WLL_QUERY_ATTR_TIME:
case EDG_WLL_QUERY_ATTR_STATEENTERTIME:
case EDG_WLL_QUERY_ATTR_LASTUPDATETIME:
- glite_lbu_TimeToDB(ec[m][n].value.t.tv_sec, &dbt);
+ glite_lbu_TimeToStr(ec[m][n].value.t.tv_sec, &dbt);
if ( conds )
{
if ( ec[m][n].op == EDG_WLL_QUERY_OP_WITHIN )
{
trio_asprintf(&aux, "%s", dbt);
free(dbt);
- glite_lbu_TimeToDB(ec[m][n].value2.t.tv_sec, &dbt);
+ glite_lbu_TimeToStr(ec[m][n].value2.t.tv_sec, &dbt);
trio_asprintf(&out, "%s OR (e.time_stamp >= %s AND e.time_stamp <= %s)", conds, aux, dbt);
free(aux);
}
{
trio_asprintf(&aux, "%s", dbt);
free(dbt);
- glite_lbu_TimeToDB(ec[m][n].value2.t.tv_sec, &dbt);
+ glite_lbu_TimeToStr(ec[m][n].value2.t.tv_sec, &dbt);
trio_asprintf(&conds, "(e.time_stamp >= %s AND e.time_stamp <= %s)", aux, dbt);
free(aux);
}
*where_flags |= FL_SEL_STATUS;
- glite_lbu_TimeToDB(jc[m][n].value.t.tv_sec, &dbt);
+ glite_lbu_TimeToStr(jc[m][n].value.t.tv_sec, &dbt);
if ( conds )
{
if ( jc[m][n].op == EDG_WLL_QUERY_OP_WITHIN )
{
trio_asprintf(&aux, "%s", dbt);
free(dbt);
- glite_lbu_TimeToDB(jc[m][n].value2.t.tv_sec, &dbt);
+ glite_lbu_TimeToStr(jc[m][n].value2.t.tv_sec, &dbt);
trio_asprintf(&tmps, "%s OR (s.%s >= %s AND s.%s <= %s)", conds, cname, aux, cname, dbt);
free(dbt);
free(aux);
{
trio_asprintf(&aux, "%s", dbt);
free(dbt);
- glite_lbu_TimeToDB(jc[m][n].value2.t.tv_sec, &dbt);
+ glite_lbu_TimeToStr(jc[m][n].value2.t.tv_sec, &dbt);
trio_asprintf(&conds, "(s.%s >= %s AND s.%s <= %s)", cname, aux, cname, dbt);
free(dbt);
free(aux);
e->any.user = f[4];
f[4] = NULL;
- e->any.timestamp.tv_sec = glite_lbu_DBToTime(f[5]);
+ e->any.timestamp.tv_sec = glite_lbu_StrToTime(f[5]);
free(f[5]); f[5] = NULL;
e->any.timestamp.tv_usec = atoi(f[6]);
e->any.level = atoi(f[7]);
free(f[7]); f[7] = NULL;
- e->any.arrived.tv_sec = glite_lbu_DBToTime(f[8]);
+ e->any.arrived.tv_sec = glite_lbu_StrToTime(f[8]);
e->any.arrived.tv_usec = 0;
free(f[8]); f[8] = NULL;
lowercase_usertag(e);
jobid = edg_wlc_JobIdGetUnique(e->any.jobId);
- glite_lbu_TimeToDB(e->any.timestamp.tv_sec, &stamp);
+ glite_lbu_TimeToStr(e->any.timestamp.tv_sec, &stamp);
ssrc = edg_wll_SourceToString(e->any.source);
if ( ctx->event_load )
- glite_lbu_TimeToDB(e->any.arrived.tv_sec, &now_s);
+ glite_lbu_TimeToStr(e->any.arrived.tv_sec, &now_s);
else
- glite_lbu_TimeToDB(time(NULL), &now_s);
+ glite_lbu_TimeToStr(time(NULL), &now_s);
edg_wll_ResetError(ctx);
switch (check_auth(ctx,e)) {
void glite_lbu_TimeToStrGeneric(time_t t, char **str, const char *amp);
void glite_lbu_TimestampToStrGeneric(double t, char **str, const char *amp);
-void glite_lbu_TimeToStr(time_t t, char **str);
-void glite_lbu_TimestampToStr(double t, char **str);
-time_t glite_lbu_StrToTime(const char *str);
-double glite_lbu_StrToTimestamp(const char *str);
double glite_lbu_DBToTimestamp(glite_lbu_DBContext ctx, const char *str);
+/* Generic helper time convert functions. */
+void glite_lbu_TimeToStr(time_t t, char **str);
+void glite_lbu_TimestampToStr(double t, char **str);
+time_t glite_lbu_StrToTime(const char *str);
+double glite_lbu_StrToTimestamp(const char *str);
+
+
/**
* Init data structure for buffered insert
*
void glite_lbu_FreeStmt(glite_lbu_Statement *stmt) {
- if (!stmt || !VALID((*stmt)->ctx->backend)) return;
+ if (!stmt || !*stmt || !VALID((*stmt)->ctx->backend)) return;
return backends[(*stmt)->ctx->backend]->freeStmt(stmt);
}