Example #1
0
int main(int argc, char **argv) {
	unsigned timeout = 1, connected = 0;

	parseArguments(argc, argv);
	daemonize();
	registerSignalHandlers();
	termInit();
	atexit(disconnectFromMPD);
	initCodesets();

	do {
		if (!connected) {
			timeout = timeout <= 30 ? timeout * 2 : 60;
			connected = connectToMPD(timeout > 10 ? 10 : timeout);
		}

		if (connected) {
			timeout = 1;
			connected = getSong();
		}

		display(timeout);
	} while (!done());

	return 0;
}
Example #2
0
int main()
{
    signal (SIGALRM, signalhandler);
    signal (SIGUSR1, reset);

    nval.it_interval.tv_sec  = 1;
    nval.it_interval.tv_usec = 0;
    nval.it_value.tv_sec  = 1;
    nval.it_value.tv_usec = 0;	
	
    sc_regInit();
    termInit();
    ax = 0x0;
    ip = 0x0;

    enum Keys key = K_UNKNOWN;
	
	displayBorders();
    displayUI();
    
    f_key = 0;
    f_ign = 0;
    
    while (key != K_Q) {
		
		readKey (&key);
		
		if (key == K_T) {
			sc_regSet(IR, 0);
			alarm(0); 
			f_key = 0;
			cu();
		}
		
		if (!f_key) {
			if (key == K_R    )  {
				sc_regSet(IR, 1);
				sc_regSet(IF, 0);
			}
			
			sc_regGet(IR, &f_key);
			
			if (f_key) {
				timerStart();        
			}
			
			if (key == K_F5   ) user_input_ax();
			if (key == K_F6   ) user_input_ip();
			if (key == K_RIGHT) if (mem_ptr < 99) ++mem_ptr;
			if (key == K_LEFT ) if (mem_ptr >  0) --mem_ptr;
			if (key == K_UP   ) if (mem_ptr - 10 >=  0) mem_ptr -= 10;
			if (key == K_DOWN ) if (mem_ptr + 10 < 100) mem_ptr += 10;
			if (key == K_L	  ) sc_memoryLoad("memory.o");
			if (key == K_S	  ) sc_memorySave("memory.o");
			if (key == K_E	  ) user_input_mem(); 
			if (key == K_I) {
				displayBorders();
				displayUI();
				sc_memoryInit();
				sc_regInit();
			}
			displayUI ();
		}
		
	}
    
	return 0;
}
Example #3
0
int main(int N, char *P[])
{
int n,Ctx;
char *dirW = ".nife";
    if (N > 2) {
       fprintf(stderr,"nife [nif-file]\n");
       return(1);
    }
    if ((sizeof(void*) != sizeof(long)) ||
       (sizeof(double) != sizeof(long long))) {
       fprintf(stderr,"Nife open-source don't runs on these machine !\n");
       return(2);
    }
    signal(SIGQUIT,SIG_IGN);
    signal(SIGABRT,SIG_IGN);
    signal(SIGUSR1,SIG_IGN);
    signal(SIGCONT,SIG_IGN);
    signal(SIGSTOP,SIG_IGN);
    signal(SIGTSTP,SIG_IGN);
    signal(SIGINT,Interrupt);
    signal(SIGTERM,Interrupt);
    signal(SIGPIPE,Interrupt);
    signal(SIGCHLD,Interrupt);
    signal(SIGQUIT,Interrupt);
    signal(SIGSEGV,Interrupt);
    signal(SIGFPE,Interrupt);
    signal(SIGALRM,Interrupt);
    /* work in ./.nife for facilities of debugging !! */
    if (chdir(dirW) != 0) {
       if (mkdir(dirW, 0755) == -1) {
          perror("mkdir"); return 1;
       }
       if (chdir(dirW) != 0) {
          perror("chdir"); return 1;
       }
    }
    termInit(); /* may stop if no term found */
    TH_init();
    initLib();
    D_Reset();
    if (N==2) {
       IF_Load();
       lectFic(P[1]);
    } else {
      printf("Welcome to Nife : Just stack it !\n");
      IF_helpS();
    }
    while (RUN) {
       if ((FD_IN+iTERM) == 0) {
          printf("> ");
          fflush(stdout);
          Ctx=0;
       } else Ctx=1;
       razErr();
       if ((n=lireLigne(FD_IN,bufP,bufP2,LBUF)) == -1)
                 printf("Line too long!\n");
       else
          if (n>0) traiteLigne(bufP,0);
    }
    IF_delAllGP();
    IF_netStopS();
    IF_netOff();
    D_Close();
    termReset();
    printf("Bye !\n");
    return 0;
}
Example #4
0
/*******************************************************************************
* main()
*
* Description:
*   Main application code
*
* See also:
*
* Arguments:
*   void
*
* Returns:
*   void
*
* Callers: C start-up code
*
* Notes :
*
*******************************************************************************/
int main(void)
{
    CBUFFNUM    testBufferNum;
    CBUFFNUM    uartOutBufferNum;
    volatile unsigned int x = 0;
    /* Initialise all used hardware and   */
    /* related interrupts                 */
    initLEDs();
    initUart2();
    initTimer2();
    initInterrupts();
    termInit();

    /* Create circular buffers            */
    cbuffInit();
    testBufferNum = cbuffCreate(testBuffer, TESTBUFFERSIZE,
                                &testBufferObj);
    uartOutBufferNum = cbuffCreate(uartOutBuffer, UARTOUTBUFFERSIZE,
                                   &uartOutBufferObj);

    /* Check buffers were created         */
    if (testBufferNum == 0 || uartOutBufferNum == 0)
    {
        error();
    }

    /* Get handles to buffers             */
    hTestBuffer = cbuffOpen(testBufferNum);
    hUartOutBuffer = cbuffOpen(uartOutBufferNum);
    /* Check buffers were opened          */
    if (hTestBuffer == (HCBUFF) 0 || hUartOutBuffer == (HCBUFF) 0)
    {
        error();
    }
    /* Start Timer based data generation  */
    startTimer2();
    /* Output statistics                  */
    while(1)
    {
        triggerUART2(hUartOutBuffer);

        updateStats(hTestBuffer);

        //termOutput(hUartOutBuffer);

        if(termIsAutomatic())
        {
            if(cbuffGetSpace(hTestBuffer) <= termGetEmptyTrigger())
            {
                termCheckBuffer(hTestBuffer);
                termFullScreenUpdate();
            }
        }
        else if(emptyBuffer == 1)
        {
            emptyBuffer = 0;
            termCheckBuffer(hTestBuffer);
            termFullScreenUpdate();
        }

        if (x >= 0x0FFF)
        {
            termOutput(hUartOutBuffer);
            x = 0;
        }
        else
        {
            x++;
        }
    }
}