当前位置: 首页>>代码示例>>C++>>正文


C++ do_update函数代码示例

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


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

示例1: set_disq_comment_func

static int
set_disq_comment_func(
        struct xuser_cnts_state *data,
        int user_id,
        const unsigned char *disq_comment)
{
    struct xuser_mongo_cnts_state *state = (struct xuser_mongo_cnts_state *) data;
    struct team_extra *extra = do_get_entry(state, user_id);
    if (!extra) return -1;
    if (!extra->disq_comment && !disq_comment) {
        return 0;
    }
    if (extra->disq_comment && !disq_comment) {
        ASSERT(ej_uuid_is_nonempty(extra->uuid));
        xfree(extra->disq_comment); extra->disq_comment = NULL;
        bson *doc = bson_new();
        bson_append_string(doc, "disq_comment", "", 0);
        bson_finish(doc);
        return do_update(state, extra, "$unset", doc);
    }
    if (extra->disq_comment && !strcmp(extra->disq_comment, disq_comment))
        return 0;
    xfree(extra->disq_comment);
    extra->disq_comment = xstrdup(disq_comment);
    if (ej_uuid_is_nonempty(extra->uuid)) {
        bson *doc = bson_new();
        bson_append_string(doc, "disq_comment", extra->disq_comment, strlen(extra->disq_comment));
        bson_finish(doc);
        return do_update(state, extra, NULL, doc);
    } else {
        return do_insert(state, extra);
    }
}
开发者ID:NUOG,项目名称:ejudge,代码行数:33,代码来源:xuser_mongo.c

示例2: handle_transfer_command

int
handle_transfer_command(struct thread_data_t * datum, char * args)
{
  long amount, balance;
  char * user, buffer[MAX_COMMAND_LENGTH];

  #ifndef NDEBUG
  if (*args == '\0') {
    fprintf(stderr,
            "[thread %lu] WARNING: [%s] arguments empty\n",
            datum->id, "transfer");
  } else {
    fprintf(stderr,
            "[thread %lu] INFO: [%s] '%s' (arguments)\n",
            datum->id, "transfer", args);
  }
  #endif
  amount = strtol(args, &args, 10);
  user = ++args;

  if (amount <= 0 || amount > MAX_TRANSACTION) {
    snprintf(buffer, MAX_COMMAND_LENGTH, "Invalid transfer amount.");
  } else if (datum->credentials.userlength
   && do_lookup(session_data.db_conn, NULL,
                datum->credentials.username,
                datum->credentials.userlength,
                &balance) == BANKING_SUCCESS) {
    if (balance < amount) {
      snprintf(buffer, MAX_COMMAND_LENGTH, "Insufficient funds.");
    } else if (do_update(session_data.db_conn, NULL,
               datum->credentials.username,
               datum->credentials.userlength,
               balance - amount)
            || do_lookup(session_data.db_conn, NULL,
               user, strnlen(user, MAX_COMMAND_LENGTH),
               &balance)
            || do_update(session_data.db_conn, NULL,
               user, strnlen(user, MAX_COMMAND_LENGTH),
               balance + amount)) {
      /* TODO atomic operation? */
      snprintf(buffer, MAX_COMMAND_LENGTH, "Cannot complete transfer.");
    } else {
      snprintf(buffer, MAX_COMMAND_LENGTH, "Transfered $%li to %s",
                                           amount, user);
    }
  } else {
    snprintf(buffer, MAX_COMMAND_LENGTH, "TRANSFER ERROR");
  }
  salt_and_pepper(buffer, NULL, &datum->buffet);
  encrypt_message(&datum->buffet, datum->credentials.key);
  send_message(&datum->buffet, datum->sock);

  return BANKING_SUCCESS;
}
开发者ID:hagemt,项目名称:crypto_fall2011,代码行数:54,代码来源:bank.c

示例3: select_items

