• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ dbi_result_free函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中dbi_result_free函数的典型用法代码示例。如果您正苦于以下问题:C++ dbi_result_free函数的具体用法?C++ dbi_result_free怎么用?C++ dbi_result_free使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了dbi_result_free函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: update_server_color

//*******************************************************************
// UPDATE SERVER COLOR
//*******************************************************************
static void update_server_color(trx *t, struct probe_result *prv)
{
  dbi_result result;
  int maxcolor, newcolor;

  if (t->def->server < 2) return;

  if (t->probe->fuse && (t->res->color < prv->color)) {
    // if this probe acts like a fuse, use the previous color if it's higher
    newcolor = prv->color;
  } else {
    newcolor = t->res->color;
  }
  maxcolor = newcolor; // init

  result = db_query(t->probe->db, 0,
                    "select max(color) as color from pr_status where server = '%u'", t->def->server);
  if (result && dbi_result_next_row(result)) {
    maxcolor = dbi_result_get_uint(result, "color");
  }
  dbi_result_free(result);
  //if (t->res->color <= maxcolor) return;

  result = db_query(t->probe->db, 0,
                    // update server set color = '200' where id = '345'
                    "update %s set %s = '%u' where %s = '%u'",
                     OPT_ARG(SERVER_TABLE_NAME), OPT_ARG(SERVER_TABLE_COLOR_FIELD), 
                     maxcolor, OPT_ARG(SERVER_TABLE_ID_FIELD), t->def->server);
  dbi_result_free(result);
}
开发者ID:BackupTheBerlios,项目名称:upwatch-svn,代码行数:33,代码来源:process.c


示例2: main

int
main (int argc, char *argv[])
{
  dbi_conn conn;
  dbi_result result;
  const char *err_msg;
  int err_code;

  if (argc < 2)
    {
      fprintf (stderr, "%s: Need a libdir as argument!\n", argv[0]);
      return 1;
    }

  dbi_initialize (argv[1]);

  conn = dbi_conn_new ("null");
  dbi_conn_connect (conn);

  /*
   * Queries
   */
  result = dbi_conn_query (conn, "COMMIT");
  assert (result != NULL);
  dbi_result_free (result);

  dbi_conn_set_option_numeric (conn, "null.error.commit", 1);
  result = dbi_conn_query (conn, "COMMIT");
  assert (result == NULL);

  dbi_conn_set_option_numeric (conn, "null.error.commit", 0);
  result = dbi_conn_query (conn, "COMMIT");
  assert (result != NULL);
  dbi_result_free (result);

  /*
   * Normal queries
   */
  result = dbi_conn_query (conn, "SELECT * FROM DUAL");
  assert (result != NULL);
  dbi_result_free (result);

  dbi_conn_set_option_numeric (conn, "null.error.query", 1);
  result = dbi_conn_query (conn, "SELECT * FROM DUAL");
  assert (result == NULL);

  dbi_conn_set_option_numeric (conn, "null.error.query", 0);
  result = dbi_conn_query (conn, "SELECT * FROM DUAL");
  assert (result != NULL);
  dbi_result_free (result);

  /*
   * Cleanup
   */
  dbi_conn_close (conn);

  dbi_shutdown ();

  return 0;
}
开发者ID:Smellerbe,项目名称:dbd-null,代码行数:60,代码来源:test-dbd-null-error.c


示例3: calc_ser_cds

