bool init() { bool Validated = true; if(Validated) Validated = initBuffer(); if(Validated) Validated = initVertexArray(); if(Validated) Validated = initProgram(); return Validated; }
void TextEdit::setText(const char *new_text) { if (!new_text) { clear(); return; } // XXX should the text be validated (FLAG_*)? size_t size = strlen(new_text); initBuffer(size + GAP_SIZE_EXPAND); insertTextAtCursor(new_text, size); }
void SendEapolStart( int fd, unsigned char *da, unsigned char *sa, WpsContext *pCtx ) { unsigned char eapol_start[] = { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00, 0x88, 0x8e, 0x02, 0x01, 0x00, 0x00 }; /* Save message for any retransmission */ freeBuffer( &pCtx->lastTx ); initBuffer( &pCtx->lastTx, (CsrUint8 *)malloc(sizeof( eapol_start )), sizeof( eapol_start ) ); memcpy( pCtx->lastTx.pStart, eapol_start, sizeof( eapol_start) ); pCtx->txCount = 0; SendEapolRequest( fd, da, sa, eapol_start, sizeof( eapol_start ) ); }
static void newframebuffer(rfbScreenInfoPtr screen, int width, int height) { unsigned char *oldfb, *newfb; maxx = width; maxy = height; oldfb = (unsigned char*)screen->frameBuffer; newfb = (unsigned char*)malloc(maxx * maxy * bpp); initBuffer(newfb); rfbNewFramebuffer(screen, (char*)newfb, maxx, maxy, 8, 3, bpp); free(oldfb); }
void FltkAggGlue::resize(int width, int height) { GNASH_REPORT_FUNCTION; if (!_offscreenbuf) { // If initialisation has not taken place yet, we don't want to touch this. return; } delete [] _offscreenbuf; initBuffer(width, height); }
LineGrid::LineGrid(int width, int depth) { for(int i = 0; i <= width; i++) { append(vec3(i, 0 ,0),vec3(i, 0, depth)); } for(int i = 0; i <= depth; i++) { append(vec3(0, 0, i),vec3(width, 0, i)); } initBuffer(); }
/** * Tests having multiple files openned and written at the same time */ int multipleOpenFilesTest() { int hr = SUCCESS; int fd, fd2, fd3, fsize = SD_SECTORSIZE; char *fname1 = "simult1"; char *fname2 = "simult2"; char *fname3 = "simult3"; char *buffer = malloc(fsize); initBuffer(buffer, fsize); FAIL_BRK4(initAndLoadDisk()); FAIL_BRK4(initFS()); // Openning the files fd = sfs_fopen(fname1); FAIL_BRK3((fd == -1), stdout, "Error: fopen for (%s) failed\n", fname1); fd2 = sfs_fopen(fname2); FAIL_BRK3((fd2 == -1), stdout, "Error: fopen for (%s) failed\n", fname2); fd3 = sfs_fopen(fname3); FAIL_BRK3((fd3 == -1), stdout, "Error: fopen for (%s) failed\n", fname3); // Writing in a different order FAIL_BRK3((sfs_fwrite(fd2, buffer, fsize) != fsize), stdout, "Error: Write failed\n"); FAIL_BRK3((sfs_fwrite(fd, buffer, fsize) != fsize), stdout, "Error: Write failed\n"); FAIL_BRK3((sfs_fwrite(fd3, buffer, fsize) != fsize), stdout, "Error: Write failed\n"); // Closing the files in different order FAIL_BRK3(sfs_fclose(fd3), stdout, "Error: Closing the file failed\n"); FAIL_BRK3(sfs_fclose(fd2), stdout, "Error: Closing the file failed\n"); FAIL_BRK3(sfs_fclose(fd), stdout, "Error: Closing the file failed\n"); FAIL_BRK3(sfs_ls(f_ls), stdout, "Error: ls failed\n"); // reload the disk and verify FAIL_BRK4(saveAndCloseDisk()); FAIL_BRK4(initAndLoadDisk()); FAIL_BRK4(verifyFile(fname1, buffer, fsize)); FAIL_BRK4(verifyFile(fname2, buffer, fsize)); FAIL_BRK4(verifyFile(fname3, buffer, fsize)); Fail: SAFE_FREE(buffer); saveAndCloseDisk(); PRINT_RESULTS("Multiple Open Files Test"); return hr; }
Socket::Socket(SOCKET sock,SOCKADDR_IN csin,ETypeConnection connection) { this->sock=sock; this->connection=connection; this->protocole=TP_TCP; this->infoConnection=csin; this->isConnect=true; initBuffer(); initMutex(mutex1); }
bool begin() { bool Validated(true); const char * Extensions = (const char *)glGetString(GL_EXTENSIONS); printf("%s", Extensions); if(Validated) Validated = initProgram(); if(Validated) Validated = initBuffer(); return Validated && glf::checkError("begin"); }
bool begin() { bool Validated = true; if(Validated) Validated = initProgram(); if(Validated) Validated = initBuffer(); if(Validated) Validated = initVertexArray(); return Validated && this->checkError("begin"); }
void initStreamLink(StreamLink* streamLink, char* streamName, Buffer* inputBuffer, char (*inputBufferArrayPointer)[], unsigned char inputBufferLength, Buffer* outputBuffer, char (*outputBufferArrayPointer)[], unsigned char outputBufferLength, OutputStream* outputStream) { streamLink->inputBuffer = inputBuffer; streamLink->outputBuffer = outputBuffer; streamLink->outputStream = outputStream; if (inputBuffer != NULL) { initBuffer(inputBuffer, inputBufferArrayPointer, inputBufferLength, streamName, IN_AS_STRING); } if (outputBuffer != NULL) { initBuffer(outputBuffer, outputBufferArrayPointer, outputBufferLength, streamName, OUT_AS_STRING); } if (outputStream != NULL) { outputStream->openOutputStream(outputStream, 0); } }
int main(void) { Clear_home(); initBuffer(); rBuf = readBuffer; wBuf = writeBuffer; (void) Cconws("STiNG test...\r\n"); BYTE found = Supexec (find_STiNG); if(!found) { sleep(3); return 0; } getServerIp(); WORD whichTests = 0; while(whichTests == 0) { showMenu(); char req = Cnecin(); if(req >= 'A' && req <= 'Z') req += 32; // to upper case if(req == 'q') break; // quit switch(req) { case 'a': // all tests whichTests = 0xffff; break; case 's': whichTests = 0x8000; break; case '0': case '1': case '2': case '3': whichTests = 1 << (req - '0'); } } if(whichTests & 1) doTest00(); if(whichTests & 2) doTest01(); if(whichTests & 4) doTest02(); if(whichTests & 8) doTest03(); if(whichTests & 0x8000) doSpeedTest(); if(whichTests != 0) writeBufferToFile(); deinitBuffer(); sleep(3); return 0; }
/* -----------------------------------------------------------------------------*/ void TTFileBuffer::setBufferSize( int size ) { if ( buffer_size != size ) { releaseBuffer(); if ( size > MAX_BUFFER_SIZE ) buffer_size = MAX_BUFFER_SIZE; else buffer_size = size; initBuffer(); } }
int readFile(Params cfg, char **files) { int fileNr, status = 0; long i; char *target, *buffer; long total = 0, remainder; FILE *fp; target = initBuffer(cfg, &status); if (status != 0) { return status; } buffer = createBuffer(cfg, &status); if (status != 0) { return status; } for (fileNr = 0; fileNr < cfg.nrFiles; fileNr++) { if (!(fp = fopen(files[fileNr], "rb"))) { fprintf(stderr, "can't open file '%s' for reading\n", files[fileNr]); return FILE_OPEN_ERROR; } for (i = 0; i < cfg.fileSize; i += cfg.bufferSize) { total += fread(buffer, sizeof(char), cfg.bufferSize, fp); if (ferror(fp)) { fprintf(stderr, "read error\n"); return READ_ERROR; } if (strncmp(buffer, target, cfg.bufferSize)) { fprintf(stderr, "read not equal to target:\n%s\n%s\n", buffer, target); return DIFF_ERROR; } } remainder = cfg.fileSize - i; if (remainder > 1) { total += fread(buffer, sizeof(char), remainder, fp); if (ferror(fp)) { fprintf(stderr, "read error\n"); return READ_ERROR; } if (strncmp(buffer, target, remainder)) { fprintf(stderr, "read not equal to target:\n%s\n%s\n", buffer, target); return DIFF_ERROR; } } fclose(fp); } free(buffer); return EXIT_SUCCESS; }
void TestInitBuffer(CuTest* tc) { char test[] = "MoooooCow"; unsigned int length = strlen (test); buffer output; CuAssertTrue(tc, initBuffer(&output,test,length) == URC_SUCCESS); buffer expected; expected.buff = test; expected.buff_size = length; expected.index = 0; expected.byte_pos=0; expected.connectedOnes=0; CuAssertTrue(tc, memcmp(&expected, &output, sizeof (buffer)) == 0); }
bool InitORL( void ) //****************** // Try and see if we will use ORL. Returns true if we'll use it. { orl_file_flags o_flags; orl_file_format o_format; orl_machine_type o_machine_type; ORLFileHnd = NULL; oFuncs.alloc = AllocMem; oFuncs.free = FreeMem; oFuncs.read = (void * (*) ( void *, int ))buffRead; oFuncs.seek = (long int (*) ( void *, long int, int ))buffSeek; ORLHnd = ORLInit( &oFuncs ); if( !ORLHnd ) { SysError( ERR_OUT_OF_MEM, false ); } initBuffer( &fileBuff, ObjFile ); o_format = ORLFileIdentify( ORLHnd, &fileBuff ); if( o_format != ORL_ELF && o_format != ORL_COFF ) { ORLFini( ORLHnd ); finiBuffer( &fileBuff ); ORLHnd = NULL; return( false ); // Will use ParseObjectOMF } ORLFileHnd = ORLFileInit( ORLHnd, &fileBuff, o_format ); if( !ORLFileHnd ) { ORLFini( ORLHnd ); finiBuffer( &fileBuff ); SysError( ERR_OUT_OF_MEM, false ); } o_machine_type = ORLFileGetMachineType( ORLFileHnd ); if( o_machine_type != ORL_MACHINE_TYPE_I386 ) { FiniORL(); Error( ERR_ORL_INV_MACHINE_TYPE, true ); exit( 1 ); } o_flags = ORLFileGetFlags( ORLFileHnd ); if( !(o_flags & ORL_FILE_FLAG_LITTLE_ENDIAN) ) { FiniORL(); Error( ERR_ORL_INV_BYTE_ORDER, true ); exit( 1 ); } UseORL = true; createHashTables(); return( true ); // Success: will use ORL }
CFFT::CFFT(QObject *parent, int size) : QObject(parent) ,window(NULL) ,winfunc(NULL) ,bufferBlock(0) ,channelSize(FRAME_SIZE) ,update(false) { xval = new double[size]; yval = new double[size]; initBuffer(size); initFFT(size); fftsize = size; setWindow(CFFT::Blackman, size); }
bool begin() { bool Validated = this->checkExtension("GL_ARB_clip_control"); if(Validated) Validated = initProgram(); if(Validated) Validated = initBuffer(); if(Validated) Validated = initVertexArray(); if(Validated) Validated = initTexture(); return Validated; }
bool begin() { bool Validated = this->checkExtension("GL_ARB_vertex_attrib_binding"); if(Validated) Validated = initProgram(); if(Validated) Validated = initBuffer(); if(Validated) Validated = initVertexArray(); if(Validated) Validated = initTexture(); return Validated; }
Packet::Packet(string p_id, string p_param, int p_sizeData, char* p_data) { initBuffer(&char_id, 4); initBuffer(&char_param, 21); for (int i=0; i < p_id.size(); i++) { this->char_id[i] = p_id[i]; } for (int i=0; i < p_param.size(); i++) { this->char_param[i] = p_param[i]; } this->sizeData = p_sizeData; if (p_data == NULL) { this->haveData = false; initBuffer(&data, 1); } else { this->haveData = true; this->data = p_data; } }
bool begin() { bool Validated = this->checkExtension("GL_ARB_shader_storage_buffer_object"); if(Validated) Validated = initBuffer(); if(Validated) Validated = initProgram(); if(Validated) Validated = initVertexArray(); if(Validated) Validated = initTexture(); return Validated; }
bool begin() { bool Validated = glf::checkGLVersion(SAMPLE_MAJOR_VERSION, SAMPLE_MINOR_VERSION); if(Validated && glf::checkExtension("GL_ARB_debug_output")) Validated = initDebugOutput(); if(Validated) Validated = initProgram(); if(Validated) Validated = initBuffer(); if(Validated) Validated = initVertexArray(); return Validated && glf::checkError("begin"); }
bool begin() { bool Validated(true); if(Validated) Validated = initProgram(); if(Validated) Validated = initBuffer(); if(Validated) Validated = initVertexArray(); if(Validated) Validated = initTexture(); return Validated; }
bool begin() { bool Validated(true); Validated = Validated && this->checkExtension("GL_ARB_copy_image"); if(Validated) Validated = initTexture(); if(Validated) Validated = initProgram(); if(Validated) Validated = initBuffer(); if(Validated) Validated = initVertexArray(); return Validated; }
bool begin() { bool Validated = true; if(Validated) Validated = initProgram(); if(Validated) Validated = initBuffer(); if(Validated) Validated = initVertexArray(); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LESS); return Validated && this->checkError("begin"); }
CameraBackgroundSkyBoxBrush::CameraBackgroundSkyBoxBrush() : _vao(0) , _vertexBuffer(0) , _indexBuffer(0) , _texture(nullptr) { #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) _backToForegroundListener = EventListenerCustom::create(EVENT_RENDERER_RECREATED, [this](EventCustom*) { initBuffer(); } ); Director::getInstance()->getEventDispatcher()->addEventListenerWithFixedPriority(_backToForegroundListener, -1); #endif }
/** * Tests the creation of a small file without attempting to read it afterwards. */ int createSimpleFileTest() { int hr = SUCCESS; int fsize = 250; char fdata[fsize]; initBuffer(fdata, fsize); FAIL_BRK4(initAndLoadDisk()); FAIL_BRK4(initFS()); FAIL_BRK4(createSmallFile("foo", fdata, fsize)); Fail: saveAndCloseDisk(); PRINT_RESULTS("Create Simple File Test"); return hr; }
bool begin() { bool Validated(true); if(Validated) Validated = initBuffer(); if(Validated) Validated = initProgram(); if(Validated) Validated = initVertexArray(); glDisable(GL_DITHER); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL_RECTANGLE_NV); return Validated; }
bool begin() { bool Validated(true); Validated = Validated && this->checkExtension("GL_EXT_texture_compression_s3tc"); if(Validated) Validated = initTexture(); if(Validated) Validated = initProgram(); if(Validated) Validated = initBuffer(); if(Validated) Validated = initVertexArray(); return Validated; }
bool begin() { bool Validated(true); Validated = Validated && this->checkExtension("GL_AMD_pinned_memory"); if(Validated) Validated = initTexture(); if(Validated) Validated = initProgram(); if(Validated) Validated = initBuffer(); if(Validated) Validated = initVertexArray(); return Validated; }