static void select_items(int n) {
	int fsel = 0;

	while (42) {
		if (n > 0)
			print_item(fsel, STATUS_BG, STATUS_FG);

		switch (wait_any_key()) {
		case KEY_ENTER:
			setvar(V_sel_item, intobj[fsel]);
			goto exit_select;
		case KEY_ESCAPE:
			setvar(V_sel_item, 0xff);
			goto exit_select;
		case KEY_UP:
			if (fsel >= 2)
				fsel -= 2;
			break;
		case KEY_DOWN:
			if (fsel + 2 < n)
				fsel += 2;
			break;
		case KEY_LEFT:
			if (fsel % 2 == 1)
				fsel--;
			break;
		case KEY_RIGHT:
			if (fsel % 2 == 0 && fsel + 1 < n)
				fsel++;
			break;
		case BUTTON_LEFT:{
				int i = find_item();
				if (i >= 0 && i < n) {
					setvar(V_sel_item, intobj[fsel = i]);
					debugC(6, kDebugLevelInventory, "item found: %d", fsel);
					show_items();
					print_item(fsel, STATUS_BG, STATUS_FG);
					do_update();
					goto exit_select;
				}
				break;
			}
		default:
			break;
		}

		show_items();
		do_update();
	}

 exit_select:
	debugC(6, kDebugLevelInventory, "selected: %d", fsel);
}
开发者ID:iPodLinux-Community,项目名称:iScummVM,代码行数:53,代码来源:inv.cpp

示例4: QFrame

    items::items(editor_resource_ptr res, QWidget* parent)
      : QFrame(parent)
      , resource_(res)
    {
      setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);

      QGridLayout* l = new QGridLayout(this);
      l->setContentsMargins(0, 0, 0, 0);

      // Tablewidget
      data_ = new QTableWidget(this);

      data_->setColumnCount(3);
      data_->setHorizontalHeaderLabels(QStringList() << "Filename" << "Type" << "?");
      data_->setColumnWidth(0, 100);
      data_->setColumnWidth(1, 75);
      data_->setColumnWidth(2, 20);

      data_->verticalHeader()->setVisible(false);

      data_->setEditTriggers(QTableWidget::NoEditTriggers);
      data_->setSelectionMode(QTableWidget::SingleSelection);
      data_->setSelectionBehavior(QTableWidget::SelectRows);
      data_->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);

      l->addWidget(data_, 0, 0, 1, 2);

      // Buttons
      QPushButton* btn_edit = new QPushButton("Edit", this);
      btn_edit->setMaximumWidth(80);
      l->addWidget(btn_edit, 2, 0, Qt::AlignCenter);
      connect(btn_edit, SIGNAL(clicked()), SLOT(do_edit()));

      QPushButton* btn_add = new QPushButton("Add", this);
      btn_add->setMaximumWidth(80);
      l->addWidget(btn_add, 1, 0, Qt::AlignCenter);
      connect(btn_add, SIGNAL(clicked()), SLOT(do_add()));

      QPushButton* btn_remove = new QPushButton("Remove", this);
      btn_remove->setMaximumWidth(80);
      l->addWidget(btn_remove, 1, 1, Qt::AlignCenter);
      connect(btn_remove, SIGNAL(clicked()), SLOT(do_remove()));

      QPushButton* btn_generate = new QPushButton("Generate", this);
      btn_generate->setMaximumWidth(80);
      l->addWidget(btn_generate, 2, 1, Qt::AlignCenter);
      connect(btn_generate, SIGNAL(clicked()), SLOT(do_generate()));

      connect(resource_.data(), SIGNAL(sig_resource_updated()), SLOT(do_update()));
      do_update();
    }
开发者ID:nelbok,项目名称:MaskedDuck,代码行数:51,代码来源:items.cpp

示例5: timer_callback

// Callbacks
void timer_callback(uint unused0, uint unused1) {
    use(unused0);
    use(unused1);
    time++;

    log_debug("Timer tick %d", time);

    if ((infinite_run != TRUE) && (time == simulation_ticks)) {
        simulation_handle_pause_resume(NULL);
        log_info("Simulation complete.\n");
        simulation_ready_to_read();
    }

    // Process the incoming spikes
    spike_t s;
    uint32_t nid;
    while (in_spikes_get_next_spike(&s)) {
        nid = (s & NEURON_ID_MASK);

        if (nid < N_COUNTERS) {
            counters[nid] += 1;
        } else {
            log_debug("Received spike from unknown neuron %d", nid);
        }
    }

    // Work out if there is any motion
    if ((time % sample_time) == 0) {

        // Do motion in pairs
        do_motion(MOTION_FORWARD, MOTION_BACK, "Forwards", "Backwards");
        do_motion(MOTION_LEFT, MOTION_RIGHT, "Left", "Right");
        do_motion(MOTION_CLOCKWISE, MOTION_C_CLOCKWISE, "Clockwise",
                  "Anti-clockwise");

        // Reset the counters
        for (uint32_t i = 0; i < N_COUNTERS; i++) {
            counters[i] = 0;
        }
    } else if ((time % update_time) == 0) {

        // Do updates in pairs
        do_update(MOTION_FORWARD, MOTION_BACK, "Forwards", "Backwards");
        do_update(MOTION_LEFT, MOTION_RIGHT, "Left", "Right");
        do_update(MOTION_CLOCKWISE, MOTION_C_CLOCKWISE, "Clockwise",
                  "Anti-clockwise");
    }
}
开发者ID:SpiNNakerManchester,项目名称:sPyNNaker,代码行数:49,代码来源:robot_motor_control.c

