bool TmovieSourceLibavcodec::init(int codecId,int AVIdx,int AVIdy) { if (!codecId || codecId>=CODEC_ID_YUY2) return false; dll=new Tdll(AVCODEC_PATH); dll->loadFunction((void**)&libavcodec_init,"libavcodec_init"); dll->loadFunction((void**)&avcodec_find_decoder,"avcodec_find_decoder"); dll->loadFunction((void**)&avcodec_open,"avcodec_open"); dll->loadFunction((void**)&avcodec_decode_video,"avcodec_decode_video"); dll->loadFunction((void**)&avcodec_flush_buffers,"avcodec_flush_buffers"); dll->loadFunction((void**)&avcodec_close,"avcodec_close"); dll->loadFunction((void**)&set_ff_idct,"set_ff_idct"); if (dll->ok) { libavcodec_init(); set_ff_idct((void*)1); avctx=(AVCodecContext*)malloc(sizeof(AVCodecContext)); memset(avctx,0,sizeof(AVCodecContext)); avctx->width =dx=AVIdx; avctx->height=dy=AVIdy; initQuant(); avctx->quant_store=quant;avctx->qstride=quantDx; DEBUGS("avcodec_find_decoder_by_name before"); AVCodec *avcodec=avcodec_find_decoder(codecId); if (!avcodec) return false; DEBUGS("avcodec_find_decoder_by_name after"); DEBUGS("avcodec_open before"); if (avcodec_open(avctx,avcodec)<0) return false; DEBUGS("avcodec_open after"); idctOld=-1; return true; } else return false; }
void do_print_all (stack *stack) { DEBUGS ('m', show_stack (stack)); int size = size_stack (stack); for (int index = 0; index < size; ++index) { print_bigint (peek_stack (stack, index)); } }
void KFActionQueue::queue(KFAction *p) { DEBUGSETUP; d->list.append(p); DEBUGS(p->objectName()); }
int PE_int_GetForwardSymbol(char *Fwd, void **Value) { char *libname; char *sym; int i; void *libbase; int ret; // -- Find seperator // PE spec says that there sould only be one, but the string may // be mutilated in the loader for(i=0;Fwd[i]!='\0';i++); for(;i&&Fwd[i]!='.';i--); Fwd[i] = '\0'; sym = &Fwd[i+1]; libname = PE_int_GetTrueFile(Fwd); DEBUGS(" PE_int_GetForwardSymbol: Get '%s' from '%s'\n", sym, libname); libbase = LoadLibrary(libname, DLL_BASE_PATH, NULL); ret = GetSymbolFromBase(libbase, sym, Value, NULL); if(!ret) { SysDebug(" PE_int_GetForwardSymbol: Unable to find '%s' in '%s'\n", sym, libname); return 0; } Fwd[i] = '.'; return ret; }
/* slot */ void KFActionQueue::actionDone(KFAction *p,bool success) { DEBUGSETUP; if (p) { if (!d->list.isEmpty() && d->list.first()==p) { d->list.removeFirst(); delete p; } else { DEBUGS( "Strange pointer received."); emit done(this,false); return; } } else { DEBUGS("Starting action queue."); } if (!success) { DEBUGS("Action failed."); emit done(this,false); return; } KFAction *next = d->list.isEmpty() ? 0 : d->list.first(); if (!next) { emit done(this,true); } else { kDebug(KFAREA) << "Running action " << next->objectName() ; QObject::connect(next,SIGNAL(done(KFAction*,bool)), this,SLOT(actionDone(KFAction*,bool))); // Propagate signals QObject::connect(next,SIGNAL(status(QString,int)), this,SIGNAL(status(QString,int))); QTimer::singleShot(0,next,SLOT(exec())); } }
void do_binop (stack *stack, bigint_binop binop) { DEBUGS ('m', show_stack (stack)); bigint *right = pop_stack (stack); bigint *left = pop_stack (stack); bigint *answer = binop (left, right); push_stack (stack, answer); free_bigint (left); free_bigint (right); }
void do_binop (stack *stack, bigint_binop binop) { DEBUGS ('m', show_stack (stack)); bigint *right = pop_stack (stack); // bigint *left = pop_stack (stack); // take the two variables bigint *answer = binop (left, right); //do the binop passed push_stack (stack, answer); free_bigint (left); free_bigint (right); }
void do_print (stack *stack) { DEBUGS ('m', show_stack (stack)); if (empty_stack(stack)) { fprintf(stderr, "mydc: stack empty\n"); } else { print_bigint (peek_stack (stack, 0), stdout); } }
token *new_token (FILE *file) { token *this = malloc (sizeof (token)); assert (this != NULL); this->file = file; this->capacity = INIT_CAPACITY; this->buffer = malloc (this->capacity); assert (this->buffer != NULL); this->buffer[0] = '\0'; this->size = 0; this->token = 0; DEBUGS ('t', show_token (this)); return this; }
void do_binop (stack *stack, bigint_binop binop) { DEBUGS ('m', show_stack (stack)); if (size_stack(stack) >= 2) { bigint *right = pop_stack (stack); bigint *left = pop_stack (stack); bigint *answer = binop (left, right); push_stack (stack, answer); free_bigint (left); free_bigint (right); } else { fprintf(stderr, "mydc: stack empty\n"); } }
/** * \fn int PE_GetSymbol(Uint Base, const char *Name, Uint *Ret) */ int PE_GetSymbol(void *Base, const char *Name, void **Ret, size_t *Size) { tPE_DOS_HEADER *dosHdr = Base; tPE_IMAGE_HEADERS *peHeaders; tPE_DATA_DIR *directory; tPE_EXPORT_DIR *expDir; Uint32 *nameTable, *addrTable; Uint16 *ordTable; int i; int symbolCount; char *name; intptr_t retVal; Uint expLen; peHeaders = (void*)( Base + dosHdr->PeHdrOffs ); directory = peHeaders->OptHeader.Directory; expDir = (void*)( Base + directory[PE_DIR_EXPORT].RVA ); expLen = directory[PE_DIR_EXPORT].Size; symbolCount = expDir->NumNamePointers; nameTable = (void*)( Base + expDir->NamePointerRVA ); ordTable = (void*)( Base + expDir->OrdinalTableRVA ); addrTable = (void*)( Base + expDir->AddressRVA ); //DEBUGS(" PE_GetSymbol: %i Symbols\n", symbolCount); for(i=0;i<symbolCount;i++) { name = (char*)( Base + nameTable[i] ); //DEBUGS(" PE_GetSymbol: '%s' = 0x%x\n", name, Base + addrTable[ ordTable[i] ]); if(strcmp(name, Name) == 0) { retVal = (intptr_t) Base + addrTable[ ordTable[i] ]; // Check for forwarding if( (intptr_t)expDir < retVal && retVal < (intptr_t)expDir + expLen) { char *fwd = (char*)retVal; DEBUGS(" PE_GetSymbol: '%s' forwards to '%s'\n", name, fwd); return PE_int_GetForwardSymbol(fwd, Ret); } *Ret = (void*)retVal; if(Size) *Size = 0; return 1; } } return 0; }
void do_print (stack *stack) { DEBUGS ('m', show_stack (stack)); print_bigint (peek_stack (stack, 0)); }
// Parse some output from the fdformat process. Lots of // #ifdefs here to account for variations in the basic // fdformat. Uses gotos to branch to whatever error message we // need, since the messages can be standardized across OSsen. // // void FDFormat::processStdOut(const QString &s) { DEBUGSETUP; #ifdef ANY_BSD if (b[0]=='F') { formatTrackCount++; emit status(QString::null, //krazy:exclude=nullstrassign for old broken gcc formatTrackCount * 100 / deviceInfo->tracks); } else if (b[0]=='E') { emit status(i18n("Error formatting track %1.", formatTrackCount),-1); } else { if (s.contains(QStringLiteral( "ioctl(FD_FORM)" ))) { emit status (i18n( "Cannot access floppy or floppy drive.\n" "Please insert a floppy and make sure that you " "have selected a valid floppy drive."),-1); return; } if (s.indexOf(QStringLiteral( "/dev/" ))>=0) { emit status(s,-1); return; } DEBUGS(s); } #elif defined(ANY_LINUX) DEBUGS(s); QRegExp regexp( QStringLiteral( "([0-9]+)" ) ); if ( s.startsWith( QStringLiteral( "bad data at cyl" ) ) || s.contains( QStringLiteral( "Problem reading cylinder" ) ) ) { if ( regexp.indexIn( s ) > -1 ) { const int track = regexp.cap(1).toInt(); emit status(i18n("Low-level formatting error at track %1.", track), -1); } else { // This error should not happen emit status(i18n("Low-level formatting error: %1", s), -1); } return; } else if (s.contains(QStringLiteral( "ioctl(FDFMTBEG)" ))) { emit status (i18n( "Cannot access floppy or floppy drive.\n" "Please insert a floppy and make sure that you " "have selected a valid floppy drive."),-1); return; } else if (s.contains(QStringLiteral( "busy" ))) // "Device or resource busy" { emit status(i18n("Device busy.\nPerhaps you need to unmount the floppy first."),-1); return; } // Be careful to leave "iotcl" as last before checking numbers else if (s.contains(QStringLiteral( "ioctl" ))) { emit status(i18n("Low-level format error: %1", s),-1); return; } // Check for numbers at last (as /dev/fd0u1440 has numbers too) else if ( regexp.indexIn(s) > -1 ) { // Normal track number (formatting or verifying) const int p = regexp.cap(1).toInt(); if ((p>=0) && (p<deviceInfo->tracks)) { emit status(QString::null, //krazy:exclude=nullstrassign for old broken gcc p * 100 / deviceInfo->tracks); } } #endif return; }
// === CODE === void *PE_Relocate(void *Base, char **envp, const char *Filename) { tPE_DOS_HEADER *dosHdr = Base; tPE_IMAGE_HEADERS *peHeaders; tPE_DATA_DIR *directory; tPE_IMPORT_DIR *impDir; tPE_HINT_NAME *name; Uint32 *importTab, *aIAT; int i, j; intptr_t iBase = (intptr_t)Base; void *pLibBase; DEBUGS("PE_Relocate: (Base=0x%x)\n", Base); peHeaders = Base + dosHdr->PeHdrOffs; directory = peHeaders->OptHeader.Directory; // === Load Import Tables impDir = Base + directory[PE_DIR_IMPORT].RVA; for( i = 0; impDir[i].DLLName != NULL; i++ ) { impDir[i].DLLName += iBase; impDir[i].ImportLookupTable += iBase/4; impDir[i].ImportAddressTable += iBase/4; DEBUGS(" PE_Relocate: DLL Required '%s'(0x%x)\n", impDir[i].DLLName, impDir[i].DLLName); pLibBase = LoadLibrary(PE_int_GetTrueFile(impDir[i].DLLName), DLL_BASE_PATH, envp); if(pLibBase == 0) { SysDebug("Unable to load required library '%s'\n", impDir[i].DLLName); return 0; } DEBUGS(" PE_Relocate: Loaded as 0x%x\n", pLibBase); importTab = impDir[i].ImportLookupTable; aIAT = impDir[i].ImportAddressTable; for( j = 0; importTab[j] != 0; j++ ) { if( importTab[j] & 0x80000000 ) DEBUGS(" PE_Relocate: Import Ordinal %i\n", importTab[j] & 0x7FFFFFFF); else { void *symPtr = 0; name = (void*)( iBase + importTab[j] ); DEBUGS(" PE_Relocate: Import Name '%s', Hint 0x%x\n", name->Name, name->Hint); if( GetSymbolFromBase(pLibBase, name->Name, symPtr, NULL) == 0 ) { SysDebug("Unable to find symbol '%s' in library '%s'\n", name->Name, impDir[i].DLLName); return 0; } aIAT[j] = (intptr_t)symPtr; } } } #if DEBUG for(i=0;i<PE_DIR_LAST;i++) { if(directory[i].RVA == 0) continue; SysDebug("directory[%i] = {RVA=0x%x,Size=0x%x}\n", i, directory[i].RVA, directory[i].Size); } #endif DEBUGS("PE_Relocate: RETURN 0x%x\n", iBase + peHeaders->OptHeader.EntryPoint); return (void*)( iBase + peHeaders->OptHeader.EntryPoint ); }