static void calc_ser_cds(struct module *mod, dbi_conn conn, int interval)
{
    int ct = 0, st = 0;
    dbi_result result = 0;
    ST_CDS *ps = NULL;
    ST_CDS *pe = NULL;
    long long rst = 0;

    ps = (ST_CDS *)mod->ser_array;
    pe = (ST_CDS *)mod->emp_array;

    st = 0;
    /* acquire ser uss stats */
    result = dbi_conn_queryf(conn, "select d_id from \"T_Device\" where d_type = 'mds' order by d_id");
    if (result) {
        while(dbi_result_next_row(result)) {
            ps[st].sdr_id = dbi_result_get_longlong(result, "d_id");
            convert_time_to_string(statis.cur_time, ps[st].sdr_record_time, 0);
            convert_time_to_string(statis.cur_time - 24*60*60, ps[st].sdr_time, 1);
            if (interval == 0) {
                ps[st].sdr_date_flag = 0;
            } else if (interval == 7) {
                ps[st].sdr_date_flag = 1;
            } else {
                ps[st].sdr_date_flag = 2;
            }
            st++;
        }
        dbi_result_free(result);
    }

    for (st = 0; st < mod->ser_record; st++)
    {
        result = dbi_conn_queryf(conn, "select e_id from \"T_Enterprise\" where \
                e_mds_id = %lld order by e_id ", ps[st].sdr_id);
        if (result) {
            while(dbi_result_next_row(result)) {
                rst = dbi_result_get_longlong(result, "e_id");
                for (ct = 0; ct < mod->emp_record; ct++) {
                    if (rst == pe[ct].sdr_id) {
                        ps[st].sdr_ptt_htime += pe[ct].sdr_ptt_htime;
                        ps[st].sdr_ptt_hcount += pe[ct].sdr_ptt_hcount;
                        ps[st].sdr_call_htime += pe[ct].sdr_call_htime;
                        ps[st].sdr_call_hcount += pe[ct].sdr_call_hcount;
                        ps[st].sdr_video_htime += pe[ct].sdr_video_htime;
                        ps[st].sdr_video_hcount += pe[ct].sdr_video_hcount;
                        ps[st].sdr_audio_htime += pe[ct].sdr_audio_htime;
                        ps[st].sdr_audio_hcount += pe[ct].sdr_audio_hcount;
                    }
                }
            }
            dbi_result_free(result);
        }
    }

    //log_cds_stats(ps, mod->ser_record);

    return;
}
开发者ID:longlovehehe,项目名称:gds,代码行数:59,代码来源:mod_cds.c


示例4: dateconds_execute

/////////////////////////////////////////////////////////////////////////////////
//
// Function:
//
// Purpose:
//
// Parameters:
//
// Return value:
//
// Author: Komatsu Yuji(Zheng Chuyu)
//
/////////////////////////////////////////////////////////////////////////////////
int dateconds_execute(const apr_uint64_t proc_jobunit_id,
                      const time_t base_time, const int beginning_of_week)
{
    int rc, rv;
    dbi_result result;
    datecond_t *obj = NULL;
    struct tm *tm = NULL;

    jhklog_trace
        ("In %s() proc_jobunit_id: %llu, base_time: %ld, beginning_of_week: %d",
         __func__, proc_jobunit_id, base_time, beginning_of_week);

    result =
        jhkdb_select
        ("SELECT * FROM proc_dateconds WHERE proc_jobunit_id = %llu",
         proc_jobunit_id);
    if (result == NULL)
        return -1;

    // unset date conditions
    if (dbi_result_get_numrows(result) == 0) {
        dbi_result_free(result);
        return CONNECTOR_KIND_NORMAL;
    }
    // init
    rc = -1;
    obj = datecond_new();

    // date condition
    while (dbi_result_next_row(result)) {
        datecond_load(obj, result);
        rv = datecond_execute(obj, base_time, beginning_of_week);
        if (rv == JHAKO_FALSE)
            continue;

        if (rv == JHAKO_TRUE) {
            rc = CONNECTOR_KIND_NORMAL;
        } else {
            rc = CONNECTOR_KIND_ERROR;
        }
        goto finish;
    }

    rc = CONNECTOR_KIND_BRANCH;
  finish:
    datecond_destroy(obj);
    dbi_result_free(result);
    return rc;
}
开发者ID:komatsuyuji,项目名称:jhako,代码行数:62,代码来源:datecond.c


示例5: delete_history

//*******************************************************************
// REMOVE ALL OCCURRENCES OF A PROBE IN THE HISTORY FILES
//*******************************************************************
static void delete_history(trx *t, struct probe_result *nxt)
{
  dbi_result result;

  result = db_query(t->probe->db, 0,
                    "delete from pr_hist "
                    "where stattime = '%u' and probe = '%u' and class = '%d'",
                    nxt->stattime, t->def->probeid, t->probe->class);
  dbi_result_free(result);
  result = db_query(t->probe->db, 0,
                    "delete from pr_status "
                    "where stattime = '%u' and probe = '%u' and class = '%d'",
                    nxt->stattime, t->def->probeid, t->probe->class);
  dbi_result_free(result);
}
开发者ID:BackupTheBerlios,项目名称:upwatch-svn,代码行数:18,代码来源:process.c