示例6: run_application

static void run_application(MYSQL &mysql,
			    Ndb_cluster_connection &cluster_connection)
{
  /********************************************
   * Connect to database via mysql-c          *
   ********************************************/
  mysql_query(&mysql, "CREATE DATABASE TEST_DB_1");
  if (mysql_query(&mysql, "USE TEST_DB_1") != 0) MYSQLERROR(mysql);
  create_table(mysql);

  /********************************************
   * Connect to database via NdbApi           *
   ********************************************/
  // Object representing the database
  Ndb myNdb( &cluster_connection, "TEST_DB_1" );
  if (myNdb.init()) APIERROR(myNdb.getNdbError());

  /*
   * Do different operations on database
   */
  do_insert(myNdb);
  do_update(myNdb);
  do_delete(myNdb);
  do_read(myNdb);
  drop_table(mysql);
  mysql_query(&mysql, "DROP DATABASE TEST_DB_1");
}
开发者ID:A-eolus,项目名称:mysql,代码行数:27,代码来源:ndbapi_simple.cpp

示例7: done_jiqi

int done_jiqi(object me) {
	
	string msg;
	
	if (!me || me->is_ghost() || environment(me)!= this_object())
		return 1;
		
	if (me->query_temp("jiqi/num")>=3) {
		msg = HIR"
һ�������ֻ���������������������ȫ������֮�У�����һ����
ˮ���ڵ�����ת�������ޱȡ�ǡ��ˮ����ã��������ᣬ������ʮ��
����һһ���ƣ����Ǵ󹦸���ˡ�\n\n"NOR;
		me->delete_temp("jiqi");
		do_update(me);
		if (me->query("eff_kee")>me->query("max_kee")) me->set("eff_kee",me->query("max_kee"));
		if (me->query("eff_gin")>me->query("max_gin")) me->set("eff_gin",me->query("max_gin"));
		if (me->query("eff_sen")>me->query("max_sen")) me->set("eff_sen",me->query("eff_sen"));
		if (me->query("kee")>me->query("eff_kee")) me->set("kee",me->query("eff_kee"));
		if (me->query("gin")>me->query("eff_gin")) me->set("gin",me->query("eff_gin"));
		if (me->query("sen")>me->query("eff_sen")) me->set("sen",me->query("eff_sen"));
	} else {
		msg = YEL"
һ�������ֻ���������������������ȫ������֮�У�����һ����
ˮ���ڵ�����ת�������ޱȡ�\n\n"NOR;
		me->delete_temp("jiqi/in_tuna");
	}
	tell_object(me,msg);
	me->stop_busy();
	return 1;
}
开发者ID:huangleon,项目名称:fy2005,代码行数:30,代码来源:hall.c

示例8: set_clar_status_func

static int
set_clar_status_func(
        struct xuser_cnts_state *data,
        int user_id,
        int clar_id,
        const ej_uuid_t *p_clar_uuid)
{
    struct xuser_mongo_cnts_state *state = (struct xuser_mongo_cnts_state *) data;
    struct team_extra *extra = do_get_entry(state, user_id);
    if (!extra) return -1;
    if (!p_clar_uuid) return -1;
    int r = team_extra_add_clar_uuid(extra, p_clar_uuid);
    if (r <= 0) return r;
    if (ej_uuid_is_nonempty(extra->uuid)) {
        bson *arr = ej_bson_unparse_array_uuid(extra->clar_uuids, extra->clar_uuids_size);
        bson *doc = bson_new();
        bson_append_array(doc, "clar_uuids", arr);
        bson_free(arr); arr = NULL;
        bson_finish(doc);
        return do_update(state, extra, NULL, doc);
    } else {
        return do_insert(state, extra);
    }
    return -1;
}
开发者ID:NUOG,项目名称:ejudge,代码行数:25,代码来源:xuser_mongo.c

