コード例 #1
0
ファイル: banner.c プロジェクト: BruceFletcher/Badges
/**
 * Animate a simple banner on the display.
 */
void banner_run(void)
{
  uint8_t  timer;

  matrix_clear_all();

  timer = timer_set_callback(4, TIMER_REPEAT, &banner_callback);

  button_pressed = 0;

  button_debounce_aux(25);

  matrix_start_scanning();

  while (1)
  {
    wipe(1);  // left to right, normal colours
    wipe(2);  // right to left, inverted colours

    if (button_pressed)
      break;
  }

  wipe(3);  // left to right, clearing display

  matrix_stop_scanning();

  timer_clear_callback(timer);
}
コード例 #2
0
ファイル: command.c プロジェクト: dtaht/hashlet
bool set_otp_zone (int fd, struct octet_buffer *otp_zone)
{

  assert (NULL != otp_zone);

  const unsigned int SIZE_OF_WRITE = 32;
  /* The device must be using an OTP read only mode */

  if (!is_otp_read_only_mode (fd))
    assert (false);

  /* The writes must be done in 32 bytes blocks */

  uint8_t nulls[SIZE_OF_WRITE];
  uint8_t part1[SIZE_OF_WRITE];
  uint8_t part2[SIZE_OF_WRITE];
  struct octet_buffer buf ={};
  wipe (nulls, SIZE_OF_WRITE);
  wipe (part1, SIZE_OF_WRITE);
  wipe (part2, SIZE_OF_WRITE);

  /* Simple check to make sure PACKAGE_VERSION isn't too long */
  assert (strlen (PACKAGE_VERSION) < 10);

  /* Setup the fixed OTP data zone */
  sprintf ((char *)part1, "CRYPTOTRONIX HASHLET REV: A");
  sprintf ((char *)part2, "SOFTWARE VERSION: %s", PACKAGE_VERSION);

  bool success = true;

  buf.ptr = nulls;
  buf.len = sizeof (nulls);

  /* Fill the OTP zone with blanks from their default FFFF */
  success = write32 (fd, OTP_ZONE, 0, buf);

  if (success)
    success = write32 (fd, OTP_ZONE, SIZE_OF_WRITE / sizeof (uint32_t), buf);

  /* Fill in the data */
  buf.ptr = part1;
  CTX_LOG (DEBUG, "Writing: %s", buf.ptr);
  if (success)
    success = write32 (fd, OTP_ZONE, 0, buf);
  buf.ptr = part2;
  CTX_LOG (DEBUG, "Writing: %s", buf.ptr);
  if (success)
    success = write32 (fd, OTP_ZONE, SIZE_OF_WRITE / sizeof (uint32_t), buf);

  /* Lastly, copy the OTP zone into one contiguous buffer.
     Ironically, the OTP can't be read while unlocked. */
  if (success)
    {
      otp_zone->len = SIZE_OF_WRITE * 2;
      otp_zone->ptr = malloc_wipe (otp_zone->len);
      memcpy (otp_zone->ptr, part1, SIZE_OF_WRITE);
      memcpy (otp_zone->ptr + SIZE_OF_WRITE, part2, SIZE_OF_WRITE);
    }
  return success;
}
コード例 #3
0
ファイル: LifeApp.cpp プロジェクト: blackketter/britepad
void LifeApp::run() {
  BritepadApp::run();
  bool mouseMoved = ((Uptime::millis() - usbMouse.lastMove()) < 500);
  AppMode mode = getAppMode();

  if (mode == MOUSE_MODE || mode == INTERACTIVE_MODE || mouseMoved) {
    if ((pad.pressed(SCREEN_PAD) || mouseMoved) && generation) {
      wipe();
    }
    coord_t lastX, lastY;
    bool draw = false;
    if (mouseMoved) {
      lastX = usbMouse.x();
      lastY = usbMouse.y();
      draw = true;
    } else if (pad.touched(SCREEN_PAD)) {
      lastX = pad.x();
      lastY = pad.y();
      draw = true;
    }

    if (draw) {
      int x, y;
      if (dots->hit(lastX, lastY, &x, &y)) {
        dots->setDot(x,y, MAXCOLOR);
        dots->updateDot(x,y);
        nextRun = pad.time() + MILLIS_DELAY;
      }
    }
  }
  iterate();
}
コード例 #4
0
 void reset(unsigned char* pTaint)
 {
     wipe(m_pHash, DIGEST_BYTES);
     m_pPos = m_pBuf;
     m_remaining = DIGEST_BYTES;
     m_pTaint = pTaint;
 }