示例6: g_malloc0

//*******************************************************************
// RETRIEVE PRECEDING RAW RECORD FROM DATABASE (well just the color)
//*******************************************************************
static struct probe_result *get_previous_record(trx *t)
{
  dbi_result result;
  struct probe_result *prv;

  prv = g_malloc0(sizeof(struct probe_result));
  if (prv == NULL) {
    return(NULL);
  }
  prv->stattime = t->res->stattime;
  prv->color = t->res->color;

  if (!t->probe->store_results) return(prv); // we probably don't have a xxxx_raw table

  result = db_query(t->probe->db, 0,
                    "select   color, stattime "
                    "from     pr_%s_raw use index(probstat) "
                    "where    probe = '%u' and stattime < '%u' "
                    "order by stattime desc limit 1", 
                    t->res->name, t->def->probeid, t->res->stattime);
  if (!result) return(prv);
  if (dbi_result_next_row(result)) {
    prv->color = dbi_result_get_uint(result, "color");
    prv->stattime = dbi_result_get_uint(result, "stattime");
  }
  dbi_result_free(result);
  t->res->prevcolor = prv->color;
  return(prv);
}
开发者ID:BackupTheBerlios,项目名称:upwatch-svn,代码行数:32,代码来源:process.c


示例7: rpserver_db_authenticate

int rpserver_db_authenticate(dbi_conn db, const char *user, const char *password)
{
  int retval = AUTH_UNKNOWN_USER;
  dbi_result result;

  LOG(LOG_INFO, "%s():%d - username: %s  password: %s", __FUNCTION__, __LINE__, user, password);

  return 0;

  result = dbi_conn_queryf(db, 
                           "SELECT * FROM `users` WHERE `username` = '%s' AND `password` = MD5('%s')",
                           user, password);

  LOG(LOG_INFO, "%s():%d - SELECT * FROM `users` WHERE `username` = '%s' AND `password` = '%s'", 
         __FUNCTION__, __LINE__, user, password);

  if (result) {
    if( dbi_result_get_numrows(result) == 1 ) {
      while (dbi_result_next_row(result)) {
          LOG(LOG_INFO, "%s():%d - User \"%s\" is known and ACTIVE.",
                 __FUNCTION__, __LINE__, user);
          retval = AUTH_VALID;
      } 
    } else {
      LOG(LOG_INFO, "%s():%d - User \"%s\" is unknown",
             __FUNCTION__, __LINE__, user);
    }
  }
  dbi_result_free(result);

  return retval;
}
开发者ID:energinet,项目名称:datalogger-server,代码行数:32,代码来源:rpserver_db.c


示例8: ensure_connection

swd::blacklist_filters swd::database::get_blacklist_filters() {
    swd::log::i()->send(swd::notice, "Get blacklist filters from db");

    ensure_connection();

    boost::unique_lock<boost::mutex> scoped_lock(dbi_mutex_);

    dbi_result res = dbi_conn_query(conn_, "SELECT id, impact, rule FROM blacklist_filters");

    if (!res) {
        throw swd::exceptions::database_exception("Can't execute blacklist_filters query");
    }

    swd::blacklist_filters filters;

    while (dbi_result_next_row(res)) {
        swd::blacklist_filter_ptr filter(new swd::blacklist_filter());
        filter->set_id(dbi_result_get_uint(res, "id"));
        filter->set_impact(dbi_result_get_uint(res, "impact"));
        filter->set_regex(dbi_result_get_string(res, "rule"));

        filters.push_back(filter);
    }

    dbi_result_free(res);

    return filters;
}
开发者ID:MiauWuffMiau,项目名称:shadowd,代码行数:28,代码来源:database.cpp


示例9: query_handler

