FileTransferHandler::FileTransferHandler(PsiAccount *pa, FileTransfer *ft) { d = new Private; d->pa = pa; d->c = 0; if(ft) { d->sending = false; d->peer = ft->peer(); d->fileName = clean_filename(ft->fileName()); d->fileSize = ft->fileSize(); d->desc = ft->description(); d->shift = calcShift(d->fileSize); d->complement = calcComplement(d->fileSize, d->shift); d->ft = ft; Jid proxy = d->pa->userAccount().dtProxy; if(proxy.isValid()) d->ft->setProxy(proxy); mapSignals(); } else { d->sending = true; d->ft = 0; } }
void _vm_free( void *ptr ) #endif { if (!ptr) { #ifndef NDEBUG mprintf(("Why are you trying to free a NULL pointer? [%s(%d)]\n", clean_filename(filename), line)); #else mprintf(("Why are you trying to free a NULL pointer?\n")); #endif return; } #ifndef NDEBUG _CrtMemBlockHeader* phd = pHdr(ptr); int nSize = phd->nDataSize; TotalRam -= nSize; if (Cmdline_show_mem_usage) unregister_malloc(filename, nSize, ptr); #endif _free_dbg(ptr, _NORMAL_BLOCK); }
void *_vm_realloc( void *ptr, int size, int quiet ) #endif { if (ptr == NULL) return vm_malloc(size); #ifndef NDEBUG size_t old_size = MALLOC_USABLE(ptr); #endif void *ret_ptr = realloc( ptr, size ); if (!ret_ptr) { if (quiet && (size > 0) && (ptr != NULL)) { // realloc doesn't touch the original ptr in the case of failure so we could still use it return NULL; } Error(LOCATION, "Out of memory."); } #ifndef NDEBUG size_t used_size = MALLOC_USABLE(ret_ptr); if ( Watch_malloc ) { // mprintf now uses SCP_strings = recursion! Whee!! fprintf( stdout, "Realloc %zu bytes [%s(%d)]\n", used_size, clean_filename(filename), line ); } TotalRam += (used_size - old_size); #endif return ret_ptr; }
void create_ce_statistics ( char *ce, char *c, char *file ) { file_stat *fs; char *fn; component_stat *cs; fn = clean_filename (file); cs = find_component (component); if (cs) { fs = find_filestat (cs, fn); if (fs == NULL) { fs = malloc (sizeof (file_stat)); memset (fs, 0, sizeof (file_stat)); fs->name = f_strdup(fn); if (cs->stat == NULL) { cs->stat = fs; } else { fs->next = cs->stat; cs->stat = fs; } } } sscanf (ce, "%f", &fs->ce); sscanf (c, "%d", &fs->c); }
void *_vm_malloc( int size, int quiet ) #endif { void *ptr = malloc( size ); if (!ptr) { if (quiet) { return NULL; } Error(LOCATION, "Out of memory."); } #ifndef NDEBUG size_t used_size = MALLOC_USABLE(ptr); if ( Watch_malloc ) { // mprintf now uses SCP_strings = recursion! Whee!! fprintf( stdout, "Malloc %zu bytes [%s(%d)]\n", used_size, clean_filename(filename), line ); } TotalRam += used_size; #endif return ptr; }
bool spifs_unlink(const char *filename) { int16_t fileId; char cleanname[SPIFS_FILENAME_LEN]; SPIFlash handler; // Clean the filename of problem characters. if (!clean_filename(filename, cleanname)) return false; // Wait for exclusive access to the SPI master bus. osMutexWait(spiMasterMutex, osWaitForever); // Open the SPI flash device. spi_flash_open(SPI0, SPI_MODE0, false, Freq_1Mbps, &handler); // Find a file id associated with the filename. fileId = spifs_find_filename(&handler, cleanname); // Erase each fileblock associated with the file. if (SPIFS_FILEID_VALID(fileId)) spifs_erase_blocks(&handler, fileId); // Close the SPI flash device. spi_flash_close(&handler); // Release exclusive access to the SPI master bus. osMutexRelease(spiMasterMutex); return true; }
virtual void OnEntry( void* address, const char* module, const char* symbol ) { UNREFERENCED_PARAMETER( address ); StackEntry entry; entry.module = clean_filename( module ); entry.symbol = symbol; m_stackFrames.push_back( entry ); }
void Error(const char * filename, int line, const char * format, ...) { SCP_string formatText; filename = clean_filename(filename); va_list args; va_start(args, format); vsprintf(formatText, format, args); va_end(args); SCP_stringstream messageStream; messageStream << "Error: " << formatText << "\n"; messageStream << "File: " << filename << "\n"; messageStream << "Line: " << line << "\n"; Error(messageStream.str().c_str()); }
void _vm_free( void *ptr ) #endif { if ( !ptr ) { #ifndef NDEBUG mprintf(("Why are you trying to free a NULL pointer? [%s(%d)]\n", clean_filename(filename), line)); #else mprintf(("Why are you trying to free a NULL pointer?\n")); #endif return; } #ifndef NDEBUG TotalRam -= MALLOC_USABLE(ptr); #endif // !NDEBUG free(ptr); }
void AssertMessage(const char * text, const char * filename, int linenum, const char * format, ...) { // We only want to display the file name filename = clean_filename(filename); SCP_stringstream msgStream; msgStream << "Assert: \"" << text << "\"\n"; msgStream << "File: " << filename << "\n"; msgStream << "Line: " << linenum << "\n"; if (format != nullptr) { SCP_string buffer; va_list args; va_start(args, format); vsprintf(buffer, format, args); va_end(args); msgStream << buffer << "\n"; mprintf(("ASSERTION: \"%s\" at %s:%d\n %s\n", text, filename, linenum, buffer.c_str())); } else { // No additional message mprintf(("ASSERTION: \"%s\" at %s:%d\n", text, filename, linenum)); } if (running_unittests) { throw AssertException(msgStream.str()); } msgStream << "\n"; msgStream << dump_stacktrace(); SCP_string messageText = msgStream.str(); set_clipboard_text(messageText.c_str()); messageText = truncateLines(msgStream, Messagebox_lines); messageText += "\n[ This info is in the clipboard so you can paste it somewhere now ]\n"; messageText += "\n\nUse Debug to break into Debugger, Exit will close the application.\n"; Error(messageText.c_str()); }
void create_be_statistics ( char *be, char *b, char *file ) { file_stat *fs; char *fn; component_stat *cs; fn = clean_filename (file); cs = find_component (component); if (cs) { fs = find_filestat (cs, fn); if (fs == NULL) { fs = malloc (sizeof (file_stat)); memset (fs, 0, sizeof (file_stat)); fs->name = f_strdup(fn); if (cs->stat == NULL) { cs->stat = fs; } else { fs->next = cs->stat; cs->stat = fs; } } } sscanf (be, "%f", &fs->be); sscanf (b, "%d", &fs->b); #if 0 if ((fs->be < 80.0) && !(fs->be == 0.0 && fs->sle == 100.0)) { cs->files_fail_on_limit++; } else { cs->files_pass_on_limit++; if (missed_functions) { cs->files_fail_untouched_functions++; } } fs->mf = missed_functions; #endif }
/** Final preparation for recording. */ void IngexRecorder::Setup( framecount_t start_timecode, const prodauto::ProjectName & project_name) { ACE_DEBUG((LM_DEBUG, ACE_TEXT("IngexRecorder::Setup()\n"))); // Get ProjectName associated with supplied name. //prodauto::ProjectName project_name; //GetProjectFromDb(project, project_name); // Store project name mProjectName = project_name; // Get current recorder settings RecorderSettings * settings = RecorderSettings::Instance(); settings->Update(mpImpl->Recorder()); /* switch (settings->timecode_mode) { case LTC_PARAMETER_VALUE: IngexShm::Instance()->TcMode(IngexShm::LTC); ACE_DEBUG((LM_DEBUG, ACE_TEXT("LTC mode\n"))); break; case VITC_PARAMETER_VALUE: IngexShm::Instance()->TcMode(IngexShm::VITC); ACE_DEBUG((LM_DEBUG, ACE_TEXT("VITC mode\n"))); break; default: ACE_DEBUG((LM_ERROR, ACE_TEXT("Unexpected timecode mode\n"))); break; } */ //unsigned int n_channels = IngexShm::Instance()->Channels(); // Tracks per channel // e.g. 5 (1 video, 4 audio) or 9 (1 video, 8 audio) // A bit dodgy as different inputs on a recorder can have // different numbers of tracks. //mTracksPerChannel = track_enables.size() / channel_enables.size(); int first_enabled_channel = -1; for (unsigned int i = 0; first_enabled_channel < 0 && i < mChannelEnable.size(); ++i) { if (mChannelEnable[i]) { first_enabled_channel = i; } } // Create any needed paths. // NB. Paths need to be same as those used in recorder_fucntions.cpp for (std::vector<EncodeParams>::iterator it = settings->encodings.begin(); it != settings->encodings.end(); ++it) { if (USE_PROJECT_SUBDIR) { std::string project_subdir = mProjectName.name; clean_filename(project_subdir); it->dir += PATH_SEPARATOR; it->dir += project_subdir; it->copy_dest += PATH_SEPARATOR; it->copy_dest += project_subdir; } FileUtils::CreatePath(it->dir); if (it->file_format == MXF_FILE_FORMAT_TYPE) { // Make Creating and Failures subdirs for MXF std::ostringstream creating_path; creating_path << it->dir << PATH_SEPARATOR << settings->mxf_subdir_creating; FileUtils::CreatePath(creating_path.str()); std::ostringstream failures_path; failures_path << it->dir << PATH_SEPARATOR << settings->mxf_subdir_failures; FileUtils::CreatePath(failures_path.str()); //std::ostringstream metadata_path; //metadata_path << it->dir << PATH_SEPARATOR << settings->mxf_subdir_metadata; //FileUtils::CreatePath(metadata_path.str()); } else { // Make Creating subdir for other formats std::ostringstream creating_path; creating_path << it->dir << PATH_SEPARATOR << CREATING_SUBDIR; FileUtils::CreatePath(creating_path.str()); } } // Set up encoding threads int encoding_i = 0; for (std::vector<EncodeParams>::const_iterator it = settings->encodings.begin(); it != settings->encodings.end(); ++it, ++encoding_i) { if (it->source == Input::NORMAL) { for (unsigned int i = 0; i < mChannelEnable.size(); i++) { if (mChannelEnable[i]) { ThreadParam tp; tp.p_rec = this; tp.p_opt = new RecordOptions; tp.p_opt->channel_num = i; tp.p_opt->index = encoding_i; tp.p_opt->resolution = it->resolution; tp.p_opt->file_format = it->file_format; tp.p_opt->bitc = it->bitc; tp.p_opt->dir = it->dir; mThreadParams.push_back(tp); } } } else if (it->source == Input::QUAD) { ThreadParam tp; tp.p_rec = this; tp.p_opt = new RecordOptions; tp.p_opt->channel_num = first_enabled_channel; tp.p_opt->index = encoding_i; tp.p_opt->quad = true; tp.p_opt->resolution = it->resolution; tp.p_opt->file_format = it->file_format; tp.p_opt->bitc = it->bitc; tp.p_opt->dir = it->dir; mThreadParams.push_back(tp); } } #if 0 // For test only, add a further encoding { ThreadParam tp; tp.p_rec = this; tp.p_opt = new RecordOptions; tp.p_opt->channel_num = 0; tp.p_opt->index = 2; tp.p_opt->resolution = 8; tp.p_opt->file_format = MXF_FILE_FORMAT_TYPE; tp.p_opt->bitc = true; tp.p_opt->dir = "/video/mxf_offline"; mThreadParams.push_back(tp); } #endif // Create and store filenames based on source, target timecode and date. ::Timecode tc(start_timecode, mFps, mDf); std::string date = DateTime::DateNoSeparators(); const char * tcode = tc.TextNoSeparators(); // We also include project name to help with copying to project-based // directories on a file-server. // Note that we make sure ident does not contain any unsuitable // characters such as '/' // Set filename stems in RecordOptions. for (std::vector<ThreadParam>::iterator it = mThreadParams.begin(); it != mThreadParams.end(); ++it) { const char * src_name = (it->p_opt->quad ? QUAD_NAME : SOURCE_NAME[it->p_opt->channel_num]); std::ostringstream ss; ss << date << "_" << tcode << "_" << mProjectName.name << "_" << mpImpl->Name() << "_" << src_name << "_" << it->p_opt->index; std::string ident = ss.str(); clean_filename(ident); it->p_opt->file_ident = ident; } // Set up some of the user comments mUserComments.clear(); mUserComments.push_back( prodauto::UserComment(AVID_UC_SHOOT_DATE_NAME, date.c_str(), STATIC_COMMENT_POSITION, 0)); }
void ReleaseWarning(const char* filename, int line, const char* format, ...) { Global_warning_count++; filename = clean_filename(filename); // output to the debug log before anything else (so that we have a complete record) SCP_string formatMessage; va_list args; va_start(args, format); vsprintf(formatMessage, format, args); va_end(args); SCP_string printfString = formatMessage; std::transform(printfString.begin(), printfString.end(), printfString.begin(), replaceNewline); mprintf(("WARNING: \"%s\" at %s:%d\n", printfString.c_str(), filename, line)); // now go for the additional popup window, if we want it ... if (Cmdline_noninteractive) { return; } if (running_unittests) { throw AssertException(printfString); } SCP_stringstream boxMsgStream; boxMsgStream << "Warning: " << formatMessage << "\n"; boxMsgStream << "File: " << filename << "\n"; boxMsgStream << "Line: " << line << "\n"; boxMsgStream << "\n"; boxMsgStream << dump_stacktrace(); set_clipboard_text(boxMsgStream.str().c_str()); SCP_string boxMessage = truncateLines(boxMsgStream, Messagebox_lines); boxMessage += "\n[ This info is in the clipboard so you can paste it somewhere now ]\n"; boxMessage += "\n\nUse Debug to break into Debugger\n"; const SDL_MessageBoxButtonData buttons[] = { { SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, 2, "Exit" }, { SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT, 1, "Continue" }, { /* .flags, .buttonid, .text */ 0, 0, "Debug" }, }; SDL_MessageBoxData boxData; memset(&boxData, 0, sizeof(boxData)); boxData.buttons = buttons; boxData.numbuttons = 3; boxData.colorScheme = nullptr; boxData.flags = SDL_MESSAGEBOX_WARNING; boxData.message = boxMessage.c_str(); boxData.title = "Warning!"; boxData.window = os::getSDLMainWindow(); gr_activate(0); int buttonId; if (SDL_ShowMessageBox(&boxData, &buttonId) < 0) { // Call failed exit(1); } switch (buttonId) { case 2: exit(1); case 0: Int3(); break; default: break; } gr_activate(1); }
/* découpe la commande en mots et les mettre dans elem elem doit se termine par NULL pour execvp */ void decoupe_cmd(char line[] , char *elem[]) { if (!line) exit; char* first = line; char* cpt = line; if (strchr(line , '&')) en_fond = 1; if (strchr(line , '*')) use_glob = 1; if (strchr(line , '>')) { redirected = 1; red_type = STDOUT; } if (strchr(line , '<')) { redirected = 1; red_type = STDIN; } if (strchr(line , '>')==(strrchr(line , '>')-1)) { double_redirection = 1; printf("first = %d ; last %d",strchr(line , '>') , strrchr(line , '>')); fflush(stdout); } int i; if (redirected) { if (red_type == STDOUT)first = strtok( line, ">"); else first = strtok( line, "<"); } if ((redirected && red_type == STDIN)) { redirected = 1; if (red_file!= NULL ) { char *_red_file; _red_file = strtok( NULL, "<" ); red_file = clean_filename(_red_file); exit; } } if (redirected && red_type == STDOUT) { redirected = 1; if (red_file!= NULL ) { char *_red_file; _red_file = strtok( NULL, ">" ); red_file = clean_filename(_red_file); exit; } } //ligne = strtok(ligne , '|'); for (i=0;i<MAXELEMS-1; i++) { /* saute les espaces */ while (*first && (isspace(*first) || (*first=='&'))) first++; /* fin de ligne ? */ if (!*first) break; /* on se souvient du début de ce mot */ elem[i] = first; cpt = first; /* cherche la fin du mot */ while (*cpt && !isspace(*cpt) ) cpt++; /* saute le mot */ /* termine le mot par un \0 et passe au suivant */ if (*cpt) { *cpt = 0; cpt++; } first = cpt; } elem[i] = NULL; // le dernier doit etre NULL pour execvp if ((i!=0)&&(((strncmp(elem[0],"ls", 2))==0)||((strncmp(elem[0],"grep", 4))==0))) { //Ajouter la colorisation int fin = 0; char* temp; do { fin++; } while (elem[fin]!=NULL); int i; for (i=fin;i>1;i--) elem[i]=elem[i-1]; elem[1]="--color=auto"; elem[fin+1] = NULL; } }
// Open the named file for reading or writing. bool spifs_open(const char *filename, bool write, SPIFSFile *file) { bool retval; int16_t fileId; uint32_t sectorOffset; SPIFSFileBlock fileBlock; SPIFlash handler; char cleanname[SPIFS_FILENAME_LEN]; // Assume we fail. retval = false; // Initialize the file structure. memset(file, 0, sizeof(SPIFSFile)); // Clean the filename of problem characters. if (!clean_filename(filename, cleanname)) return false; // Wait for exclusive access to the SPI master bus. osMutexWait(spiMasterMutex, osWaitForever); // Open the SPI flash device. spi_flash_open(SPI0, SPI_MODE0, false, Freq_1Mbps, &handler); // Get the file id of any file with the same filename. fileId = spifs_find_filename(&handler, cleanname); // Are we opening the file for writing? if (write) { // Erase each fileblock associated with the existing file. if (SPIFS_FILEID_VALID(fileId)) spifs_erase_blocks(&handler, fileId); // Find a free sector. fileId = spifs_free_block(&handler); // Did we find a free sector? if (SPIFS_FILEID_VALID(fileId)) { // Prepare the sector for writing. file->write = true; file->fileId = fileId; file->blockId = 0; file->blockSize = SPIFS_FILENAME_LEN; file->blockIndex = SPIFS_FILENAME_LEN; file->thisId = fileId; file->nextId = -1; file->position = SPIFS_FILENAME_LEN; // Get the byte offset of the sector at the start of the file. // The sector id is equal to the file id. sectorOffset = SPIFS_SECTORID_TO_BYTEOFFSET(fileId); // Write the file id. spi_flash_write(&handler, sectorOffset + SPIFS_FILEID_OFFSET, (uint8_t *) &file->fileId, sizeof(int16_t)); // Write the block id. spi_flash_write(&handler, sectorOffset + SPIFS_BLOCKID_OFFSET, (uint8_t *) &file->blockId, sizeof(int16_t)); // Write the file name. spi_flash_write(&handler, sectorOffset + SPIFS_FILENAME_OFFSET, (uint8_t *) cleanname, SPIFS_FILENAME_LEN); // We won't write the other header information until we begin // writing the next file block or the file is closed. // We succeeded opening the file for writing. retval = true; } } else { // If we are reading a file we must have a valid file id. if (SPIFS_FILEID_VALID(fileId)) { // Get the byte offset of the sector at the start of the file. // The sector id is equal to the file id. sectorOffset = SPIFS_SECTORID_TO_BYTEOFFSET(fileId); // Read in the first block header. spi_flash_read(&handler, sectorOffset, (uint8_t *) &fileBlock, sizeof(fileBlock)); // Initialize the file structure. file->write = false; file->fileId = fileBlock.fileId; file->blockId = fileBlock.blockId; file->blockSize = fileBlock.blockSize; file->blockIndex = SPIFS_FILENAME_LEN; file->thisId = fileBlock.fileId; file->nextId = fileBlock.nextId; file->position = SPIFS_FILENAME_LEN; // Sanity check the block size. if (!SPIFS_BLOCKSIZE_VALID(file->blockSize)) file->blockSize = SPIFS_BLOCK_SIZE; // We succeeded opening the file for reading. retval = true; } } // Close the SPI flash device. spi_flash_close(&handler); // Release exclusive access to the SPI master bus. osMutexRelease(spiMasterMutex); return retval; }