示例9: do_choice

void do_choice(int choice)
{
	printf("is in the process of the first %d a choice \n", choice);

	switch (choice)
	{
		case INSERT :
			do_insert();
			break;
		case QUERY:
			do_query();
			break;
		case UPDATE:
			do_update();
			break;
		case DELETE:
			do_delete();
			break;
		case LIST:
			do_list_all();
			break;
		case QUIT:
			do_quit();
			break;
		default:
			break;
	}
}
开发者ID:Eaeth,项目名称:myNCCL,代码行数:28,代码来源:version2.1.c

示例10: process_cmd

short process_cmd(void) {
    char cmd[4];
    short ret = 0;

    RECV(STDIN, cmd, sizeof(cmd));

    if (0 == memcmp((void *)CMD_BUY, cmd, sizeof(CMD_BUY))) {
    	ret = do_buy();
    } else if (0 == memcmp((void *)CMD_CHECK, cmd, sizeof(CMD_CHECK))) {
    	ret = do_check();
    } else if (0 == memcmp((void *)CMD_ADD, cmd, sizeof(CMD_ADD))) {
    	ret = do_add();
    } else if (0 == memcmp((void *)CMD_RM, cmd, sizeof(CMD_RM))) {
    	ret = do_rm();
    } else if (0 == memcmp((void *)CMD_UPDATE, cmd, sizeof(CMD_UPDATE))) {
    	ret = do_update();
    } else if (0 == memcmp((void *)CMD_ONSALE, cmd, sizeof(CMD_ONSALE))) {
    	ret = do_onsale();
    } else if (0 == memcmp((void *)CMD_NOSALE, cmd, sizeof(CMD_NOSALE))) {
    	ret = do_nosale();
    } else if (0 == memcmp((void *)CMD_LIST, cmd, sizeof(CMD_LIST))) {
    	ret = do_list();
    } else if (0 == memcmp((void *)CMD_QUIT, cmd, sizeof(CMD_QUIT))) {
    	ret = -2;
    } else {
    	ret = -1;
    }

	return ret;
}
开发者ID:CyberGrandChallenge,项目名称:samples,代码行数:30,代码来源:products.c

示例11: run_application

static void run_application(MYSQL &mysql,
			    Ndb_cluster_connection &cluster_connection,
			    const char* table,
			    const char* db)
{
  /********************************************
   * Connect to database via mysql-c          *
   ********************************************/
 char db_stmt[256];
 sprintf(db_stmt, "CREATE DATABASE %s\n", db);
  mysql_query(&mysql, db_stmt);
 sprintf(db_stmt, "USE %s", db);
  if (mysql_query(&mysql, db_stmt) != 0) MYSQLERROR(mysql);
  create_table(mysql, table);

  /********************************************
   * Connect to database via NdbApi           *
   ********************************************/
  // Object representing the database
  Ndb myNdb( &cluster_connection, db );
  if (myNdb.init()) APIERROR(myNdb.getNdbError());

  /*
   * Do different operations on database
   */
  do_insert(myNdb, table);
  do_update(myNdb, table);
  do_delete(myNdb, table);
  do_read(myNdb, table);
  /*
   * Drop the table
   */
  mysql_query(&mysql, db_stmt);
}
开发者ID:ForcerKing,项目名称:ShaoqunXu-mysql5.7,代码行数:34,代码来源:main.cpp

示例12: ISeos

int
ISeos(InputStream stream)
{
    BaseStream base = &stream->base;
    if (!base->iseos && MUST_BE_UPDATED(base))
	do_update(base);
    return base->iseos;
}
开发者ID:macks,项目名称:w3m,代码行数:8,代码来源:istream.c

示例13: run_game

void run_game(nstate *state)
{
	while(state->state == STATE_RUNNING) {
		GrGetNextEventTimeout(&state->event, timeout_delay(state));
		handle_event(state);
		if(state->state == STATE_PAUSED) do_pause(state);
		if(state->state == STATE_RUNNING) do_update(state);
	}
}
开发者ID:Joel397,项目名称:Ongoing_work_files,代码行数:9,代码来源:ntetris.c

示例14: deposit_command