static char
query_handler(char *query_name, char *myq)
{

    if(myq == NULL) {
        myq = "SELECT NULL";
    }
    if(query_name == NULL) {
        query_name = "noname";
    }
    if(query_name == "") {
        query_name = "noname";
    }
    dbi_initialize(NULL);
    conn = dbi_conn_new("mysql");
    dbi_conn_set_option(conn, "host", getenv("DB_HOSTNAME"));
    dbi_conn_set_option(conn, "username", getenv("DB_USERNAME"));
    dbi_conn_set_option(conn, "password", getenv("DB_PASSWORD"));
    dbi_conn_set_option(conn, "dbname", getenv("DB_DATABASE"));
    dbi_conn_set_option(conn, "encoding", "UTF-8");
    if (dbi_conn_connect(conn) < 0) {
        printf("Could not connect. Please check the option settings and if the" \
            "specific driver is available\n");
    } else {
        result = dbi_conn_queryf(conn, myq, threshold);
        if (result) {
        xmlAddChild(sql_node,query_doc(result,query_name));
        dbi_result_free(result);
        }
        dbi_conn_close(conn);
    }
    return 0;

}
开发者ID:savonix,项目名称:dbrs2xml,代码行数:34,代码来源:fcgi_in_c_example.c


示例10: com_test

///////////////////////////////////
// developer's utils ;-)
int com_test(int p, param_list param)
{
	dbi_result result;
	unsigned int idnumber;
	const char *fullname;
	 int j,k;
	 for(k=1;k<10;k++)
	 {
	 for(j=1; j<100; j++)
	 {
		 char *fen=get_fen();
		 result = dbi_conn_queryf(conn, "INSERT INTO test (fen) values ('%s')",fen);
		 FREE(fen);
		 if (result) {
			while (dbi_result_next_row(result)) {
			  pprintf(p,"OK\n");
			}
			dbi_result_free(result);
			}
			else
			{
			  //pprintf(p,"no result\n");
			}
	 }
	}
  pprintf(p,"OK\n");
	return COM_OK;
}
开发者ID:SKAcz,项目名称:bics-current,代码行数:30,代码来源:adminproc.c


示例11: dateconds_put_history

/////////////////////////////////////////////////////////////////////////////////
//
// Function:
//
// Purpose:
//
// Parameters:
//
// Return value:
//
// Author: Komatsu Yuji(Zheng Chuyu)
//
/////////////////////////////////////////////////////////////////////////////////
int dateconds_put_history(const apr_uint64_t proc_jobunit_id,
                          const apr_uint64_t hist_jobunit_id)
{
    int rc;
    datecond_t *obj;
    dbi_result result;

    jhklog_debug("In %s() proc_jobunit_id: %llu, hist_jobunit_id: %llu",
                 __func__, proc_jobunit_id, hist_jobunit_id);

    result =
        jhkdb_select
        ("SELECT * FROM proc_dateconds WHERE proc_jobunit_id = %llu",
         proc_jobunit_id);
    if (result == NULL)
        return -1;

    rc = -1;
    obj = datecond_new();
    while (dbi_result_next_row(result)) {
        datecond_load(obj, result);
        obj->hist_jobunit_id = hist_jobunit_id;
        if (hist_datecond_insert(obj) == 0)
            goto error;
    }

    rc = 0;
  error:
    datecond_destroy(obj);
    dbi_result_free(result);
    return rc;
}
开发者ID:komatsuyuji,项目名称:jhako,代码行数:45,代码来源:datecond.c


示例12: afsql_dd_run_query

/**
 * afsql_dd_run_query:
 *
 * Run an SQL query on the connected database.
 *
 * NOTE: This function can only be called from the database thread.
 **/
static gboolean
afsql_dd_run_query(AFSqlDestDriver *self, const gchar *query, gboolean silent, dbi_result *result)
{
  dbi_result db_res;

  msg_debug("Running SQL query",
            evt_tag_str("query", query),
            NULL);

  db_res = dbi_conn_query(self->dbi_ctx, query);
  if (!db_res)
    {
      const gchar *dbi_error;

      if (!silent)
        {
          dbi_conn_error(self->dbi_ctx, &dbi_error);
          msg_error("Error running SQL query",
                    evt_tag_str("type", self->type),
                    evt_tag_str("host", self->host),
                    evt_tag_str("port", self->port),
                    evt_tag_str("user", self->user),
                    evt_tag_str("database", self->database),
                    evt_tag_str("error", dbi_error),
                    evt_tag_str("query", query),
                    NULL);
        }
      return FALSE;
    }
  if (result)
    *result = db_res;
  else
    dbi_result_free(db_res);
  return TRUE;
}
开发者ID:algernon,项目名称:syslog-ng-old,代码行数:42,代码来源:afsql.c


