void MediaPluginGStreamer010::sizeChanged() { // the shared writing space has possibly changed size/location/whatever // Check to see whether the movie's NATURAL size has been set yet if (1 == mNaturalWidth && 1 == mNaturalHeight) { mNaturalWidth = mCurrentWidth; mNaturalHeight = mCurrentHeight; writeToLog("Media NATURAL size better detected as %dx%d", mNaturalWidth, mNaturalHeight); } // if the size has changed then the shm has changed and the app needs telling if (mCurrentWidth != mPreviousWidth || mCurrentHeight != mPreviousHeight) { mPreviousWidth = mCurrentWidth; mPreviousHeight = mCurrentHeight; LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA, "size_change_request"); message.setValue("name", mTextureSegmentName); message.setValueS32("width", mNaturalWidth); message.setValueS32("height", mNaturalHeight); writeToLog("<--- Sending size change request to application with name: '%s' - natural size is %d x %d", mTextureSegmentName.c_str(), mNaturalWidth, mNaturalHeight); sendMessage(message); } }
void Logger::error(const char *msg) { if (logLevel >= LOGGER_LEVEL_ERROR) { EnterCriticalSection(&logger_critical_section); if (msg == NULL) msg = "(null)"; writeToLog("ERROR: ", false); writeToLog(msg, true); if (listener != NULL) { if (listenerLogLevel >= LOGGER_LEVEL_ERROR) { messagesToListener.push_back(std::make_pair<int, std::string>(LOGGER_LEVEL_ERROR, msg)); assert(messagesToListener.size() != 20000); } } else if(msg) { if (listener == NULL) { cachedMessages.push_back(std::make_pair<int, std::string>(LOGGER_LEVEL_ERROR, msg)); } } LeaveCriticalSection(&logger_critical_section); } }
extern "C" __declspec(dllexport) BOOL APIENTRY DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { DWORD id = 0; extern const char __ihook_version__[]; switch (fdwReason) { case DLL_PROCESS_ATTACH: writeToLog(__ihook_version__); id = hookitByAddress((DWORD) ¬hing, (DWORD) &hook_nothing); if (id <= 0) { writeToLog("Something goes wrong, check returned value"); return -1; } id = hookitByName((char*)"HttpOpenRequestA", (char*)"wininet.dll", (DWORD) hook_OpenRequest); if (id <= 0) { writeToLog("Something goes wrong, check returned value"); return -2; } nothing("hook function code"); break; case DLL_PROCESS_DETACH: unhookByName((char *) "HttpOpenRequestA", (char*) "wininet.dll"); unhookByAddress((DWORD) ¬hing); break; } return TRUE; }
void Maze::scanForEntrances() { for (uint32_t i = 1; i <= getFloorCount(); i++) { Map* curMap = getFloor(i); if (i == 1) { // In this case, we want up stairs. bool foundEntrance = false; bool multipleWarned = false; for (int32_t y = 0; y < curMap->getHeight(); y++) { for (int32_t x = 0; x < curMap->getWidth(); x++) { Activatable* act = curMap->getActivatable(x, y); if (act) { Stairs* stairs = act->asStairs(); if (stairs && stairs->getDirection() == StairDirection::UP) { Facing dstFacing = stairs->getDestinationFacing(); // Adjust the position so that when the player enters, they're // facing the right direction, and in the right position. int32_t dstX = x; int32_t dstY = y; switch(dstFacing) { case Facing::NORTH: dstY--; break; case Facing::EAST: dstX++; break; case Facing::SOUTH: dstY++; break; case Facing::WEST: dstX--; break; } if (foundEntrance && !multipleWarned) { writeToLog(MessageLevel::WARNING, "Maze::scanForEntrances(): Multiple up stairs found on floor of maze."); multipleWarned = true; } else { if (!curMap->canEntityEnter(dstX, dstY)) { writeToLog(MessageLevel::WARNING, "Maze::scanForEntrances(): Entrance as specified would place player in solid wall."); } else { mazeEntrance = Entrance(i, dstX, dstY, dstFacing); foundEntrance = true; } } } } } } } else { // Otherwise, we're looking for geomagnetic poles. This is currently // not implemented. Mostly because geopoles don't exist. } } }
bool MediaPluginGStreamer010::load() { if (!mDoneInit) return false; // error setStatus(STATUS_LOADING); writeToLog("setting up media..."); mIsLooping = false; mVolume = (float) 0.1234567; // minor hack to force an initial volume update // Create a pumpable main-loop for this media mPump = g_main_loop_new (NULL, FALSE); if (!mPump) { setStatus(STATUS_ERROR); return false; // error } // instantiate a playbin element to do the hard work mPlaybin = gst_element_factory_make ("playbin", "play"); if (!mPlaybin) { setStatus(STATUS_ERROR); return false; // error } // get playbin's bus GstBus *bus = gst_pipeline_get_bus (GST_PIPELINE (mPlaybin)); if (!bus) { setStatus(STATUS_ERROR); return false; // error } mBusWatchID = gst_bus_add_watch (bus, llmediaimplgstreamer_bus_callback, this); gst_object_unref (bus); if (NULL == getenv("LL_GSTREAMER_EXTERNAL")) { // instantiate a custom video sink mVideoSink = GST_SLVIDEO(gst_element_factory_make ("private-slvideo", "slvideo")); if (!mVideoSink) { writeToLog("Could not instantiate private-slvideo element."); // todo: cleanup. setStatus(STATUS_ERROR); return false; // error } // connect the pieces g_object_set(mPlaybin, "video-sink", mVideoSink, NULL); } return true; }
Maze* Maze::mazeFromXML(const std::string& filename) { Maze* newMaze = nullptr; try { XMLDocument doc; if (doc.LoadFile(filename.c_str()) == XML_SUCCESS) { XMLElement* root = doc.RootElement(); if (!root || std::string(root->Name()).compare("maze") != 0) { throw std::runtime_error("Maze::mazeFromXML(): Not a maze file."); } XMLElement* floorElement = root->FirstChildElement("floor"); if (!floorElement) { throw std::runtime_error("Maze::mazeFromXML(): Empty maze."); } newMaze = new Maze(); while (floorElement && newMaze->getFloorCount() < Maze::MAX_FLOORS) { if (!floorElement->GetText()) { throw std::runtime_error("Maze::mazeFromXML(): Empty floor element."); } Map* floor = Map::mapFromXML(floorElement->GetText()); if (!floor) { throw std::runtime_error("Maze::mazeFromXML(): Could not load a floor."); } newMaze->floors.push_back(floor); floorElement = floorElement->NextSiblingElement("floor"); } if (floorElement) { // There was more than MAX_FLOORS floors. Best report it. writeToLog(MessageLevel::WARNING, "Maze::mazeFromXML(): More than 256 floors specified for the maze. Stop this madness!"); } newMaze->scanForEntrances(); } } catch (std::exception& e) { if (newMaze) { delete newMaze; newMaze = nullptr; } writeToLog(MessageLevel::ERROR, "%s\n", e.what()); } return newMaze; }
void printFileList(struct FileType files[], int numberOfFiles){ for(int i = 0 ; i != numberOfFiles ; ++i){ struct FileType fileType = files[i]; printf("%-13s %-15f %-15s\n", fileType.file_type, fileType.size / 1024.0, fileType.file_name); char placeholder[64]; sprintf(placeholder,"%s %f %s", fileType.file_type, fileType.size / 1024.0, fileType.file_name ); writeToLog(placeholder); } printf("Press any key to continue.\n"); writeToLog("Press any key to continue.\n"); getchar(); executeFileExplorer(); }
void Server::runAccepter() { if(!isFull()) { sf::Uint16 OpenSlot = 0; for(sf::Uint16 i = 1; OpenSlot == 0; i++) { if(isSlotOpen(i)) OpenSlot = i; } { std::wstringstream ss; ss << L"Started listen on port {YD" << Port+OpenSlot << L"}."; writeToLog(ss.str()); } if(Listener.listen(Port+OpenSlot) != sf::Socket::Done) { { std::wstringstream ss; ss << "{RDFailed to listen on port} {YD" << Port+OpenSlot << L"}"; writeToLog(ss.str()); } } else { clientAccess.lock(); delete Clients[OpenSlot-1]; Clients[OpenSlot-1] = new Client(); clientAccess.unlock(); if(Listener.accept(Clients[OpenSlot-1]->Socket) != sf::Socket::Done) { { std::wstringstream ss; ss << L"{RDFailed to accept incomming connection on slot} {YDno. " << OpenSlot << L"}."; writeToLog(ss.str()); } } else { { std::wstringstream ss; ss << L"{GDClient connected} on port {YD" << OpenSlot+Port << L"}."; writeToLog(ss.str()); } Clients[OpenSlot-1]->Dead = false; Clients[OpenSlot-1]->listenThread = new sf::Thread(&Client::listen, Clients.at(OpenSlot-1)); Clients[OpenSlot-1]->listenThread->launch(); } Listener.close(); } } Listening = false; }
bool MediaPluginGStreamer010::navigateTo ( const std::string urlIn ) { if (!mDoneInit) return false; // error setStatus(STATUS_LOADING); writeToLog("Setting media URI: %s", urlIn.c_str()); mSeekWanted = false; if (NULL == mPump || NULL == mPlaybin) { setStatus(STATUS_ERROR); return false; // error } // set URI g_object_set (G_OBJECT (mPlaybin), "uri", urlIn.c_str(), NULL); //g_object_set (G_OBJECT (mPlaybin), "uri", "file:///tmp/movie", NULL); // navigateTo implicitly plays, too. play(1.0); return true; }
bool Logger::connect(Connection *connection) { if(_conn) { writeToLog("LOGGER: Logger::Initialize need only be called once\n"); return false; } if(!connection) { writeToLog("LOGGER: Logger:Initialize passed null value\n"); return false; } _conn = connection; return true; }
void routerUpdate(string message, char routerName) // "Host to Host" Router update message looks like: "U d1 cost1 d2 cost2 … dn costn" { message.erase(0, 1); char * context; bool tableChanged = false; char *update = &message[0]; char *tok = strtok_s(update, " ", &context); while(tok != NULL) { char rt = tok[0]; int dt = atoi(strtok_s(NULL, " ", &context)); int cost = table[rt].distance; int newCost = table[routerName].distance + dt; tok = strtok_s(NULL, " ", &context); if (newCost < cost) { tableChanged = true; table[rt].distance = newCost; table[rt].nextHop = routerName; } } if (tableChanged) { writeToLog("New table"); tableToLog(); sendRoutTableAll(); } }
bool MediaPluginGStreamer010::unload () { if (!mDoneInit) return false; // error writeToLog("unloading media..."); // stop getting callbacks for this bus g_source_remove(mBusWatchID); mBusWatchID = 0; if (mPlaybin) { gst_element_set_state (mPlaybin, GST_STATE_NULL); gst_object_unref (GST_OBJECT (mPlaybin)); mPlaybin = NULL; } if (mPump) { g_main_loop_quit(mPump); mPump = NULL; } mVideoSink = NULL; setStatus(STATUS_NONE); return true; }
INLINE FORCE_INLINE void handlePatchMemory() { int i; if(!stackPatchList) { stackPatchList = xalloc(STACK_PATCH_ALLOC_BLOCK * sizeof(StackPatchDescription)); stackPatchListLength = STACK_PATCH_ALLOC_BLOCK; stackPatchListIndexPointer = -1; stackPatchListNeedsSorting = 0; stackPatchListIterator = -1; if(!stackPatchList) return; writeToLog("Patch stack is empty...allocating %d byte-block [total = %d[real = %d]]\n", STACK_PATCH_ALLOC_BLOCK,stackPatchListLength,stackPatchListLength* sizeof(StackPatchDescription)); for(i = 0; i < STACK_PATCH_ALLOC_BLOCK; i++ ) { getPatchPtr(i)->patchData = NULL; getPatchPtr(i)->patchAddress = 0; } return; } if(stackPatchListIndexPointer >= stackPatchListLength-1) { stackPatchList = xrealloc(stackPatchList ,STACK_PATCH_ALLOC_BLOCK * sizeof(StackPatchDescription)); if(stackPatchList) stackPatchListLength += STACK_PATCH_ALLOC_BLOCK; writeToLog("Patch stack running out of memory...re-allocated a %d byte-block [total = %d[real = %d]]\n", STACK_PATCH_ALLOC_BLOCK,stackPatchListLength,stackPatchListLength* sizeof(StackPatchDescription)); if(!stackPatchList) return; for(i = stackPatchListIndexPointer+1; i < stackPatchListLength; i++ ) { getPatchPtr(i)->patchData = NULL; getPatchPtr(i)->patchAddress = 0; } } }
MediaPluginGStreamer010::~MediaPluginGStreamer010() { //writeToLog("MediaPluginGStreamer010 destructor"); closedown(); writeToLog("GStreamer010 destructor"); }
void tableToLog() { writeToLog("Router Cost Nexthop"); writeToLog("----------------------------"); for (auto iter = table.begin(); iter != table.end(); iter++) { routingEntry entry = iter->second; string line; line = iter->first; line += " "; line += to_string(entry.distance); line += " "; line += entry.nextHop; writeToLog(line); } writeToLog("----------------------------"); }
bool MediaPluginGStreamer010::pause() { writeToLog("pausing media..."); // todo: error-check this? gst_element_set_state(mPlaybin, GST_STATE_PAUSED); return true; }
bool MediaPluginGStreamer010::stop() { writeToLog("stopping media..."); // todo: error-check this? gst_element_set_state(mPlaybin, GST_STATE_READY); return true; }
bool MediaPluginGStreamer010::play(double rate) { // NOTE: we don't actually support non-natural rate. writeToLog("playing media... rate=%f", rate); // todo: error-check this? gst_element_set_state(mPlaybin, GST_STATE_PLAYING); return true; }
void IRCServer::sendData(QString txt) { if(txt.size() > 0) { writeToLog("[SND] " + txt); if (this->state() == QAbstractSocket::ConnectedState) { this->write((txt + "\r\n").toUtf8()); } } }
LLViewerStatsRecorder::~LLViewerStatsRecorder() { if (mObjectCacheFile != NULL) { // last chance snapshot writeToLog(0.f); LLFile::close(mObjectCacheFile); mObjectCacheFile = NULL; } }
bool Server::isSlotOpen(sf::Uint16 slot) { if(slot>0 && slot<=config.max_connections) { sf::Lock lock(clientAccess); return Clients[slot-1]->isDead(); } else { writeToLog(L"{RDInvalid slot request.}"); return false; } }
Logger::Helper::~Helper() { try { writeToLog(); } catch (std::exception &e) { // you shouldn't throw exceptions from a sink Q_UNUSED(e); assert(!"exception in logger helper destructor"); throw; } }
void htmlgenInit(const char* dest) { writeToLog("Starting html generator(dst = [%s])\n",dest); bufferOut = 0; if(out) htmlgenRelease(); out = fopen(dest,"wb"); }
/** * Validates everything. Returns true if no errors, false otherwise. */ bool OBJModel::validate() { try { for (uint32_t i = 0; i < faces.size(); i++) { OBJFace f = faces.at(i); bool vtAvail = false; bool vnAvail = false; for (uint32_t j = 0; j < f.getTripletCount(); j++) { int32_t v = f.getV(j); int32_t vt = f.getVT(j); int32_t vn = f.getVN(j); if (v != 0) { if (v >= vertices.size()) { throw std::out_of_range("OBJModel::validate"); } } else { throw std::runtime_error("OBJModel::validate"); } if (vt != 0) { // Each specifier must have the same number of arguments. if (j != 0 && !vtAvail) { throw std::runtime_error("OBJModel::validate"); } vtAvail = true; if (vt >= textureCoords.size()) { throw std::out_of_range("OBJModel::validate"); } } if (vn != 0) { // Each specifier must have the same number of arguments. if (j != 0 && !vnAvail) { throw std::runtime_error("OBJModel::validate"); } vnAvail = true; if (vn >= normals.size()) { throw std::out_of_range("OBJModel::validate"); } } } } } catch (std::exception& e) { writeToLog(MessageLevel::ERROR, "EXCEPTION: %s\n", e.what()); valid = false; return false; } valid = true; return true; }
Logger::Helper::~Helper() { try { writeToLog(); } catch(std::exception&) { // you shouldn't throw exceptions from a sink Q_ASSERT(!"exception in logger helper destructor"); throw; } }
void GoForKick:: Play() { if (1) //ball1.center.y>360 { std::string g = "State == GoForKick y="; stringstream p; p << (int) ball1.center.y; g += p.str(); writeToLog(logFile, g); if (ball1.x_ball_spot > 3 && ball1.x_ball_spot < 7) { GoTo(0, StateList[State].stateString, ball1.x_ball_spot); //forward writeToLog(logFile, "GoForKick forward"); } else if (ball1.x_ball_spot < 4) { GoTo(6, StateList[State].stateString, ball1.x_ball_spot); //right writeToLog(logFile, "GoForKick right"); } else if (ball1.x_ball_spot > 6) { GoTo(-6, StateList[State].stateString, ball1.x_ball_spot); //left writeToLog(logFile, "GoForKick left"); } sleep(4); GoTo(0, StateList[State].stateString, ball1.x_ball_spot); // if (ball1.center.y<420) // sleep(15); // sleep(11) sleep(20); GoStop(); writeToLog(logFile, "Kick"); Action::GetInstance()->Start(4); while (Action::GetInstance()->IsRunning()) usleep(8 * 1000); } State = GoToBall; }
void Server::run() { writeToLog(L"Main Network Thread started."); sf::Clock clock; while(Run) { if(!isFull() && !Listening) { Listening = true; AccepterThread->launch(); } sf::Packet packet; sf::IpAddress ip; sf::Uint16 port; if(Socket.receive(packet, ip, port) == sf::Socket::Done) { if(handleUDPPacket(packet, ip, port)) { //Success } else { std::wstringstream ss; ss << L"Packet error on {YDUDP Socket}."; writeToLog(ss.str()); } } } }
//Functions related to find/replace : Start void executeFindAndReplace(){ FILE * file; char nameOfFile[256]; char textToFind[256]; char textToReplace[256]; char buffer[256]; printf("File Name\n"); writeToLog("File Name"); scanf("%s", nameOfFile); printFileContents(nameOfFile); file = fopen(nameOfFile, "r"); if(!file){ printf("The file you entered does not exist or is empty!\n"); writeToLog("The file you entered does not exist or is empty!"); fclose(file); displayMainMenu(); return; } printf("Enter text to find.\n"); writeToLog("Enter text to find."); scanf("%s", textToFind); writeToLog(textToFind); printf("Enter text to replace.\n"); writeToLog("Enter text to replace."); scanf("%s", textToReplace); writeToLog(textToReplace); while(fgets(buffer, 256, (FILE*) file)){ replace(buffer, textToFind, textToReplace); } fclose(file); displayMainMenu(); }
Logger::Helper::~Helper() { try { writeToLog(); if (level == QsLogging::FatalLevel) abort(); } catch(std::exception&) { // you shouldn't throw exceptions from a sink assert(!"exception in logger helper destructor"); throw; } }
// Functions related to the main menu void displayMainMenu(){ int option = -1; printf("+++++++++++++++++++++++\n"); printf("Sys Admin Utility\n"); printf("1. File Explorer\n"); printf("2. Find and Replace\n"); printf("3. Show the Log\n"); printf("4. Exit\n"); printf("+++++++++++++++++++++++\n"); printf("Please enter an option between 1 to 4 \n"); writeToLog("Please enter an option between 1 to 4 "); scanf("%d", &option); while(validate(option) == -1) { printf("You entered an invalid option.... please re enter an option between 1 to 4\n "); writeToLog("You entered an invalid option.... please re enter an option between 1 to 4"); scanf("%d", &option); } executeOption(option); }