Beispiel #1
0
//*******************************************************************
// Get the results of the MySQL query into our probe_def structure
//*******************************************************************
static void imap_set_def_fields(trx *t, struct probe_def *probedef, dbi_result result)
{
  struct imap_def *def = (struct imap_def *) probedef;

  if (dbi_result_next_row(result)) {
    def->ipaddress   = dbi_result_get_string_copy_idx(result, 0);
    def->description = dbi_result_get_string_copy_idx(result, 1);
    def->server   = dbi_result_get_uint_idx(result, 2);
    def->yellow   = dbi_result_get_float_idx(result, 3);
    def->red      = dbi_result_get_float_idx(result, 4);
    def->contact  = dbi_result_get_float_idx(result, 5);
    if (dbi_result_get_string_idx(result, 6)) {
      strcpy(def->hide, dbi_result_get_string_idx(result, 6));
    } else {
      strcpy(def->hide, "no");
    }
    if (dbi_result_get_string_idx(result, 7)) {
      strcpy(def->email, dbi_result_get_string_idx(result, 7));
    } else {
      strcpy(def->email, "");
    }
    if (dbi_result_get_string_idx(result, 8)) {
      strcpy(def->sms, dbi_result_get_string_idx(result, 8));
    } else {
      strcpy(def->sms, "");
    }
    def->delay = dbi_result_get_uint_idx(result, 9);
    def->username = dbi_result_get_string_copy_idx(result, 10);
    def->password = dbi_result_get_string_copy_idx(result, 11);
  }
}
Beispiel #2
0
/**
 * SQL callback. Return a string from a query
 * Should be called as in:
 *
 *   gchar *string;
 *   tagsistant_query("SQL statement", return_string, &string); // note the &
 * 
 * @param return_string string pointer cast to void* which holds the string to be returned
 * @param result dbi_result pointer
 * @return 0 (always, due to SQLite policy, may change in the future)
 */
int tagsistant_return_string(void *return_string, dbi_result result)
{
	gchar **result_string = (gchar **) return_string;

	*result_string = dbi_result_get_string_copy_idx(result, 1);

	dbg('s', LOG_INFO, "Returning string: %s", *result_string);

	return (0);
}
Beispiel #3
0
char *dbi_result_get_string_copy(dbi_result Result, const char *fieldname) {
  char *ERROR = "ERROR";
  unsigned int fieldidx;
  dbi_error_flag errflag;

  fieldidx = _find_field(RESULT, fieldname, &errflag);
  if (errflag != DBI_ERROR_NONE) {
    dbi_conn_t *conn = RESULT->conn;
    _error_handler(conn, DBI_ERROR_BADNAME);
    return strdup(ERROR);
  }
  return dbi_result_get_string_copy_idx(Result, fieldidx+1);
}