示例13: afsql_dd_ensure_table_is_syslogng_conform

/**
 * afsql_dd_validate_table:
 *
 * Check if the given table exists in the database. If it doesn't
 * create it, if it does, check if all the required fields are
 * present and create them if they don't.
 *
 * NOTE: This function can only be called from the database thread.
 **/
static gboolean
afsql_dd_ensure_table_is_syslogng_conform(AFSqlDestDriver *self, GString *table)
{
  dbi_result db_res = NULL;
  gboolean success = FALSE;

  if (self->flags & AFSQL_DDF_DONT_CREATE_TABLES)
    return TRUE;

  _sanitize_sql_identifier(table->str);

  if (_is_table_syslogng_conform(self, table->str))
    return TRUE;

  if (_is_table_present(self, table->str, &db_res))
    {
      /* table exists, check structure */
      success = _ensure_table_is_syslogng_conform(self, db_res, table->str);
      if (db_res)
        dbi_result_free(db_res);
    }
  else
    {
      /* table does not exist, create it */
      success = _table_create(self, table->str) && _table_create_indexes(self, table->str);
    }

  if (success)
    {
      /* we have successfully created/altered the destination table, record this information */
      _remember_table_as_syslogng_conform(self, table->str);
    }

  return success;
}
开发者ID:jbfuzier,项目名称:syslog-ng,代码行数:44,代码来源:afsql.c


示例14: get_table_list

template<> StrVec
GncDbiProviderImpl<DbType::DBI_MYSQL>::get_index_list (dbi_conn conn)
{
    StrVec retval;
    const char* errmsg;
    auto tables = get_table_list(conn, "");
    for (auto table_name : tables)
    {
        auto result = dbi_conn_queryf (conn,
                                       "SHOW INDEXES IN %s WHERE Key_name != 'PRIMARY'",
                                       table_name.c_str());
        if (dbi_conn_error (conn, &errmsg) != DBI_ERROR_NONE)
        {
            PWARN ("Index Table Retrieval Error: %s on table %s\n",
                   errmsg, table_name.c_str());
            continue;
        }

        while (dbi_result_next_row (result) != 0)
        {
            std::string index_name {dbi_result_get_string_idx (result, 3)};
            retval.push_back(index_name + " " + table_name);
        }
        dbi_result_free (result);
    }

    return retval;
}
开发者ID:Mechtilde,项目名称:gnucash,代码行数:28,代码来源:gnc-dbiproviderimpl.hpp


示例15: rpserver_db_pair_lookup

int rpserver_db_pair_lookup(dbi_conn *db, const char *localid, char *buf, size_t maxlen)
{
    
    dbi_result *result; 
    int len = 0;
        
    result = dbi_conn_queryf(db,  
			     "SELECT hname FROM "DB_TABLE_DEVICES
			     " WHERE localid='%s' AND name IS NULL "
			     ,localid);

    if(result){
	if(dbi_result_next_row(result)) {
	    len +=  snprintf(buf+len, maxlen-len, "%s",
			     dbi_result_get_string(result, "hname"));
	} 
    } else {
        const char *err;
        dbi_conn_error(db, &err);
        LOG(LOG_INFO, "%s():%d - dbi error querying database (%s)\n", 
            __FUNCTION__, __LINE__, err);
        return -1;
    }

    dbi_result_free(result);

    return len;

    
}
开发者ID:energinet,项目名称:datalogger-server,代码行数:30,代码来源:rpserver_db.c


示例16: dbi_conn_queryf

template <DbType P> void
GncDbiProviderImpl<P>::drop_index(dbi_conn conn, const std::string& index)
{
    dbi_result result = dbi_conn_queryf (conn, "DROP INDEX %s", index.c_str());
    if (result)
        dbi_result_free (result);
}
开发者ID:Mechtilde,项目名称:gnucash,代码行数:7,代码来源:gnc-dbiproviderimpl.hpp


