Ejemplo n.º 1
0
int main_thread()
{
#if LWIP_DHCP==1
	int mscnt = 0;
#endif
	/* initialize lwIP before calling sys_thread_new */
    lwip_init();

    /* any thread using lwIP should be created using sys_thread_new */
    sys_thread_new("NW_THRD", network_thread, NULL,
            THREAD_STACKSIZE,
            DEFAULT_THREAD_PRIO);
#if LWIP_DHCP==1
    while (1) {
#ifdef OS_IS_FREERTOS
    	vTaskDelay(DHCP_FINE_TIMER_MSECS / portTICK_RATE_MS);
#else
    	sleep(DHCP_FINE_TIMER_MSECS);
#endif
		if (server_netif.ip_addr.addr) {
			xil_printf("DHCP request success\r\n");
			print_ip_settings(&(server_netif.ip_addr), &(server_netif.netmask), &(server_netif.gw));
			/* print all application headers */
			print_headers();
			/* now we can start application threads */
			launch_app_threads();
			break;
		}
		mscnt += DHCP_FINE_TIMER_MSECS;
		if (mscnt >= 10000) {
			xil_printf("ERROR: DHCP request timed out\r\n");
			xil_printf("Configuring default IP of 192.168.1.10\r\n");
			IP4_ADDR(&(server_netif.ip_addr),  192, 168,   1, 10);
			IP4_ADDR(&(server_netif.netmask), 255, 255, 255,  0);
			IP4_ADDR(&(server_netif.gw),      192, 168,   1,  1);
			print_ip_settings(&(server_netif.ip_addr), &(server_netif.netmask), &(server_netif.gw));
			/* print all application headers */
			print_headers();
			launch_app_threads();
			break;
		}

	}
#ifdef OS_IS_FREERTOS
	vTaskDelete(NULL);
#endif
#endif

    return 0;
}
Ejemplo n.º 2
0
void torrent_view::render()
{
	print_tabs();
	print_headers();

	int lines_printed = header_size;

	int torrent_index = 0;

	for (std::vector<lt::torrent_status const*>::iterator i = m_filtered_handles.begin();
		i != m_filtered_handles.end(); ++torrent_index)
	{
		if (torrent_index < m_scroll_position)
		{
			++i;
			continue;
		}
		if (lines_printed >= m_height)
			break;

		lt::torrent_status const& s = **i;
		if (!s.handle.is_valid())
		{
			i = m_filtered_handles.erase(i);
			continue;
		}
		++i;

		set_cursor_pos(0, torrent_index + header_size - m_scroll_position);
		print_torrent(s, torrent_index == m_active_torrent);
		++lines_printed;
	}

	clear_rows(torrent_index + header_size, m_height);
}
Ejemplo n.º 3
0
static void run()
{
    VALUE stack_start;
    VALUE code;
    void Init_stack _((VALUE*));

    Init_stack(&stack_start);
    code = compile(eruby_filename);
    if (eruby_sync) {
	print_headers(-1);
    }
    else {
	replace_stdout();
    }
    code = eval(code, eruby_filename);
    if (eruby_mode == MODE_FILTER &&
	(RTEST(ruby_debug) || RTEST(ruby_verbose))) {
	print_generated_code(stderr, code, 0);
    }
    rb_exec_end_proc();
    if (!eruby_sync) {
	flush_buffer();
    }
    ruby_finalize();
}
Ejemplo n.º 4
0
static void print_headers(const char *tok,
    const taglist_t *h1, const taglist_t *h2, const taglist_t *h3)
{
    if (!h1 || !h2 || !h3) {
        assert(!h1 && !h2 && !h3);
        return;
    }
    print_headers(tok, h1->pred, h2->pred, h3->pred);
    printf("%.*s%.*s\n",
        (int)(h2->dist - h1->dist), tok + h1->dist,
        (int)(h3->dist - h2->dist), tok + h2->dist);
}
Ejemplo n.º 5
0
int
process_request_contents()
{
	client.request->headers = parse_headers(client.request->contents,&client.request->body);
	debug("Headers:\n%s",print_headers(NULL,client.request->headers));
	if (!client.request->headers) {
		error("No request headers on request %i\n",client.request);
		return -1;
	}
	request_headers(client.request, _("peer"),socket_peer(client.request->socket));
	return 0;
}
Ejemplo n.º 6
0
void network_thread(void *p)
{
    struct netif *netif;
    struct ip_addr ipaddr, netmask, gw;

    /* the mac address of the board. this should be unique per board */
    unsigned char mac_ethernet_address[] = { 0x00, 0x0A, 0x35, 0x02, 0x2D, 0x8C };

    netif = &server_netif;
    //xil_printf("Inside NW_THREAD\r\n");

#if 1
    /* initliaze IP addresses to be used */
    //IP4_ADDR(&ipaddr,  192, 168,   1, 10);
    //IP4_ADDR(&netmask, 255, 255, 255,  0);
    //IP4_ADDR(&gw,      192, 168,   1,  1);
    IP4_ADDR(&ipaddr,  10, 0,   18, 100);
    IP4_ADDR(&netmask, 255, 255, 255,  0);
    IP4_ADDR(&gw,      10, 0,   18,  1);
#else
    IP4_ADDR(&ipaddr,  172, 16,   0, 10);
    IP4_ADDR(&netmask, 255, 255, 255,  0);
    IP4_ADDR(&gw,      172, 16,   0,  1);
#endif

    /* print out IP settings of the board */
    print("\r\n\r\n");
    print("-----BPM Server Application ------\r\n\n");
    print_ip_settings(&ipaddr, &netmask, &gw);

    /* print all application headers */
    print_headers();

    /* Add network interface to the netif_list, and set it as default */
    if (!xemac_add(netif, &ipaddr, &netmask, &gw, mac_ethernet_address, PLATFORM_EMAC_BASEADDR)) {
        xil_printf("Error adding N/W interface\r\n");
        return;
    }
    netif_set_default(netif);

    /* specify that the network if is up */
    netif_set_up(netif);

    /* start packet receive thread - required for lwIP operation */
    sys_thread_new("xemacif_input_thread", (void(*)(void*))xemacif_input_thread, netif,
            THREAD_STACKSIZE,
            DEFAULT_THREAD_PRIO);

    /* now we can start application threads */
    launch_app_threads();

    return;
}
Ejemplo n.º 7
0
int main(int argc, char *argv[]){

  int parsed, n_read, n_written;
  char outfile[FILENAME_MAX];

  parsed=parser(argc, argv);
  if(!parsed){
    return 1;
  }

  /* tell us what you think you are doing */
  print_parsed_info();

  /* open input and output files */
  fpin=fopen(cat_filename,"r");
  if(fpin==NULL){
    fprintf(stderr,"Cannot open %s for reading.  Exiting.\n",cat_filename);
    return 1;
  }
  sprintf(outfile,"%s.txt",basename);
  fpout=fopen(outfile,"w");
  if(fpout==NULL){
    fprintf(stderr,"Cannot open %s for writing.  Exiting.\n",outfile);
    return 1;
  }

  /* sort out headers */
  print_headers(argc, argv);

  n_read=0;
  n_written=0;
  while(!feof(fpin)){
    read_event();
    n_read++;
    if(check_criteria()){
      write_event();
      n_written++;
    }
  }

  /* close files */
  fclose(fpin);
  fclose(fpout);

  /* report */
  printf("%d / %d events matched criteria\n", n_written, n_read);

  return 0;
}
Ejemplo n.º 8
0
static int
ostream_write(void *data, const char *buf, size_t size, size_t *pret)
{
    struct ostream *ostr = data;
    
    if (!(ostr->flags & OSTREAM_INITIALIZED)) {
	if (option_mime && print_headers(ostr))
	    return dico_stream_last_error(ostr->transport);
	ostr->flags |= OSTREAM_INITIALIZED;
    }
    if (buf[0] == '.' && dico_stream_write(ostr->transport, ".", 1))
	return dico_stream_last_error(ostr->transport);
    *pret = size;
    return dico_stream_write(ostr->transport, buf, size);
}
Ejemplo n.º 9
0
static void flush_buffer()
{
    char *out;
    int nout;

#if RUBY_VERSION_CODE >= 180
    out = RSTRING_PTR(rb_stdout);
    nout = RSTRING_LEN(rb_stdout);
#else
    out = RSTRING(rb_defout)->ptr;
    nout = RSTRING(rb_defout)->len;
#endif
    print_headers(nout);
    fwrite(out, nout, 1, stdout);
    fflush(stdout);
}
Ejemplo n.º 10
0
/**
 * Function to process get requests received from clients.
 * @param server_struct is the main structure for the server.
 * @param connection is the connection in MHD
 * @param url is the requested url
 * @param con_cls is a pointer used to know if this is the first call or not
 * @returns an int that is either MHD_NO or MHD_YES upon failure or not.
 */
