Exemplo n.º 1
0
Arquivo: prbot.c Projeto: rfw/prbot
int
main(int argc, char *argv[])
{
    // Compile some regexes.
    if (regcomp(&new_pr_regex, NEW_PR_PATTERN, REG_EXTENDED)) {
        fprintf(stderr, "Failed to compile regex.\n");
        return 1;
    }

    // Initialize SQLite gunk.
    int retval;

    retval = sqlite3_open(DATABASE_NAME, &db);
    if (retval) {
        fprintf(stderr, "Failed to open database: %s\n", sqlite3_errmsg(db));
        return 1;
    }

    retval = sqlite3_exec(db, INITIALIZE_DB, 0, 0, 0);
    if (retval) {
        fprintf(stderr, "Failed to initialize database: %s\n", sqlite3_errmsg(db));
        return 1;
    }
 
    // Kick off the IRC connection.
	char buf[BUF_LEN];
	struct ircbuf ircbuf;
	ircbuf_init(&ircbuf, buf, BUF_LEN);

	int fd = irc_connect(IRC_HOST, IRC_PORT);
	if (fd < 0) {
		fprintf(stderr, "Failed to open connection.\n");
		return 1;
	}

	irc_nick(fd, IRC_NICK, NULL);
	irc_join(fd, IRC_CHANNEL);

	char *line;
	while ((line = irc_getline(fd, &ircbuf))) {
		printf("%s\n", line);

		struct ircmsg msg;
		irc_parseline(line, &msg);
		if (!dispatch_handler(fd, &msg))
			return 2;
	}

	return 0;
}
static void* _spi_driver_thread(void *data)
{
	spi_dev_t	*dev = data;

	if (_spi_register_interface(data) != EOK)
		return NULL;

	while (1) {
		if ((dev->ctp = dispatch_block(dev->ctp)) != NULL)
			dispatch_handler(dev->ctp);
		else
			break;
	}

	return NULL;
}
Exemplo n.º 3
0
int main(int argc, char *argv[])
{
	dispatch_t              *dpp;
	resmgr_attr_t           resmgr_attr;
	dispatch_context_t      *ctp;
	resmgr_connect_funcs_t  connect_funcs;
	resmgr_io_funcs_t       io_funcs;
	iofunc_attr_t           io_attr;

	printf("Start resource manager\n");

	fifoHandler = init_fifo();
	pthread_mutex_init(&resource_mutex, NULL);

	// create dispatch.
	if (!(dpp = dispatch_create()))
		error("dispatch_create()");

	// initialize resource manager attributes.
	memset(&resmgr_attr, 0, sizeof(resmgr_attr));
	resmgr_attr.nparts_max = 1;
	resmgr_attr.msg_max_size = 2048;

	// set standard connect and io functions.
	iofunc_func_init(_RESMGR_CONNECT_NFUNCS, &connect_funcs,
	_RESMGR_IO_NFUNCS, &io_funcs);
	iofunc_attr_init(&io_attr, S_IFNAM | 0666, 0, 0);

	io_funcs.read = io_read;
	io_funcs.write = io_write;

	// establish resource manager
	if (resmgr_attach(dpp, &resmgr_attr, "/dev/myresource", _FTYPE_ANY, 0, &connect_funcs, &io_funcs, &io_attr) < 0)
		error("resmgr_attach()");

	// wait forever, handling messages.
	ctp = dispatch_context_alloc(dpp);
	while(1)
	{
		if (!(ctp = dispatch_block(ctp)))
			error("dispatch_block()");
		dispatch_handler(ctp);
	}
	exit(EXIT_SUCCESS);
}
Exemplo n.º 4
0
void DMA2_Stream7_IRQHandler(void) {
    dispatch_handler(DMA2_STREAM7);
}
Exemplo n.º 5
0
void DMA2_Stream6_IRQHandler(void) {
    dispatch_handler(DMA2_STREAM6);
}
Exemplo n.º 6
0
void __irq_dma2_channel3(void) {
    dispatch_handler(DMA2, DMA_CH3);
}
Exemplo n.º 7
0
//void __irq_dma2_stream7(void) {
void __irq_DMA2_Stream7_IRQHandler(void) {
    dispatch_handler(DMA2, DMA_STREAM7);
}
Exemplo n.º 8
0
//void __irq_dma2_stream2(void) {
void __irq_dma2_channel3(void) {
    dispatch_handler(DMA2, DMA_STREAM2);
}
Exemplo n.º 9
0
void DMA2_Stream0_IRQHandler(void) {
    dispatch_handler(DMA2_STREAM0);
}
Exemplo n.º 10
0
main (int argc, char *argv[])
{
    int pathID;

    setvbuf (stdout, NULL, _IOLBF, 0);

    printf ("%s:  starting...\n", progname);

    options (argc, argv);

    /*
     * allocate and initialize a dispatch structure for use by our
     * main loop
    */
    
    dpp = dispatch_create ();
    if (dpp == NULL) {
        fprintf (stderr, "%s:  couldn't dispatch_create: %s\n",
                         progname, strerror (errno));
        exit (1);
    }
    
    /*
     * set up the resource manager attributes structure, we'll
     * use this as a way of passing information to resmgr_attach().
     * For now, we just use defaults.
    */
    
    memset (&rattr, 0, sizeof (rattr)); /* using the defaults for rattr */
    
    /*
     * intialize the connect functions and I/O functions tables to
     * their defaults by calling iofunc_func_init().
     * 
     * connect_funcs, and io_funcs variables are already declared.
     * 
    */
     iofunc_func_init (_RESMGR_CONNECT_NFUNCS, &connect_funcs,
                      _RESMGR_IO_NFUNCS, &io_funcs);
    
                      
    /* over-ride the connect_funcs handler for open with our io_open,
     * and over-ride the io_funcs handlers for read and write with our
     * io_read and io_write handlers
     */
    connect_funcs.open = io_open;
    io_funcs.read = io_read;
    io_funcs.write = io_write;

    
    /* initialize our device description structure
     */
     
    iofunc_attr_init (&ioattr, S_IFCHR | 0666, NULL, NULL);
    /*
     *  call resmgr_attach to register our prefix with the
     *  process manager, and also to let it know about our connect
     *  and I/O functions.
     *
     *  On error, returns -1 and errno is set.
    */
    pathID = resmgr_attach (dpp, &rattr, EXAMPLE_NAME, _FTYPE_ANY, 0,
                                     &connect_funcs, &io_funcs, &ioattr);
    if (pathID == -1) {
        fprintf (stderr, "%s:  couldn't attach pathname: %s\n",
                         progname, strerror (errno));
        exit (1);
    }

    ctp = dispatch_context_alloc (dpp);
    
    while (1) {
        if ((ctp = dispatch_block (ctp)) == NULL) {
            fprintf (stderr, "%s:  dispatch_block failed: %s\n",
                             progname, strerror (errno));
            exit (1);
        }
        dispatch_handler (ctp);
    }
}
Exemplo n.º 11
0
main( int argc, char **argv)
{
  resmgr_attr_t resmgr_attr;
  dispatch_t *dpp;
  dispatch_context_t *ctp;
  int id;
  int pci_id;
  char *device;

  /* check to see if device number is specified when invoked */
  if( argc == 1 ){
    fprintf(stderr, "%s: Invoke with device number (i.e. 1 = /dev/ics660-1)\n",argv[0]);
    return EXIT_FAILURE;
  }
  
  device = calloc((size_t) 64, sizeof(char));
  strcat(device,"/dev/ics660-");
  strcat(device,(const char *) argv[1]);
  printf("_ICS660_DRV: INITIALIZING DEVICE %s\n",device);
  
  sscanf(argv[1],"%d",&pci_id);
  printf("_ICS660_DRV: DEVICE ID %d\n",pci_id);

  ics660 = (struct ics660b *)ics660_drv_init((int) pci_id);

  /* initialize dispatch interface */
  if((dpp = dispatch_create()) == NULL){
    fprintf(stderr, "%s: Unable to allocate dispatch handle.\n", argv[0]);
    return EXIT_FAILURE;
  }
  /* initialize resource manager attributes */
  memset(&resmgr_attr, 0, sizeof resmgr_attr);
  resmgr_attr.nparts_max = 1;
  resmgr_attr.msg_max_size = 2048;

  /* initialize functions for handling messages */
  iofunc_func_init(_RESMGR_CONNECT_NFUNCS, &connect_funcs, 
		   _RESMGR_IO_NFUNCS, &io_funcs);
  io_funcs.read = io_read;
  io_funcs.write = io_write;
  io_funcs.devctl = io_devctl;

 /* initialize attribute structure used by the device */
  iofunc_attr_init(&attr, S_IFNAM | 0666, 0, 0);
  //attr.nbytes = strlen(buffer)+1;

  /* attach our device name */
  id = resmgr_attach(dpp,            // dispatch handle
		     &resmgr_attr,   // resource manager attrs
		     device,  // device name
		     _FTYPE_ANY,     // open type
		     0,              // flags
		     &connect_funcs, // connect routines
		     &io_funcs,      // I/O routines
		     &attr);         // handle
  if(id == -1){
    fprintf(stderr, "%s: Unable to attach name.\n",argv[0]);
    return EXIT_FAILURE;
  }
  /* allocate a context structure */
  ctp = dispatch_context_alloc(dpp);

  /* start the resource manager messager loop */
  while(1){
    if((ctp = dispatch_block(ctp)) == NULL) {
      fprintf(stderr,"block_error\n");
      return EXIT_FAILURE;
    }
    dispatch_handler(ctp);
  }
}
Exemplo n.º 12
0
Arquivo: dma.c Projeto: Saul2588/ousia
void __irq_dma1_channel6(void) {
    dispatch_handler(DMA1, DMA_CH6);
}
Exemplo n.º 13
0
int main(int argc, char *argv[]) {
	dispatch_t *dpp;
	resmgr_attr_t resmgr_attr;
	dispatch_context_t *ctp;
	resmgr_connect_funcs_t connect_funcs;
	resmgr_io_funcs_t io_funcs;
	iofunc_attr_t io_attr;

	printf("Start resource manager\n");

	/* Init mutex for counter variable */
	if (pthread_mutex_init(&lock, NULL) != 0){
	        printf("\n mutex init failed\n");
	        return 1;
	}

	/* Create dispatch. */
	if (!(dpp = dispatch_create()))
		error("dispatch_create()");

	/* Initialize resource manager attributes. */
	memset(&resmgr_attr, 0, sizeof(resmgr_attr));
	resmgr_attr.nparts_max = 1;
	resmgr_attr.msg_max_size = 2048;

	/* Set standard connect and io functions. */
	iofunc_func_init(_RESMGR_CONNECT_NFUNCS,
				&connect_funcs,
				_RESMGR_IO_NFUNCS,
				&io_funcs);
	iofunc_attr_init(&io_attr, S_IFNAM | 0666, 0, 0);

	/* Override functions */
	io_funcs.read = io_read;
	io_funcs.write = io_write;

	/* Establish resource manager */
	if (resmgr_attach(dpp,
				&resmgr_attr,
				"/dev/myresource",
				_FTYPE_ANY,
				0,
				&connect_funcs,
				&io_funcs,
				&io_attr)
					< 0)
		error("resmgr_attach()");

	/* Create counter thread */
	if (pthread_create(&tid, NULL, &counter, NULL) != 0)
		printf("can't create counter thread\n");

	/* Wait forever, handling messages. */
	ctp = dispatch_context_alloc(dpp);
	while(1){
		if (!(ctp = dispatch_block(ctp)))
			error("dispatch_block()");
		dispatch_handler(ctp);
	}
	pthread_mutex_destroy(&lock);

	exit(EXIT_SUCCESS);
}
Exemplo n.º 14
0
//int init_bttvx(int video_mode, int device_number, int w, int h) //Video format, device id, width and height
int 
main (int argc, char * argv[])
{
	int i; 
	/* declare variables we'll be using */
	resmgr_attr_t		resmgr_attr;
	dispatch_t			*dpp;
	dispatch_context_t  *ctp;
	int                 id;
	int video_format = 0;
	int device_id = 0;
	char device_name[100];
	char shell_command[100];
	char buffer[20];
	char buffer2[20];
	int bus, dev_func;


	//Check the arguments
	
	if ( argc == 1 || argc > 3)
	{
		printf("Use: ./bttvx video_format [device_id]\n");
		printf("0 ----> PAL\n");
		printf("1 ----> NTSC\n"); 
		printf("2 ----> S-Video\n");
		exit(0);
	}
	

	//Get video format
	video_format = atoi(argv[1]);

	//Check driver index
	if (argv[2] != NULL)
	{
		device_id = atoi(argv[2]);
		if (device_id < 0 || device_id > BTTV_MAX)
		{
			printf("bttvx: Sorry!, the device id overcomes the maximum number of devices allowed\n");
			exit(0);
		}
	}
	

	//Filling passed width and height
	
	width = W;
	height= H;
	
	image_buffer = (unsigned char *) malloc (width*height*deep);
		
	strcpy(device_name,"/dev/bttvx");
	strcat(device_name,itoa(device_id,buffer,10)); //Complete the name

	init_bttvx(video_format,device_id, width,height, 0, 0);
	
	/* initialize dispatch interface */
	
	if((dpp = dispatch_create()) == NULL) 
	{
		fprintf(stderr, 
			    "%s: Unable to allocate dispatch handle.\n",
				argv[0]);
		return EXIT_FAILURE;
	}
	

	/* initialize resource manager attributes */
	memset(&resmgr_attr, 0, sizeof resmgr_attr);
	
	resmgr_attr.nparts_max = 1;
	resmgr_attr.msg_max_size=VBIBUF_SIZE;

	/* initialize functions for handling messages */
	
	iofunc_func_init(_RESMGR_CONNECT_NFUNCS, 
					 &connect_funcs,
					 _RESMGR_IO_NFUNCS, 
					 &io_funcs);

	io_funcs.read = io_read;
	//io_funcs.devctl = io_devctl;
	connect_funcs.open = io_open;
	
	/* initialize attribute structure used by the device */
	iofunc_attr_init(&attr, 
					 S_IFNAM | 0666, 
					 0, 0);
	//attr.nbytes = VBIBUF_SIZE + 1;
	attr.nbytes = VBIBUF_SIZE;

    /* attach our device name */
    id = resmgr_attach(dpp,            /* dispatch handle        */
                       &resmgr_attr,   /* resource manager attrs */
                       device_name,  /* device name            */
                       _FTYPE_ANY,     /* open type              */
                       0,              /* flags                  */
                       &connect_funcs, /* connect routines       */
                       &io_funcs,      /* I/O routines           */
                       &attr);         /* handle                 */
    if(id == -1) {
        fprintf(stderr, "%s: Unable to attach name.\n", argv[0]);
        return EXIT_FAILURE;
    }

	/* allocate a context structure */
	ctp = dispatch_context_alloc(dpp);

	/* start the resource manager message loop */
	
	while(1) 
	{
		if((ctp = dispatch_block(ctp)) == NULL) 
		{
			fprintf(stderr, "block error\n");
			return EXIT_FAILURE;
		}
		dispatch_handler(ctp);
	}
}
Exemplo n.º 15
0
//void __irq_dma1_stream6(void) {
void __irq_dma1_channel7(void) {
    dispatch_handler(DMA1, DMA_STREAM6);
}
Exemplo n.º 16
0
//void __irq_dma1_stream7(void) {
void __irq_adc3(void) {
    dispatch_handler(DMA1, DMA_STREAM7);
}
Exemplo n.º 17
0
void DMA2_Stream1_IRQHandler(void) {
    dispatch_handler(DMA2_STREAM1);
}
Exemplo n.º 18
0
//void __irq_dma2_stream3(void) {
void __irq_dma2_channel4_5(void) {
    dispatch_handler(DMA2, DMA_STREAM3);
}
Exemplo n.º 19
0
void DMA2_Stream2_IRQHandler(void) {
    dispatch_handler(DMA2_STREAM2);
}
Exemplo n.º 20
0
int main(int argc, char **argv) {
	pcap_t *fp; 
	struct pcap_pkthdr *header;
	const u_char *pkt_data;
	char errbuf[PCAP_ERRBUF_SIZE];
	char source[PCAP_BUF_SIZE];
	int res;
	
	log_file = fopen("log.txt", "w");

	WRITE_TO_LOG("Start main");
	if(argc!=2) {
		fprintf(stderr, "Usage: %s filename", argv[0]);
		exit(EXIT_FAILURE);
	}

	/*Create the source string from the filename*/
	WRITE_TO_LOG("Creating the source string from the filename");
	if(pcap_createsrcstr(
		source,					//To keep source string
		PCAP_SRC_FILE,			//We're opening a file
		NULL,					//Remote host
		NULL,					//Port on the remote host
		argv[1],	//Name of the file to be opened
		errbuf) != 0)
	{
		fprintf(stderr, "\nError creating source string: %s", errbuf);
		exit(EXIT_FAILURE);
	}
	/*Open the capture file*/
	WRITE_TO_LOG("Open the capture file");
	if((fp=pcap_open(
		source,				//Device name
		65536,				//Portion of the packet to be captured
		PCAP_OPENFLAG_PROMISCUOUS, //Promiscuous mode
		1000,				//Read timeout
		NULL,				//Authentication on remote host
		errbuf))==NULL)
	{
		fprintf(stderr, "\nUnable to open the file %s: %s", argv[1], errbuf);
		exit(EXIT_FAILURE);
	}

	WRITE_TO_LOG("Calling dispatch handler");

	while((res=pcap_next_ex(fp, &header, &pkt_data))>=0) {
		dispatch_handler(NULL, header, pkt_data);
	}

	if(res==-1) {
		fprintf(stderr, "Error opening the file for reading packets: %s\n", pcap_geterr(fp));
		exit(EXIT_FAILURE);
	}

	//pcap_loop(fp, 0, dispatch_handler, NULL);
	WRITE_TO_LOG("Calling perform_regex");
	perform_regex("regex_list.txt", "C:\\smtp_dump_output.txt");
	//perform_regex("regex_list.txt", "C:\\agentlog.txt");
	Sleep(10000);
	

	WRITE_TO_LOG("Exiting..");
	fclose(log_file);

}
Exemplo n.º 21
0
void DMA2_Stream3_IRQHandler(void) {
    dispatch_handler(DMA2_STREAM3);
}
Exemplo n.º 22
0
void __irq_dma_channel7(void) {
    dispatch_handler(DMA1, DMA_CH7);
}
Exemplo n.º 23
0
void DMA2_Stream4_IRQHandler(void) {
    dispatch_handler(DMA2_STREAM4);
}
Exemplo n.º 24
0
void __irq_dma2_channel4_5(void) {
    dispatch_handler(DMA2, DMA_CH4);
    dispatch_handler(DMA2, DMA_CH5);
}
Exemplo n.º 25
0
void DMA2_Stream5_IRQHandler(void) {
    dispatch_handler(DMA2_STREAM5);
}