示例17: db_add_registration

/**
 * Add a new registration to the database
 *
 * @param c the db configuration
 * @param s the server
 * @param r the registration
 *
 * @return 1 on success
 */
int db_add_registration(struct config *c, struct server *s, struct registration *r)
{
	char *req = "INSERT INTO registrations (server_id, serveradmin, name, password) VALUES (%i, %i, %s, %s);";
	char *quoted_name, *quoted_pass;
	dbi_result res;
	struct channel *ch;
	struct player_channel_privilege *priv;
	size_t iter, iter2;

	dbi_conn_quote_string_copy(c->conn, r->name, &quoted_name);
	dbi_conn_quote_string_copy(c->conn, r->password, &quoted_pass);

	res = dbi_conn_queryf(c->conn, req, s->id, r->global_flags, quoted_name, quoted_pass);
	if (res == NULL) {
		logger(LOG_WARN, "db_add_registration : SQL query failed");
	} else {
		r->db_id = dbi_conn_sequence_last(c->conn, NULL);
		dbi_result_free(res);
	}
	free(quoted_pass);
	free(quoted_name);

	ar_each(struct channel *, ch, iter, s->chans)
		ar_each(struct player_channel_privilege *, priv, iter2, ch->pl_privileges)
			if (priv->reg == PL_CH_PRIV_REGISTERED && priv->pl_or_reg.reg == r) {
				logger(LOG_INFO, "db_add_registration : adding a new pl_chan_priv");
				db_add_pl_chan_priv(c, priv);
			}
		ar_end_each;
	ar_end_each;
	return 1;
}
开发者ID:3050860,项目名称:soliloque-server,代码行数:41,代码来源:db_registration.c


示例18: db_create_registrations

/**
 * Go through the database, read and add to the server all
 * the registrations stored.
 *
 * @param c the configuration of the db
 * @param s the server
 */
int db_create_registrations(struct config *c, struct server *s)
{
	char *q = "SELECT * FROM registrations WHERE server_id = %i;";
	struct registration *r;
	char *name, *pass;
	dbi_result res;

	res = dbi_conn_queryf(c->conn, q, s->id);

	if (res) {
		while (dbi_result_next_row(res)) {
			r = new_registration();
			r->db_id = dbi_result_get_uint(res, "id");
			r->global_flags = dbi_result_get_uint(res, "serveradmin");
			name = dbi_result_get_string_copy(res, "name");
			strncpy(r->name, name, MIN(29, strlen(name)));
			pass = dbi_result_get_string_copy(res, "password");
			strcpy(r->password, pass);
			add_registration(s, r);
			/* free temporary variables */
			free(pass); free(name);
		}
		dbi_result_free(res);
	}
	return 1;
}
开发者ID:3050860,项目名称:soliloque-server,代码行数:33,代码来源:db_registration.c


示例19: find_expired_probes

