示例#1
0
文件: main.c 项目: zonbrisad/Tester
int main(int argc, char *argv[]) {
	int i;
	
	UNUSED(argc);
	UNUSED(argv);
	
	signal(SIGINT, sigInt);
	signal(SIGHUP, sigHup);
	
	printf("\nMakeplate linux C example.\n\n\n");

	INFOPRINT("Information printout\n");
	
	DEBUGPRINT("Debug printout\n");
	
	WARNINGPRINT("Warning printout\n");
	
	ERRORPRINT("Error printout\n");
	
	DEBUG_DO(printf("Debug do\n"));
	
	
	i = 0;
	
	printf("Var i = %2x\n", i);
	BIT_SET(i, 4);
	printf("Var i = %2x\n", i);
	BIT_SET(i, 2);
	printf("Var i = %2x\n", i);
	BIT_CLEAR(i,4);
	printf("Var i = %2x\n", i);

	
	printf("Use CTRL-C to stop program\n");
	while(1) {
	}
	
	return 0;
}
示例#2
0
void program(struct arg_int  *time)
{
    int sec = 0;

    /*Firing the FSM so lanch the program*/
    get_fsm()->fire(EVENT_SETUP, NULL); /* TODO: if you have a config file use the path instead of null */
    get_fsm()->fire(EVENT_START, NULL);

    //If time argument is given the program terminates itself automatically
    if(time->count){
      INFOPRINT("The program is going to be terminated %d sec later", *(time->ival));
    }

    while(running){
      thread_sleep(1000);
      if(time->count && *(time->ival) < ++sec){
        break;
      }
    }

    get_fsm()->fire(EVENT_STOP, NULL);
    get_fsm()->fire(EVENT_SHUTDOWN, NULL);

}
示例#3
0
void conf_load_from_dictionary(dictionary *conf)
{

  INFOPRINT("Configuration setup complete");
}
示例#4
0
/**
 * Main function of server applcation that creates the tunnel interface, starts threads and configures the connections
 */
int main(int argc, char **argv)
{
    //initializing system io components
    init_sysio();
    const char* __progname__ = argv[0];

    /*Setting up the interrupt and binding it to a handler*/
    init_interrupt(&exit_signal, SIGINT, BOOL_FALSE);
    set_interrupt_sh(&exit_signal, _exit_handler);

    /*The program uses argtable2 implementation for parsing arguments
     * More information and examples for argtable2:
     *
     * http://argtable.sourceforge.net/example/index.html
     *
     * */
    struct arg_lit  *help = arg_lit0("h","help","show help");
    struct arg_int  *time = arg_int0("t", "time", "<n>", "time interval");
    struct arg_end  *end  = arg_end(20);
    void* argtable[] = {help, time, end};
    int nerrors;
    int exitcode=EXIT_SUCCESS;


    /* verify the argtable[] entries were allocated sucessfully */
    if (arg_nullcheck(argtable) != 0)
    {
      /* NULL entries were detected, some allocations must have failed */
      ERRORPRINT("%s: insufficient memory\n",__progname__);
      exitcode=1;
      goto exit;
    }

    /* Parse the command line as defined by argtable[] */
    nerrors = arg_parse(argc,argv,argtable);

    /* special case: '--help' takes precedence over error reporting */
    if (help->count > 0)
    {
      INFOPRINT("Usage: %s", __progname__);
      arg_print_syntax(stdout,argtable,"\n");
      arg_print_glossary(stdout,argtable,"  %-20s %s\n");
      exitcode=0;
      goto exit;
    }

    /* If the parser returned any errors then display them and exit */
    if (nerrors > 0)
    {
      /* Display the error details contained in the arg_end struct.*/
      arg_print_errors(stdout,end,__progname__);
      INFOPRINT("Try '%s --help' for more information.\n",__progname__);
      exitcode=1;
      goto exit;
    }

    INFOPRINT("Service build by using devclego version %s.\n\n", DEVCLEGO_VERSION);

    /*devclego starts here
     * Build the abstract finite state machine by ceating it
     * and then running the program.
     * After the program proc finished, fsm is doomed.*/
    fsm_ctor();
    program(time);
    fsm_dtor();
exit:
	return exitcode;
}
示例#5
0
文件: common.cpp 项目: GYGit/reactos
STDMETHODIMP_(NTSTATUS) CCMIAdapter::init(PRESOURCELIST ResourceList, PDEVICE_OBJECT aDeviceObject)
{
    PAGED_CODE();
	ASSERT(ResourceList);
	ASSERT(aDeviceObject);
	ASSERT(ResourceList->FindTranslatedPort(0));
	DBGPRINT(("CCMIAdapter[%p]::init()", this));

	NTSTATUS ntStatus = STATUS_SUCCESS;

	RtlFillMemory(&mixerCache, 0xFF, 0xFF);
	RtlFillMemory(&cm, sizeof(cm), 0x00);

	DeviceObject = aDeviceObject;

	cm.IOBase = 0;
	for (unsigned int i=0;i<ResourceList->NumberOfPorts();i++) {
		if (ResourceList->FindTranslatedPort(i)->u.Port.Length == 0x100) {
			cm.IOBase = (UInt32*)ResourceList->FindTranslatedPort(i)->u.Port.Start.QuadPart;
		}
	}

	if (cm.IOBase == 0) {
		return STATUS_INSUFFICIENT_RESOURCES;
	}
	cm.MPUBase = 0;

#ifdef WAVERT
	INFOPRINT(("Driver Version: %s-WAVERT", CMIVERSION));
#else
	INFOPRINT(("Driver Version: %s", CMIVERSION));
#endif
	INFOPRINT(("Configuration:"));
	INFOPRINT(("    IO Base:      0x%X", cm.IOBase));
	INFOPRINT(("    MPU Base:     0x%X", cm.MPUBase));

	if (!queryChip()) {
		return STATUS_INSUFFICIENT_RESOURCES;
	}

	INFOPRINT(("    Chip Version: %d", cm.chipVersion));
	INFOPRINT(("    Max Channels: %d", cm.maxChannels));
	INFOPRINT(("    CanAC3HW:     %d", cm.canAC3HW));

	resetController();

	ntStatus = PcNewInterruptSync(&(InterruptSync), NULL, ResourceList, 0, InterruptSyncModeNormal);
	if (!NT_SUCCESS(ntStatus) || !(InterruptSync)) {
		DBGPRINT(("Failed to create an interrupt sync!"));
		return STATUS_INSUFFICIENT_RESOURCES;
	}
	ntStatus = InterruptSync->RegisterServiceRoutine(InterruptServiceRoutine, (PVOID)this, FALSE);
	if (!NT_SUCCESS(ntStatus)) {
		DBGPRINT(("Failed to register ISR!"));
		return ntStatus;
	}

	ntStatus = InterruptSync->Connect();
	if (!NT_SUCCESS(ntStatus)) {
		DBGPRINT(("Failed to connect the ISR with InterruptSync!"));
		return ntStatus;
	}

	// Initialize the device state.
	CurrentPowerState = PowerDeviceD0;

	return ntStatus;
}