rem: LOG(L_ERR, "pdomain_load_presentities: Error while querying presentity\n"); return -1; } if (res) { for (i = 0; i < res->n; i++) { presentity_t *presentity = NULL;  db_row_t *row = &res->rows[i]; db_val_t *row_vals = ROW_VALUES(row); int presid = row_vals[presid_col].val.int_val; str uri; if (!row_vals[uri_col].nul) { uri.s = row_vals[uri_col].val.string_val; uri.len = strlen(uri.s); }
add: LOG(L_ERR, "pdomain_load_presentities: Error while querying presentity\n"); close_pa_db_connection(db); return -1; } if (res) { for (i = 0; i < res->n; i++) {  db_row_t *row = &res->rows[i]; db_val_t *row_vals = ROW_VALUES(row); int presid = row_vals[presid_col].val.int_val; str uri; if (!row_vals[uri_col].nul) { uri.s = (char *)row_vals[uri_col].val.string_val; uri.len = strlen(uri.s); }
context: int pdomain_load_presentities(pdomain_t *pdomain){     if (use_db) {	  db_key_t query_cols[1];	  db_op_t  query_ops[1];	  db_val_t query_vals[1];	  db_key_t result_cols[4];	  db_res_t *res;	  int n_query_cols = 0;	  int n_result_cols = 0;	  int uri_col;	  int presid_col;	  int i;	  query_cols[n_query_cols] = "pdomain";	  query_ops[n_query_cols] = OP_EQ;	  query_vals[n_query_cols].type = DB_STR;	  query_vals[n_query_cols].nul = 0;	  query_vals[n_query_cols].val.str_val = *pdomain->name;	  n_query_cols++;	  result_cols[uri_col = n_result_cols++] = "uri";	  result_cols[presid_col = n_result_cols++] = "presid";	  if (pa_dbf.use_table(pa_db, presentity_table) < 0) {		  LOG(L_ERR, "pdomain_load_presentities: Error in use_table\n");		  return -1;	  }	  if (pa_dbf.query (pa_db, query_cols, query_ops, query_vals,			result_cols, n_query_cols, n_result_cols, 0, &res) < 0) {	       LOG(L_ERR, "pdomain_load_presentities: Error while querying presentity\n");	       return -1;	  }	  if (res) {	       for (i = 0; i < res->n; i++) {		    presentity_t *presentity = NULL;		    /* fill in tuple structure from database query result */		    db_row_t *row = &res->rows[i];		    db_val_t *row_vals = ROW_VALUES(row);		    int presid = row_vals[presid_col].val.int_val;		    str uri;		    if (!row_vals[uri_col].nul) {			 uri.s = row_vals[uri_col].val.string_val;			 uri.len = strlen(uri.s);		    }		    LOG(L_INFO, "pdomain_load_presentities: pdomain=%.*s presentity uri=%.*s presid=%d\n",			pdomain->name->len, pdomain->name->s, uri.len, uri.s, presid);		    new_presentity_no_wb(pdomain, &uri, &presentity);		    if (presentity) {			 add_presentity(pdomain, presentity);			 presentity->presid = presid;		    }	       }	       pa_dbf.free_result(pa_db, res);	  }	  	  { 	       presentity_t *presentity;	       for (presentity = pdomain->first; presentity; presentity = presentity->next) {		    db_read_watcherinfo(presentity);	       }	  }     }     return 0;}