int find_expired_probes(struct dbspec *dbspec)
{
  xmlDocPtr doc;
  xmlNodePtr probe;
  dbi_result result;
  dbi_conn conn;
  int count = 0;
  char buf[10];

  sprintf(buf, "%d", dbspec->port);

  conn = open_database(OPT_ARG(DBTYPE), dbspec->host, buf, dbspec->db,
                     dbspec->user, dbspec->password);
  if (!conn) return 0;

  doc = UpwatchXmlDoc("result", NULL);

  // find all expired probes, but skip those for which processing
  // has been stopped for some reason
  result = db_query(conn, 0, "select probe.name, pr_status.probe, " 
                             "       pr_status.server, pr_status.color, "
                             "       pr_status.expires "
                             "from   pr_status, probe "
                             "where  probe.id = pr_status.class and color <> 400 "
                             "       and expires < UNIX_TIMESTAMP()-30 "
                             "       and expires < probe.lastseen"
                             "       and probe.expiry = 'yes'");
  if (!result) goto errexit;

  while (dbi_result_next_row(result)) {
    char buffer[256];
    time_t now = time(NULL);

    probe = xmlNewChild(xmlDocGetRootElement(doc), NULL, dbi_result_get_string(result, "name"), NULL);
    xmlSetProp(probe, "realm", dbspec->realm);
    xmlSetProp(probe, "id", dbi_result_get_string(result, "probe"));
    xmlSetProp(probe, "server", dbi_result_get_string(result, "server"));
    sprintf(buffer, "%u", (int) now);	xmlSetProp(probe, "date", buffer);
    xmlSetProp(probe, "expires", dbi_result_get_string(result, "expires"));

    xmlNewChild(probe, NULL, "color", "400");  // PURPLE
    xmlNewChild(probe, NULL, "prevcolor", dbi_result_get_string(result, "color"));

    LOG(LOG_INFO, "%s: purpled %s %d", dbspec->realm, dbi_result_get_string(result, "name"), 
                                                      dbi_result_get_uint(result, "probe"));
    count++;
  }
  if (count) {
    xmlSetDocCompressMode(doc, OPT_VALUE_COMPRESS);
    spool_result(OPT_ARG(SPOOLDIR), OPT_ARG(OUTPUT), doc, NULL);
    LOG(LOG_INFO, "%s: purpled %u probes", dbspec->realm, count);
  }

errexit:
  if (result) dbi_result_free(result);
  if (conn) close_database(conn);
  if (doc) xmlFreeDoc(doc);
  return count;
}
开发者ID:BackupTheBerlios,项目名称:upwatch-svn,代码行数:59,代码来源:run.c


示例20: refresh_database

void refresh_database(dbi_conn conn)
{
  dbi_result result;
  char qry[1024];

  sprintf(qry,  "SELECT pr_pop3_def.id, pr_pop3_def.domid, pr_pop3_def.tblid, pr_realm.name, "
                "       pr_pop3_def.ipaddress, pr_pop3_def.username, "
                "       pr_pop3_def.password, "
                "       pr_pop3_def.yellow,  pr_pop3_def.red "
                "FROM   pr_pop3_def, pr_realm "
                "WHERE  pr_pop3_def.id > 1 and pr_pop3_def.disable <> 'yes'"
                "       and pr_pop3_def.pgroup = '%d' and pr_realm.id = pr_pop3_def.domid",
                (unsigned)OPT_VALUE_GROUPID);

  result = db_query(conn, 1, qry);
  if (!result) {
    return;
  }
    
  while (dbi_result_next_row(result)) {
    int id;
    struct probedef *probe;

    id = dbi_result_get_uint(result, "id");
    probe = g_hash_table_lookup(cache, &id);
    if (!probe) {
      probe = g_malloc0(sizeof(struct probedef));
      if (dbi_result_get_uint(result, "domid") > 1) {
        probe->probeid = dbi_result_get_uint(result, "tblid");
        probe->realm=strdup(dbi_result_get_string(result, "name"));
      } else {
        probe->probeid = probe->id;
      }
      g_hash_table_insert(cache, guintdup(id), probe);
    }

    if (probe->ipaddress) g_free(probe->ipaddress);
    probe->ipaddress = dbi_result_get_string_copy(result, "ipaddress");
    if (probe->username) g_free(probe->username);
    probe->username = dbi_result_get_string_copy(result, "username");
    if (probe->password) g_free(probe->password);
    probe->password = dbi_result_get_string_copy(result, "password");
    probe->yellow = dbi_result_get_float(result, "yellow");
    probe->red = dbi_result_get_float(result, "red");
    if (probe->msg) g_free(probe->msg);
    probe->msg = NULL;
    probe->seen = 1;
  }
  if (dbi_conn_error_flag(conn)) {
    const char *errmsg;
    dbi_conn_error(conn, &errmsg);
    LOG(LOG_ERR, "%s", errmsg);
    g_hash_table_foreach(cache, reset_seen, NULL);
  } else {
    g_hash_table_foreach_remove(cache, return_seen, NULL);
  }
  dbi_result_free(result);
}
开发者ID:BackupTheBerlios,项目名称:upwatch-svn,代码行数:58,代码来源:run.c



注:本文中的dbi_result_free函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ dbinit函数代码示例发布时间:2022-05-30
下一篇:
C++ dbi_next函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap