static bool LoadOldblivion(PROCESS_INFORMATION * info) { bool result = false; HANDLE syncEvent = CreateEvent(NULL, 0, 0, "OldblivionInjectionCompleted"); if(syncEvent) { if(InjectDLL(info, "oldblivion.dll", false)) { switch(WaitForSingleObject(syncEvent, g_options.m_threadTimeout)) { case WAIT_OBJECT_0: _MESSAGE("oldblivion loaded"); result = true; break; case WAIT_ABANDONED: _ERROR("LoadOldblivion: waiting for oldblivion = WAIT_ABANDONED"); break; case WAIT_TIMEOUT: _ERROR("LoadOldblivion: waiting for oldblivion = WAIT_TIMEOUT"); break; } } else _ERROR("couldn't inject oldblivion dll"); CloseHandle(syncEvent); } else _ERROR("couldn't create oldblivion sync event (%d)", GetLastError()); return result; }
bool LoadJsonFromFile(const char * filePath, Json::Value &jsonData) { IFileStream currentFile; if (!currentFile.Open(filePath)) { _ERROR("%s: couldn't open file (%s) Error (%d)", __FUNCTION__, filePath, GetLastError()); return true; } char buf[512]; std::string jsonString; while (!currentFile.HitEOF()){ currentFile.ReadString(buf, sizeof(buf) / sizeof(buf[0])); jsonString.append(buf); } currentFile.Close(); Json::Features features; features.all(); Json::Reader reader(features); bool parseSuccess = reader.parse(jsonString, jsonData); if (!parseSuccess) { _ERROR("%s: Error occured parsing json for %s.", __FUNCTION__, filePath); return true; } return false; }
static void OnAttach(void) { gLog.SetPrintLevel(IDebugLog::kLevel_Error); gLog.SetLogLevel(IDebugLog::kLevel_DebugMessage); std::string dllSuffix; bool steamVersion; // paranoia check if(!TestChecksum("oblivion.exe", &dllSuffix, &steamVersion)) { _ERROR("checksum not found"); return; } // /extreme/ paranoia check if(!steamVersion) { _ERROR("not a steam version!?"); return; } // build full path to our dll std::string dllPath; dllPath = GetCWD() + "\\obse_" + dllSuffix + ".dll"; _MESSAGE("dll = %s", dllPath.c_str()); // load it if(!LoadLibrary(dllPath.c_str())) { _ERROR("couldn't load dll"); } }
static int __handle_packet(struct player *player, struct packet *packet) { struct packet_handler *handler; int ret = -1; if (packet_deserialize(packet) < 0) { _ERROR("%s: packet deserialize failed for type %d in slot %d.\n", __FUNCTION__, packet->type, player->id); return -1; } handler = packet_handler_for_type(packet->type); if (handler == NULL || handler->handle_func == NULL) { _ERROR("%s: unknown message of type %d for slot %d.\n", __FUNCTION__, packet->type, player->id); return -1; } ret = handler->handle_func(player, packet); if (ret < 0) { _ERROR("%s:handler failed for type %d from slot %d.\n", __FUNCTION__, packet->type, player->id); return -1; } return 0; }
static int server_auth_callback (void * userdata, const char * realm, int attempt, char * username, char * password) { struct neon_handle * h = userdata; if (! h->purl->userinfo || ! h->purl->userinfo[0]) { _ERROR ("Authentication required, but no credentials set"); return 1; } char * * authtok = g_strsplit (h->purl->userinfo, ":", 2); if (strlen (authtok[1]) > NE_ABUFSIZ - 1 || strlen (authtok[0]) > NE_ABUFSIZ - 1) { _ERROR ("Username/Password too long"); g_strfreev (authtok); return 1; } g_strlcpy (username, authtok[0], NE_ABUFSIZ); g_strlcpy (password, authtok[1], NE_ABUFSIZ); _DEBUG ("Authenticating: Username: %s, Password: %s", username, password); g_strfreev (authtok); return attempt; }
bool OBSEPlugin_Query(const OBSEInterface * obse, PluginInfo * info) { info->infoVersion = PluginInfo::kInfoVersion; info->name = "RUST"; info->version = 1; if(!obse->isEditor) { if(obse->obseVersion < OBSE_VERSION_INTEGER) { _ERROR("OBSE version too old (got %08X expected at least %08X)", obse->obseVersion, OBSE_VERSION_INTEGER); return false; } if(obse->oblivionVersion != OBLIVION_VERSION) { _ERROR("incorrect Oblivion version (got %08X need %08X)", obse->oblivionVersion, OBLIVION_VERSION); return false; } } else return false; if (IsRUDEPresent()) { _MESSAGE("RuntimeScriptProfiler cannot run alongside the RuntimeDebugger OBSE plugin!"); return false; } return true; }
void ReportBadFormlist(COMMAND_ARGS, BGSListForm * listForm) { _ERROR("### BAD FORMLIST ###"); _ERROR("script: %08X", scriptObj ? scriptObj->refID : 0); _ERROR("offset: %08X", *opcodeOffsetPtr); _ERROR("list: %08X", listForm ? listForm->refID : 0); }
int vector_new(TALLOC_CTX *context, struct vector **out_vector) { int ret = -1; TALLOC_CTX *temp_context; struct vector *vec; temp_context = talloc_new(NULL); if (temp_context == NULL) { _ERROR("%s: out of memory allocating temporary context for vector.\n", __FUNCTION__); ret = -1; goto out; } vec = talloc_zero(temp_context, struct vector); if (vec == NULL) { _ERROR("%s: out of memory allocating temporary context for vector.\n", __FUNCTION__); ret = -1; goto out; } vec->capacity = 1; vec->size = 0; vector_realloc(vec); *out_vector = (struct vector *)talloc_steal(context, vec); ret = 0; out: talloc_free(temp_context); return ret; }
int player_hp_read(struct packet *packet, const uv_buf_t *buf) { int ret = -1, pos = 0; TALLOC_CTX *temp_context; struct player_hp *player_hp; temp_context = talloc_new(NULL); if (temp_context == NULL) { _ERROR("%s: out of memory allocating temp context for player hp.\n", __FUNCTION__); ret = -ENOMEM; goto out; } player_hp = talloc_zero(temp_context, struct player_hp); if (player_hp == NULL) { _ERROR("%s: out of memory allocating player hp packet.\n", __FUNCTION__); ret = -ENOMEM; goto out; } player_hp->id = buf->base[pos++]; player_hp->life = *(uint16_t *)(buf->base + pos); pos += sizeof(uint16_t); player_hp->life_max = *(uint16_t *)(buf->base + pos); packet->data = talloc_steal(packet, player_hp); ret = 0; out: talloc_free(temp_context); return ret; }
int player_hp_new(TALLOC_CTX *ctx, const struct player *player, uint16_t life, uint16_t life_max, struct packet **out_packet) { int ret = -1; TALLOC_CTX *temp_context; struct packet *packet; temp_context = talloc_new(NULL); if (temp_context == NULL) { _ERROR("%s: out of memory allocating temp context for packet %d\n", __FUNCTION__, PACKET_TYPE_PLAYER_HP); ret = -ENOMEM; goto out; } packet = talloc(temp_context, struct packet); if (packet == NULL) { _ERROR("%s: out of memory allocating packet %d\n", __FUNCTION__, PACKET_TYPE_PLAYER_HP); ret = -ENOMEM; goto out; } packet->type = PACKET_TYPE_PLAYER_HP; packet->len = PACKET_HEADER_SIZE; packet->data = NULL; *out_packet = (struct packet *)talloc_steal(ctx, packet); ret = 0; out: talloc_free(temp_context); return ret; }
int chat_message_new(TALLOC_CTX *ctx, const struct player *player, const struct colour colour, const char *message, struct packet **out_packet) { int ret = -1; TALLOC_CTX *temp_context; struct packet *packet; struct chat_message *chat_message; char *message_copy; temp_context = talloc_new(NULL); if (temp_context == NULL) { _ERROR("%s: out of memory allocating temp context for packet %d\n", __FUNCTION__, PACKET_TYPE_CHAT_MESSAGE); ret = -ENOMEM; goto out; } packet = talloc(temp_context, struct packet); if (packet == NULL) { _ERROR("%s: out of memory allocating packet type %d\n", __FUNCTION__, PACKET_TYPE_CHAT_MESSAGE); ret = -ENOMEM; goto out; } chat_message = talloc(temp_context, struct chat_message); if (chat_message == NULL) { _ERROR("%s: out of memory allocating chat_message.\n", __FUNCTION__); ret = -ENOMEM; goto out; } packet->type = PACKET_TYPE_CHAT_MESSAGE; packet->len = PACKET_HEADER_SIZE + strlen(message) + binary_writer_7bit_len(strlen(message)); chat_message->id = player->id; chat_message->colour = colour; message_copy = talloc_strdup(temp_context, message); if (message_copy == NULL) { _ERROR("%s: out of memory copying chat message to packet.\n", __FUNCTION__); ret = -ENOMEM; goto out; } chat_message->message = talloc_steal(packet, message_copy); packet->data = (void *)talloc_steal(packet, chat_message); *out_packet = (struct packet *)talloc_steal(ctx, packet); ret = 0; out: talloc_free(temp_context); return ret; }
bool OBSEPlugin_Query(const OBSEInterface * obse, PluginInfo * info) { _MESSAGE("query"); // fill out the info structure info->infoVersion = PluginInfo::kInfoVersion; info->name = "obse_plugin_example"; info->version = 1; // version checks if(!obse->isEditor) { if(obse->obseVersion < OBSE_VERSION_INTEGER) { _ERROR("OBSE version too old (got %08X expected at least %08X)", obse->obseVersion, OBSE_VERSION_INTEGER); return false; } #if OBLIVION if(obse->oblivionVersion != OBLIVION_VERSION) { _ERROR("incorrect Oblivion version (got %08X need %08X)", obse->oblivionVersion, OBLIVION_VERSION); return false; } #endif g_serialization = (OBSESerializationInterface *)obse->QueryInterface(kInterface_Serialization); if(!g_serialization) { _ERROR("serialization interface not found"); return false; } if(g_serialization->version < OBSESerializationInterface::kVersion) { _ERROR("incorrect serialization version found (got %08X need %08X)", g_serialization->version, OBSESerializationInterface::kVersion); return false; } g_arrayIntfc = (OBSEArrayVarInterface*)obse->QueryInterface(kInterface_ArrayVar); if (!g_arrayIntfc) { _ERROR("Array interface not found"); return false; } g_scriptIntfc = (OBSEScriptInterface*)obse->QueryInterface(kInterface_Script); } else { // no version checks needed for editor } // version checks pass return true; }
int server_connect (char *servername, int serverport) { struct addrinfo hints; struct addrinfo *ai; char port[16]; int res; #if WIN32 VERBOSE("Using win32 sockets\n"); WSADATA WSAData; if((res = WSAStartup(MAKEWORD(2,0), &WSAData)) != 0) printf("Impossible d'initialiser l'API Winsock 2.0\n"); #endif VERBOSE("Entring Server_connect\n"); /* on initialise la socket */ VERBOSE("Servername: %s\n", servername); VERBOSE("Port: %d\n", serverport); memset(&hints, 0, sizeof(hints)); hints.ai_family = AF_INET; hints.ai_socktype = SOCK_STREAM; snprintf(port, sizeof(port), "%d", serverport); if ((res = getaddrinfo(servername, port, &hints, &ai)) != 0) { _ERROR("Error with getaddrinfo: %s\n", gai_strerror(res)); return -1; } /* creation de la socket */ if ( (server_socket = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol)) < 0) { _ERROR("Error creating shoutcast socket. Exiting.\n"); return -2; } VERBOSE("Socket Creation Sucessful.\n"); VERBOSE("Connection in progress...\n"); /* requete de connexion */ if(connect(server_socket, ai->ai_addr, ai->ai_addrlen) < 0 ) { perror("socket"); _ERROR("Remote host connection failed.\n"); return -3; } else { VERBOSE("Connected.\n"); } FD_ZERO(&rfds); FD_SET(server_socket, &rfds); return server_socket; }
//Sends a command to the server and returns the response QString Pop3Client::doCommand(QString command,bool isMultiline) { // qDebug() << "sending command: " << command << "\n"; QString response; qint64 writeResult = m_sock->write(command.toAscii()); if (writeResult != command.size()) _ERROR("Could not write all bytes: "); if (writeResult > 0 && !m_sock->waitForBytesWritten(WRITE_TIMEOUT)) _ERROR("Could not write bytes from buffer: "); if (!ReadResponse(isMultiline,response)) return ""; return response; }
/* database_write */ static int database_write(const char *compiler, int language) { char *error = NULL, query[MAX_BUFFER_SIZE], compilershort[10]; /* Check if the required table is available */ char sql[] = "CREATE TABLE IF NOT EXISTS readelf_language ( \ id INTEGER PRIMARY KEY, \ name VARCHAR NOT NULL, \ language INTEGER, \ compiler VARCHAR, \ compiler_short VARCHAR);"; OUTPUT_VERBOSE((5, "%s", _BLUE("Writing to database"))); if (SQLITE_OK != sqlite3_exec(globals.db, sql, NULL, NULL, &error)) { OUTPUT(("%s %s", _ERROR("SQL error"), error)); sqlite3_free(error); return PERFEXPERT_ERROR; } bzero(compilershort, 10); if (NULL != strstr(compiler, "GNU C ")) { strcpy(compilershort, "gcc"); } if (NULL != strstr(compiler, "GNU C++")) { strcpy(compilershort, "g++"); } if (NULL != strstr(compiler, "GNU F")) { strcpy(compilershort, "gfortran"); } if (NULL != strstr(compiler, "Intel(R) C ")) { strcpy(compilershort, "icc"); } if (NULL != strstr(compiler, "Intel(R) C++")) { strcpy(compilershort, "icpc"); } if (NULL != strstr(compiler, "Intel(R) Fortran")) { strcpy(compilershort, "ifort"); } bzero(query, MAX_BUFFER_SIZE); sprintf(query, "INSERT INTO readelf_language (id, name, language, compiler," " compiler_short) VALUES (%llu, '%s', %d, '%s', '%s');", globals.unique_id, globals.program, language, compiler, compilershort); if (SQLITE_OK != sqlite3_exec(globals.db, query, NULL, NULL, &error)) { OUTPUT(("%s %s %s", _ERROR("SQL error"), error, query)); sqlite3_free(error); return PERFEXPERT_ERROR; } return PERFEXPERT_SUCCESS; }
/* perfexpert_database_connect */ int perfexpert_database_connect(sqlite3 **db, const char *file) { sqlite3_backup *pBackup; sqlite3 *disk_db; char *error = NULL; /* Check if file exists */ if (-1 == access(file, F_OK)) { OUTPUT(("%s (%s)", _ERROR((char *)"file not found"), file)); goto CLEAN_UP; } /* Open the DB on disk */ if (SQLITE_OK != sqlite3_open(file, &disk_db)) { OUTPUT(("%s (%s), %s", _ERROR((char *)"openning database"), file, sqlite3_errmsg(disk_db))); goto CLEAN_UP; } /* Open the DB in memory */ if (SQLITE_OK != sqlite3_open(":memory:", db)) { OUTPUT(("%s (%s)", _ERROR((char *)"openning in-memory database"), sqlite3_errmsg(*db))); goto CLEAN_UP; } /* Copy the data from disk DB to in-memory DB */ pBackup = sqlite3_backup_init(*db, "main", disk_db, "main"); if (pBackup) { (void)sqlite3_backup_step(pBackup, -1); (void)sqlite3_backup_finish(pBackup); } if (SQLITE_OK != sqlite3_errcode(*db)) { goto CLEAN_UP; } /* Enable foreign keys */ if (SQLITE_OK != sqlite3_exec(*db, "PRAGMA foreign_keys = ON;", NULL, NULL, &error)) { OUTPUT(("%s %s", _ERROR("SQL error (enabling foreign keys)"), error)); sqlite3_free(error); goto CLEAN_UP; } OUTPUT_VERBOSE((4, " connected to %s", file)); return PERFEXPERT_SUCCESS; CLEAN_UP: sqlite3_close(*db); sqlite3_close(disk_db); return PERFEXPERT_ERROR; }
static bool SteamCheckActive(void) { bool result = false; HMODULE steamAPI = LoadLibrary("steam_api.dll"); if(steamAPI) { typedef bool (* _SteamAPI_IsSteamRunning)(void); _SteamAPI_IsSteamRunning SteamAPI_IsSteamRunning = NULL; // this just checks HKCU\Software\Valve\Steam\ActiveProcess\pid // to see if it's running, however process IDs can be reused and it doesn't clean the registry key // on exit SteamAPI_IsSteamRunning = (_SteamAPI_IsSteamRunning)GetProcAddress(steamAPI, "SteamAPI_IsSteamRunning"); if(SteamAPI_IsSteamRunning) { UInt32 startTime = GetTickCount(); const UInt32 kSteamTimeout = 10 * 1000; // 10 seconds while((GetTickCount() - startTime) >= kSteamTimeout) { if(SteamAPI_IsSteamRunning()) { result = true; break; } Sleep(100); } if(!result) { _ERROR("timed out waiting for steam boot"); } } else { _ERROR("couldn't get steam API ptr"); } FreeLibrary(steamAPI); } else { _ERROR("couldn't load steam API DLL (%08X)", GetLastError()); } return result; }
int chat_message_read(struct packet *packet) { int ret = -1, pos = 0, message_len = 0; TALLOC_CTX *temp_context; struct chat_message *chat_message; char *message; char *message_copy; temp_context = talloc_new(NULL); if (temp_context == NULL) { _ERROR("%s: out of memory allocating temp context for player info.\n", __FUNCTION__); ret = -ENOMEM; goto out; } chat_message = talloc_zero(temp_context, struct chat_message); if (chat_message == NULL) { _ERROR("%s: out of memory allocating player info.\n", __FUNCTION__); ret = -ENOMEM; goto out; } chat_message->id = packet->data_buffer[pos++]; chat_message->colour = *(struct colour *)(packet->data_buffer + pos); pos += sizeof(struct colour); binary_reader_read_string_buffer(packet->data_buffer, pos, &message_len, &message); message_copy = talloc_size(temp_context, message_len + 1); if (message_copy == NULL) { _ERROR("%s: out of memory allocating chat message from packet.\n", __FUNCTION__); ret = -ENOMEM; goto out; } memcpy(message_copy, message, message_len); message_copy[message_len] = '\0'; chat_message->message = talloc_steal(chat_message, message_copy); packet->data = (void *)talloc_steal(packet, chat_message); ret = 0; out: talloc_free(temp_context); return ret; }
static void HookMain(void * retAddr) { if(hookInstalled) return; else hookInstalled = true; _MESSAGE("HookMain: thread = %d retaddr = %016I64X", GetCurrentThreadId(), retAddr); std::string runtimePath = GetRuntimePath(); _MESSAGE("runtimePath = %s", runtimePath.c_str()); bool isEditor = false; // check version etc std::string dllSuffix; ProcHookInfo procHookInfo; if(!IdentifyEXE(runtimePath.c_str(), isEditor, &dllSuffix, &procHookInfo)) { _ERROR("unknown exe"); return; } const char * dllPrefix = (isEditor == false) ? "\\skse64_" : "\\skse64_editor_"; g_dllPath = GetRuntimeDirectory() + dllPrefix + dllSuffix + ".dll"; _MESSAGE("dll = %s", g_dllPath.c_str()); LoadLibrary(g_dllPath.c_str()); }
char *getvmname(char ip[INET_ADDRSTRLEN]) { struct in_addr vmaddr = {0}; struct hostent *he; char *name; int i = 0; if(ip[0] == '\0') { return NULL; } if(0 == inet_aton(ip, &vmaddr)) { _ERROR("inet_aton(): bad ip %s\n", ip); exit(EXIT_FAILURE); } if(NULL == (he = gethostbyaddr(&vmaddr, 4, AF_INET))) { herror("ERROR gethostbyaddr()"); exit(EXIT_FAILURE); } name = he->h_name; while(name != NULL && name[0] != 'v' && name[1] != 'm') { name = he->h_aliases[i]; i++; } return name; }
/** * returns -1 if id was smaller then the one here * returns 0 is the id was the same * returns 1 if it was added/updated */ int add_bid(struct bid_node** head, uint32_t broadcast_id, char src_ip[INET_ADDRSTRLEN]) { struct bid_node* ptr; for(ptr = *head; ptr != NULL; ptr = ptr->next) { if(0 == strcmp(ptr->src_ip, src_ip)) { _DEBUG("%s\n", "found maching bid node"); if(ptr->broadcast_id > broadcast_id) { _DEBUG("%s\n", "trying to add broadcast_id that was smaller"); return -1; } else if(ptr->broadcast_id == broadcast_id) { _DEBUG("%s\n", "trying to add broadcast_id that was equal"); return 0; } ptr->broadcast_id = broadcast_id; return 1; } } _DEBUG("%s\n", "did not find a matching bid_node, adding another"); ptr = malloc(sizeof(struct bid_node)); if(ptr == NULL) { _ERROR("%s\n", "malloc for bid_node failed"); exit(EXIT_FAILURE); } strncpy(ptr->src_ip, src_ip, INET_ADDRSTRLEN); ptr->broadcast_id = broadcast_id; ptr->next = *head; *head = ptr; return 1; }
/* module_init */ int module_init(void) { /* Initialize variables */ my_module_globals.compiler = NULL; my_module_globals.source = NULL; my_module_globals.help_only = PERFEXPERT_FALSE; /* Parse module options */ if (PERFEXPERT_SUCCESS != parse_module_args(myself_module.argc, myself_module.argv)) { OUTPUT(("%s", _ERROR("parsing module arguments"))); return PERFEXPERT_ERROR; } /* Enable extended interface */ myself_module.set_compiler = &module_set_compiler; myself_module.set_source = &module_set_source; myself_module.set_flag = &module_set_flag; myself_module.set_library = &module_set_library; myself_module.get_flag = &module_get_flag; myself_module.get_library = &module_get_library; OUTPUT_VERBOSE((5, "%s", _MAGENTA("initialized"))); return PERFEXPERT_SUCCESS; }
tree_data *rb_search(rb_tree * tree, long int distance) { rb_node *p; long int cmp; tree->pa[0] = NULL; tree->da[0] = 0; tree->k = 1; for (p = tree->root; p != NULL; p = p->rb_link[tree->da[tree->k - 1]]) { if (distance == (p->data).distance) { /* if the distance already exists, then we return the data and put it in to_delete */ tree->to_delete = p; return &(p->data); } cmp = COMPARE(distance, (p->data).distance); tree->pa[tree->k] = p; tree->da[tree->k++] = cmp > 0; if (tree->k >= TREE_MAX_HEIGHT) { _ERROR("maximum tree heigh exceeded"); } } return NULL; }
TESForm * TempClone(TESForm * thisForm) { TESForm * result = NULL; if(thisForm) { IFormFactory * factory = IFormFactory::GetFactoryForType(thisForm->formType); if(factory) { result = factory->Create(); if(result) { result->Init(); result->CopyFrom(thisForm); result->CopyFromEx(thisForm); } else { _ERROR("Form::TempClone: factory for type %02X failed", thisForm->formType); } } else { _MESSAGE("Form::TempClone: tried to clone form %08X (type %02X), no factory found", thisForm->formID, thisForm->formType); } } return result; }
static FillBufferResult fill_buffer (struct neon_handle * h) { int bsize = free_rb (& h->rb); int to_read = MIN (bsize, NEON_NETBLKSIZE); char buffer[NEON_NETBLKSIZE]; bsize = ne_read_response_block (h->request, buffer, to_read); if (! bsize) { _DEBUG ("<%p> End of file encountered", h); return FILL_BUFFER_EOF; } if (bsize < 0) { _ERROR ("<%p> Error while reading from the network", (void *) h); ne_request_destroy (h->request); h->request = NULL; return FILL_BUFFER_ERROR; } _DEBUG ("<%p> Read %d bytes of %d", h, bsize, to_read); write_rb (& h->rb, buffer, bsize); return FILL_BUFFER_SUCCESS; }
/** * Init paramtes and states for flyControler * * @param * void * * @return * bool * */ bool flyControlerInit() { if (pthread_mutex_init(&controlMotorMutex, NULL) != 0) { _ERROR("(%s-%d) controlMotorMutex init failed\n", __func__, __LINE__); return false; } setLeaveFlyControlerFlag(false); disenableFlySystem(); setAdjustPeriod(DEFAULT_ADJUST_PERIOD); setGyroLimit(DEFAULT_GYRO_LIMIT); setAngularLimit(DEFAULT_ANGULAR_LIMIT); setMotorGain(SOFT_PWM_CCW1, 1); setMotorGain(SOFT_PWM_CW1, 1); setMotorGain(SOFT_PWM_CCW2, 1); setMotorGain(SOFT_PWM_CW2, 1); setAltitudePidOutputLimitation(15.f); // 15 cm/sec rollAttitudeOutput = 0.f; pitchAttitudeOutput = 0.f; yawAttitudeOutput = 0.f; altHoltAltOutput = 0.f; maxThrottleOffset = 1000.f; return true; }
BOOL OPCEngine::initialize( IN enum serverTypeCOM type, IN REFCLSID clsid, IN UINT rgsResource, IN HINSTANCE hInst, IN DWORD coInit) // COM init mode { _TRACE(TL_INF, TG_ENG, (_T("initialize engine; clsid:%8.8X-%4.4X-%4.4X-%2.2X%2.2X%2.2X%2.2X%2.2X%2.2X%2.2X%2.2X"), clsid.Data1, clsid.Data2, clsid.Data3, clsid.Data4[0], clsid.Data4[1], clsid.Data4[2], clsid.Data4[3], clsid.Data4[4], clsid.Data4[5], clsid.Data4[6], clsid.Data4[7])); HRESULT res; g_clsid = clsid; g_registerId = rgsResource; m_type = type; if (type != InProc) { if (SUCCEEDED(res = ::CoInitializeEx(NULL, coInit))) m_initialized = TRUE; else _ERROR(TG_ENG, OPCENGINE_ERR_COM,(_T("Can't initialize COM: coInit:0x%X [0x%X]"), coInit, res)); } _Module.Init(g_objectMap, hInst); ::CoFileTimeNow(&m_startTime); GenericPointer<GenericServer> pg = m_creator->createServer(TRUE); m_opcRoot->addBranch(pg); pg->setName(_T("PublicGroups")); _TRACE(TL_DEB, TG_ENG, (_T("< initialize 0x%X"), res)); return SUCCEEDED(res); }
bool WriteDisplayData(Json::Value jDisplayList) { Json::StyledWriter writer; std::string jsonString = writer.write(jDisplayList); if (!jsonString.length()) { return true; } char filePath[MAX_PATH]; sprintf_s(filePath, "%s/DBM_MuseumData.json", GetUserDirectory().c_str()); IFileStream currentFile; IFileStream::MakeAllDirs(filePath); if (!currentFile.Create(filePath)) { _ERROR("%s: couldn't create preset file (%s) Error (%d)", __FUNCTION__, filePath, GetLastError()); return true; } currentFile.WriteBuf(jsonString.c_str(), jsonString.length()); currentFile.Close(); return false; }
/* perfexpert_util_filename_only */ int perfexpert_util_filename_only(const char *file, char **only) { char *local_copy = NULL, *token = NULL, *last = NULL, *str = NULL; if (NULL == file) { OUTPUT(("%s", _ERROR((char *)"file is NULL"))); return PERFEXPERT_ERROR; } PERFEXPERT_ALLOC(char, local_copy, (strlen(file) + 1)); strcpy(local_copy, file); token = strtok(local_copy, "/"); while (token = strtok(NULL, "/")) { last = token; } if (NULL == last) { *only = (char *)file; } else { PERFEXPERT_ALLOC(char, str, (strlen(last) + 1)); strcpy(str, last); *only = str; } PERFEXPERT_DEALLOC(local_copy); return PERFEXPERT_SUCCESS; }
int section_tile_frame_new(TALLOC_CTX *ctx, const struct player *player, struct vector_2d coords, struct packet **out_packet) { int ret = -1; TALLOC_CTX *temp_context; struct packet *packet; struct section_tile_frame *section_tile_frame; temp_context = talloc_new(NULL); if (temp_context == NULL) { _ERROR("%s: out of memory allocating temp context for packet %d\n", __FUNCTION__, PACKET_TYPE_SECTION_TILE_FRAME); ret = -ENOMEM; goto out; } packet = talloc(temp_context, struct packet); if (packet == NULL) { _ERROR("%s: out of memory allocating packet %d\n", __FUNCTION__, PACKET_TYPE_SECTION_TILE_FRAME); ret = -ENOMEM; goto out; } section_tile_frame = talloc_zero(temp_context, struct section_tile_frame); if (section_tile_frame == NULL) { _ERROR("%s: out of memory tile section.\n", __FUNCTION__); ret = -ENOMEM; goto out; } packet->type = PACKET_TYPE_SECTION_TILE_FRAME; section_tile_frame->x = coords.x; section_tile_frame->y = coords.y; section_tile_frame->dx = coords.x + 1; section_tile_frame->dy = coords.y + 1; packet->len = PACKET_HEADER_SIZE + PACKET_LEN_SECTION_TILE_FRAME; packet->data = talloc_steal(packet, section_tile_frame); *out_packet = (struct packet *)talloc_steal(ctx, packet); ret = 0; out: talloc_free(temp_context); return ret; }