コード例 #5
0
ファイル: Gravity.c プロジェクト: OHamm/Random
void draw(double speedx, double speedy){
	pthread_t pth;
	struct thread_data data[1];
	int thr;
	SDL_Surface* screen = NULL;
	SDL_Init(SDL_INIT_EVERYTHING);
	SDL_Event evt;
	//Fill background
	screen = SDL_SetVideoMode(SIZEOFSCREEN,SIZEOFSCREEN,32,SDL_SWSURFACE);
	wipe(screen);
	
	data[0].screen = screen;
	data[0].speedx = speedx;
	data[0].speedy = speedy;
	
	if ((thr=pthread_create(&pth,NULL,gravity,(void*)&data))!=0){
		perror("Erreur");
		exit(EXIT_FAILURE);
	}
	printf("Press E to exit\n");
	fflush(stdout);
	do{
		SDL_WaitEvent(&evt);
	}while(evt.type != SDL_KEYDOWN || evt.key.keysym.sym != SDLK_e);
	quit_nicely=1;
	SDL_Quit();
}
コード例 #6
0
ファイル: keys.c プロジェクト: AbrahamJewowich/FreeSWITCH
void
pubKeyEnd(struct PubKey *pub)
{
	if (pub) {
		bnEnd(&pub->n);
		bnEnd(&pub->e);
		wipe(pub);
	}
}
コード例 #7
0
ファイル: AudioOutput.cpp プロジェクト: andrewgmorris/mumble
AudioOutput::~AudioOutput() {
	bRunning = false;
	wait();
	wipe();

	delete [] fSpeakers;
	delete [] fSpeakerVolume;
	delete [] bSpeakerPositional;
}
コード例 #8
0
ファイル: keys.c プロジェクト: AbrahamJewowich/FreeSWITCH
void
secKeyEnd(struct SecKey *sec)
{
	if (sec) {
		bnEnd(&sec->d);
		bnEnd(&sec->p);
		bnEnd(&sec->q);
		bnEnd(&sec->u);
		wipe(sec);
	}
}
コード例 #9
0
ファイル: main.c プロジェクト: NovemberFoxtrot/sea
void wipe(char **xy, int i, int j) {
	for (int x = -1; x < 2; x++) {
		for (int y = -1; y < 2; y++) {
			if (i + x < 0 || i + x > 9) continue;
			if (j + y < 0 || j + y > 9) continue;
			if (xy[i + x][j + y] != 'w') continue;

			xy[i + x][j + y] = '.';

			wipe(xy, i + x, j + y);
		}
	}
}
コード例 #10
0
ファイル: menu.cpp プロジェクト: johndoe123/scummvm
void MenuItem::select(byte which) {
    if (!_options[which]._valid)
        return;

    _choiceNum = which;
    wipe();

    if (_choiceNum == _optionNum)
        _choiceNum--; // Off the bottom.
    if (_choiceNum > _optionNum)
        _choiceNum = 0; // Off the top, I suppose.

    (_menu->*_menu->_menuBar._menuItems[_activeNum]._chooseFunc)();
}
コード例 #11
0
ファイル: MeshManager.cpp プロジェクト: e-biz/arpi-gl
    //----------------------------------------------------------------------------------------------
    void MeshManager::wipe() {
        Log::trace(TAG, "Wiping MeshManager...");

        assert(mFallbackMesh != nullptr);
        mFallbackMesh->wipe();

        for (auto& kv : mMeshes) {
            auto mesh = kv.second;
            assert(mesh != nullptr);
            mesh->wipe();
        }

        Log::trace(TAG, "MeshManager wiped");
    }
コード例 #12
0
ファイル: main.c プロジェクト: NovemberFoxtrot/sea
int count_lakes(char **xy) {
	int result = 0;

	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			if (xy[i][j] != '.') {
				result++;
				wipe(xy, i, j);
			}
		}
	}

	return result;
}
コード例 #13
0
ファイル: lamboot.c プロジェクト: haxplorer/ckptrd
/*
 *	bail
 *
 *	Function:	- cleans up and bails out
 *	Returns:	- does not return, exits with error code
 */
