• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ Exit函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中Exit函数的典型用法代码示例。如果您正苦于以下问题:C++ Exit函数的具体用法?C++ Exit怎么用?C++ Exit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了Exit函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: printf

// #################################################################
// 計算領域のセルIDとカット情報を設定する
void IP_Step::setup(int* bcd,
                    Control* R,
                    const int NoMedium,
                    const MediumList* mat,
                    const int NoCompo,
                    const CompoList* cmp,
                    long long* cut,
                    int* bid)
{
  int mid_fluid;        /// 流体
  int mid_solid;        /// 固体

  // 流体
  if ( (mid_fluid = FBUtility::findIDfromLabel(mat, NoMedium, m_fluid)) == 0 )
  {
    Hostonly_ printf("\tLabel '%s' is not listed in MediumList\n", m_fluid.c_str());
    Exit(0);
  }
  
  // 固体
  if ( (mid_solid = FBUtility::findIDfromLabel(mat, NoMedium, m_solid)) == 0 )
  {
    Hostonly_ printf("\tLabel '%s' is not listed in MediumList\n", m_solid.c_str());
    Exit(0);
  }
  


  // ローカル
  int ix = size[0];
  int jx = size[1];
  int kx = size[2];
  int gd = guide;
  
  REAL_TYPE dx = pitch[0];
  //REAL_TYPE dy = pitch[1];
  REAL_TYPE dz = pitch[2];
  
  // ローカルな無次元位置
  REAL_TYPE ox, oz;
  ox = origin[0];
  oz = origin[2];
  

  // step length 有次元値
  REAL_TYPE len = G_origin[0] + width/R->RefLength; // グローバルな無次元位置
  
  // step height 有次元値
  REAL_TYPE ht  = G_origin[2] + height/R->RefLength; // グローバルな無次元位置

  
#pragma omp parallel for firstprivate(ix, jx, kx, gd, mid_solid, ox, oz, dx, dz, len, ht) schedule(static)
  for (int k=1; k<=kx; k++) {
    for (int j=1; j<=jx; j++) {
      for (int i=1; i<=ix; i++) {
        size_t m = _F_IDX_S3D(i, j, k, ix, jx, kx, gd);
        REAL_TYPE x = ox + 0.5*dx + dx*(i-1); // position of cell center
        REAL_TYPE z = oz + 0.5*dz + dz*(k-1); // position of cell center
        REAL_TYPE s = (len - x)/dx;
        
        if ( z <= ht )
        {
          if ( (x <= len) && (len < x+dx) )
          {
            setBit5(bid[m], mid_solid, X_plus);
            int r = quantize9(s);
            setCut9(cut[m], r, X_plus);
            
            size_t m1 = _F_IDX_S3D(i+1, j, k, ix, jx, kx, gd);
            setBit5(bid[m1], mid_solid, X_minus);
            int rr = quantize9(1.0-s);
            setCut9(cut[m1], rr, X_minus);
          }
          else if ( (x-dx < len) && (len < x) )
          {
            setBit5(bid[m], mid_solid, X_minus);
            int r = quantize9(-s);
            setCut9(cut[m], r, X_minus);
            
            size_t m1 = _F_IDX_S3D(i-1, j, k, ix, jx, kx, gd);
            setBit5(bid[m1], mid_solid, X_plus);
            int rr = quantize9(1.0+s);
            setCut9(cut[m1], rr, X_plus);
          }
        }

      }
    }
  }
  
#pragma omp parallel for firstprivate(ix, jx, kx, gd, mid_solid, ox, oz, dx, dz, len, ht) schedule(static)
  for (int k=1; k<=kx; k++) {
    for (int j=1; j<=jx; j++) {
      for (int i=1; i<=ix; i++) {
        size_t m = _F_IDX_S3D(i, j, k, ix, jx, kx, gd);
        REAL_TYPE x = ox + 0.5*dx + dx*(i-1); // position of cell center
        REAL_TYPE z = oz + 0.5*dz + dz*(k-1); // position of cell center
        REAL_TYPE c = (ht - z)/dz;
//.........这里部分代码省略.........
开发者ID:acda2270,项目名称:FFVC,代码行数:101,代码来源:IP_Step.C


示例2: getenv


//.........这里部分代码省略.........
#endif

    }

    // Open display
    if((Dpy = XOpenDisplay(DisplayName)) == 0) {
        cerr << APPNAME << ": could not open display '"
             << DisplayName << "'" << endl;
        if (!testing) StopServer();
        exit(ERR_EXIT);
    }

    // Get screen and root window
    Scr = DefaultScreen(Dpy);
    Root = RootWindow(Dpy, Scr);


    // for tests we use a standard window
    if (testing) {
        Window RealRoot = RootWindow(Dpy, Scr);
        Root = XCreateSimpleWindow(Dpy, RealRoot, 0, 0, 640, 480, 0, 0, 0);
        XMapWindow(Dpy, Root);
        XFlush(Dpy);
    } else {
        blankScreen();
    }

    HideCursor();

    // Create panel
    LoginPanel = new Panel(Dpy, Scr, Root, &cfg, themedir);

    // Start looping
    XEvent event;
    int panelclosed = 1;
    int Action;
    bool firstloop = true; // 1st time panel is shown (for automatic username)

    while(1) {
        if(panelclosed) {
            // Init root
            setBackground(themedir);

            // Close all clients
            if (!testing) {
                KillAllClients(False);
                KillAllClients(True);
            }

            // Show panel
            LoginPanel->OpenPanel();
        }

        Action = WAIT;
        LoginPanel->GetInput()->Reset();
        if (firstloop && cfg.getOption("default_user") != "") {
            LoginPanel->GetInput()->SetName(cfg.getOption("default_user") );
            firstloop = false;
        }

        while(Action == WAIT) {
            XNextEvent(Dpy, &event);
            Action = LoginPanel->EventHandler(&event);
        }

        if(Action == FAIL) {
            panelclosed = 0;
            LoginPanel->ClearPanel();
            XBell(Dpy, 100);
        } else {
            // for themes test we just quit
            if (testing) {
                Action = EXIT;
            }
            panelclosed = 1;
            LoginPanel->ClosePanel();

            switch(Action) {
                case LOGIN:
                    Login();
                    break;
                case CONSOLE:
                    Console();
                    break;
                case REBOOT:
                    Reboot();
                    break;
                case HALT:
                    Halt();
                    break;
                case SUSPEND:
                    Suspend();
                    break;
                case EXIT:
                    Exit();
                    break;
            }
        }
    }
}
开发者ID:BackupTheBerlios,项目名称:slim-svn,代码行数:101,代码来源:app.cpp


示例3: Exit

void ColourPickerActivity::OnTryExit(ExitMethod method)
{
	Exit();
}
开发者ID:MrZacbot,项目名称:The-Powder-Toy,代码行数:4,代码来源:ColourPickerActivity.cpp


示例4: RecoverState

void RecoverState(QHLP_PAR *qhlp)
{
ISI_DL snapshot;
ISI_DL_SYS sys;
QDPLUS_PKT pkt;
struct { ISI_SEQNO seqno; UINT32 index; } beg, end;
static char *fid = "RecoverState";

/* Get the current state of the disk loop */

    if (!isidlSnapshot(qhlp->input.dl, &snapshot, &sys)) {
        LogMsg("%s: isidlSnapshot failed: %s", fid, strerror(errno));
        Exit(MY_MOD_ID + 3);
    }

/* If there isn't any preserved state, then configure to dump the entire QDP disk loop */

    if (qhlp->qdplus->state != QDPLUS_STATE_OK) {
        LogMsg("no valid HLP state data found, default to oldest QDP data available");
        history.nxtndx = snapshot.sys->index.oldest;
        history.endndx = snapshot.sys->index.yngest;
        if (!VerifyIndicies(&snapshot)) Exit(MY_MOD_ID + 4);
        qdplusSetLcqStateFlag(qhlp->qdplus, QDP_LCQ_STATE_PRODUCTION);
        LogMsg("going into production mode with nxtndx=0x%08x, endndx=0x%08x\n", history.nxtndx, history.endndx);
        return;
    }

/* We have state... find the range of packets to preload */

    if (!qdplusStateSeqnoLimits(qhlp->qdplus, &beg.seqno, &end.seqno)) {
        LogMsg("%s: qdplusStateSeqnoLimits: %s", fid, strerror(errno));
        Exit(MY_MOD_ID + 5);
    }

    if (isiIsUndefinedSeqno(&beg.seqno) || isiIsUndefinedSeqno(&end.seqno)) {
        LogMsg("empty HLP state data found, default to oldest QDP data available");
        history.nxtndx = snapshot.sys->index.oldest;
        history.endndx = snapshot.sys->index.yngest;
        if (!VerifyIndicies(&snapshot)) Exit(MY_MOD_ID + 6);
        qdplusSetLcqStateFlag(qhlp->qdplus, QDP_LCQ_STATE_PRODUCTION);
        LogMsg("going into production mode with nxtndx=0x%08x, endndx=0x%08x\n", history.nxtndx, history.endndx);
        return;
    }

    if (!isiIsAbsoluteSeqno(&beg.seqno) || !isiIsAbsoluteSeqno(&end.seqno)) {
        LogMsg("%s: unexpected non-absolute sequence numbers", fid);
        Exit(MY_MOD_ID + 7);
    }

    beg.index = isidlSearchDiskLoopForSeqno(&snapshot, &beg.seqno, ISI_UNDEFINED_INDEX, ISI_UNDEFINED_INDEX);
    LogMsg("beg.seqno = %s, beg.index = 0x%08x\n", isiSeqnoString(&beg.seqno, NULL), beg.index);
    end.index = isidlSearchDiskLoopForSeqno(&snapshot, &end.seqno, ISI_UNDEFINED_INDEX, ISI_UNDEFINED_INDEX);
    LogMsg("end.seqno = %s, end.index = 0x%08x\n", isiSeqnoString(&end.seqno, NULL), end.index);

/* If we can't find the desired packets (disk loop overwritten?) then start with current data */

    if (!isiIsValidIndex(beg.index) || !isiIsValidIndex(end.index)) {
        LogMsg("unable to locate dl indices for HLP state data, default to start with current QDP data");
        history.nxtndx = snapshot.sys->index.yngest;
        history.endndx = snapshot.sys->index.yngest;
        if (!VerifyIndicies(&snapshot)) Exit(MY_MOD_ID + 8);
        qdplusSetLcqStateFlag(qhlp->qdplus, QDP_LCQ_STATE_PRODUCTION);
        LogMsg("going into production mode with nxtndx=0x%08x, endndx=0x%08x\n", history.nxtndx, history.endndx);
        return;
    }

/* We know where to find the data to backfill, set up reader accordingly */

    history.nxtndx = beg.index;
    history.endndx = end.index;
    if (!VerifyIndicies(&snapshot)) Exit(MY_MOD_ID + 9);

/* Backfill the LCQ */

    qdplusSetLcqStateFlag(qhlp->qdplus, QDP_LCQ_STATE_INITIALIZE);
    LogMsg("recovering state with data from indicies 0x%08x through 0x%08x", history.nxtndx, history.endndx);

    do {
        QuitOnShutdown(MY_MOD_ID + 9);
        ReadNextPacket(qhlp, &pkt);
        if (qdplusProcessPacket(qhlp->qdplus, &pkt) == NULL) {
            LogMsg("%s: qdplusProcessPacket failed: %s", fid, strerror(errno));
            Exit(MY_MOD_ID + 10);
        }
    } while (history.status == DATA_AVAILABLE);

    qdplusSetLcqStateFlag(qhlp->qdplus, QDP_LCQ_STATE_PRODUCTION);
    LogMsg("state recovery complete");
}
开发者ID:jandog8990,项目名称:asl-station-processor,代码行数:89,代码来源:read.c


示例5: Exit

void CMenuTeam::OnPrevious(void)
{
    // Go to the previous screen
    Exit(MENUACTION_PREVIOUS);
}
开发者ID:aprams,项目名称:Bombermaaan,代码行数:5,代码来源:CMenuTeam.cpp


示例6: main

void main(int argc, char ** argv)
{
  Circular_Buffer * cir_buffer;
  uint32 h_mem;
  sem_t s_procs_completed;

  char hello_world[STRING_LENGTH] = "Hello world";
  int ct = 0;

  if (argc != 3) { 
    Printf("Usage: "); Printf(argv[0]); Printf(" <handle_to_shared_memory_page> <handle_to_page_mapped_semaphore>\n"); 
    Exit();
  }

  // Convert the command-line strings into integers for use as handles
  h_mem = dstrtol(argv[1], NULL, 10); // The "10" means base 10
  s_procs_completed = dstrtol(argv[2], NULL, 10);

  // Map shared memory page into this process's memory space
  if ((cir_buffer = (Circular_Buffer *)shmat(h_mem)) == NULL) {
    Printf("Could not map the virtual address to the memory in "); Printf(argv[0]); Printf(", exiting...\n");
    Exit();
  }


  while(ct < STRING_LENGTH){
    // Get the lock
    if(lock_acquire(cir_buffer->buffer_lock) != SYNC_SUCCESS){
      Printf("Get the lock failed !!!!!!!!!!!!!!!!!!\n");
      Exit();
    }

    /* Printf("Producer %d holds the lock %d, head = %d, tail = %d\n", getpid(), cir_buffer->buffer_lock, cir_buffer->head, cir_buffer->tail); */

    // Producer an item to the buffer
    if((cir_buffer->head + 1) % BUFFERSIZE == cir_buffer->tail){
      // The buffer is full, do nothing
    }
    else{
      // Insert the character
      cir_buffer->space[cir_buffer->head] = hello_world[ct];

      /* Printf("buffer lock: %d\n", cir_buffer->buffer_lock); */
      Printf("Producer %d inserted: %c\n", getpid(), hello_world[ct]);

      // Update head and ct
      ct++;
      cir_buffer->head = (cir_buffer->head + 1) % BUFFERSIZE;
    }

    // Release the lock
    if(lock_release(cir_buffer->buffer_lock) != SYNC_SUCCESS){
      Printf("Producer %d release the lock %d failed !!!!!!!!!!!!!!!!!!\n", getpid(), cir_buffer->buffer_lock);
      Exit();
    }
  }



  // Signal the semaphore to tell the original process that we're done
  Printf("Producer: PID %d is complete.\n", getpid());
  

  if(sem_signal(s_procs_completed) != SYNC_SUCCESS) {
    Printf("Bad semaphore s_procs_completed (%d) in ", s_procs_completed); Printf(argv[0]); Printf(", exiting...\n");
    Exit();
  }

  return;
}
开发者ID:zhan1182,项目名称:OS-Design,代码行数:70,代码来源:producer.c


示例7: ExportKeyring


//.........这里部分代码省略.........
                  option);
              id=HexStringToStringInfo(argv[i]);
              break;
            }
          ThrowKeyringException(OptionFatalError,"unrecognized option: `%s'",
            option);
          break;
        }
        case 'h':
        {
          if ((LocaleCompare("help",option+1) == 0) ||
              (LocaleCompare("-help",option+1) == 0))
            KeyringUsage();
          ThrowKeyringException(OptionFatalError,"unrecognized option: `%s'",
            option);
          break;
        }
        case 'l':
        {
          if (LocaleCompare(option,"-list") == 0)
            {
              ssize_t
                list;

              if (*option == '+')
                break;
              i++;
              if (i == (ssize_t) argc)
                ThrowKeyringException(OptionError,"missing list type: `%s'",
                  option);
              if (LocaleCompare(argv[i],"configure") == 0)
                {
                  (void) ListConfigureInfo((FILE *) NULL,exception);
                  Exit(0);
                }
              list=ParseWizardOption(WizardListOptions,WizardFalse,argv[i]);
              if (list < 0)
                ThrowKeyringException(OptionFatalError,"unrecognized list "
                  "type: `%s'",argv[i]);
              (void) ListWizardOptions((FILE *) NULL,(WizardOption) list,
                exception);
              Exit(0);
              break;
            }
          if (LocaleCompare("log",option+1) == 0)
            {
              if (*option == '+')
                break;
              i++;
              if ((i == (ssize_t) argc) ||
                  (strchr(argv[i],'%') == (char *) NULL))
                ThrowKeyringException(OptionFatalError,"missing argument: `%s'",
                  option);
              break;
            }
          ThrowKeyringException(OptionFatalError,"unrecognized option: `%s'",
            option);
          break;
        }
        case 'v':
        {
          if (LocaleCompare(option,"-version") == 0)
            {
              (void) fprintf(stdout,"Version: %s\n",GetWizardVersion(
                (size_t *) NULL));
              (void) fprintf(stdout,"Copyright: %s\n\n",GetWizardCopyright());
开发者ID:ImageMagick,项目名称:WizardsToolkit,代码行数:67,代码来源:keyring.c


示例8: main

/**
 * \brief Main function.
 */
int main(int argc, char **argv)
{
  char            *s,*t;
  int             size,sizes,sizet;
  int             i,j,k,P;
  int             cond;
  int             *simi,res,Paux;
  int             *a,*b;
  FILE            *f,*f2;
  fpos_t          filepos;
  int             my_rank,set;
  struct timeval  ini, fi;
  struct timezone tz;


  bsp_begin(atoi(argv[1]));

  size = atoi(argv[1]);

  f=fopen(argv[2],"r");
  if (f==NULL) Exit("Error: File %s not found\n",argv[2]);
  fscanf(f,"%d",&sizes);

  if (sizes%size != 0)
    Exit("Error: The sequences have to have multiple of "
         "processes quantity size");

  f2=fopen(argv[3],"r");

  if (f2==NULL) Exit("Error: File %s not found\n",argv[3]);

  fscanf(f2,"%d",&sizet);

  if (bsp_pid() == 0)
    if (sizet%size != 0)
      Exit("Error: The sequences have to have multiple of "
         "processes quantity size");

  P = atoi(argv[4]);

  if (bsp_pid() == 0)
    printf("align %d %s %s %d\n",size,argv[2],argv[3],P);

  sizes /= size;
  sizet /= size;

  s = (char*) malloc (sizes*sizeof(char));
  t = (char*) malloc (sizet*sizeof(char));

  if (s == NULL || t == NULL)
    Exit("No memory\n");


  a = (int*)malloc ((sizet+1)*sizeof(int));
  b = (int*)malloc ((sizes+1)*sizeof(int));


  if (a == NULL || b == NULL)
    Exit("No memory\n");


  if (bsp_pid() == size-1)
  {
    simi = (int*) malloc(P*sizeof(int));
    if (simi == NULL) Exit("No memory\n");
  }

  Paux = 0;

  bsp_push_reg(s,sizes*sizeof(char));
  bsp_push_reg(b,(sizes+1)*sizeof(int));
  bsp_push_reg(&filepos,sizeof(long int));
  bsp_push_reg(&i,sizeof(int));

  bsp_sync();

  gettimeofday(&ini,&tz);
  
  for (k = 0; k < P*size + size -1; k++)
  {
    if (k >= bsp_pid() && k <= P*size+bsp_pid()-1)
      cond = 1;
    else
      cond = 0;

    set = 0;
    if (cond==1 && (k-bsp_pid())%size == 0)/*start of a reading*/
    {
      if (bsp_pid() == 0 && k < size);
      else if (bsp_pid() == 0)
      {
	bsp_get(size-1,&filepos,0,&filepos,sizeof(long int));
      }
      else
      {
	bsp_get(bsp_pid()-1,&filepos,0,&filepos,sizeof(long int));
      }
//.........这里部分代码省略.........
开发者ID:felps,项目名称:FTFramework,代码行数:101,代码来源:align.c


示例9: main

void main(int argc, char ** argv)
{
  Circular_Buffer * cir_buffer;
  uint32 h_mem;
  sem_t s_procs_completed;

  int ct = 0;

  if (argc != 3) { 
    Printf("Usage: "); Printf(argv[0]); Printf(" <handle_to_shared_memory_page> <handle_to_page_mapped_semaphore>\n"); 
    Exit();
  }

  // Convert the command-line strings into integers for use as handles
  h_mem = dstrtol(argv[1], NULL, 10); // The "10" means base 10
  s_procs_completed = dstrtol(argv[2], NULL, 10);

  // Map shared memory page into this process's memory space
  if ((cir_buffer = (Circular_Buffer *)shmat(h_mem)) == NULL) {
    Printf("Could not map the virtual address to the memory in "); Printf(argv[0]); Printf(", exiting...\n");
    Exit();
  }


  while(ct < STRING_LENGTH){
    // Get the lock
    if(lock_acquire(cir_buffer->buffer_lock) != SYNC_SUCCESS){
      Printf("Get the lock failed !!!!!!!!!!!!!!!!!!\n");
      Exit();
    }

    /* Printf("Consumer %d holds the lock %d, head = %d, tail = %d\n", getpid(), cir_buffer->buffer_lock, cir_buffer->head, cir_buffer->tail); */

    //Printf("Consumer, before checking if buffer empty.\n");
    // Consume an item to the buffer
    while(cir_buffer->head == cir_buffer->tail){
      // conditional wait when empty
      if(cond_wait(cir_buffer->buffer_cond) != SYNC_SUCCESS)
	{
	  Printf("Consumer conditional wait not empty unsuccessful.\n");
	  Exit();
	}
    }
    
    // Remove the character
    Printf("Consumer %d removed: %c\n", getpid(), cir_buffer->space[cir_buffer->tail]);
    
    if (cir_buffer->nitem == 5)
      {
	if(cond_signal(cir_buffer->buffer_cond) != SYNC_SUCCESS)
	  {
	    Printf("Consumer conditioanl signal not full unsuccessful.\n");
	    Exit();
	  }
      }
    // Update tail and ct
    ct++;
    cir_buffer->tail = (cir_buffer->tail + 1)  % BUFFERSIZE;
    cir_buffer->nitem -= 1;

    // Release the lock
    if(lock_release(cir_buffer->buffer_lock) != SYNC_SUCCESS){
      Printf("Consumer %d release the lock %d failed !!!!!!!!!!!!!!!!!!\n", getpid(), cir_buffer->buffer_lock);
      Exit();
    }
  }



  // Signal the semaphore to tell the original process that we're done
  Printf("Consumer: PID %d is complete.\n", getpid());


  if(sem_signal(s_procs_completed) != SYNC_SUCCESS) {
    Printf("Bad semaphore s_procs_completed (%d) in ", s_procs_completed); Printf(argv[0]); Printf(", exiting...\n");
    Exit();
  }

  return;
}
开发者ID:zhan1182,项目名称:OS-Design,代码行数:80,代码来源:consumer.c


示例10: DEncrypt

bool DEncrypt(const char* filename)
{
		//Open allocate/read a file into memory
	FILE *pFile;
	pFile = fopen (filename, "rb");
	if(! pFile)
		Exit("Failed to open input file\n");

	long lFileSize; //Size of input file
	unsigned char *pBuff; //Holds the input file contents
	unsigned char *pOutBuff; //Holds the output goodies

	// obtain file size.
	fseek (pFile , 0 , SEEK_END);
	lFileSize= ftell (pFile);
	rewind (pFile);

	// allocate memory to contain the whole file.
	pBuff = (unsigned char*) malloc (lFileSize);
	pOutBuff = (unsigned char*) malloc (lFileSize);

	if (pBuff == NULL || pOutBuff == NULL)
	{
		fclose(pFile);
		std::cout << "Could not allocate buffer" << std::endl;
                return false;
	}

	// copy the file into the buffer.
	fread (pBuff,1,lFileSize,pFile);
	
	//clean the output buffer
	memset(pOutBuff,NULL,lFileSize);

	fclose(pFile);

	//Lets start the ice goodies!
	IceKey ice( 0 ); // level 0 = 64bit key
	ice.set( (unsigned char*) g_ICEKey ); // set key

	int blockSize = ice.blockSize();

	unsigned char *p1 = pBuff;
	unsigned char *p2 = pOutBuff;

	// encrypt data in 8 byte blocks
	int bytesLeft = lFileSize;

	while ( bytesLeft >= blockSize )
	{
		if ( g_Encrypt )
			ice.encrypt( p1, p2 );
		else
			ice.decrypt( p1, p2 );

		bytesLeft -= blockSize;
		p1+=blockSize;
		p2+=blockSize;
	}

	//The end chunk doesn't get an encryption?  that sux...
	memcpy( p2, p1, bytesLeft );

	size_t outLength = strlen(filename) + MAX_EXTENSION + 1;
	char *pOutPath = (char *)malloc(outLength);
	strncpy(pOutPath,filename,outLength);

	SetExtension(pOutPath, outLength, g_Extension);

	pFile = fopen (pOutPath , "wb");
	if(pFile == NULL)
	{
		fprintf( stderr, "Was not able to open output file for writing.\n" );
		free(pBuff);
		free(pOutBuff);
		free(pOutPath);
		return false;
	}

	fwrite (pOutBuff , 1 , lFileSize , pFile);
	fclose (pFile);

	free(pBuff);
	free(pOutBuff);
	free(pOutPath);

	return true;
}
开发者ID:9A9A,项目名称:vice_standalone,代码行数:88,代码来源:Main.cpp


示例11: main

/*
The entry point, see usage for I/O
*/
int main(int argc, char* argv[])
{
	if(argc < 2)
	{
		Usage();
		exit( 0 );
	}
	
	//By default we output .ctx
	strncpy( g_Extension, ".ctx",MAX_EXTENSION );
	memset(g_ICEKey,0,MAX_ICE_KEY);

	int i = 1;
	while( i < argc )
	{
		if( STRING_CMP( argv[i], "-h" ) == 0 )
		{
			Usage();
			exit( 0 );
		} 
		else if( STRING_CMP( argv[i], "-d" ) == 0 )
		{
			g_Encrypt = false;
		} 
		else if( STRING_CMP( argv[i], "-x" ) == 0 )
		{
			//Extension
			i++;

			if ( strlen( argv[i] ) > MAX_EXTENSION )
			{
				Exit("Your Extension is too big.\n");
			}

			strncpy( g_Extension, argv[i], MAX_EXTENSION );
		}
		else if( STRING_CMP( argv[i], "-k" ) == 0 )
		{
			//Key
			i++;

			if ( strlen( argv[i] ) != MAX_ICE_KEY )
			{
				Exit("Your ICE key needs to be 8 characters long.\n");
			}

			strncpy( g_ICEKey, argv[i], MAX_ICE_KEY );
		}
		else 
		{
			break;
		}
		i++;
	}

	if(g_ICEKey[0] == '\0') {
		Exit("You need to specify a key.\n");
	}
	//Parse files starting from current arg position
	if(argv[i] == NULL && (strlen(argv[i]) < 1))
		Exit("Was not about to find a file to parse\n");


	//Directory enumeration by Red Comet
	//Thanks Google and bvh for directory class
	if( strstr(argv[i],"*") != NULL ){
		oslink::directory dir("."); //Create list of files inside current directory
		char* pch = strstr(argv[i],"."); //Get pointer to the '.' in the file extension we want
		char sExt[5] = "";

		strncpy(sExt,pch,4);
				
		while (dir){
			
			//Check each file to see if it matches wildcard
			std::string nFile;
			nFile = dir.next();
			
			if( strstr(nFile.c_str(),sExt) != NULL ){
				
				if(DEncrypt(nFile.c_str()))
					std::cout << "Handled file: " << nFile << " successfully." << std::endl;
			}

		}
	}else{
		if(DEncrypt(argv[i]))
			std::cout << "Handled file: " << argv[i] << " successfully." << std::endl;
	}
	//End Red Comet code
}
开发者ID:9A9A,项目名称:vice_standalone,代码行数:94,代码来源:Main.cpp


示例12: Exit

void TaskWindow::NotifyDone(Task * task)
{
	if(closeOnDone)
		Exit();
	done = true;
}
开发者ID:ChallengedGamer69,项目名称:The-Powder-Toy,代码行数:6,代码来源:TaskWindow.cpp


示例13: Intro_4

func Intro_4()
{
	npc_pyrit->Exit();
	return ScheduleNext(30);
}
开发者ID:aburgm,项目名称:openclonk,代码行数:5,代码来源:SeqIntro.c


示例14: main

int main(int argc, char *argv[])
{
   char *datafn, *s;
   int nSeg;
   void Initialise(void);
   void LoadFile(char *fn);
   void EstimateModel(void);
   void SaveModel(char *outfn);
   
   if(InitShell(argc,argv,hinit_version,hinit_vc_id)<SUCCESS)
      HError(2100,"HInit: InitShell failed");
   InitMem();   InitLabel();
   InitMath();  InitSigP();
   InitWave();  InitAudio();
   InitVQ();    InitModel();
   if(InitParm()<SUCCESS)  
      HError(2100,"HInit: InitParm failed");
   InitTrain(); InitUtil();

   if (!InfoPrinted() && NumArgs() == 0)
      ReportUsage();
   if (NumArgs() == 0) Exit(0);
   SetConfParms();

   CreateHMMSet(&hset,&gstack,FALSE);
   while (NextArg() == SWITCHARG) {
      s = GetSwtArg();
      if (strlen(s)!=1) 
         HError(2119,"HInit: Bad switch %s; must be single letter",s);
      switch(s[0]){
      case 'e':
         epsilon = GetChkedFlt(0.0,1.0,s); break;
      case 'i':
         maxIter = GetChkedInt(0,100,s); break;
      case 'l':
         if (NextArg() != STRINGARG)
            HError(2119,"HInit: Segment label expected");
         segLab = GetStrArg();
         break;
      case 'm':
         minSeg = GetChkedInt(1,1000,s); break;
      case 'n':
         newModel = FALSE; break;
      case 'o':
         outfn = GetStrArg();
         break;
      case 'u':
         SetuFlags(); break;
      case 'v':
         minVar = GetChkedFlt(0.0,10.0,s); break;
      case 'w':
         mixWeightFloor = MINMIX * GetChkedFlt(0.0,10000.0,s); 
         break;
      case 'B':
         saveBinary = TRUE;
         break;
      case 'F':
         if (NextArg() != STRINGARG)
            HError(2119,"HInit: Data File format expected");
         if((dff = Str2Format(GetStrArg())) == ALIEN)
            HError(-2189,"HInit: Warning ALIEN Data file format set");
         break;
      case 'G':
         if (NextArg() != STRINGARG)
            HError(2119,"HInit: Label File format expected");
         if((lff = Str2Format(GetStrArg())) == ALIEN)
            HError(-2189,"HInit: Warning ALIEN Label file format set");
         break;
      case 'H':
         if (NextArg() != STRINGARG)
            HError(2119,"HInit: HMM macro file name expected");
         AddMMF(&hset,GetStrArg());
         break;
      case 'I':
         if (NextArg() != STRINGARG)
            HError(2119,"HInit: MLF file name expected");
         LoadMasterFile(GetStrArg());
         break;
      case 'L':
         if (NextArg()!=STRINGARG)
            HError(2119,"HInit: Label file directory expected");
         labDir = GetStrArg(); break;
      case 'M':
         if (NextArg()!=STRINGARG)
            HError(2119,"HInit: Output macro file directory expected");
         outDir = GetStrArg();
         break;
      case 'T':
         if (NextArg() != INTARG)
            HError(2119,"HInit: Trace value expected");
         trace = GetChkedInt(0,01777,s);
         break;
      case 'X':
         if (NextArg()!=STRINGARG)
            HError(2119,"HInit: Label file extension expected");
         labExt = GetStrArg(); break;
      default:
         HError(2119,"HInit: Unknown switch %s",s);
      }
   }
//.........这里部分代码省略.........
开发者ID:botonchou,项目名称:AlgoFinal,代码行数:101,代码来源:HInit.c


示例15: main

int main(int argc, const char *argv[]) {
   const char **arg1, *a;
   char *mainwaitstring;
   char buff[10];
   double rto;
   int i, argc0, result;
   struct utsname ubuf;
   int lockrc;

   if (mainwaitstring = getenv("SOCAT_MAIN_WAIT")) {
       sleep(atoi(mainwaitstring));
   }
   diag_set('p', strchr(argv[0], '/') ? strrchr(argv[0], '/')+1 : argv[0]);

   /* we must init before applying options because env settings have lower
      priority and are to be overridden by options */
   if (xioinitialize(XIO_MAYALL) != 0) {
      Exit(1);
   }

   xiosetopt('p', "%");
   xiosetopt('o', ":");

   argc0 = argc;	/* save for later use */
   arg1 = argv+1;  --argc;
   while (arg1[0] && (arg1[0][0] == '-')) {
      switch (arg1[0][1]) {
      case 'V': socat_version(stdout); Exit(0);
#if WITH_HELP
      case '?':
      case 'h':
	 socat_usage(stdout);
	 xioopenhelp(stdout, (arg1[0][2]=='?'||arg1[0][2]=='h') ? (arg1[0][3]=='?'||arg1[0][3]=='h') ? 2 : 1 : 0);
	 Exit(0);
#endif /* WITH_HELP */
      case 'd': diag_set('d', NULL); break;
#if WITH_FILAN
      case 'D': xioparams->debug = true; break;
#endif
      case 'l':
	 switch (arg1[0][2]) {
	 case 'm': /* mixed mode: stderr, then switch to syslog; + facility */
	    diag_set('s', NULL);
	    xiosetopt('l', "m");
	    xioparams->logopt = arg1[0][2];
	    xiosetopt('y', &arg1[0][3]);
	    break;
	 case 'y': /* syslog + facility */
	    diag_set(arg1[0][2], &arg1[0][3]);
	    break;
	 case 'f': /* to file, +filename */
	 case 'p': /* artificial program name */
	    if (arg1[0][3]) {
	       diag_set(arg1[0][2], &arg1[0][3]);
	    } else if (arg1[1]) {
	       diag_set(arg1[0][2], arg1[1]);
	       ++arg1, --argc;
	    } else {
	       Error1("option -l%c requires an argument; use option \"-h\" for help", arg1[0][2]);
	    }
	    break;
	 case 's': /* stderr */
	    diag_set(arg1[0][2], NULL);
	    break;
	 case 'u':
	    diag_set('u', NULL);
	    break;
	 case 'h':
	    diag_set_int('h', true);
	    break;
	 default:
	    Error1("unknown log option \"%s\"; use option \"-h\" for help", arg1[0]);
	    break;
	 }
	 break;
      case 'v': xioparams->verbose = true; break;
      case 'x': xioparams->verbhex = true; break;
      case 'b': if (arg1[0][2]) {
	    a = *arg1+2;
	 } else {
	    ++arg1, --argc;
	    if ((a = *arg1) == NULL) {
	       Error("option -b requires an argument; use option \"-h\" for help");
	       Exit(1);
	    }
	 }
	 xioparams->bufsiz = strtoul(a, (char **)&a, 0);
	 break;
      case 's':
	 diag_set_int('e', E_FATAL); break;
      case 't': if (arg1[0][2]) {
	    a = *arg1+2;
	 } else {
	    ++arg1, --argc;
	    if ((a = *arg1) == NULL) {
	       Error("option -t requires an argument; use option \"-h\" for help");
	       Exit(1);
	    }
	 }
	 rto = strtod(a, (char **)&a);
//.........这里部分代码省略.........
开发者ID:dest-unreach,项目名称:socat2,代码行数:101,代码来源:socat.c


示例16: StartUp


//.........这里部分代码省略.........
	wPreferences.cursor[WCUR_BOTTOMRIGHTRESIZE] = XCreateFontCursor(dpy, XC_bottom_right_corner);
	wPreferences.cursor[WCUR_VERTICALRESIZE] = XCreateFontCursor(dpy, XC_sb_v_double_arrow);
	wPreferences.cursor[WCUR_HORIZONRESIZE] = XCreateFontCursor(dpy, XC_sb_h_double_arrow);
	wPreferences.cursor[WCUR_WAIT] = XCreateFontCursor(dpy, XC_watch);
	wPreferences.cursor[WCUR_QUESTION] = XCreateFontCursor(dpy, XC_question_arrow);
	wPreferences.cursor[WCUR_TEXT] = XCreateFontCursor(dpy, XC_xterm);	/* odd name??? */
	wPreferences.cursor[WCUR_SELECT] = XCreateFontCursor(dpy, XC_cross);

	Pixmap cur = XCreatePixmap(dpy, DefaultRootWindow(dpy), 16, 16, 1);
	GC gc = XCreateGC(dpy, cur, 0, NULL);
	XColor black;
	memset(&black, 0, sizeof(XColor));
	XSetForeground(dpy, gc, 0);
	XFillRectangle(dpy, cur, gc, 0, 0, 16, 16);
	XFreeGC(dpy, gc);
	wPreferences.cursor[WCUR_EMPTY] = XCreatePixmapCursor(dpy, cur, cur, &black, &black, 0, 0);
	XFreePixmap(dpy, cur);

	/* emergency exit... */
	sig_action.sa_handler = handleSig;
	sigemptyset(&sig_action.sa_mask);

	sig_action.sa_flags = SA_RESTART;
	sigaction(SIGQUIT, &sig_action, NULL);
	/* instead of catching these, we let the default handler abort the
	 * program. The new monitor process will take appropriate action
	 * when it detects the crash.
	 sigaction(SIGSEGV, &sig_action, NULL);
	 sigaction(SIGBUS, &sig_action, NULL);
	 sigaction(SIGFPE, &sig_action, NULL);
	 sigaction(SIGABRT, &sig_action, NULL);
	 */

	sig_action.sa_handler = handleExitSig;

	/* Here we set SA_RESTART for safety, because SIGUSR1 may not be handled
	 * immediately. -Dan */
	sig_action.sa_flags = SA_RESTART;
	sigaction(SIGTERM, &sig_action, NULL);
	sigaction(SIGINT, &sig_action, NULL);
	sigaction(SIGHUP, &sig_action, NULL);
	sigaction(SIGUSR1, &sig_action, NULL);
	sigaction(SIGUSR2, &sig_action, NULL);

	/* ignore dead pipe */
	/* Because POSIX mandates that only signal with handlers are reset
	 * accross an exec*(), we do not want to propagate ignoring SIGPIPEs
	 * to children. Hence the dummy handler.
	 * Philippe Troin <[email protected]>
	 */
	sig_action.sa_handler = &dummyHandler;
	sig_action.sa_flags = SA_RESTART;
	sigaction(SIGPIPE, &sig_action, NULL);

	/* handle dead children */
	sig_action.sa_handler = buryChild;
	sig_action.sa_flags = SA_NOCLDSTOP | SA_RESTART;
	sigaction(SIGCHLD, &sig_action, NULL);

	/* Now we unblock all signals, that may have been blocked by the parent
	 * who exec()-ed us. This can happen for example if Window Maker crashes
	 * and restarts itself or another window manager from the signal handler.
	 * In this case, the new proccess inherits the blocked signal mask and
	 * will no longer react to that signal, until unblocked.
	 * This is because the signal handler of the proccess who crashed (parent)
	 * didn't return, and the signal remained blocked. -Dan
开发者ID:jafd,项目名称:wmaker,代码行数:67,代码来源:startup.c


示例17: switch

// ----------------------------------------------------
// CDbtestAppUi::HandleCommandL(TInt aCommand)
// ?implementation_description
// ----------------------------------------------------
//
void CDbtestAppUi::HandleCommandL(TInt aCommand)
{
	switch ( aCommand )
        {
        case EAknSoftkeyBack:
        case EEikCmdExit:
		{
			Exit();
			break;
		}
	case EdbtestCmdAppOBEX:
		//bt->transfer_logs();
		break;
        case EdbtestCmdAppTest:
		{
#if 0
			if (!is_open) {
				User::LeaveIfError(sockserv.Connect());
				User::LeaveIfError(sock.Open(sockserv, KAfInet, KSockStream, KUndefinedProtocol));
				TInetAddr a(INET_ADDR(128, 214, 48, 81) , 80);

				TRequestStatus s;
				sock.Connect(a, s);
				User::WaitForRequest(s);
				status_change(_L("opened"));
				is_open=true;
			} else {
				sock.CancelAll();
				sock.Close();
				sockserv.Close();
				status_change(_L("closed"));
				is_open=false;
			}
#else
#  if 0
			//transferer->log_gps();
			/*
			TInetAddr a(INET_ADDR(128, 214, 48, 81) , 21);
			ftp->Connect(a, _L8("tkt_cntx"), _L8("dKFJmqBi"));
			current_state=CONNECTING;
			*/
			/*
			run(this);
			*/
#  else
			//wap->Connect(1, _L("http://db.cs.helsinki.fi/~mraento/cgi-bin/put.pl"));
#  endif

#endif

		}
		break;
		
	case EdbtestCmdAppCommDb:
		{
			CCommDbDump* dump=CCommDbDump::NewL();
			CleanupStack::PushL(dump);
			dump->DumpDBtoFileL(_L("c:\\commdb.txt"));
			CleanupStack::PopAndDestroy();
		}
		break;
	case EdbtestCmdAppCert:
		{
			auto_ptr<CCertInstaller> i(CCertInstaller::NewL(AppContext()));
			i->InstallCertL(_L("c:\\hy.der"));
		}
	case EdbtestCmdAppDiscover:
		//discoverer->search();
		break;
	case EdbtestCmdAppCtmGSM:
		{
		TBuf<40> s;
		RDevRecharger c;
		TInt ret=0;
		TInt u=0;
		bool done=false;
		while (!done) {
			ret=c.Open(u);
			if (ret==KErrNone) {
				done=true;
			} else {
				++u;
				if (u==KNullUnit) done=true;
			}
		}
		if (ret!=KErrNone) {
			s.Format(_L("Open: %d"), ret);
		} else {
			TChargeInfoV1 i;
			i.iRawTemperature=i.iSmoothedTemperature=0;
			i.iChargeType=EChargeNone;
			TChargeInfoV1Buf b(i);
			c.ChargeInfo(b);
			s.Format(_L("%d r %d s %d t %d"), u, i.iRawTemperature, i.iSmoothedTemperature, i.iChargeType)	;
		}
//.........这里部分代码省略.........
开发者ID:flaithbheartaigh,项目名称:jaikuengine-mobile-client,代码行数:101,代码来源:Dbtestappui.cpp


示例18: main


//.........这里部分代码省略.........
            netsnmp_ds_set_boolean(NETSNMP_DS_APPLICATION_ID, 
				   NETSNMP_DS_AGENT_ROLE, SUB_AGENT);
        } else {
            netsnmp_ds_set_boolean(NETSNMP_DS_APPLICATION_ID, 
				   NETSNMP_DS_AGENT_ROLE, MASTER_AGENT);
        }
    } else {
        netsnmp_ds_set_boolean(NETSNMP_DS_APPLICATION_ID, 
			       NETSNMP_DS_AGENT_ROLE, agent_mode);
    }

    for (cptr = argvrestart, i = 0; i < argc; i++) {
        strcpy(cptr, argv[i]);
        *(argvptr++) = cptr;
        cptr += strlen(argv[i]) + 1;
    }
    *cptr = 0;
    *argvptr = NULL;

#ifdef BUFSIZ
    setvbuf(stdout, NULL, _IOLBF, BUFSIZ);
#endif
    /*
     * Initialize the world.  Detach from the shell.  Create initial user.  
     */
    if(!dont_fork) {
        int quit = ! netsnmp_ds_get_boolean(NETSNMP_DS_APPLICATION_ID,
                                            NETSNMP_DS_AGENT_QUIT_IMMEDIATELY);
        ret = netsnmp_daemonize(quit, snmp_stderrlog_status());
        /*
         * xxx-rks: do we care if fork fails? I think we should...
         */
        if(ret != 0)
            Exit(1);                /*  Exit logs exit val for us  */
    }

    SOCK_STARTUP;
    init_agent(app_name);        /* do what we need to do first. */
    init_mib_modules();

    /*
     * start library 
     */
    init_snmp(app_name);

    if ((ret = init_master_agent()) != 0) {
        /*
         * Some error opening one of the specified agent transports.  
         */
        Exit(1);                /*  Exit logs exit val for us  */
    }

#if HAVE_GETPID
    if (pid_file != NULL) {
        /*
         * unlink the pid_file, if it exists, prior to open.  Without
         * doing this the open will fail if the user specified pid_file
         * already exists.
         */
        unlink(pid_file);
        fd = open(pid_file, O_CREAT | O_EXCL | O_WRONLY, 0600);
        if (fd == -1) {
            snmp_log_perror(pid_file);
            if (!netsnmp_ds_get_boolean(NETSNMP_DS_APPLICATION_ID, 
                                        NETSNMP_DS_AGENT_NO_ROOT_ACCESS)) {
                exit(1);
开发者ID:KrisChaplin,项目名称:LRT2x4_v1.0.2.06_GPL_source,代码行数:67,代码来源:snmpd.c


示例19: waitup

int
waitup(int echildok, int *retstatus)
{
	Envy *e;
	int pid;
	int slot;
	Symtab *s;
	Word *w;
	Job *j;
	char buf[ERRMAX];
	Bufblock *bp;
	int uarg = 0;
	int done;
	Node *n;
	Proces 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ ExitCritical函数代码示例发布时间:2022-05-30
下一篇:
C++ ExecuteEvent函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap