Exemplo n.º 1
0
int
main( int argc, char **argv ) {
    if ( parsecmdline( argc, argv ) )
        return 1 ;
    constructcmdline(argv[0]) ;
    return system( ckermitcmd ) ;
}
Exemplo n.º 2
0
int main(int argc, char **argv) {

	int usemenu = parsecmdline(argc, argv);//./server port -i -n -l

	short unsigned int key[3];
	key[0] = getpid();
	key[1] = time(NULL);
	seed48(key);
			
    serverdata_type *s = readinput(inputfile, sdata);//read server.dat or saved-data to initiate dU* and p*

	pthread_t thread;
	if (usemenu) {int pthread_id = pthread_create(&thread, NULL, runmenu, (void *)s);
	//printf("pthread_id=%d\n",pthread_id);
	}
	int socket = bindsocket(port);
	//printf("socket=%d\n",socket);

	if (!usemenu) printf("No menu will be available\n");
	initparameters(s);
	//printf("key = %d\n", s->key);
// main loop - we read requests and complete transactions
	while (FOREVER_EVER_EVER) {
		//printf("entering loop\n");
		processrequest(socket, s);
		//printf("finishing loop\n");
	}

	return 0;

}
int main(int argc, char **argv)
{
    struct configuration *config = NULL;
    struct question_db *qdb = NULL;
    struct template_db *tdb = NULL;
    int flags = 0;
    char *owner;
    int i;

    setlocale(LC_ALL, "");

    config = config_new();
    parsecmdline(config, argc, argv);

    /* always load all translations if running standalone */
    unsetenv("DEBCONF_DROP_TRANSLATIONS");

    /* If debconf is already running, use debconfclient to load
     * the templates;
     * This is a hack until we introduce a standard debconf
     * primitive for doing this.
     */
    if (getenv("DEBIAN_HAS_FRONTEND") != NULL)
    {
         add_questions_debconf(argc, argv);
         exit(0);
    }

    /* parse the configuration info */
    if (config->read(config, DEBCONFCONFIG) == 0)
        DIE("Error reading configuration information");

    /* initialize database modules */
    if ((tdb = template_db_new(config, NULL)) == 0)
        DIE("Cannot initialize DebConf template database");
    if ((qdb = question_db_new(config, tdb, NULL)) == 0)
        DIE("Cannot initialize DebConf config database");

    tdb->methods.load(tdb);
    qdb->methods.load(qdb);

    owner = argv[optind];
    i = optind + 1;
    if (merge)
        flags |= DC_LOADTEMPLATE_MERGE;
    while (i < argc)
    {
        template_db_loadfile(tdb, qdb, argv[i++], owner, flags);
    }

    if (tdb->methods.save(tdb) != DC_OK)
	exit(1);
    if (qdb->methods.save(qdb) != DC_OK)
	exit(1);
    template_db_delete(tdb);
    question_db_delete(qdb);
    config_delete(config);

    return EXIT_SUCCESS;
}
Exemplo n.º 4
0
/* main().
 */