static int process_get_request(server_struct_t *server_struct, struct MHD_Connection *connection, const char *url, void **con_cls)
{
    static int aptr = 0;
    int success = MHD_NO;
    gchar *answer = NULL;


    if (&aptr != *con_cls)
        {
            /* do never respond on first call */
            *con_cls = &aptr;

            success = MHD_YES;
        }
    else
        {
            if (get_debug_mode() == TRUE)
                {
                    print_debug(_("Requested get url: %s\n"), url);
                    print_headers(connection);
                }

            if (g_str_has_suffix(url, ".json"))
                { /* A json format answer was requested */
                    answer = get_json_answer(server_struct, connection, url);
                }
            else
                { /* An "unformatted" answer was requested */
                    answer = get_unformatted_answer(server_struct, url);
                }

                /* reset when done */
                *con_cls = NULL;

                /* Do not free answer variable as MHD will do it for us ! */
                success = create_MHD_response(connection, answer);
        }

    return success;

}
Ejemplo n.º 11
0
/* Send HTTP request to the remote peer */
static void submit_request(http2_session_data *session_data) {
  int32_t stream_id;
  http2_stream_data *stream_data = session_data->stream_data;
  const char *uri = stream_data->uri;
  const struct http_parser_url *u = stream_data->u;
  nghttp2_nv hdrs[] = {
      MAKE_NV2(":method", "GET"),
      MAKE_NV(":scheme", &uri[u->field_data[UF_SCHEMA].off],
              u->field_data[UF_SCHEMA].len),
      MAKE_NV(":authority", stream_data->authority, stream_data->authoritylen),
      MAKE_NV(":path", stream_data->path, stream_data->pathlen)};
  fprintf(stderr, "Request headers:\n");
  print_headers(stderr, hdrs, ARRLEN(hdrs));
  stream_id = nghttp2_submit_request(session_data->session, NULL, hdrs,
                                     ARRLEN(hdrs), NULL, stream_data);
  if (stream_id < 0) {
    errx(1, "Could not submit HTTP request: %s", nghttp2_strerror(stream_id));
  }

  stream_data->stream_id = stream_id;
}
Ejemplo n.º 12
0
int main(int argc, char **argv)
{
     int fd_in = 0, fd_out = 0;
     int ret;
     char ip[CI_IPLEN];
     ci_connection_t *conn;
     ci_request_t *req;
     ci_headers_list_t *req_headers = NULL;
     ci_headers_list_t *resp_headers = NULL;

     CI_DEBUG_LEVEL = 1;        /*Default debug level is 1 */
     ci_cfg_lib_init();

     if (!ci_args_apply(argc, argv, options)) {
          ci_args_usage(argv[0], options);
          exit(-1);
     }

#if ! defined(_WIN32)
     __log_error = (void (*)(void *, const char *,...)) log_errors;     /*set c-icap library log  function */
#else
     __vlog_error = vlog_errors;        /*set c-icap library  log function for win32..... */
#endif


     if (!(conn = ci_client_connect_to(icap_server, port, 0))) {
          ci_debug_printf(1, "Failed to connect to icap server.....\n");
          exit(-1);
     }

     req = ci_client_request(conn, icap_server, service);

     if (xheaders)
	 ci_icap_append_xheaders(req, xheaders);

     ci_client_get_server_options(req, CONN_TIMEOUT);
     ci_debug_printf(10, "OK done with options!\n");
     ci_conn_remote_ip(conn, ip);
     ci_debug_printf(1, "ICAP server:%s, ip:%s, port:%d\n\n", icap_server, ip,
                     port);

     if (!send_preview) {
         req->preview = -1;
     } else if (preview_size >= 0 && preview_size < req->preview) {
         req->preview = preview_size;
     }

     /*If service does not support allow 204 disable it*/
     if (!req->allow204)
         allow204 = 0;
     
     if (!input_file && !request_url && !resp_url) {
          ci_debug_printf(1, "OPTIONS:\n");
          ci_debug_printf(1,
                          "\tAllow 204: %s\n\tPreview: %d\n\tKeep alive: %s\n",
                          (req->allow204 ? "Yes" : "No"), req->preview,
                          (req->keepalive ? "Yes" : "No")
              );
          print_headers(req);
     }
     else {
          if (input_file && (fd_in = open(input_file, O_RDONLY)) < 0) {
               ci_debug_printf(1, "Error opening file %s\n", input_file);
               exit(-1);
          }

          if (output_file) {
               if ((fd_out =
                    open(output_file, O_CREAT | O_RDWR | O_EXCL,
                         S_IRWXU | S_IRGRP)) < 0) {
                    ci_debug_printf(1, "Error opening output file %s\n",
                                    output_file);
                    exit(-1);
               }
          }
          else {
               fd_out = fileno(stdout);
          }

          ci_client_request_reuse(req);

          ci_debug_printf(10, "Preview:%d keepalive:%d,allow204:%d\n",
                          req->preview, req->keepalive, req->allow204);

          ci_debug_printf(10, "OK allocating request going to send request\n");

	  req->type = ICAP_RESPMOD;
          if (allow204)
              req->allow204 = 1;
          if (allow206)
              req->allow206 = 1;

	  if (xheaders)
	      ci_icap_append_xheaders(req, xheaders);

	  if (request_url) {
	       req_headers = ci_headers_create();
               build_reqmod_headers(request_url, method_str, fd_in, req_headers);
	       req->type = ICAP_REQMOD;
	  }
          else if (send_headers) {
               resp_headers = ci_headers_create();
	       build_respmod_headers(fd_in, resp_headers);
               if (resp_url) {
                   req_headers = ci_headers_create();
	           build_reqmod_headers(resp_url, method_str, 0, req_headers);
               }
          }

	  if(req_headers && http_xheaders)
	      ci_headers_addheaders(req_headers, http_xheaders);

          if (resp_headers && http_resp_xheaders)
	      ci_headers_addheaders(resp_headers, http_resp_xheaders);

          ret = ci_client_icapfilter(req,
                                     CONN_TIMEOUT,
                                     req_headers,
                                     resp_headers,
                                     (fd_in > 0 ? (&fd_in): NULL),
                                     (int (*)(void *, char *, int)) fileread,
                                     &fd_out,
                                     (int (*)(void *, char *, int)) filewrite);

          if (ret == 206) {
              ci_debug_printf(1, "Partial modification (Allow 206 response): "
                              "use %ld from the original body data\n", 
                              req->i206_use_original_body);
              copy_data(fd_in, fd_out, req->i206_use_original_body);

          }

          close(fd_in);
          close(fd_out);

          if (ret == 204) {
               ci_debug_printf(1,
                               "No modification needed (Allow 204 response)\n");
               if (output_file)
                    unlink(output_file);
          }

          if (verbose)
               print_headers(req);

          ci_debug_printf(2, "Done\n");
     }
     ci_connection_destroy(conn);
     return 0;
}
Ejemplo n.º 13
0
Archivo: main.c Proyecto: Kinae/Ksecret
int main(int argc, char **argv) {

	char *filepath = NULL;
	uint8_t *key = NULL;
	int app_mode = 0;
	int ret_value = 0; 

	int optch;
	extern int opterr;
	char format[] = "f:k:DE";

	opterr = 1;

	while((optch = getopt(argc, argv, format)) != -1) {
		switch(optch) {
			case 'f':
				filepath = optarg;
				break;
			case 'k':
				key = optarg;
				break;
			case 'D':
				app_mode = DECRYPTION_MODE;
				break;
			case 'E':
				app_mode = ENCRYPTION_MODE;
				break;
		}
	}

	if(key == NULL) { 
		fprintf(stderr, "No secret key has been specified. Use the -k option to set the secret key\n");
		return EXIT_FAILURE;
	}

	if(filepath == NULL) {
		fprintf(stderr, "No file has been specified. Use the -f option to set the filepath\n");
		return EXIT_FAILURE;
	}

	if(app_mode == 0) {
		fprintf(stderr, "No mode has been specified. Use -D (decryption) or -E (encryption)\n");
		return EXIT_FAILURE;
	}

	print_headers();

	switch(app_mode) {
		case DECRYPTION_MODE :
		 	ret_value = decryption_mode(key, filepath);	
			if(ret_value == -1) {
				fprintf(stderr, "Error while decrypting\n");	
				return EXIT_FAILURE;
			}
			break;
		case ENCRYPTION_MODE :
			ret_value = encryption_mode(key, filepath);
			if(ret_value == -1) {
				fprintf(stderr, "Error while encrypting\n");	
				return EXIT_FAILURE;
			}
			break;
	}

	return EXIT_SUCCESS;
}
Ejemplo n.º 14
0
static int lex(input_t *in, long *count, long *total)
{
    const char *s1, *s2, *v1, *v2, *v3, *v4, *m1, *m2, *rp1, *rp2, *rt1, *rt2;
    taglist_t *h1, *h2, *h3;
    long c, t;

    c = 0; t = 0;
loop:
    in->tok = in->cur;

{
	YYCTYPE yych;
	if ((YYLIMIT - YYCURSOR) < 15) YYFILL(15);
	yych = *YYCURSOR;
	switch (yych) {
	case 0x00:	goto yy2;
	case '\n':	goto yy6;
	case '!':
	case '#':
	case '$':
	case '%':
	case '&':
	case '\'':
	case '*':
	case '+':
	case '-':
	case '.':
	case '0':
	case '1':
	case '2':
	case '3':
	case '4':
	case '5':
	case '6':
	case '7':
	case '8':
	case '9':
	case 'A':
	case 'B':
	case 'C':
	case 'D':
	case 'E':
	case 'F':
	case 'G':
	case 'I':
	case 'J':
	case 'K':
	case 'L':
	case 'M':
	case 'N':
	case 'O':
	case 'P':
	case 'Q':
	case 'R':
	case 'S':
	case 'T':
	case 'U':
	case 'V':
	case 'W':
	case 'X':
	case 'Y':
	case 'Z':
	case '^':
	case '_':
	case '`':
	case 'a':
	case 'b':
	case 'c':
	case 'd':
	case 'e':
	case 'f':
	case 'g':
	case 'h':
	case 'i':
	case 'j':
	case 'k':
	case 'l':
	case 'm':
	case 'n':
	case 'o':
	case 'p':
	case 'q':
	case 'r':
	case 's':
	case 't':
	case 'u':
	case 'v':
	case 'w':
	case 'x':
	case 'y':
	case 'z':
	case '|':
	case '~':
		in->yyt1 = YYCURSOR;
		goto yy8;
	case 'H':
		in->yyt1 = in->yyt7 = YYCURSOR;
		goto yy9;
	default:	goto yy4;
	}
yy2:
	++YYCURSOR;
	{ *count = c; *total = t; return 0; }
yy4:
	++YYCURSOR;
yy5:
	{ return 1; }
yy6:
	++YYCURSOR;
	{ goto loop; }
yy8:
	yych = *(YYMARKER = ++YYCURSOR);
	switch (yych) {
	case ' ':
	case '!':
	case '#':
	case '$':
	case '%':
	case '&':
	case '\'':
	case '*':
	case '+':
	case '-':
	case '.':
	case '0':
	case '1':
	case '2':
	case '3':
	case '4':
	case '5':
	case '6':
	case '7':
	case '8':
	case '9':
	case 'A':
	case 'B':
	case 'C':
	case 'D':
	case 'E':
	case 'F':
	case 'G':
	case 'H':
	case 'I':
	case 'J':
	case 'K':
	case 'L':
	case 'M':
	case 'N':
	case 'O':
	case 'P':
	case 'Q':
	case 'R':
	case 'S':
	case 'T':
	case 'U':
	case 'V':
	case 'W':
	case 'X':
	case 'Y':
	case 'Z':
	case '^':
	case '_':
	case '`':
	case 'a':
	case 'b':
	case 'c':
	case 'd':
	case 'e':
	case 'f':
	case 'g':
	case 'h':
	case 'i':
	case 'j':
	case 'k':
	case 'l':
	case 'm':
	case 'n':
	case 'o':
	case 'p':
	case 'q':
	case 'r':
	case 's':
	case 't':
	case 'u':
	case 'v':
	case 'w':
	case 'x':
	case 'y':
	case 'z':
	case '|':
	case '~':	goto yy13;
	default:	goto yy5;
	}
yy9:
	yych = *(YYMARKER = ++YYCURSOR);
	switch (yych) {
	case ' ':
	case '!':
	case '#':
	case '$':
	case '%':
	case '&':
	case '\'':
	case '*':
	case '+':
	case '-':
	case '.':
	case '0':
	case '1':
	case '2':
	case '3':
	case '4':
	case '5':
	case '6':
	case '7':
	case '8':
	case '9':
	case 'A':
	case 'B':
	case 'C':
	case 'D':
	case 'E':
	case 'F':
	case 'G':
	case 'H':
	case 'I':
	case 'J':
	case 'K':
	case 'L':
	case 'M':
	case 'N':
	case 'O':
	case 'P':
	case 'Q':
	case 'R':
	case 'S':
	case 'U':
	case 'V':
	case 'W':
	case 'X':
	case 'Y':
	case 'Z':
	case '^':
	case '_':
	case '`':
	case 'a':
	case 'b':
	case 'c':
	case 'd':
	case 'e':
	case 'f':
	case 'g':
	case 'h':
	case 'i':
	case 'j':
	case 'k':
	case 'l':
	case 'm':
	case 'n':
	case 'o':
	case 'p':
	case 'q':
	case 'r':
	case 's':
	case 't':
	case 'u':
	case 'v':
	case 'w':
	case 'x':
	case 'y':
	case 'z':
	case '|':
	case '~':	goto yy13;
	case 'T':	goto yy14;
	default:	goto yy5;
	}
yy10:
	yych = *++YYCURSOR;
	switch (yych) {
	case '!':
	case '$':
	case '%':
	case '&':
	case '\'':
	case '(':
	case ')':
	case '*':
	case ',':
	case ':':
	case ';':
	case '=':
	case '_':
	case '~':
		in->yyt3 = YYCURSOR;
		goto yy15;
	case '+':
	case '-':
	case '.':
	case '0':
	case '1':
	case '2':
	case '3':
	case '4':
	case '5':
	case '6':
	case '7':
	case '8':
	case '9':
	case 'A':
	case 'B':
	case 'C':
	case 'D':
	case 'E':
	case 'F':
	case 'G':
	case 'H':
	case 'I':
	case 'J':
	case 'K':
	case 'L':
	case 'M':
	case 'N':
	case 'O':
	case 'P':
	case 'Q':
	case 'R':
	case 'S':
	case 'T':
	case 'U':
	case 'V':
	case 'W':
	case 'X':
	case 'Y':
	case 'Z':
	case 'a':
	case 'b':
	case 'c':
	case 'd':
	case 'e':
	case 'f':
	case 'g':
	case 'h':
	case 'i':
	case 'j':
	case 'k':
	case 'l':
	case 'm':
	case 'n':
	case 'o':
	case 'p':
	case 'q':
	case 'r':
	case 's':
	case 't':
	case 'u':
	case 'v':
	case 'w':
	case 'x':
	case 'y':
	case 'z':
		in->yyt3 = YYCURSOR;
		goto yy17;
	case '/':
		in->yyt3 = YYCURSOR;
		goto yy19;
	case '[':
	case ']':
		in->yyt3 = YYCURSOR;
		goto yy21;
	default:	goto yy11;
	}
yy11:
	YYCURSOR = YYMARKER;
	goto yy5;
yy12:
	++YYCURSOR;
	if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
	yych = *YYCURSOR;
yy13:
	switch (yych) {
	case ' ':
		in->yyt2 = YYCURSOR;
		goto yy10;
	case '!':
	case '#':
	case '$':
	case '%':
	case '&':
	case '\'':
	case '*':
	case '+':
	case '-':
	case '.':
	case '0':
	case '1':
	case '2':
	case '3':
	case '4':
	case '5':
	case '6':
	case '7':
	case '8':
	case '9':
	case 'A':
	case 'B':
	case 'C':
	case 'D':
	case 'E':
	case 'F':
	case 'G':
	case 'H':
	case 'I':
	case 'J':
	case 'K':
	case 'L':
	case 'M':
	case 'N':
	case 'O':
	case 'P':
	case 'Q':
	case 'R':
	case 'S':
	case 'T':
	case 'U':
	case 'V':
	case 'W':
	case 'X':
	case 'Y':
	case 'Z':
	case '^':
	case '_':
	case '`':
	case 'a':
	case 'b':
	case 'c':
	case 'd':
	case 'e':
	case 'f':
	case 'g':
	case 'h':
	case 'i':
	case 'j':
	case 'k':
	case 'l':
	case 'm':
	case 'n':
	case 'o':
	case 'p':
	case 'q':
	case 'r':
	case 's':
	case 't':
	case 'u':
	case 'v':
	case 'w':
	case 'x':
	case 'y':
	case 'z':
	case '|':
	case '~':	goto yy12;
	default:	goto yy11;
	}
yy14:
	yych = *++YYCURSOR;
	switch (yych) {
	case 'T':	goto yy23;
	default:	goto yy13;
	}
yy15:
	++YYCURSOR;
	if ((YYLIMIT - YYCURSOR) < 11) YYFILL(11);
	yych = *YYCURSOR;
	switch (yych) {
	case ' ':
		in->yyt4 = YYCURSOR;
		goto yy24;
	case '!':
	case '$':
	case '%':
	case '&':
	case '\'':
	case '(':
	case ')':
	case '*':
	case '+':
	case ',':
	case '-':
	case '.':
	case '0':
	case '1':
	case '2':
	case '3':
	case '4':
	case '5':
	case '6':
	case '7':
	case '8':
	case '9':
	case ':':
	case ';':
	case '=':
	case 'A':
	case 'B':
	case 'C':
	case 'D':
	case 'E':
	case 'F':
	case 'G':
	case 'H':
	case 'I':
	case 'J':
	case 'K':
	case 'L':
	case 'M':
	case 'N':
	case 'O':
	case 'P':
	case 'Q':
	case 'R':
	case 'S':
	case 'T':
	case 'U':
	case 'V':
	case 'W':
	case 'X':
	case 'Y':
	case 'Z':
	case '_':
	case 'a':
	case 'b':
	case 'c':
	case 'd':
	case 'e':
	case 'f':
	case 'g':
	case 'h':
	case 'i':
	case 'j':
	case 'k':
	case 'l':
	case 'm':
	case 'n':
	case 'o':
	case 'p':
	case 'q':
	case 'r':
	case 's':
	case 't':
	case 'u':
	case 'v':
	case 'w':
	case 'x':
	case 'y':
	case 'z':
	case '~':	goto yy15;
	case '@':	goto yy25;
	case '[':
	case ']':	goto yy21;
	default:	goto yy11;
	}
yy17:
	++YYCURSOR;
	if ((YYLIMIT - YYCURSOR) < 14) YYFILL(14);
	yych = *YYCURSOR;
	switch (yych) {
	case ' ':
		in->yyt4 = YYCURSOR;
		goto yy24;
	case '!':
	case '$':
	case '%':
	case '&':
	case '\'':
	case '(':
	case ')':
	case '*':
	case ',':
	case ';':
	case '=':
	case '_':
	case '~':	goto yy15;
	case '+':
	case '-':
	case '.':
	case '0':
	case '1':
	case '2':
	case '3':
	case '4':
	case '5':
	case '6':
	case '7':
	case '8':
	case '9':
	case 'A':
	case 'B':
	case 'C':
	case 'D':
	case 'E':
	case 'F':
	case 'G':
	case 'H':
	case 'I':
	case 'J':
	case 'K':
	case 'L':
	case 'M':
	case 'N':
	case 'O':
	case 'P':
	case 'Q':
	case 'R':
	case 'S':
	case 'T':
	case 'U':
	case 'V':
	case 'W':
	case 'X':
	case 'Y':
	case 'Z':
	case 'a':
	case 'b':
	case 'c':
	case 'd':
	case 'e':
	case 'f':
	case 'g':
	case 'h':
	case 'i':
	case 'j':
	case 'k':
	case 'l':
	case 'm':
	case 'n':
	case 'o':
	case 'p':
	case 'q':
	case 'r':
	case 's':
	case 't':
	case 'u':
	case 'v':
	case 'w':
	case 'x':
	case 'y':
	case 'z':	goto yy17;
	case ':':	goto yy26;
	case '@':	goto yy25;
	case '[':
	case ']':	goto yy21;
	default:	goto yy11;
	}
yy19:
	++YYCURSOR;
	if ((YYLIMIT - YYCURSOR) < 11) YYFILL(11);
	yych = *YYCURSOR;
yy20:
	switch (yych) {
	case ' ':
		in->yyt4 = YYCURSOR;
		goto yy24;
	case '!':
	case '$':
	case '%':
	case '&':
	case '\'':
	case '(':
	case ')':
	case '*':
	case '+':
	case ',':
	case '-':
	case '.':
	case '/':
	case '0':
	case '1':
	case '2':
	case '3':
	case '4':
	case '5':
	case '6':
	case '7':
	case '8':
	case '9':
	case ':':
	case ';':
	case '=':
	case '?':
	case '@':
	case 'A':
	case 'B':
	case 'C':
	case 'D':
	case 'E':
	case 'F':
	case 'G':
	case 'H':
	case 'I':
	case 'J':
	case 'K':
	case 'L':
	case 'M':
	case 'N':
	case 'O':
	case 'P':
	case 'Q':
	case 'R':
	case 'S':
	case 'T':
	case 'U':
	case 'V':
	case 'W':
	case 'X':
	case 'Y':
	case 'Z':
	case '_':
	case 'a':
	case 'b':
	case 'c':
	case 'd':
	case 'e':
	case 'f':
	case 'g':
	case 'h':
	case 'i':
	case 'j':
	case 'k':
	case 'l':
	case 'm':
	case 'n':
	case 'o':
	case 'p':
	case 'q':
	case 'r':
	case 's':
	case 't':
	case 'u':
	case 'v':
	case 'w':
	case 'x':
	case 'y':
	case 'z':
	case '~':	goto yy19;
	default:	goto yy11;
	}
yy21:
	++YYCURSOR;
	if ((YYLIMIT - YYCURSOR) < 11) YYFILL(11);
	yych = *YYCURSOR;
yy22:
	switch (yych) {
	case ' ':
		in->yyt4 = YYCURSOR;
		goto yy24;
	case '!':
	case '$':
	case '%':
	case '&':
	case '\'':
	case '(':
	case ')':
	case '*':
	case '+':
	case ',':
	case '-':
	case '.':
	case '0':
	case '1':
	case '2':
	case '3':
	case '4':
	case '5':
	case '6':
	case '7':
	case '8':
	case '9':
	case ':':
	case ';':
	case '=':
	case 'A':
	case 'B':
	case 'C':
	case 'D':
	case 'E':
	case 'F':
	case 'G':
	case 'H':
	case 'I':
	case 'J':
	case 'K':
	case 'L':
	case 'M':
	case 'N':
	case 'O':
	case 'P':
	case 'Q':
	case 'R':
	case 'S':
	case 'T':
	case 'U':
	case 'V':
	case 'W':
	case 'X':
	case 'Y':
	case 'Z':
	case '[':
	case ']':
	case '_':
	case 'a':
	case 'b':
	case 'c':
	case 'd':
	case 'e':
	case 'f':
	case 'g':
	case 'h':
	case 'i':
	case 'j':
	case 'k':
	case 'l':
	case 'm':
	case 'n':
	case 'o':
	case 'p':
	case 'q':
	case 'r':
	case 's':
	case 't':
	case 'u':
	case 'v':
	case 'w':
	case 'x':
	case 'y':
	case 'z':
	case '~':	goto yy21;
	default:	goto yy11;
	}
yy23:
	yych = *++YYCURSOR;
	switch (yych) {
	case 'P':	goto yy27;
	default:	goto yy13;
	}
yy24:
	yych = *++YYCURSOR;
	switch (yych) {
	case 'H':
		in->yyt5 = YYCURSOR;
		goto yy28;
	default:	goto yy11;
	}
yy25:
	yych = *++YYCURSOR;
	switch (yych) {
	case ' ':	goto yy11;
	default:	goto yy22;
	}
yy26:
	yych = *++YYCURSOR;
	switch (yych) {
	case '/':	goto yy31;
	default:	goto yy30;
	}
yy27:
	yych = *++YYCURSOR;
	switch (yych) {
	case '/':	goto yy34;
	default:	goto yy13;
	}
yy28:
	yych = *++YYCURSOR;
	switch (yych) {
	case 'T':	goto yy35;
	default:	goto yy11;
	}
yy29:
	++YYCURSOR;
	if ((YYLIMIT - YYCURSOR) < 11) YYFILL(11);
	yych = *YYCURSOR;
yy30:
	switch (yych) {
	case ' ':
		in->yyt4 = YYCURSOR;
		goto yy24;
	case '!':
	case '$':
	case '%':
	case '&':
	case '\'':
	case '(':
	case ')':
	case '*':
	case '+':
	case ',':
	case '-':
	case '.':
	case '0':
	case '1':
	case '2':
	case '3':
	case '4':
	case '5':
	case '6':
	case '7':
	case '8':
	case '9':
	case ':':
	case ';':
	case '=':
	case 'A':
	case 'B':
	case 'C':
	case 'D':
	case 'E':
	case 'F':
	case 'G':
	case 'H':
	case 'I':
	case 'J':
	case 'K':
	case 'L':
	case 'M':
	case 'N':
	case 'O':
	case 'P':
	case 'Q':
	case 'R':
	case 'S':
	case 'T':
	case 'U':
	case 'V':
	case 'W':
	case 'X':
	case 'Y':
	case 'Z':
	case '_':
	case 'a':
	case 'b':
	case 'c':
	case 'd':
	case 'e':
	case 'f':
	case 'g':
	case 'h':
	case 'i':
	case 'j':
	case 'k':
	case 'l':
	case 'm':
	case 'n':
	case 'o':
	case 'p':
	case 'q':
	case 'r':
	case 's':
	case 't':
	case 'u':
	case 'v':
	case 'w':
	case 'x':
	case 'y':
	case 'z':
	case '~':	goto yy29;
	case '/':
	case '?':	goto yy19;
	case '@':	goto yy32;
	case '[':
	case ']':	goto yy21;
	default:	goto yy11;
	}
yy31:
	yych = *++YYCURSOR;
	switch (yych) {
	case '/':	goto yy36;
	default:	goto yy20;
	}
yy32:
	++YYCURSOR;
	if ((YYLIMIT - YYCURSOR) < 11) YYFILL(11);
	yych = *YYCURSOR;
	switch (yych) {
	case ' ':
		in->yyt4 = YYCURSOR;
		goto yy24;
	case '!':
	case '$':
	case '%':
	case '&':
	case '\'':
	case '(':
	case ')':
	case '*':
	case '+':
	case ',':
	case '-':
	case '.':
	case '0':
	case '1':
	case '2':
	case '3':
	case '4':
	case '5':
	case '6':
	case '7':
	case '8':
	case '9':
	case ':':
	case ';':
	case '=':
	case 'A':
	case 'B':
	case 'C':
	case 'D':
	case 'E':
	case 'F':
	case 'G':
	case 'H':
	case 'I':
	case 'J':
	case 'K':
	case 'L':
	case 'M':
	case 'N':
	case 'O':
	case 'P':
	case 'Q':
	case 'R':
	case 'S':
	case 'T':
	case 'U':
	case 'V':
	case 'W':
	case 'X':
	case 'Y':
	case 'Z':
	case '_':
	case 'a':
	case 'b':
	case 'c':
	case 'd':
	case 'e':
	case 'f':
	case 'g':
	case 'h':
	case 'i':
	case 'j':
	case 'k':
	case 'l':
	case 'm':
	case 'n':
	case 'o':
	case 'p':
	case 'q':
	case 'r':
	case 's':
	case 't':
	case 'u':
	case 'v':
	case 'w':
	case 'x':
	case 'y':
	case 'z':
	case '~':	goto yy32;
	case '/':
	case '?':
	case '@':	goto yy19;
	case '[':
	case ']':	goto yy21;
	default:	goto yy11;
	}
yy34:
	yych = *++YYCURSOR;
	switch (yych) {
	case '0':
	case '1':
	case '2':
	case '3':
	case '4':
	case '5':
	case '6':
	case '7':
	case '8':
	case '9':	goto yy37;
	default:	goto yy11;
	}
yy35:
	yych = *++YYCURSOR;
	switch (yych) {
	case 'T':	goto yy38;
	default:	goto yy11;
	}
yy36:
	yych = *++YYCURSOR;
	switch (yych) {
	case '@':	goto yy19;
	default:	goto yy40;
	}
yy37:
	yych = *++YYCURSOR;
	switch (yych) {
	case '.':	goto yy43;
	default:	goto yy11;
	}
yy38:
	yych = *++YYCURSOR;
	switch (yych) {
	case 'P':	goto yy44;
	default:	goto yy11;
	}
yy39:
	++YYCURSOR;
	if ((YYLIMIT - YYCURSOR) < 11) YYFILL(11);
	yych = *YYCURSOR;
yy40:
	switch (yych) {
	case ' ':
		in->yyt4 = YYCURSOR;
		goto yy24;
	case '!':
	case '$':
	case '%':
	case '&':
	case '\'':
	case '(':
	case ')':
	case '*':
	case '+':
	case ',':
	case '-':
	case '.':
	case '0':
	case '1':
	case '2':
	case '3':
	case '4':
	case '5':
	case '6':
	case '7':
	case '8':
	case '9':
	case ':':
	case ';':
	case '=':
	case 'A':
	case 'B':
	case 'C':
	case 'D':
	case 'E':
	case 'F':
	case 'G':
	case 'H':
	case 'I':
	case 'J':
	case 'K':
	case 'L':
	case 'M':
	case 'N':
	case 'O':
	case 'P':
	case 'Q':
	case 'R':
	case 'S':
	case 'T':
	case 'U':
	case 'V':
	case 'W':
	case 'X':
	case 'Y':
	case 'Z':
	case '_':
	case 'a':
	case 'b':
	case 'c':
	case 'd':
	case 'e':
	case 'f':
	case 'g':
	case 'h':
	case 'i':
	case 'j':
	case 'k':
	case 'l':
	case 'm':
	case 'n':
	case 'o':
	case 'p':
	case 'q':
	case 'r':
	case 's':
	case 't':
	case 'u':
	case 'v':
	case 'w':
	case 'x':
	case 'y':
	case 'z':
	case '~':	goto yy39;
	case '/':
	case '?':	goto yy19;
	case '@':
	case '[':
	case ']':	goto yy41;
	default:	goto yy11;
	}
yy41:
	++YYCURSOR;
	if ((YYLIMIT - YYCURSOR) < 11) YYFILL(11);
	yych = *YYCURSOR;
	switch (yych) {
	case ' ':
		in->yyt4 = YYCURSOR;
		goto yy24;
	case '!':
	case '$':
	case '%':
	case '&':
	case '\'':
	case '(':
	case ')':
	case '*':
	case '+':
	case ',':
	case '-':
	case '.':
	case '0':
	case '1':
	case '2':
	case '3':
	case '4':
	case '5':
	case '6':
	case '7':
	case '8':
	case '9':
	case ':':
	case ';':
	case '=':
	case 'A':
	case 'B':
	case 'C':
	case 'D':
	case 'E':
	case 'F':
	case 'G':
	case 'H':
	case 'I':
	case 'J':
	case 'K':
	case 'L':
	case 'M':
	case 'N':
	case 'O':
	case 'P':
	case 'Q':
	case 'R':
	case 'S':
	case 'T':
	case 'U':
	case 'V':
	case 'W':
	case 'X':
	case 'Y':
	case 'Z':
	case '[':
	case ']':
	case '_':
	case 'a':
	case 'b':
	case 'c':
	case 'd':
	case 'e':
	case 'f':
	case 'g':
	case 'h':
	case 'i':
	case 'j':
	case 'k':
	case 'l':
	case 'm':
	case 'n':
	case 'o':
	case 'p':
	case 'q':
	case 'r':
	case 's':
	case 't':
	case 'u':
	case 'v':
	case 'w':
	case 'x':
	case 'y':
	case 'z':
	case '~':	goto yy41;
	case '/':
	case '?':
	case '@':	goto yy19;
	default:	goto yy11;
	}
yy43:
	yych = *++YYCURSOR;
	switch (yych) {
	case '0':
	case '1':
	case '2':
	case '3':
	case '4':
	case '5':
	case '6':
	case '7':
	case '8':
	case '9':	goto yy45;
	default:	goto yy11;
	}
yy44:
	yych = *++YYCURSOR;
	switch (yych) {
	case '/':	goto yy46;
	default:	goto yy11;
	}
yy45:
	yych = *++YYCURSOR;
	switch (yych) {
	case ' ':
		in->yyt8 = YYCURSOR;
		goto yy47;
	default:	goto yy11;
	}
yy46:
	yych = *++YYCURSOR;
	switch (yych) {
	case '0':
	case '1':
	case '2':
	case '3':
	case '4':
	case '5':
	case '6':
	case '7':
	case '8':
	case '9':	goto yy48;
	default:	goto yy11;
	}
yy47:
	yych = *++YYCURSOR;
	switch (yych) {
	case '0':
	case '1':
	case '2':
	case '3':
	case '4':
	case '5':
	case '6':
	case '7':
	case '8':
	case '9':
		in->yyt9 = YYCURSOR;
		goto yy49;
	default:	goto yy11;
	}
yy48:
	yych = *++YYCURSOR;
	switch (yych) {
	case '.':	goto yy50;
	default:	goto yy11;
	}
yy49:
	yych = *++YYCURSOR;
	switch (yych) {
	case '0':
	case '1':
	case '2':
	case '3':
	case '4':
	case '5':
	case '6':
	case '7':
	case '8':
	case '9':	goto yy51;
	default:	goto yy11;
	}
yy50:
	yych = *++YYCURSOR;
	switch (yych) {
	case '0':
	case '1':
	case '2':
	case '3':
	case '4':
	case '5':
	case '6':
	case '7':
	case '8':
	case '9':	goto yy52;
	default:	goto yy11;
	}
yy51:
	yych = *++YYCURSOR;
	switch (yych) {
	case '0':
	case '1':
	case '2':
	case '3':
	case '4':
	case '5':
	case '6':
	case '7':
	case '8':
	case '9':	goto yy53;
	default:	goto yy11;
	}
yy52:
	yych = *++YYCURSOR;
	switch (yych) {
	case '\n':
		in->yyt6 = YYCURSOR;
		goto yy54;
	default:	goto yy11;
	}
yy53:
	yych = *++YYCURSOR;
	switch (yych) {
	case ' ':
		in->yyt10 = YYCURSOR;
		goto yy55;
	default:	goto yy11;
	}
yy54:
	yych = *++YYCURSOR;
	switch (yych) {
	case '\n':
		YYMTAGN (in->yyt15);
		YYMTAGN (in->yyt14);
		YYMTAGN (in->yyt13);
		in->yyt7 = in->yyt8 = in->yyt9 = in->yyt10 = in->yyt11 = in->yyt12 = NULL;
		goto yy56;
	case '!':
	case '#':
	case '$':
	case '%':
	case '&':
	case '\'':
	case '*':
	case '+':
	case '-':
	case '.':
	case '0':
	case '1':
	case '2':
	case '3':
	case '4':
	case '5':
	case '6':
	case '7':
	case '8':
	case '9':
	case 'A':
	case 'B':
	case 'C':
	case 'D':
	case 'E':
	case 'F':
	case 'G':
	case 'H':
	case 'I':
	case 'J':
	case 'K':
	case 'L':
	case 'M':
	case 'N':
	case 'O':
	case 'P':
	case 'Q':
	case 'R':
	case 'S':
	case 'T':
	case 'U':
	case 'V':
	case 'W':
	case 'X':
	case 'Y':
	case 'Z':
	case '^':
	case '_':
	case '`':
	case 'a':
	case 'b':
	case 'c':
	case 'd':
	case 'e':
	case 'f':
	case 'g':
	case 'h':
	case 'i':
	case 'j':
	case 'k':
	case 'l':
	case 'm':
	case 'n':
	case 'o':
	case 'p':
	case 'q':
	case 'r':
	case 's':
	case 't':
	case 'u':
	case 'v':
	case 'w':
	case 'x':
	case 'y':
	case 'z':
	case '|':
	case '~':
		YYMTAGP (in->yyt13);
		in->yyt7 = in->yyt8 = in->yyt9 = in->yyt10 = in->yyt11 = in->yyt12 = NULL;
		goto yy58;
	default:	goto yy11;
	}
yy55:
	yych = *++YYCURSOR;
	switch (yych) {
	case 0x00:
	case 0x01:
	case 0x02:
	case 0x03:
	case 0x04:
	case 0x05:
	case 0x06:
	case 0x07:
	case 0x08:
	case '\v':
	case '\f':
	case '\r':
	case 0x0E:
	case 0x0F:
	case 0x10:
	case 0x11:
	case 0x12:
	case 0x13:
	case 0x14:
	case 0x15:
	case 0x16:
	case 0x17:
	case 0x18:
	case 0x19:
	case 0x1A:
	case 0x1B:
	case 0x1C:
	case 0x1D:
	case 0x1E:
	case 0x7F:	goto yy11;
	case '\n':
		in->yyt11 = in->yyt12 = YYCURSOR;
		goto yy62;
	default:
		in->yyt11 = YYCURSOR;
		goto yy60;
	}
yy56:
	++YYCURSOR;
	m1 = in->yyt1;
	m2 = in->yyt2;
	rt1 = in->yyt3;
	rt2 = in->yyt4;
	v3 = in->yyt5;
	v4 = in->yyt6;
	v1 = in->yyt7;
	v2 = in->yyt8;
	s1 = in->yyt9;
	s2 = in->yyt10;
	rp1 = in->yyt11;
	rp2 = in->yyt12;
	h1 = in->yyt13;
	h2 = in->yyt14;
	h3 = in->yyt15;
	{
#ifndef VERIFY
        c += 1;
        t += (v2 - v1) + (s2 - s1) + (rp2 - rp1)
            + (m2 - m1) + (rt2 - rt1) + (v4 - v3);
        for (; h1 != 0; h1 = h1->pred, h2 = h2->pred, h3 = h3->pred) {
            t += (h2->dist - h1->dist) + (h3->dist - h2->dist);
        }
#else
        if (s1) printf("%.*s %.*s %.*s\n",
            (int)(v2 - v1), v1,
            (int)(s2 - s1), s1,
            (int)(rp2 - rp1), rp1);
        if (m1) printf("%.*s %.*s %.*s\n",
            (int)(m2 - m1), m1,
            (int)(rt2 - rt1), rt1,
            (int)(v4 - v3), v3);
        print_headers(in->tok, h1, h2, h3);
        printf("\n");
#endif
        taglistpool_clear(&in->tlp, in);
        goto loop;
    }
yy58:
	++YYCURSOR;
	if (YYLIMIT <= YYCURSOR) YYFILL(1);
	yych = *YYCURSOR;
	switch (yych) {
	case '!':
	case '#':
	case '$':
	case '%':
	case '&':
	case '\'':
	case '*':
	case '+':
	case '-':
	case '.':
	case '0':
	case '1':
	case '2':
	case '3':
	case '4':
	case '5':
	case '6':
	case '7':
	case '8':
	case '9':
	case 'A':
	case 'B':
	case 'C':
	case 'D':
	case 'E':
	case 'F':
	case 'G':
	case 'H':
	case 'I':
	case 'J':
	case 'K':
	case 'L':
	case 'M':
	case 'N':
	case 'O':
	case 'P':
	case 'Q':
	case 'R':
	case 'S':
	case 'T':
	case 'U':
	case 'V':
	case 'W':
	case 'X':
	case 'Y':
	case 'Z':
	case '^':
	case '_':
	case '`':
	case 'a':
	case 'b':
	case 'c':
	case 'd':
	case 'e':
	case 'f':
	case 'g':
	case 'h':
	case 'i':
	case 'j':
	case 'k':
	case 'l':
	case 'm':
	case 'n':
	case 'o':
	case 'p':
	case 'q':
	case 'r':
	case 's':
	case 't':
	case 'u':
	case 'v':
	case 'w':
	case 'x':
	case 'y':
	case 'z':
	case '|':
	case '~':	goto yy58;
	case ':':	goto yy63;
	default:	goto yy11;
	}
yy60:
	++YYCURSOR;
	if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
	yych = *YYCURSOR;
	switch (yych) {
	case 0x00:
	case 0x01:
	case 0x02:
	case 0x03:
	case 0x04:
	case 0x05:
	case 0x06:
	case 0x07:
	case 0x08:
	case '\v':
	case '\f':
	case '\r':
	case 0x0E:
	case 0x0F:
	case 0x10:
	case 0x11:
	case 0x12:
	case 0x13:
	case 0x14:
	case 0x15:
	case 0x16:
	case 0x17:
	case 0x18:
	case 0x19:
	case 0x1A:
	case 0x1B:
	case 0x1C:
	case 0x1D:
	case 0x1E:
	case 0x7F:	goto yy11;
	case '\n':
		in->yyt12 = YYCURSOR;
		goto yy62;
	default:	goto yy60;
	}
yy62:
	yych = *++YYCURSOR;
	switch (yych) {
	case '\n':
		YYMTAGN (in->yyt15);
		YYMTAGN (in->yyt14);
		YYMTAGN (in->yyt13);
		in->yyt1 = in->yyt2 = in->yyt3 = in->yyt4 = in->yyt5 = in->yyt6 = NULL;
		goto yy56;
	case '!':
	case '#':
	case '$':
	case '%':
	case '&':
	case '\'':
	case '*':
	case '+':
	case '-':
	case '.':
	case '0':
	case '1':
	case '2':
	case '3':
	case '4':
	case '5':
	case '6':
	case '7':
	case '8':
	case '9':
	case 'A':
	case 'B':
	case 'C':
	case 'D':
	case 'E':
	case 'F':
	case 'G':
	case 'H':
	case 'I':
	case 'J':
	case 'K':
	case 'L':
	case 'M':
	case 'N':
	case 'O':
	case 'P':
	case 'Q':
	case 'R':
	case 'S':
	case 'T':
	case 'U':
	case 'V':
	case 'W':
	case 'X':
	case 'Y':
	case 'Z':
	case '^':
	case '_':
	case '`':
	case 'a':
	case 'b':
	case 'c':
	case 'd':
	case 'e':
	case 'f':
	case 'g':
	case 'h':
	case 'i':
	case 'j':
	case 'k':
	case 'l':
	case 'm':
	case 'n':
	case 'o':
	case 'p':
	case 'q':
	case 'r':
	case 's':
	case 't':
	case 'u':
	case 'v':
	case 'w':
	case 'x':
	case 'y':
	case 'z':
	case '|':
	case '~':
		YYMTAGP (in->yyt13);
		in->yyt1 = in->yyt2 = in->yyt3 = in->yyt4 = in->yyt5 = in->yyt6 = NULL;
		goto yy58;
	default:	goto yy11;
	}
yy63:
	++YYCURSOR;
	if (YYLIMIT <= YYCURSOR) YYFILL(1);
	yych = *YYCURSOR;
	switch (yych) {
	case 0x00:
	case 0x01:
	case 0x02:
	case 0x03:
	case 0x04:
	case 0x05:
	case 0x06:
	case 0x07:
	case 0x08:
	case '\v':
	case '\f':
	case '\r':
	case 0x0E:
	case 0x0F:
	case 0x10:
	case 0x11:
	case 0x12:
	case 0x13:
	case 0x14:
	case 0x15:
	case 0x16:
	case 0x17:
	case 0x18:
	case 0x19:
	case 0x1A:
	case 0x1B:
	case 0x1C:
	case 0x1D:
	case 0x1E:
	case 0x7F:	goto yy11;
	case '\t':
	case ' ':
		YYMTAGP (in->yyt14);
		goto yy64;
	case '\n':
		in->yyt16 = in->yyt15;
		YYMTAGP (in->yyt16);
		YYMTAGP (in->yyt14);
		goto yy66;
	default:
		YYMTAGP (in->yyt14);
		goto yy67;
	}
yy64:
	++YYCURSOR;
	if (YYLIMIT <= YYCURSOR) YYFILL(1);
	yych = *YYCURSOR;
	switch (yych) {
	case 0x00:
	case 0x01:
	case 0x02:
	case 0x03:
	case 0x04:
	case 0x05:
	case 0x06:
	case 0x07:
	case 0x08:
	case '\v':
	case '\f':
	case '\r':
	case 0x0E:
	case 0x0F:
	case 0x10:
	case 0x11:
	case 0x12:
	case 0x13:
	case 0x14:
	case 0x15:
	case 0x16:
	case 0x17:
	case 0x18:
	case 0x19:
	case 0x1A:
	case 0x1B:
	case 0x1C:
	case 0x1D:
	case 0x1E:
	case 0x7F:	goto yy11;
	case '\t':
	case ' ':	goto yy64;
	case '\n':
		in->yyt16 = in->yyt15;
		YYMTAGP (in->yyt16);
		goto yy66;
	default:	goto yy67;
	}
yy66:
	++YYCURSOR;
	if (YYLIMIT <= YYCURSOR) YYFILL(1);
	yych = *YYCURSOR;
	switch (yych) {
	case '\t':
	case ' ':	goto yy64;
	case '\n':
		in->yyt15 = in->yyt16;
		goto yy56;
	case '!':
	case '#':
	case '$':
	case '%':
	case '&':
	case '\'':
	case '*':
	case '+':
	case '-':
	case '.':
	case '0':
	case '1':
	case '2':
	case '3':
	case '4':
	case '5':
	case '6':
	case '7':
	case '8':
	case '9':
	case 'A':
	case 'B':
	case 'C':
	case 'D':
	case 'E':
	case 'F':
	case 'G':
	case 'H':
	case 'I':
	case 'J':
	case 'K':
	case 'L':
	case 'M':
	case 'N':
	case 'O':
	case 'P':
	case 'Q':
	case 'R':
	case 'S':
	case 'T':
	case 'U':
	case 'V':
	case 'W':
	case 'X':
	case 'Y':
	case 'Z':
	case '^':
	case '_':
	case '`':
	case 'a':
	case 'b':
	case 'c':
	case 'd':
	case 'e':
	case 'f':
	case 'g':
	case 'h':
	case 'i':
	case 'j':
	case 'k':
	case 'l':
	case 'm':
	case 'n':
	case 'o':
	case 'p':
	case 'q':
	case 'r':
	case 's':
	case 't':
	case 'u':
	case 'v':
	case 'w':
	case 'x':
	case 'y':
	case 'z':
	case '|':
	case '~':
		in->yyt15 = in->yyt16;
		YYMTAGP (in->yyt13);
		goto yy58;
	default:	goto yy11;
	}
yy67:
	++YYCURSOR;
	if (YYLIMIT <= YYCURSOR) YYFILL(1);
	yych = *YYCURSOR;
	switch (yych) {
	case 0x00:
	case 0x01:
	case 0x02:
	case 0x03:
	case 0x04:
	case 0x05:
	case 0x06:
	case 0x07:
	case 0x08:
	case '\v':
	case '\f':
	case '\r':
	case 0x0E:
	case 0x0F:
	case 0x10:
	case 0x11:
	case 0x12:
	case 0x13:
	case 0x14:
	case 0x15:
	case 0x16:
	case 0x17:
	case 0x18:
	case 0x19:
	case 0x1A:
	case 0x1B:
	case 0x1C:
	case 0x1D:
	case 0x1E:
	case 0x7F:	goto yy11;
	case '\t':	goto yy69;
	case '\n':
		in->yyt16 = in->yyt15;
		YYMTAGP (in->yyt16);
		goto yy66;
	default:	goto yy67;
	}
yy69:
	++YYCURSOR;
	if (YYLIMIT <= YYCURSOR) YYFILL(1);
	yych = *YYCURSOR;
	switch (yych) {
	case 0x00:
	case 0x01:
	case 0x02:
	case 0x03:
	case 0x04:
	case 0x05:
	case 0x06:
	case 0x07:
	case 0x08:
	case '\v':
	case '\f':
	case '\r':
	case 0x0E:
	case 0x0F:
	case 0x10:
	case 0x11:
	case 0x12:
	case 0x13:
	case 0x14:
	case 0x15:
	case 0x16:
	case 0x17:
	case 0x18:
	case 0x19:
	case 0x1A:
	case 0x1B:
	case 0x1C:
	case 0x1D:
	case 0x1E:
	case 0x7F:	goto yy11;
	case '\t':	goto yy69;
	case '\n':
		YYMTAGP (in->yyt15);
		goto yy71;
	case ' ':	goto yy67;
	default:	goto yy72;
	}
yy71:
	++YYCURSOR;
	if (YYLIMIT <= YYCURSOR) YYFILL(1);
	yych = *YYCURSOR;
	switch (yych) {
	case '\n':	goto yy56;
	case '!':
	case '#':
	case '$':
	case '%':
	case '&':
	case '\'':
	case '*':
	case '+':
	case '-':
	case '.':
	case '0':
	case '1':
	case '2':
	case '3':
	case '4':
	case '5':
	case '6':
	case '7':
	case '8':
	case '9':
	case 'A':
	case 'B':
	case 'C':
	case 'D':
	case 'E':
	case 'F':
	case 'G':
	case 'H':
	case 'I':
	case 'J':
	case 'K':
	case 'L':
	case 'M':
	case 'N':
	case 'O':
	case 'P':
	case 'Q':
	case 'R':
	case 'S':
	case 'T':
	case 'U':
	case 'V':
	case 'W':
	case 'X':
	case 'Y':
	case 'Z':
	case '^':
	case '_':
	case '`':
	case 'a':
	case 'b':
	case 'c':
	case 'd':
	case 'e':
	case 'f':
	case 'g':
	case 'h':
	case 'i':
	case 'j':
	case 'k':
	case 'l':
	case 'm':
	case 'n':
	case 'o':
	case 'p':
	case 'q':
	case 'r':
	case 's':
	case 't':
	case 'u':
	case 'v':
	case 'w':
	case 'x':
	case 'y':
	case 'z':
	case '|':
	case '~':
		YYMTAGP (in->yyt13);
		goto yy58;
	default:	goto yy11;
	}
yy72:
	++YYCURSOR;
	if (YYLIMIT <= YYCURSOR) YYFILL(1);
	yych = *YYCURSOR;
	switch (yych) {
	case 0x00:
	case 0x01:
	case 0x02:
	case 0x03:
	case 0x04:
	case 0x05:
	case 0x06:
	case 0x07:
	case 0x08:
	case '\v':
	case '\f':
	case '\r':
	case 0x0E:
	case 0x0F:
	case 0x10:
	case 0x11:
	case 0x12:
	case 0x13:
	case 0x14:
	case 0x15:
	case 0x16:
	case 0x17:
	case 0x18:
	case 0x19:
	case 0x1A:
	case 0x1B:
	case 0x1C:
	case 0x1D:
	case 0x1E:
	case 0x7F:	goto yy11;
	case '\t':	goto yy73;
	case '\n':
		in->yyt16 = in->yyt15;
		YYMTAGP (in->yyt16);
		goto yy66;
	default:	goto yy67;
	}
yy73:
	++YYCURSOR;
	if (YYLIMIT <= YYCURSOR) YYFILL(1);
	yych = *YYCURSOR;
	switch (yych) {
	case '\t':
	case ' ':	goto yy73;
	case '\n':
		YYMTAGP (in->yyt15);
		goto yy71;
	default:	goto yy11;
	}
}

}
Ejemplo n.º 15
0
void network_thread(void *p)
{
    struct netif *netif;
    struct ip_addr ipaddr, netmask, gw;
#if LWIP_DHCP==1
    int mscnt = 0;
#endif
    /* the mac address of the board. this should be unique per board */
    unsigned char mac_ethernet_address[] = { 0x00, 0x0a, 0x35, 0x00, 0x01, 0x02 };

    netif = &server_netif;

#if LWIP_DHCP==0
    /* initliaze IP addresses to be used */
    IP4_ADDR(&ipaddr,  192, 168,   1, 10);
    IP4_ADDR(&netmask, 255, 255, 255,  0);
    IP4_ADDR(&gw,      192, 168,   1,  1);
#endif

    /* print out IP settings of the board */
    print("\r\n\r\n");
    print("-----lwIP Socket Mode Demo Application ------\r\n");

#if LWIP_DHCP==0
    print_ip_settings(&ipaddr, &netmask, &gw);
    /* print all application headers */
#endif

#if LWIP_DHCP==1
	ipaddr.addr = 0;
	gw.addr = 0;
	netmask.addr = 0;
#endif
    /* Add network interface to the netif_list, and set it as default */
    if (!xemac_add(netif, &ipaddr, &netmask, &gw, mac_ethernet_address, PLATFORM_EMAC_BASEADDR)) {
        xil_printf("Error adding N/W interface\r\n");
        return;
    }
    netif_set_default(netif);

    /* specify that the network if is up */
    netif_set_up(netif);

    /* start packet receive thread - required for lwIP operation */
    sys_thread_new("xemacif_input_thread", (void(*)(void*))xemacif_input_thread, netif,
            THREAD_STACKSIZE,
            DEFAULT_THREAD_PRIO);

#if LWIP_DHCP==1
    dhcp_start(netif);
    while (1) {
#ifdef OS_IS_FREERTOS
		vTaskDelay(DHCP_FINE_TIMER_MSECS / portTICK_RATE_MS);
#else
		sleep(DHCP_FINE_TIMER_MSECS);
#endif
		dhcp_fine_tmr();
		mscnt += DHCP_FINE_TIMER_MSECS;
		if (mscnt >= DHCP_COARSE_TIMER_SECS*1000) {
			dhcp_coarse_tmr();
			mscnt = 0;
		}
	}
#else
    print_headers();
    launch_app_threads();
#ifdef OS_IS_FREERTOS
    vTaskDelete(NULL);
#endif
#endif
    return;
}
Ejemplo n.º 16
0
int main()
{
	struct netif *netif, server_netif;
	struct ip_addr ipaddr, netmask, gw;

	/* the mac address of the board. this should be unique per board */
	unsigned char mac_ethernet_address[] = { 0x00, 0x0a, 0x35, 0x00, 0x01, 0x02 };

	netif = &server_netif;

	if (init_platform() < 0) {
		xil_printf("ERROR initializing platform.\r\n");
		return -1;
	}

	xil_printf("\r\n\r\n");
	xil_printf("-----lwIP RAW Mode Demo Application ------\r\n");
	/* initliaze IP addresses to be used */
#if (LWIP_DHCP==0)
	IP4_ADDR(&ipaddr,  192, 168,   1, 10);
	IP4_ADDR(&netmask, 255, 255, 255,  0);
	IP4_ADDR(&gw,      192, 168,   1,  1);
    print_ip_settings(&ipaddr, &netmask, &gw);
#endif
	lwip_init();

#if (LWIP_DHCP==1)
	ipaddr.addr = 0;
	gw.addr = 0;
	netmask.addr = 0;
#endif

	/* Add network interface to the netif_list, and set it as default */
	if (!xemac_add(netif, &ipaddr, &netmask, &gw, mac_ethernet_address, PLATFORM_EMAC_BASEADDR)) {
		xil_printf("Error adding N/W interface\r\n");
		return -1;
	}
	netif_set_default(netif);

	/* specify that the network if is up */
	netif_set_up(netif);

	/* now enable interrupts */
	platform_enable_interrupts();

#if (LWIP_DHCP==1)
	/* Create a new DHCP client for this interface.
	 * Note: you must call dhcp_fine_tmr() and dhcp_coarse_tmr() at
	 * the predefined regular intervals after starting the client.
	 */
	dhcp_start(netif);
	dhcp_timoutcntr = 24;
	TxPerfConnMonCntr = 0;
	while(((netif->ip_addr.addr) == 0) && (dhcp_timoutcntr > 0)) {
		xemacif_input(netif);
		if (TcpFastTmrFlag) {
			tcp_fasttmr();
			TcpFastTmrFlag = 0;
		}
		if (TcpSlowTmrFlag) {
			tcp_slowtmr();
			TcpSlowTmrFlag = 0;
		}
	}
	if (dhcp_timoutcntr <= 0) {
		if ((netif->ip_addr.addr) == 0) {
			xil_printf("DHCP Timeout\r\n");
			xil_printf("Configuring default IP of 192.168.1.10\r\n");
			IP4_ADDR(&(netif->ip_addr),  192, 168,   1, 10);
			IP4_ADDR(&(netif->netmask), 255, 255, 255,  0);
			IP4_ADDR(&(netif->gw),      192, 168,   1,  1);
		}
	}
	/* receive and process packets */
	print_ip_settings(&(netif->ip_addr), &(netif->netmask), &(netif->gw));
#endif

	/* start the application (web server, rxtest, txtest, etc..) */
	start_applications();
	print_headers();

	while (1) {
		if (TcpFastTmrFlag) {
			tcp_fasttmr();
			TcpFastTmrFlag = 0;
		}
		if (TcpSlowTmrFlag) {
			tcp_slowtmr();
			TcpSlowTmrFlag = 0;
		}
		xemacif_input(netif);
		transfer_data();
	}

    /* never reached */
    cleanup_platform();

	return 0;
}
Ejemplo n.º 17
0
static int accept_msg(const struct sockaddr_nl *who,
		      struct rtnl_ctrl_data *ctrl,
		      struct nlmsghdr *n, void *arg)
{
	FILE *fp = (FILE *)arg;