int
deposit_command(char * args)
{
  size_t len, i;
  char * username;
  const char * residue;
  long int amount, balance;

  /* Advance args to the first token, this is the username */
  len = strnlen(args, MAX_COMMAND_LENGTH);
  for (i = 0; *args == ' ' && i < len; ++i, ++args);
  for (username = args; *args != '\0' && i < len; ++i, ++args) {
    if (*args == ' ') { *args = '\0'; i = len; }
  }
  len = strnlen(username, (size_t)(args - username));

  /* We should now be at the addition amount */
  amount = strtol(args, (char **)(&residue), 10);
  #ifndef NDEBUG
  if (*residue != '\0') {
    fprintf(stderr,
            "WARNING: ignoring '%s' (argument residue)\n",
            residue);
  }
  #endif

  /* Ensure the transaction amount is sane, TODO better solution? */
  if (amount < -MAX_TRANSACTION || amount > MAX_TRANSACTION) {
    fprintf(stderr,
            "ERROR: amount (%li) exceeds maximum transaction (%i)\n",
            amount, MAX_TRANSACTION);
    return BANKING_SUCCESS;
  }

  /* Prepare and run actual queries */
  if (do_lookup(session_data.db_conn, &residue,
                username, len, &balance)) {
    fprintf(stderr, "ERROR: no account found for '%s'\n", username);
  } else if (do_update(session_data.db_conn, &residue,
                       username, len, balance + amount)) {
    fprintf(stderr,
            "ERROR: unable to complete request on ('%s', %li)\n",
            username, balance);
  } else {
    printf("A transaction of $%li brings %s's balance from $%li to $%li\n",
           amount, username, balance, balance + amount);
  }
  #ifndef NDEBUG
  if (*residue != '\0') {
    fprintf(stderr, "WARNING: ignoring '%s' (query residue)\n", residue);
  }
  #endif

  return BANKING_SUCCESS;
}
开发者ID:hagemt,项目名称:crypto_fall2011,代码行数:55,代码来源:bank.c

示例15: update_file

/*
 * update a single file.
 * parse the "tokens" and check the version
 * if the version is newer, update it from the website
 */
static void update_file(char *tokens)
{
   char *file = NULL;
   char *rev = NULL;
   char *curr = NULL;
   char *url = NULL;
   size_t i, n = 0;
   char *tok;
   char errbuf[ERR_MAX_LEN];
  
   DEBUG_MSG("update_file");

   /* count the number of tokens delimited by ' ' */
   for (i = 0; i < strlen(tokens); i++)
      if (tokens[i] == ' ')
         n++;

   /* the token is invalid */
   if (n != 2)
      return;
   
   /* split the tokens */
   file = strdup(ec_strtok(tokens, " ", &tok));
   rev = strdup(ec_strtok(NULL, " ", &tok));
   url = strdup(ec_strtok(NULL, " ", &tok));
   
   /* get the current revision */
   if (get_current_rev(file, &curr, errbuf) == 0) {
      fprintf(stdout, " + %-18s -> "EC_COLOR_RED"ERROR"EC_COLOR_END"  %s\n", file, errbuf);
   } else {
      fprintf(stdout, " + %-18s -> revision "EC_COLOR_BLUE"%-4s"EC_COLOR_END" updating to "EC_COLOR_CYAN"%-4s"EC_COLOR_END"... ", file, curr, rev );
      fflush(stdout);
  
      /* update it if the current rev is different (newer) */
      if (!strcmp(curr, rev))
         fprintf(stdout, EC_COLOR_GREEN"OK"EC_COLOR_END"\n");
      else if (strcmp(curr, rev) < 0) {
         if (GBL_OPTIONS->silent)
            fprintf(stdout, EC_COLOR_YELLOW"NEED UPDATE"EC_COLOR_END"\n");
         else { 
            if (do_update(file, url, errbuf))
               fprintf(stdout, EC_COLOR_YELLOW"UPDATED"EC_COLOR_END"\n");
            else
               fprintf(stdout, EC_COLOR_RED"ERROR"EC_COLOR_END"  %s\n", errbuf);
         }
      } else
         fprintf(stdout, EC_COLOR_RED"NEWER"EC_COLOR_END"  %s\n", errbuf);
         
   }
   
   SAFE_FREE(curr);
   SAFE_FREE(file);
   SAFE_FREE(rev);
   SAFE_FREE(url);
}
开发者ID:SpiderLabs,项目名称:ettercap,代码行数:60,代码来源:ec_update.c


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