int main(int argc, char *argv[])
{
    parsecmdline(argc, argv);
    if (!readinputfile())
	return EXIT_FAILURE;
    processcontents();
    writesource();
    return 0;
}
Exemplo n.º 5
0
int main(int argc,char **argv)
{
  int n;

  for (n=0;n<HARD_USERLIMIT;n++)
    pchild[n]=(child_t *)NULL;
  for (n=0;n<LOGININFO_COUNT;n++)
    logininfo[n]=(logininfo_t *)NULL;

  parsecmdline(argc,argv);

  while (reinit) {
    reinit=0;
    preinit();
    
    if (readini()<0) exit(1);
    if (!checkconf()) exit(1);
    
    do_writepidfile();
    do_changeroot();

    if (daemonmode) {
      if (fork()==0) startserver();
      exit(0); /* better be sure */
    } else startserver();
    for (n=0;n<maxusers;n++)
      if (pchild[n]) {
	free(pchild[n]);
	pchild[n]=(child_t *)NULL;
      }
    for (n=0;n<logininfocount;n++)
      if (logininfo[n]) {
	free(logininfo[n]);
	logininfo[n]=(logininfo_t *)NULL;
      }
  }
  exit(0);
}
Exemplo n.º 6
0
// application entry point
void main(int argc,char *argv[])
{
  int system_time=0;
  int frame_counter=0;
  int time0;
  char s[20]="";

  if (argc<2) {
    printusage();
    return;
  }

  // parses command line parameters
  parsecmdline(argc-2,argv+2);

  // initializes the video mode and geometry module
  int mode=-1;
  if (vbe_init()) {
    mode=vbe_findmode(scrwidth,scrheight,8);
    if (!mode) mode=-1;
  }
  if (mode==-1) vbe_done();
  if (!vbe_setmode(mode,backbuffl)) goto err;
  setscreensize(vbe_width,vbe_height);
  scr_cols=vbe_width;
  scr_bpp=vbe_bpp;

  // initializes the keyboard
  kbd_init();

  // initializes the timer
  timer_init();

  // initializes the mouse
  mouse_init();

  // reads the map
  if (!map_init(argv[1])) goto err;
  vbe_setpal((Tcolor *)palette,0,256);

  // main loop
  time0=timer_clocks;
  while(player_idle(timer_clocks)) {
    // draws the current frame
    draw_init(vbe_backbuffer,vbe_width,vbe_height);
    map_draw();

    // calculates the frame rate
    frame_counter++;
    int dt=timer_clocks-time0;
    if (dt>500) {
      float fps = (frame_counter*1000.)/dt;
      sprintf(s,"%.1f FPS",fps);
      time0 = timer_clocks;
      frame_counter = 0;
    }
    textout(vbe_backbuffer,0,0,s,255);

    // flips the video pages
    vbe_flip(waitfl);

    // applies the mouse movement
    if (player_keys & kRUN) player_rotate(-mousedy*0.01,0,-mousedx*0.01);
    else player_rotate(-mousedy*0.005,0,-mousedx*0.005);
    mousedx=0;mousedy=0;

    // clears the keyboard queue
    while (kbhit()) getch();
  }
 err:
  vbe_done();
  vbe_settext();
}
Exemplo n.º 7
0
int
main(int argc, char *argv[])
{
	DIR *dp;
	struct dirent *entry;
	pid_t pid;
	struct procstat ps;
	char cmdline[BUFSIZ], *cmd, *cmdbase = NULL, *p, *arg = NULL;
	int i, found = 0;
	int sflag = 0, oflag = 0;
	struct pidentry *pe, *tmp;

	ARGBEGIN {
	case 's':
		sflag = 1;
		break;
	case 'o':
		oflag = 1;
		arg = EARGF(usage());
		break;
	default:
		usage();
	} ARGEND;

	if (!argc)
		return 1;

	TAILQ_INIT(&omitpid_head);

	for (p = strtok(arg, ","); p; p = strtok(NULL, ",")) {
		pe = emalloc(sizeof(*pe));
		if (strcmp(p, "%PPID") == 0)
			pe->pid = getppid();
		else
			pe->pid = estrtol(p, 10);
		TAILQ_INSERT_TAIL(&omitpid_head, pe, entry);
	}

	if (!(dp = opendir("/proc")))
		eprintf("opendir /proc:");

	while ((entry = readdir(dp))) {
		if (!pidfile(entry->d_name))
			continue;
		pid = estrtol(entry->d_name, 10);
		if (oflag) {
			TAILQ_FOREACH(pe, &omitpid_head, entry)
				if (pe->pid == pid)
					break;
			if (pe)
				continue;
		}
		if (parsestat(pid, &ps) < 0)
			continue;
		if (parsecmdline(ps.pid, cmdline,
				 sizeof(cmdline)) < 0) {
			cmd = ps.comm;
			cmdbase = cmd;
		} else {
			if ((p = strchr(cmdline, ' ')))
				*p = '\0';
			cmd = cmdline;
			cmdbase = basename(cmdline);
		}
		/* Workaround for login shells */
		if (cmd[0] == '-')
			cmd++;
		for (i = 0; i < argc; i++) {
			if (strcmp(cmd, argv[i]) == 0 ||
			    strcmp(cmdbase, argv[i]) == 0) {
				putword(entry->d_name);
				found++;
				if (sflag)
					goto out;
			}
		}
	}

out:
	if (found)
		putchar('\n');

	closedir(dp);

	for (pe = TAILQ_FIRST(&omitpid_head); pe; pe = tmp) {
		tmp = TAILQ_NEXT(pe, entry);
		TAILQ_REMOVE(&omitpid_head, pe, entry);
		free(pe);
	}

	return 0;
}
Exemplo n.º 8
0
int main(int argc, char **argv)
{
	FILE						*infile, *outfile;
	int							t1, t2;
	VO_AUDIO_CODECAPI			AudioAPI;
	VO_MEM_OPERATOR				moper;
	VO_CODEC_INIT_USERDATA		useData;
	VO_HANDLE					hCodec;
	VO_CODECBUFFER				inData;
	VO_CODECBUFFER				outData;
	VO_AUDIO_OUTPUTINFO			outInfo;
    int							firstWrite = 1;
	int							eofFile = 0;
	int							*info=(int*)inBuf;
	int							bytesLeft, nRead;
	int							EncoderdFrame = 0;
	int							total = 0;
	int							isOutput = 1;
	int							returnCode;
	AACENC_PARAM				aacpara;
	void						*handle;
	void						*pfunc;
	VOGETAUDIODECAPI			pGetAPI;
	const char					*infileName = NULL;
    const char					*outfileName = NULL;

	returnCode = parsecmdline(argc,argv, &infileName, &outfileName, &aacpara);
	if(returnCode)
	{
		printf("%s", HelpString);
		return 0;
	}

	/* open input file */
	infile = fopen(infileName, "rb");
	if (!infile) {
		printf("Open input file fail...");
		return -1;
	}

	/* open output file */
	if(isOutput)
	{
		outfile = fopen(outfileName, "wb");
		if (!outfile) {
			printf("Open output file fail...");
			return -1;
		}
	}
	// set memory operators;
	moper.Alloc = cmnMemAlloc;
	moper.Copy = cmnMemCopy;
	moper.Free = cmnMemFree;
	moper.Set = cmnMemSet;
	moper.Check = cmnMemCheck;
	useData.memflag = VO_IMF_USERMEMOPERATOR;
	useData.memData = (VO_PTR)(&moper);
	// open encoder dll;
	handle = dlopen("libstagefright.so", RTLD_NOW);
	if(handle == 0)
	{
		printf("open dll error......");
		return -1;
	}
	// Get API;
	pfunc = dlsym(handle, "voGetAACEncAPI");
	if(pfunc == 0)
	{
		printf("open function error......");
		return -1;
	}
	pGetAPI = (VOGETAUDIODECAPI)pfunc;
	returnCode  = pGetAPI(&AudioAPI);
	if(returnCode)
		return -1;


//#######################################   Init Encoding Section   #########################################
	returnCode = AudioAPI.Init(&hCodec, VO_AUDIO_CodingAAC, &useData);
	if(returnCode < 0)
	{
		printf("#### VOI_Error2:fail to initialize the Encoderr###\n");
		return -1;
	}

	returnCode = AudioAPI.SetParam(hCodec, VO_PID_AAC_ENCPARAM, &aacpara);

	inData.Buffer = inBuf;
	bytesLeft = ReadFile2Buf(infile,inData.Buffer,READ_SIZE);

//#######################################    Encoding Section   #########################################

	do {

		inData.Length    = bytesLeft;
		outData.Buffer   = outBuf;
		outData.Length = 1024*8;

		t1 = clock();

		returnCode = AudioAPI.SetInputData(hCodec,&inData);

		do {
			outData.Buffer   = outBuf;
			outData.Length = 1024*8;

			returnCode = AudioAPI.GetOutputData(hCodec,&outData, &outInfo);

			if(returnCode == 0)
				EncoderdFrame++;
			if(returnCode == VO_ERR_LICENSE_ERROR)
				break;

#if VO_AAC_E_OUTPUT
			if (isOutput && returnCode == 0)
			{
				fwrite(outData.Buffer, 1, outData.Length, outfile);
			}
#endif
		} while(returnCode != (VO_ERR_INPUT_BUFFER_SMALL));

		if(returnCode == VO_ERR_LICENSE_ERROR)
			break;

		t2 = clock();
		total += t2 - t1;

		if (!eofFile) {
			nRead = ReadFile2Buf(infile, inBuf,READ_SIZE);
			bytesLeft = nRead;
			inData.Buffer = inBuf;
			if (feof(infile))
				eofFile = 1;
		}

	} while (!eofFile && returnCode);


//################################################  End Encoding Section  #######################################################
	returnCode = AudioAPI.Uninit(hCodec);

	fclose(infile);
	if (outfile)
    {
        fclose(outfile);
    }
	dlclose(handle);
	return 0;
}