static void
bail(int sig)
{
  int err_save;			/* saved error code */

  err_save = errno;
  wipe();
  if (fl_verbose || fl_debug) 
    fprintf(stderr, "lamboot did NOT complete successfully\n");
  lam_ssi_base_close();
  if (err_save != 0)
    exit(err_save);
  else
    exit(sig); 
  /* Since we want to return with non zero exit status, exit status is
     set to signal number if its 0 */
}
コード例 #14
0
ファイル: owncloudfolder.cpp プロジェクト: Big-Data/mirall
void ownCloudFolder::slotLocalPathChanged( const QString& dir )
{
    QDir notifiedDir(dir);
    QDir localPath( path() );

    if( notifiedDir.absolutePath() == localPath.absolutePath() ) {
        if( !localPath.exists() ) {
            qDebug() << "XXXXXXX The sync folder root was removed!!";
            if( _thread && _thread->isRunning() ) {
                qDebug() << "CSync currently running, set wipe flag!!";
            } else {
                qDebug() << "CSync not running, wipe it now!!";
                wipe();
            }

            qDebug() << "ALARM: The local path was DELETED!";
        }
    }
}
コード例 #15
0
ファイル: MeshManager.cpp プロジェクト: e-biz/arpi-gl
    //----------------------------------------------------------------------------------------------
    void MeshManager::unload() {
        Log::trace(TAG, "Unloading MeshManager...");

        assert(mFallbackMesh != nullptr);
        mFallbackMesh->wipe();
        mFallbackMesh = nullptr; //release reference count

        for (auto& kv : mMeshes) {
            const std::string& sid = kv.first;
            auto mesh = kv.second;
            assert(mesh != nullptr);
            Log::trace(TAG, "Deleting Mesh %s", sid.c_str());
            mesh->wipe();
        }

        mMeshes.clear();

        Log::trace(TAG, "MeshManager unloaded");
    }
コード例 #16
0
ファイル: main.c プロジェクト: lhcoyle4/16bit-arm-memcpy
int main(void) {
    int i, n;
    char *source, *dest;

    for(i = 0; i < 1000; i++) {
        /* fill the memory with a known pattern */
        wipe(memory);

        /* randomly generated parameters */
        n = 1 + (rand() & 1023);
        //n = 512;
        source = memory + rand() % (MEM_SIZE-n);
        dest = memory + rand() % (MEM_SIZE-n);
        //source = memory + 1022;
        //dest = memory + 1478;

        blockmove(source, dest, n);
        verify(source, dest, n);
    }
    return 0;
}
コード例 #17
0
ファイル: owncloudfolder.cpp プロジェクト: Big-Data/mirall
void ownCloudFolder::slotCSyncFinished()
{
    qDebug() << "-> CSync Finished slot with error " << _csyncError;

    if (_csyncError) {
        _syncResult.setStatus(SyncResult::Error);

        qDebug() << "  ** error Strings: " << _errors;
        _syncResult.setErrorStrings( _errors );
        qDebug() << "    * owncloud csync thread finished with error";
        if( _wipeDb ) wipe();
    } else if (_csyncUnavail) {
        _syncResult.setStatus(SyncResult::Unavailable);
    } else {
        _syncResult.setStatus(SyncResult::Success);
    }

    if( _thread && _thread->isRunning() ) {
        _thread->quit();
    }
    emit syncFinished( _syncResult );
}
コード例 #18
0
void solve(char** board, int boardRowSize, int boardColSize) {
    bool** walked = malloc(sizeof(bool*) * boardRowSize);
    int size = boardRowSize * boardColSize / 2;
    size = size < 2 ? 2 : size;
    int* xq = malloc(sizeof(int) * size);
	int* yq = malloc(sizeof(int) * size);
    int i, j;
    for (i = 0 ; i < boardRowSize ; i++) {
        walked[i] = malloc(sizeof(bool) * boardColSize);
        for (j = 0 ; j < boardColSize ; j++) {
            walked[i][j] = (board[i][j] == 'X'); // assume the 'X' is walked
        }
    }
    for (i = 0 ; i < boardRowSize ; i++) {
        for (j = 0 ; j < boardColSize ; j++) {
            if (walked[i][j] == false) {
                if (isSurrounded(board, boardRowSize, boardColSize, walked, i, j, xq, yq, size)) {
                    wipe(board, boardRowSize, boardColSize, walked, i, j, xq, yq, size);
                }
            }
        }
    }
}
コード例 #19
0
ファイル: MeshManager.cpp プロジェクト: e-biz/arpi-gl
    //----------------------------------------------------------------------------------------------
    Status MeshManager::reload() {
        Log::trace(TAG, "Reloading MeshManager...");

        mFallbackMesh->wipe();
        mLoad(mFallbackMesh, FALLBACK_MESH_SID);

        for (auto& kv : mMeshes) {
            const std::string& sid = kv.first;
            auto mesh = kv.second;
            if (mesh != nullptr) {
                mesh->wipe();
                mesh->clearCache();
                if (mLoad(mesh, sid) != STATUS_OK) {
                    Log::error(TAG, "Error while refreshing mesh %s", sid.c_str());
                    assert(false);
                    return STATUS_KO;
                }
            }
        }

        Log::trace(TAG, "MeshManager reloaded");
        return STATUS_OK;
    }