	if (n->nlmsg_type == RTM_NEWROUTE || n->nlmsg_type == RTM_DELROUTE) {
		struct rtmsg *r = NLMSG_DATA(n);
		int len = n->nlmsg_len - NLMSG_LENGTH(sizeof(*r));

		if (len < 0) {
			fprintf(stderr, "BUG: wrong nlmsg len %d\n", len);
			return -1;
		}

		if (r->rtm_flags & RTM_F_CLONED)
			return 0;

		if (r->rtm_family == RTNL_FAMILY_IPMR ||
		    r->rtm_family == RTNL_FAMILY_IP6MR) {
			print_headers(fp, "[MROUTE]", ctrl);
			print_mroute(who, n, arg);
			return 0;
		} else {
			print_headers(fp, "[ROUTE]", ctrl);
			print_route(who, n, arg);
			return 0;
		}
	}

	if (n->nlmsg_type == RTM_NEWLINK || n->nlmsg_type == RTM_DELLINK) {
		ll_remember_index(who, n, NULL);
		print_headers(fp, "[LINK]", ctrl);
		print_linkinfo(who, n, arg);
		return 0;
	}
	if (n->nlmsg_type == RTM_NEWADDR || n->nlmsg_type == RTM_DELADDR) {
		print_headers(fp, "[ADDR]", ctrl);
		print_addrinfo(who, n, arg);
		return 0;
	}
	if (n->nlmsg_type == RTM_NEWADDRLABEL || n->nlmsg_type == RTM_DELADDRLABEL) {
		print_headers(fp, "[ADDRLABEL]", ctrl);
		print_addrlabel(who, n, arg);
		return 0;
	}
	if (n->nlmsg_type == RTM_NEWNEIGH || n->nlmsg_type == RTM_DELNEIGH ||
	    n->nlmsg_type == RTM_GETNEIGH) {
		if (preferred_family) {
			struct ndmsg *r = NLMSG_DATA(n);

			if (r->ndm_family != preferred_family)
				return 0;
		}

		print_headers(fp, "[NEIGH]", ctrl);
		print_neigh(who, n, arg);
		return 0;
	}
	if (n->nlmsg_type == RTM_NEWPREFIX) {
		print_headers(fp, "[PREFIX]", ctrl);
		print_prefix(who, n, arg);
		return 0;
	}
	if (n->nlmsg_type == RTM_NEWRULE || n->nlmsg_type == RTM_DELRULE) {
		print_headers(fp, "[RULE]", ctrl);
		print_rule(who, n, arg);
		return 0;
	}
	if (n->nlmsg_type == RTM_NEWNETCONF) {
		print_headers(fp, "[NETCONF]", ctrl);
		print_netconf(who, ctrl, n, arg);
		return 0;
	}
	if (n->nlmsg_type == NLMSG_TSTAMP) {
		print_nlmsg_timestamp(fp, n);
		return 0;
	}
	if (n->nlmsg_type == RTM_NEWNSID || n->nlmsg_type == RTM_DELNSID) {
		print_headers(fp, "[NSID]", ctrl);
		print_nsid(who, n, arg);
		return 0;
	}
	if (n->nlmsg_type != NLMSG_ERROR && n->nlmsg_type != NLMSG_NOOP &&
	    n->nlmsg_type != NLMSG_DONE) {
		fprintf(fp, "Unknown message: type=0x%08x(%d) flags=0x%08x(%d)len=0x%08x(%d)\n",
			n->nlmsg_type, n->nlmsg_type,
			n->nlmsg_flags, n->nlmsg_flags, n->nlmsg_len,
			n->nlmsg_len);
	}
	return 0;
}
Ejemplo n.º 18
0
static void format_thread_info(FILE *fp, struct emailinfo *email,
			       int level, int *num_replies,
			       struct emailinfo* subdir_email, FILE *fp_body,
			       int threadnum, bool is_first)
{
    char *subj, *tmpname;
    char *href = NULL;
    char buffer[256];
    char *first_attributes = (is_first) ? " accesskey=\"j\" name=\"first\" id=\"first\"" : "";

#ifdef HAVE_ICONV
    subj = convchars(email->subject, "utf-8");
    tmpname = convchars(email->name, "utf-8");
#else
    subj = convchars(email->subject, email->charset);
    tmpname = convchars(email->name, email->charset);
#endif

    if (set_files_by_thread) {
	int maybe_reply = 0;
	int is_reply = 1;
	fprintf(fp_body, "<a name =\"%.4d\" id=\"%.4d\"></a>", email->msgnum, email->msgnum);
	print_headers(fp_body, email, TRUE);
	if ((set_show_msg_links && set_show_msg_links != 4) || !set_usetable) {
	    fprintf(fp_body, "</ul>\n");
	}
	/* maybe_reply only affects code in finelink.c which we don't want to run twice? */
	printbody(fp_body, email, maybe_reply, is_reply);
	if (level == 0) {
	    sprintf(buffer, "thread_body%d.%s",
		    threadnum, set_htmlsuffix);
	    href = buffer;
	}
	is_reply = print_links(fp_body, email, PAGE_TOP, TRUE);
    }
    if (!href)
	href = msg_href(email, subdir_email, FALSE);

    /* Print the thread info */
    if (set_indextable) {
	fprintf(fp,
		"<tr><td>%s<a href=\"%s\"%s><strong>%s</strong></a></td>"
		"<td nowrap><a name=\"%d\" id=\"%d\">%s</a></td>" "<td nowrap>%s</td></tr>\n",
		level > 1 ? "--&gt; " : "", 
		href, first_attributes,
		subj, email->msgnum, email->msgnum, tmpname, getindexdatestr(email->date));
    }
    else {
        if (num_open_li[level] != 0) {
	  fprintf (fp, "</li>\n");
	  num_open_li[level]--;
	}
	fprintf(fp, "<li><a href=\"%s\"%s>%s</a>&nbsp;"
		"<a name=\"%d\" id=\"%d\"><em>%s</em></a>&nbsp;<em>(%s)</em>\n", 
		href, first_attributes, 
		subj, email->msgnum, email->msgnum, tmpname, getindexdatestr(email->date));
    }
    if (subj)
      free(subj);
    if (tmpname)
      free(tmpname);
    ++num_replies[level];
    if (!set_indextable)
      ++num_open_li[level];
    email->flags |= PRINT_THREAD;	/* its written now */
}
Ejemplo n.º 19
0
int main()
{
	struct netif *netif, server_netif;
	struct ip_addr ipaddr, netmask, gw;

	/* the mac address of the board. this should be unique per board */
	unsigned char mac_ethernet_address[] = { 0x00, 0x0a, 0x35, 0x00, 0x01, 0x02 };

	netif = &server_netif;

        if (init_platform() < 0) {
            xil_printf("ERROR initializing platform.\r\n");
            return -1;
        }

	/* initliaze IP addresses to be used */
#if 1
	IP4_ADDR(&ipaddr,  192, 168,   1, 10);
	IP4_ADDR(&netmask, 255, 255, 255,  0);
	IP4_ADDR(&gw,      192, 168,   1,  1);
#else
	IP4_ADDR(&ipaddr,  172, 16,   0, 10);
	IP4_ADDR(&netmask, 255, 255, 255,  0);
	IP4_ADDR(&gw,      172, 16,   0,  1);
#endif

        xil_printf("\r\n\r\n");
        xil_printf("-----lwIP RAW Mode Demo Application ------\r\n");
        print_ip_settings(&ipaddr, &netmask, &gw);

	lwip_init();

  	/* Add network interface to the netif_list, and set it as default */
	if (!xemac_add(netif, &ipaddr, &netmask, &gw, mac_ethernet_address, PLATFORM_EMAC_BASEADDR)) {
		xil_printf("Error adding N/W interface\r\n");
		return -1;
	}
	netif_set_default(netif);

	/* Create a new DHCP client for this interface.
	 * Note: you must call dhcp_fine_tmr() and dhcp_coarse_tmr() at
	 * the predefined regular intervals after starting the client.
	 */
	/* dhcp_start(netif); */

	/* now enable interrupts */
	platform_enable_interrupts();

	/* specify that the network if is up */
	netif_set_up(netif);

	/* start the application (web server, rxtest, txtest, etc..) */
	start_applications();
	print_headers();

	/* receive and process packets */
	while (1) {
		xemacif_input(netif);
		transfer_data();
	}

        /* never reached */
    cleanup_platform();

	return 0;
}
Ejemplo n.º 20
0
int main(int argc, char **argv){
     int fd_in,fd_out;
     int ret,port=1344;
     char ip[CI_IPLEN];
     ci_connection_t *conn;
     request_t *req;
     ci_headers_list_t *headers;

     CI_DEBUG_LEVEL=1; /*Default debug level is 1*/

     if(!ci_args_apply(argc,argv,options)){
	 ci_args_usage(argv[0],options);
	 exit(-1);
     }

#if ! defined(_WIN32)
     __log_error=(void(*)(void *, const char *,... ))log_errors; /*set c-icap library log  function*/
#else
     __vlog_error=vlog_errors; /*set c-icap library  log function for win32.....*/
#endif


     if(!(conn=ci_client_connect_to(icap_server,port,AF_INET))){
	 ci_debug_printf(1,"Failed to connect to icap server.....\n");
	 exit(-1);
     }

     req=ci_client_request(conn,icap_server,service);

     ci_client_get_server_options(req,CONN_TIMEOUT);
     ci_debug_printf(10,"OK done with options!\n");
     ci_conn_remote_ip(conn,ip);
     ci_debug_printf(1,"ICAP server:%s, ip:%s, port:%d\n\n",icap_server,ip,port);

     if(!input_file){
	  ci_debug_printf(1,"OPTIONS:\n");
	  ci_debug_printf(1,"\tAllow 204: %s\n\tPreview: %d\n\tKeep alive: %s\n",
			  (req->allow204?"Yes":"No"),
			  req->preview,
			  (req->keepalive?"Yes":"No")
	       );
	  print_headers(req);
     }
     else{
	  if((fd_in=open(input_file,O_RDONLY))<0){
	       ci_debug_printf(1,"Error openning file %s\n",input_file);
	       exit(-1);
	  }
	  
	  if(output_file){
	       if((fd_out=open(output_file,O_CREAT|O_RDWR|O_EXCL,S_IRWXU|S_IRGRP))<0){
		    ci_debug_printf(1,"Error opening output file %s\n",output_file);
		    exit(-1);
	       }
	  }
	  else{
	       fd_out=fileno(stdout);
	  }
	  
	  ci_client_request_reuse(req);

	  ci_debug_printf(10,"Preview:%d keepalive:%d,allow204:%d\n",
			  req->preview,req->keepalive,req->allow204);
	  
	  ci_debug_printf(10,"OK allocating request going to send request\n");

	  if(send_headers){
	       headers=ci_headers_make();
	       ci_headers_add(headers,"Filetype: Unknown");
	       ci_headers_add(headers,"User: chtsanti");
	  }
	  else
	       headers=NULL;

	  ret=ci_client_icapfilter(req,
				   CONN_TIMEOUT,
				   headers,
				   &fd_in,(int (*)(void *,char *,int))fileread,
				   &fd_out,(int (*)(void *,char *,int))filewrite
	       );
	  close(fd_in);
	  close(fd_out);

	  if(ret==204){
	       ci_debug_printf(1,"No modification needed (Allow 204 responce)\n");
	       if(output_file)
		    unlink(output_file);
	  }
	  
	  if(verbose)
	       print_headers(req);
	  
	  ci_debug_printf(2, "Done\n");
     }
     close(conn->fd);      
     return 0;
}