void Table::add_instruction ( std::string& predicate, std::string& operation, std::string& destination, std::string& operand1, std::string& operand2, std::string& shift_type, std::string& shamt ) { Instruction op; get_predicate(predicate, op); get_operation(operation, op); get_destination(destination, op); get_operand1(operand1, op); get_operand2(operand2, op); get_shift_type(shift_type, op); get_shamt(shamt, op); op.stop_bit = false; op.size = instruction_size[op.type]; op.address = address; address += op.size; instructions.push(op); }
int builtin_cd(char **av, char ***envp) { char *path; if (!(get_in_env(*envp, "PWD"))) change_env_pwd(envp); path = get_destination(av, envp); if (path) { if (chdir(path)) { ft_putstr_fd("Error : can't change to this directory : ", 2); ft_putendl_fd(path, 2); return (1); } else { change_env_oldpwd(envp); change_env_pwd(envp); } } else return (1); return (0); }
/** * \brief This function is called when the map is started and * the opening transition is finished. */ void Map::notify_opening_transition_finished() { visible_surface->set_opacity(255); // because the transition effect may have changed the opacity check_suspended(); entities->notify_map_opening_transition_finished(); get_lua_context().map_on_opening_transition_finished(*this, get_destination()); }
/** This actually causes the player to pass through the exit. * \a m is the mapping with the exit information; if you want information * about the player or the room, use this_player() and environment(this_player()) * respectively. An error message is printed if the exit fails. * * A fair amount of error checking has already been done on \a m, so the core * information is most likely valid. * * \return True on success, false on failure. */ int exit_action() { string dir; object dest_room; mapping walk_dest; if( query_closed() ) { msg("The gate is closed, and impassable."); return 1; } if( previous_object()->query_is_mirror() ) { dir = previous_object()->query_dir(); dest_room = environment(); walk_dest = previous_object()->exit_shape(); } else { dir = query_dir(); dest_room = get_destination(); if( !dest_room ) { msg("Exit exists, but the destination does not exist. Report a bug."); return 0; } walk_dest = exit_shape(); } // Note that "unclipped" is set, since exits are sometimes outside of room boundaries. if( sizeof(walk_dest) ) { WALK_DAEMON->init_walk_action( walk_dest, 0, ({ 0, (previous_object()->query_is_mirror()?previous_object():this_object()), this_player(), ST_STANDING, 0 }), 1 );
int exit_action() { object dest; if( !member(query_spots(), this_player()->query_coord()) ) { msg("To go that way, you must walk onto the pad."); return 0; } else if( !query_active() ) { msg("The pad is inactive."); return 0; } dest = get_destination( link ); if( !dest ) { msg( "That exit doesn't seem to lead anywhere!"); debug(object_name(this_object()) + " complains: I'm an unlinked exit."); return 0; } this_player()->move_player( dest, "teleport" ); if( dest_coord ) this_player()->set_coord( dest_coord ); if( this_player()->query_is_player() || this_player()->query_possessor() ) "/bin/look"->main(); return 1; }
bool Soldier::update_location() { Cart_Vector vect; vect = (get_destination() - location); if (fabs(vect.x) <= fabs((get_delta()).x) && fabs(vect.y) <= fabs((get_delta()).y)) { location = get_destination(); cout << display_code << get_id() << ": I'm there!" << endl; return true; } else location.x = location.x + ((get_delta()).x); location.y = location.y + ((get_delta()).y); cout << display_code << get_id() << ": step..." << endl; return false; }
// Public methods void GlobalPlanner::send_next_step(){ get_map_data(); populate_all_nodes(); get_destination(); get_current_location(); calculate_path(); find_next_step(); }
void LocalPlanner::move_to_point(){ get_current_location(); get_destination(); calculate_new_heading(); if (check_heading_difference() == 0) resolve_heading(); else resolve_distance(); }
/** * \brief Starts the map. * * The map must be loaded. * The background music starts and the map script is initialized. */ void Map::start() { this->started = true; this->visible_surface->set_opacity(255); Music::play(music_id); this->entities->notify_map_started(); get_lua_context().run_map(*this, get_destination()); }
/*! * \internal * \brief Converts a pjsip_rx_data structure to an ast_msg structure. * * \details Attempts to fill in as much information as possible into the given * msg structure copied from the given request data. * * \param rdata The SIP request * \param msg The asterisk message structure to fill in. */ static enum pjsip_status_code rx_data_to_ast_msg(pjsip_rx_data *rdata, struct ast_msg *msg) { #define CHECK_RES(z_) do { if (z_) { ast_msg_destroy(msg); \ return PJSIP_SC_INTERNAL_SERVER_ERROR; } } while (0) int size; char buf[MAX_BODY_SIZE]; pjsip_name_addr *name_addr; const char *field; pjsip_status_code code; struct ast_sip_endpoint *endpt = ast_pjsip_rdata_get_endpoint(rdata); const char *context = S_OR(endpt->message_context, endpt->context); /* make sure there is an appropriate context and extension*/ if ((code = get_destination(rdata, context, buf)) != PJSIP_SC_OK) { return code; } CHECK_RES(ast_msg_set_context(msg, "%s", context)); CHECK_RES(ast_msg_set_exten(msg, "%s", buf)); /* to header */ name_addr = (pjsip_name_addr *)rdata->msg_info.to->uri; if ((size = pjsip_uri_print(PJSIP_URI_IN_FROMTO_HDR, name_addr, buf, sizeof(buf)-1)) > 0) { buf[size] = '\0'; /* prepend the tech */ CHECK_RES(ast_msg_set_to(msg, "%s", sip_to_pjsip(buf, ++size, sizeof(buf)-1))); } /* from header */ name_addr = (pjsip_name_addr *)rdata->msg_info.from->uri; if ((size = pjsip_uri_print(PJSIP_URI_IN_FROMTO_HDR, name_addr, buf, sizeof(buf)-1)) > 0) { buf[size] = '\0'; CHECK_RES(ast_msg_set_from(msg, "%s", buf)); } /* receive address */ field = pj_sockaddr_print(&rdata->pkt_info.src_addr, buf, sizeof(buf)-1, 1); CHECK_RES(ast_msg_set_var(msg, "PJSIP_RECVADDR", field)); /* body */ if (print_body(rdata, buf, sizeof(buf) - 1) > 0) { CHECK_RES(ast_msg_set_body(msg, "%s", buf)); } /* endpoint name */ if (endpt->id.self.name.valid) { CHECK_RES(ast_msg_set_var(msg, "PJSIP_PEERNAME", endpt->id.self.name.str)); } CHECK_RES(headers_to_vars(rdata, msg)); return PJSIP_SC_OK; }
char *get_location(FILE *file, RegDesc *registers, Symbol *symbol) { debug("Get location: %s", symbol->name); int reg = registers_contains(registers, symbol); if (reg >= 0) return registers[reg].name; else { return get_destination(file, registers, symbol); } }
void code_spill_reg(FILE *file, RegDesc *registers, int reg) { RegDesc desc = registers[reg]; if (desc.modified == FALSE) return;//No need to update memory debug("Spilling Register %s holding %s", desc.name, desc.symbol->name); char *dest = get_destination(file, registers, desc.symbol); code_instruction(file, MOVE, desc.name, dest); registers[reg].modified = FALSE;//Don't keep spilling }
void code_load_reg(FILE *file, RegDesc *registers, int reg, Symbol *symbol) { char *name = registers[reg].name; debug("Code_Load_Reg %s to %d", symbol->name, reg); switch (symbol->type->code) { case TYPE_NATURAL: code_instruction(file, MOVE, make_integer(symbol->value.integer), name); break; default: code_instruction(file, MOVE, get_destination(file, registers, symbol), name); break; } }
void LocalZipTask::run() { set_has_error(false); // 检查路径存在性 const QString source = get_source(), destination = get_destination(); if (!QFileInfo(source).exists()) { set_msg("Source path not exists: " + source); set_has_error(true); return; } if (!QFileInfo(QFileInfo(destination).path()).exists()) // XXX QFileInfo.path() 返回父目录 { set_msg("Parent directory of ZIP destination not exists: " + QFileInfo(destination).path()); set_has_error(true); return; } // 首先检查是否需要更新 set_msg("Checking..."); bool needUpdate = true; if (QFileInfo(destination).exists() && !QFileInfo(destination).isDir()) { const QDateTime mtime = QFileInfo(destination).lastModified(); needUpdate = newer_than(source, mtime); } if (!needUpdate) { set_msg("No need to update at " + QString::fromStdString(DateTime().get_clock_str()) + "."); return; } // 计算工作量 set_msg("Counting..."); _total_files = count_files(source); _compressed_files = 0; // 压缩文件/文件夹到zip bool rs = zip(); if (rs) set_msg("Last done at " + QString::fromStdString(DateTime().get_clock_str()) + "."); state_changed(); }
void create_operation::rollback() { if (has_deployed()) { config_.file_manager->move(get_destination(), cache_path_); } }
FlightUSAirway *FlightUSAirway::clone() { FlightUSAirway *new_flight = new FlightUSAirway(get_flight_num(), get_price(), get_duration(), get_departure()->copy(), get_source(), get_destination()); return new_flight; }
FlightSoutWest *FlightSoutWest::clone() { FlightSoutWest *new_flight = new FlightSoutWest(get_flight_num(), get_price(), get_duration(), get_departure()->copy(), get_source(), get_destination()); return new_flight; }
FlightDelta *FlightDelta::clone() { FlightDelta *new_flight = new FlightDelta(get_flight_num(), get_price(), get_duration(), get_departure()->copy(), get_source(), get_destination()); return new_flight; }
int main (int argc, char **argv) { fct_init(); /* A captured sFlow datagram (#14) */ u_int32_t packet[] = { htonl(0x00000005), htonl(0x00000001), htonl(0xb2116ff2), htonl(0x00000010), htonl(0x00002eb2), htonl(0x55f10676), htonl(0x00000006), htonl(0x00000001), htonl(0x000000d0), htonl(0x00003bc4), htonl(0x000001fd), htonl(0x000003e8), htonl(0x00e971b8), htonl(0x00000000), htonl(0x000001fd), htonl(0x00000000), htonl(0x00000002), htonl(0x00000001), htonl(0x00000090), htonl(0x00000001), htonl(0x00000552), htonl(0x00000004), htonl(0x00000080), htonl(0x01005e31), htonl(0x1af56c9c), htonl(0xed6213d6), htonl(0x08004500), htonl(0x054034d9), htonl(0x40003a11), htonl(0x7b3ad460), htonl(0xb312e931), htonl(0x1af5090a), htonl(0x090a052c), htonl(0x00004700), htonl(0x651ee36d), htonl(0x579e13dc), htonl(0x65de7811), htonl(0x377a5cf7), htonl(0x9e21eba7), htonl(0x0f8ebcf1), htonl(0x0ecfa7d7), htonl(0xef1810a4), htonl(0x4da7bcf3), htonl(0x3b8dbae7), htonl(0x8a9ef3c1), htonl(0x3bb875e7), htonl(0x9ab9ef3c), htonl(0x17d73cf7), htonl(0x9e06eee7), htonl(0x9ef3c73a), htonl(0xd194e203), htonl(0x01dea7f6), htonl(0xa8da1200), htonl(0x00000108), htonl(0x33cfb36f), htonl(0x000003e9), htonl(0x00000010), htonl(0x00000000), htonl(0x00000000), htonl(0x00000000), htonl(0x00000000), htonl(0x00000001), htonl(0x000000d0), htonl(0x00003bc5), htonl(0x000001fd), htonl(0x000003e8), htonl(0x00e975a0), htonl(0x00000000), htonl(0x000001fd), htonl(0x00000000), htonl(0x00000002), htonl(0x00000001), htonl(0x00000090), htonl(0x00000001), htonl(0x00000552), htonl(0x00000004), htonl(0x00000080), htonl(0x01005e31), htonl(0x1a8f6c9c), htonl(0xed6213d6), htonl(0x08004500), htonl(0x0540394a), htonl(0x40003a11), htonl(0x772fd460), htonl(0xb312e931), htonl(0x1a8f090a), htonl(0x090a052c), htonl(0x00004700), htonl(0x65125e8a), htonl(0x2878413c), htonl(0xa8569182), htonl(0x2f223570), htonl(0x558b4499), htonl(0x27625ad6), htonl(0xbabafb77), htonl(0x8d556e64), htonl(0xf68b6690), htonl(0x85d0d9ac), htonl(0x491de099), htonl(0x2159c756), htonl(0xeb74a2a5), htonl(0x7e019e40), htonl(0xc90f57bc), htonl(0x1e66e5b4), htonl(0x9522a3dc), htonl(0x301446f8), htonl(0x31f31f3f), htonl(0xdbf78329), htonl(0x9baf89b3), htonl(0x000003e9), htonl(0x00000010), htonl(0x00000000), htonl(0x00000000), htonl(0x00000000), htonl(0x00000000), htonl(0x00000001), htonl(0x000000d0), htonl(0x00003bc6), htonl(0x000001fd), htonl(0x000003e8), htonl(0x00e97988), htonl(0x00000000), htonl(0x000001fd), htonl(0x00000000), htonl(0x00000002), htonl(0x00000001), htonl(0x00000090), htonl(0x00000001), htonl(0x00000552), htonl(0x00000004), htonl(0x00000080), htonl(0x01005e31), htonl(0x1a686c9c), htonl(0xed6213d6), htonl(0x08004500), htonl(0x05403d93), htonl(0x40003a11), htonl(0x730dd460), htonl(0xb312e931), htonl(0x1a68090a), htonl(0x090a052c), htonl(0x00004700), htonl(0x651a8c9a), htonl(0xc8698831), htonl(0x20740075), htonl(0x1608600a), htonl(0x0640060e), htonl(0x40788603), htonl(0x003203a0), htonl(0x13815260), htonl(0x0d9060d2), htonl(0xf93129c1), htonl(0x078b801a), htonl(0x803a02a0), htonl(0x06600d80), htonl(0x3302843f), htonl(0x80789fb7), htonl(0x0941c6a3), htonl(0xde806e8e), htonl(0x02941392), htonl(0x19c82dc8), htonl(0x14383213), htonl(0x01007408), htonl(0x000003e9), htonl(0x00000010), htonl(0x00000000), htonl(0x00000000), htonl(0x00000000), htonl(0x00000000), htonl(0x00000001), htonl(0x000000d0), htonl(0x00003bc7), htonl(0x000001fd), htonl(0x000003e8), htonl(0x00e97d70), htonl(0x00000000), htonl(0x000001fd), htonl(0x00000000), htonl(0x00000002), htonl(0x00000001), htonl(0x00000090), htonl(0x00000001), htonl(0x00000552), htonl(0x00000004), htonl(0x00000080), htonl(0x01005e31), htonl(0x1a486c9c), htonl(0xed6213d6), htonl(0x08004500), htonl(0x05409771), htonl(0x40003a11), htonl(0x194ed460), htonl(0xb313e931), htonl(0x1a48090a), htonl(0x090a052c), htonl(0x00004700), htonl(0x65120000), htonl(0x00000000), htonl(0x00000000), htonl(0x00000000), htonl(0x00000000), htonl(0x00000000), htonl(0x00000000), htonl(0x00000000), htonl(0x00000000), htonl(0x00000000), htonl(0x00000000), htonl(0x00000000), htonl(0x00000000), htonl(0x00000000), htonl(0x00000000), htonl(0x00000000), htonl(0x00000000), htonl(0x00000000), htonl(0x00000000), htonl(0x00000000), htonl(0x00000000), htonl(0x000003e9), htonl(0x00000010), htonl(0x00000000), htonl(0x00000000), htonl(0x00000000), htonl(0x00000000), htonl(0x00000001), htonl(0x000000d0), htonl(0x00003bc8), htonl(0x000001fd), htonl(0x000003e8), htonl(0x00e98158), htonl(0x00000000), htonl(0x000001fd), htonl(0x00000000), htonl(0x00000002), htonl(0x00000001), htonl(0x00000090), htonl(0x00000001), htonl(0x00000552), htonl(0x00000004), htonl(0x00000080), htonl(0x01005e31), htonl(0x1aa16c9c), htonl(0xed6213d6), htonl(0x08004500), htonl(0x05404682), htonl(0x40003a11), htonl(0x69e5d460), htonl(0xb312e931), htonl(0x1aa1090a), htonl(0x090a052c), htonl(0x00004700), htonl(0x6519ccaf), htonl(0x5e165667), htonl(0x3a001dc5), htonl(0x5faf0000), htonl(0x01081b5e), htonl(0x6563af95), htonl(0xebd15aaf), htonl(0x95baf95b), htonl(0xaf656ebc), htonl(0xcac3d7a2), htonl(0xb0000001), htonl(0x091b5f2b), htonl(0x0d5e8af5), htonl(0xecadd7ca), htonl(0xdd7cac75), htonl(0xe656339d), htonl(0x807d6bcc), htonl(0xac000001), htonl(0x0a1b5e8a), htonl(0xc55e32b2), htonl(0xaf95baf6), htonl(0x000003e9), htonl(0x00000010), htonl(0x00000000), htonl(0x00000000), htonl(0x00000000), htonl(0x00000000), htonl(0x00000001), htonl(0x000000d0), htonl(0x00003bc9), htonl(0x000001fd), htonl(0x000003e8), htonl(0x00e98540), htonl(0x00000000), htonl(0x000001fd), htonl(0x00000000), htonl(0x00000002), htonl(0x00000001), htonl(0x00000090), htonl(0x00000001), htonl(0x00000552), htonl(0x00000004), htonl(0x00000080), htonl(0x01005e31), htonl(0x1a906c9c), htonl(0xed6213d6), htonl(0x08004500), htonl(0x05404acb), htonl(0x40003a11), htonl(0x65add460), htonl(0xb312e931), htonl(0x1a90090a), htonl(0x090a052c), htonl(0x00004700), htonl(0x651baafe), htonl(0x0bdedfbc), htonl(0xbd602300), htonl(0x2174c3ce), htonl(0x4b2371b8), htonl(0xe6ffdcf5), htonl(0x786be4e8), htonl(0xc0fd26c2), htonl(0xeed3a46f), htonl(0x4c46f9a6), htonl(0x5db1ca70), htonl(0x79466014), htonl(0xad3298d5), htonl(0x0bb5be20), htonl(0x069402c7), htonl(0xf3a2f740), htonl(0x8b297b99), htonl(0x605378ac), htonl(0xccd10ea4), htonl(0x352cb6f5), htonl(0xc00eb400), htonl(0x000003e9), htonl(0x00000010), htonl(0x00000000), htonl(0x00000000), htonl(0x00000000), htonl(0x00000000) }; sflow_sample_data_t *sample = NULL; sflow_flow_record_t *record = NULL; sflow_raw_header_t *header = NULL; struct sockaddr_storage ss; assert_int(1, next_sample(&packet, sizeof (packet), &sample), "Load sample #1"); assert_int(1, is_sample_format(sample, FLOW_SAMPLE), "Sample #1: format"); assert_int(15300, ntohl(((sflow_flow_sample_t *) (sample + 1))->sequence_number), "Sample #1: seq_number"); assert_int(1, next_record(sample, &record), "Load record #1:1"); assert_int(1, is_record_format(record, RAW_HEADER), "Record #1:1: format"); header = (sflow_raw_header_t *) (record + 1); assert_int(1, get_source(header, &ss), "Record #1:1: Loading source address"); assert_ip("212.96.179.18", &ss, "Record #1:1: Source address"); assert_int(1, get_destination(header, &ss), "Record #1:1: Loading destination address"); assert_ip("233.49.26.245", &ss, "Record #1:1: Destination address"); assert_int(1, next_record(sample, &record), "Load record #1:2"); assert_int(0, is_record_format(record, RAW_HEADER), "Record #1:2: format"); assert_int(0, next_record(sample, &record), "Record #1:3 should fail"); assert_int(1, next_sample(&packet, sizeof (packet), &sample), "Load sample #2"); assert_int(1, is_sample_format(sample, FLOW_SAMPLE), "Sample #2: format"); assert_int(15301, ntohl(((sflow_flow_sample_t *) (sample + 1))->sequence_number), "Sample #2: seq_number"); assert_int(1, next_sample(&packet, sizeof (packet), &sample), "Load sample #3"); assert_int(1, is_sample_format(sample, FLOW_SAMPLE), "Sample #3: format"); assert_int(15302, ntohl(((sflow_flow_sample_t *) (sample + 1))->sequence_number), "Sample #3: seq_number"); assert_int(1, next_sample(&packet, sizeof (packet), &sample), "Load sample #4"); assert_int(1, is_sample_format(sample, FLOW_SAMPLE), "Sample #4: format"); assert_int(15303, ntohl(((sflow_flow_sample_t *) (sample + 1))->sequence_number), "Sample #4: seq_number"); assert_int(1, next_sample(&packet, sizeof (packet), &sample), "Load sample #5"); assert_int(1, is_sample_format(sample, FLOW_SAMPLE), "Sample #5: format"); assert_int(15304, ntohl(((sflow_flow_sample_t *) (sample + 1))->sequence_number), "Sample #5: seq_number"); assert_int(1, next_sample(&packet, sizeof (packet), &sample), "Load sample #6"); assert_int(1, is_sample_format(sample, FLOW_SAMPLE), "Sample #6: format"); assert_int(15305, ntohl(((sflow_flow_sample_t *) (sample + 1))->sequence_number), "Sample #6: seq_number"); assert_int(0, next_sample(&packet, sizeof (packet), &sample), "Sample #7 should fail"); fct_send(); return 0; }
bool LocalZipTask::zip() { const QString source = get_source(), destination = get_destination(); // 在临时文件区新建zip文件 QTemporaryFile tmp("XXXXXX.zip"); tmp.open(); QuaZip zip(tmp.fileName()); zip.setFileNameCodec("UTF8"); zip.open(QuaZip::mdCreate); // 添加注释 zip.setComment("Create automatically by organic/syncer."); // 添加文件 IgnoreList ignore_list; stack<QString> relatives; relatives.push(""); while (!relatives.empty()) { const QString r = relatives.top(); relatives.pop(); // 执行栈里的特殊操作 if (r == SPECIAL_ID) { ignore_list.pop_config(); continue; } update_state(r + " ..."); // 处理中断操作 if (RUNNING != get_state()) { set_msg("Cancled."); return false; } // 处理忽略列表 const QString p = path_join(source, r); if (ignore_list.is_ignored(r)) { _compressed_files += count_files(p); continue; } if (!QFileInfo(p).isDir()) { QFile in(p); if (!in.open(QIODevice::ReadOnly)) { set_msg("Failed to open file: " + p); set_has_error(true); return false; } QuaZipFile out(&zip); const QString rr = (r.isEmpty() ? QFileInfo(source).fileName() : r); out.open(QIODevice::WriteOnly, QuaZipNewInfo(rr, p)); const qint64 BUF_LEN = 64 * 1024; char buf[BUF_LEN]; for (qint64 pos = 0, len = in.size(); pos < len; ) { qint64 readSize = qMin(BUF_LEN, len - pos); if (in.read(buf, readSize) != readSize) { set_msg("Failed to read file: " + rr); set_has_error(true); return false; } out.write(buf, readSize); pos += readSize; } in.close(); out.close(); ++_compressed_files; } else { // 处理忽略列表 if (QFileInfo(path_join(p, IGNORE_FILE1)).exists()) { ignore_list.push_config(r, path_join(p, IGNORE_FILE1)); relatives.push(SPECIAL_ID); } else if (QFileInfo(path_join(p, IGNORE_FILE2)).exists()) { ignore_list.push_config(r, path_join(p, IGNORE_FILE2)); relatives.push(SPECIAL_ID); } else if (QFileInfo(path_join(p, IGNORE_FILE3)).exists()) { ignore_list.push_config(r, path_join(p, IGNORE_FILE3)); relatives.push(SPECIAL_ID); } // 遍历文件夹 QStringList children = QDir(p).entryList(QDir::Files | QDir::Dirs | QDir::AccessMask | QDir::NoDotAndDotDot); for (size_t i = 0, size = children.size(); i < size; ++i) { const QString& e = children.at(i); relatives.push(path_join(r, e)); } } } zip.close(); tmp.close(); // 拷贝临时文件到目标地址 if (QFileInfo(destination).exists() && !remove_file(destination)) { set_msg("Failed to remove old destination ZIP file."); set_has_error(true); return false; } if (!copy_file(tmp.fileName(), destination)) { set_msg("Failed to copy tmp file to destination ZIP file."); set_has_error(true); return false; } tmp.remove(); return true; }