コード例 #20
0
//--------------------------------------------------------------
void ofxMtlBoxFitting::make(int s) {
	seed = s;
	ofSeedRandom(seed);
	wipe();
	for (int r=0; r<rows; r++) {
		for (int c=0; c<cols; c++) {
			int cell = cells[r][c];
			if (cell != 0) continue;
			// figure out the size of area to occupy
			int sizer, limit;
			do {
				limit = MIN(cols-c, rows-r);
				limit = MIN(limit, maxsizer);
				sizer = int(ofRandom(0, limit))+1;
			} while(isOccupied(c,r,sizer,sizer));
			// flag all cells as occupied by width x height area
			doOccupy(c,r,sizer,sizer,sizer);
			// indicate work to perform in upper-left cell
			int work = WORK_DONE;
			cells[r][c] |= (work<<16);
		} // for c
	} // for r
}
コード例 #21
0
ファイル: folder.cpp プロジェクト: stonerl/client
void Folder::slotAboutToRemoveAllFiles(SyncFileItem::Direction, bool *cancel)
{
    QString msg =
        tr("This sync would remove all the files in the sync folder '%1'.\n"
           "This might be because the folder was silently reconfigured, or that all "
           "the files were manually removed.\n"
           "Are you sure you want to perform this operation?");
    QMessageBox msgBox(QMessageBox::Warning, tr("Remove All Files?"),
                       msg.arg(alias()));
    msgBox.addButton(tr("Remove all files"), QMessageBox::DestructiveRole);
    QPushButton* keepBtn = msgBox.addButton(tr("Keep files"), QMessageBox::AcceptRole);
    if (msgBox.exec() == -1) {
        *cancel = true;
        return;
    }
    *cancel = msgBox.clickedButton() == keepBtn;
    if (*cancel) {
        wipe();
        // speed up next sync
        _lastEtag.clear();
        _forceSyncOnPollTimeout = true;
        QTimer::singleShot(50, this, SLOT(slotRunEtagJob()));
    }
}
コード例 #22
0
ファイル: wipe.c プロジェクト: 2fast4u88/oxygen_system_core
int wipe_main (int argc, char *argv[])
{
    char *whatToWipe;

    if (argc != 2) return usage();

    whatToWipe = argv[1];

    if (0 == strcmp (whatToWipe, "system")) {
        fprintf(stdout, "Wiping /system\n");
        wipe ("/system");
        fprintf(stdout, "Done wiping /android\n");
    } else if (0 == strcmp (whatToWipe, "data")) {
        fprintf(stdout, "Wiping /data\n");
        wipe ("/data");
        fprintf(stdout, "Done wiping /data\n");
    } else if (0 == strcmp (whatToWipe, "all")) {
        fprintf(stdout, "Wiping /system and /data\n");
        wipe ("/system");
        wipe ("/data");
        fprintf(stdout, "Done wiping /system and /data\n");
    } else if (0 == strcmp(whatToWipe, "nuke")) {
		int ret;
		fprintf(stdout, "Nuking the device...\n");
		wipe ("/system");
        wipe ("/data");
		fprintf(stdout, "Device nuked! Rebooting...\n");
		ret = reboot(RB_AUTOBOOT);
	    if (ret < 0) {
	        fprintf(stderr, "Reboot failed, %s\n", strerror(errno));
	        return 1;
	    }
	} else {
        return usage();
    }

    return 0;
}
コード例 #23
0
ファイル: wipe.c プロジェクト: 2fast4u88/oxygen_system_core
static void wipe (const char *path) 
{
    DIR *dir;
    struct dirent *de;
    int ret;

    dir = opendir(path);

    if (dir == NULL) {
        fprintf (stderr, "Error opendir'ing %s '%s'\n",
                    path, strerror(errno));
        return;
    }

    char *filenameOffset;

    strcpy(nameBuffer, path);
    strcat(nameBuffer, "/");

    filenameOffset = nameBuffer + strlen(nameBuffer);

    for (;;) {
        de = readdir(dir);

        if (de == NULL) {
            break;
        }

        if (0 == strcmp(de->d_name, ".")
                || 0 == strcmp(de->d_name, "..")
                || 0 == strcmp(de->d_name, "lost+found")
        ) {
            continue;
        }

        strcpy(filenameOffset, de->d_name);

        ret = lstat (nameBuffer, &statBuffer);

        if (ret != 0) {
            fprintf(stderr, "stat() error on '%s' '%s'\n", 
                    nameBuffer, strerror(errno));
        }

        if(S_ISDIR(statBuffer.st_mode)) {
            int i;
            char *newpath;

#if 0
            closedir(dir);
#endif

            newpath = strdup(nameBuffer);
            wipe(newpath);

            /* Leave directories created by init, they have special permissions. */
            for (i = 0; INIT_DIRS[i]; i++) {
                if (strcmp(INIT_DIRS[i], newpath) == 0) {
                    break;
                }
            }
            if (INIT_DIRS[i] == NULL) {
                ret = rmdir(newpath);
                if (ret != 0) {
                    fprintf(stderr, "rmdir() error on '%s' '%s'\n", 
                        newpath, strerror(errno));
                }
            }

            free(newpath);

#if 0
            dir = opendir(path);
            if (dir == NULL) {
                fprintf (stderr, "Error opendir'ing %s '%s'\n",
                            path, strerror(errno));
                return;
            }
#endif

            strcpy(nameBuffer, path);
            strcat(nameBuffer, "/");

        } else {
            ret = unlink(nameBuffer);

            if (ret != 0) {
                fprintf(stderr, "unlink() error on '%s' '%s'\n", 
                    nameBuffer, strerror(errno));
            }
        }
    }

    closedir(dir);

}
コード例 #24
0
ファイル: backup.cpp プロジェクト: Abhishekh-TEL/pdroid
/* This is just copied from the shell's built-in wipe command. */
static int wipe (const char *path) 
{
    DIR *dir;
    struct dirent *de;
    int ret;
    int i;

    dir = opendir(path);

    if (dir == NULL) {
        fprintf (stderr, "Error opendir'ing %s: %s\n",
                    path, strerror(errno));
        return 0;
    }

    char *filenameOffset;

    strcpy(nameBuffer, path);
    strcat(nameBuffer, "/");

    filenameOffset = nameBuffer + strlen(nameBuffer);

    for (;;) {
        de = readdir(dir);

        if (de == NULL) {
            break;
        }

        if (0 == strcmp(de->d_name, ".")
                || 0 == strcmp(de->d_name, "..")
                || 0 == strcmp(de->d_name, "lost+found")
        ) {
            continue;
        }

        strcpy(filenameOffset, de->d_name);
        bool noBackup = false;
        
        /* See if this is a path we should skip. */
        for (i = 0; SKIP_PATHS[i].path; i++) {
            if (strcmp(SKIP_PATHS[i].path, nameBuffer) == 0) {
                if (opt_backupAll || SKIP_PATHS[i].type == SPECIAL_NO_BACKUP) {
                    // In this case we didn't back up the directory --
                    // we do want to wipe its contents, but not the
                    // directory itself, since the restore file won't
                    // contain the directory.
                    noBackup = true;
                }
                break;
            }
        }
        
        if (!noBackup && SKIP_PATHS[i].path != NULL) {
            // This is a SPECIAL_NO_TOUCH directory.
            continue;
        }

        ret = lstat (nameBuffer, &statBuffer);

        if (ret != 0) {
            fprintf(stderr, "warning -- stat() error on '%s': %s\n", 
                    nameBuffer, strerror(errno));
            continue;
        }

        if(S_ISDIR(statBuffer.st_mode)) {
            int i;
            char *newpath;

            newpath = strdup(nameBuffer);
            if (wipe(newpath) == 0) {
                free(newpath);
                closedir(dir);
                return 0;
            }
            
            if (!noBackup) {
                ret = rmdir(newpath);
                if (ret != 0) {
                    fprintf(stderr, "warning -- rmdir() error on '%s': %s\n", 
                        newpath, strerror(errno));
                }
            }

            free(newpath);

            strcpy(nameBuffer, path);
            strcat(nameBuffer, "/");

        } else {
            ret = unlink(nameBuffer);

            if (ret != 0) {
                fprintf(stderr, "warning -- unlink() error on '%s': %s\n", 
                    nameBuffer, strerror(errno));
            }
        }
    }

    closedir(dir);
    
    return 1;
}
コード例 #25
0
ファイル: hotkey_manager.cpp プロジェクト: Martin9295/wesnoth
manager::~manager()
{
	wipe();
}
コード例 #26
0
ファイル: main.c プロジェクト: mersinvald/maze-generator
int main()
{
    Parms_t input;
/*
    input.width = 10;
    input.height = 10;
    input.fullscreen = 0;//SDL_WINDOW_FULLSCREEN;
    input.windowH = 200;
    input.windowW = 200;
    input.animationDelay = 0;
    input.framesDrop = 1;
    input.startPoint.x = 1;
    input.startPoint.y = 1;
    input.exitPoint.x  = 7;
    input.exitPoint.y  = 7;
*/
    Parms_t      last;
    bool         quit = false;
    Data_t       d;
    RenderData_t rd;

    srand(clock());

    //инициализация SDL2
    SDL_Init(SDL_INIT_VIDEO);
    input = getInput(1, ALL, input);
    SDL_Window   *window   = SDL_CreateWindow("Labytinth", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, input.windowW, input.windowH, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | input.fullscreen | SDL_WINDOW_BORDERLESS);
    SDL_GL_CreateContext(window);
    SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1);
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4);
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);
    SDL_Event event;

    //OpenGL 4.1
    glMatrixMode(GL_PROJECTION|GL_MODELVIEW);
    glLoadIdentity();
    glEnableClientState(GL_VERTEX_ARRAY);
    glEnableClientState(GL_COLOR_ARRAY);
    glOrtho(-input.windowW/2,input.windowW/2,input.windowH/2,-input.windowH/2,0,1);
    glClearColor( 1, 1, 1, 0 );
    SDL_GL_SetSwapInterval( 1 ); //vsync

    uint8_t *data;
    bool     flagChanged = 0;
    Action_t flagAction = NOTHING;
    bool     flagGenerated = 0;
    bool     flagGeneratorData   = 0;
    bool     flagSolverData   = 0;
    uint16_t i = 0;


    glClear(GL_COLOR_BUFFER_BIT);
    SDL_GL_SwapWindow(window);

    while(!quit){
        while(SDL_PollEvent(&event)){
            if(event.type == SDL_QUIT)
                quit = true;

            else if (event.type == SDL_KEYDOWN){
                    switch (event.key.keysym.sym){
                case  SDLK_g:      flagAction = GENERATE;      break;
                case  SDLK_s:      flagAction = SOLVE;         break;
                case  SDLK_TAB:    flagAction = STOP;          break;
                case  SDLK_ESCAPE: quit = 1;                   break;
                case  SDLK_UP:     input.framesDrop++;         break;
                case  SDLK_RIGHT:  input.animationDelay++;
                case  SDLK_DOWN:   input.framesDrop = (input.framesDrop - 1 > 0) ? input.framesDrop - 1 : 1;
                                   break;
                case  SDLK_LEFT:   input.animationDelay = (input.animationDelay - 1 >= 0) ? input.animationDelay - 1 : 0;
                                   break;
                }
            }
        }
        if(flagAction == GENERATE){
            if(!flagGeneratorData){
                d                 = initGeneratorData(input.width, input.height, input.startPoint);
                rd                = initRenderData(d, input.windowW, input.windowH);
                flagGeneratorData = true;
                flagGenerated     = false;
                flagSolverData    = false;

                glVertexPointer(2, GL_FLOAT, sizeof(Vertex_t), rd.vertices);
                glColorPointer(3, GL_UNSIGNED_BYTE, sizeof(VertexColor_t), rd.verticesColor);

            }
            for(i = 0; i < input.framesDrop; i++){
                if(d.unvisitedNum != 0){
                    generateStep(&d);
                }
                else{
                    flagGeneratorData = false;
                    flagGenerated     = true;
                    flagAction        = NOTHING;
                    break;
                }
            }
            d.maze[d.startPoint.y][d.startPoint.x] = CURRENT;
            renderMatrix(d.maze, rd, GENERATE);
            d.maze[d.startPoint.y][d.startPoint.x] = GENVISITED;
            flagChanged = true;
        }
        else if(flagAction == SOLVE && flagGenerated){
            if(!flagSolverData){
                d = initSeekerData(d, input.startPoint, input.exitPoint);
                rd = clearSeekerColorArray(d.maze, rd);
                flagSolverData = true;
            }
            for(i = 0; i < input.framesDrop; i++){
                if((d.startPoint.x != d.exitPoint.x || d.startPoint.y != d.exitPoint.y) && d.error != 1){
                    seekStep(&d);
                }
                else if(d.error){
                    printf("ERROR: Lanyrinth cannot be solved! :C\n");
                }
                else{
                    flagSolverData = false;
                    flagAction = NOTHING;
                    setMode(d.exitPoint, d.maze, WAY);
                    break;
                }
            }
            setMode(d.startPoint, d.maze, CURRENT);
            renderMatrix(d.maze, rd, SOLVE);
            setMode(d.startPoint, d.maze, WAY);
            flagChanged = true;
        }
        else if(flagAction == STOP){
            last = input;
            input = getInput(0, GENERATE, last);
            if((last.width != input.width) || (last.height != input.height)){
                flagGenerated     = false;
                flagGeneratorData = false;
                flagSolverData    = false;
            }
            flagAction  = NOTHING;
            flagChanged = true;
        }
        else if(flagAction == OUTPUT){
            data = malloc(input.windowW * input.windowH * 4 * sizeof(uint8_t));
            glReadBuffer(GL_FRONT);
            glReadPixels(0, 0, input.windowW , input.windowH,  GL_RGBA, GL_UNSIGNED_BYTE, data);
            flagAction = NOTHING;

        }
        if(flagAction != NOTHING || flagChanged){
            SDL_Delay(input.animationDelay);
            SDL_GL_SwapWindow(window);
            flagChanged = false;
        }
    }

    //cleanup
    wipe(d.stack);
    return 0;
}
コード例 #27
0
ファイル: database.cpp プロジェクト: dv1/ion_player
void CAdPlugDatabase::wipe(CRecord *record)
{
  if(!lookup(record->key)) return;
  wipe();
}
コード例 #28
0
ファイル: LifeApp.cpp プロジェクト: blackketter/britepad
void LifeApp::seed() {
  wipe();
  for (int i = 0; i < SEEDS; i++) {
    dots->setDot(random(getDotsWide()), random(getDotsHigh()), MINCOLOR);
  }
}
コード例 #29
0
 void purge()
 {
     resetSeed();
     reset(NULL);
     wipe(m_pBuf, DIGEST_BYTES);
 }
コード例 #30
0
ファイル: shodbc.c プロジェクト: roman-neuhauser/shellsql
int main(int argc, char *argv[])
{
	int errn;
	string *str;
	int complete = -1;
	int i;
	long ans;
	long logintimeout = 20;
	char *s;
	char *password;
	char *username;

	if(argc < 4)
	{
		fprintf(stderr, "Usage: %s user password connecstring\n", argv[0]);
		exit(1);
	}

	if((mes = new_message(0)) == NULL)
	{
		fprintf(stderr, "%s: Cannot open message queue\n", argv[0]);
		exit(1);
	}


	/*
	 * I believe a fork duplicates malloced stuff, I am in the poo if it does not :-)
	 */
	errn = fork();

	if(errn == -1)
	{
		fprintf(stderr, "%s: Cannot fork child process\n", argv[0]);
		exit(1);
	}
	else if(errn)
	{
/*
 * This is the parent - which behaves like clien
 */

		/*
		 * Initially just a status message is snt back, zero string length 
		 *
		 * Still needs a string to put it into
		 */


		str = new_string();
		
		if(message_receive(mes, str, &complete, MES_SERVER_TO_CLIENT) < 0)
		{
			fprintf(stderr, "%s: %s\n", argv[0], string_s(str));
			message_destroy(mes);
			message_delete(mes);
			string_delete(str);
			exit(1);
		}
		else
		{
			printf("%d\n",message_id(mes)) ;
			message_delete(mes);
			string_delete(str);
			exit(0);
		}
	}
/*
 * All parents have exited now
 */

/*
 * This is all a child
 */

	/*
	 * I think I need to do this here...
	 * I do not fully understand why, it just works!
	 * otherwise shell parent hangs!
	 */

	setsid();
	if(fork()) exit(0);
	close(0);
	close(1);
	close(2);

	/*
	 * We are in daemon mode now
	 */

	/*
	 * open the database
	 */

	str = new_string();

	for(i=3;i<argc;i++)
	{
		string_cat(str, argv[i]);
		if(i < argc - 1) string_cat_c(str, ' ');
	}

	username = strdup(argv[1]);
	password = strdup(argv[2]);

	wipe(argv[2]);
	wipe(argv[1]);

	ans = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &(env));
	if((ans != SQL_SUCCESS) && (ans != SQL_SUCCESS_WITH_INFO))
	{
		message_status(mes, 127, "ODBC: Cannot allocate environment handle\n", MES_SERVER_TO_CLIENT);
		message_delete(mes);
		free(username);
		free(password);
		exit(1);
	}

	ans = SQLSetEnvAttr(env, SQL_ATTR_ODBC_VERSION, (void*)SQL_OV_ODBC3, 0); 

	if ((ans != SQL_SUCCESS) && (ans != SQL_SUCCESS_WITH_INFO))
	{
		SQLFreeHandle(SQL_HANDLE_ENV, env);
		message_status(mes, 127, "ODBC: Cannot set environment handle attributes\n", MES_SERVER_TO_CLIENT);
		message_delete(mes);
		exit(1);
	}

	/* 2. allocate connection handle, set timeout */

	ans = SQLAllocHandle(SQL_HANDLE_DBC, env, &(hdbc)); 

	if ((ans != SQL_SUCCESS) && (ans != SQL_SUCCESS_WITH_INFO))
	{
		SQLFreeHandle(SQL_HANDLE_ENV, env);
		message_status(mes, 127, "ODBC: Cannot allocate database handle\n", MES_SERVER_TO_CLIENT);
		message_delete(mes);
		free(username);
		free(password);
		exit(1);
	}

	/*
 	 * TODO - Parameterize ODBC_TIMEOUT as environment variable
	 */

	s = getenv("ODBC_TIMEOUT");
	if(s != NULL)
	{
		if(*s)
		{
			logintimeout = atol(s);
		}
	}

	SQLSetConnectAttr(hdbc, SQL_LOGIN_TIMEOUT, (SQLPOINTER)logintimeout, 0);

	/* 3. Connect to the datasource  */

	ans = SQLConnect(hdbc, (SQLCHAR*) string_s(str), SQL_NTS,
                                     (SQLCHAR*) username, SQL_NTS,
                                     (SQLCHAR*) password, SQL_NTS);

	if ((ans != SQL_SUCCESS) && (ans != SQL_SUCCESS_WITH_INFO))
	{
		message_status(mes, 127, "ODBC: Cannot connect to database\n", MES_SERVER_TO_CLIENT);
		message_delete(mes);
/*
		SQLGetDiagRec(SQL_HANDLE_DBC, V_OD_hdbc,1, 
		              V_OD_stat, &V_OD_err,V_OD_msg,100,&V_OD_mlen);
		printf("%s (%d)\n",V_OD_msg,V_OD_err);
 */
		SQLFreeHandle(SQL_HANDLE_DBC, hdbc);
		SQLFreeHandle(SQL_HANDLE_ENV, env);
		free(username);
		free(password);
		exit(1);
	}


	/*
	 * Transmit to parent that we are hunky dory
	 */

	message_status(mes, 0, "", MES_SERVER_TO_CLIENT);

	/*
	 * We are open for business - Lets go
 	 */

	mainloop();

	/*
	 * At the end, tidy up
	 */

	SQLDisconnect(hdbc);
	SQLFreeHandle(SQL_HANDLE_DBC, hdbc);
	SQLFreeHandle(SQL_HANDLE_ENV, env);

	message_destroy(mes);
	message_delete(mes);

	free(username);
	free(password);

	exit(0);
}