Exemplo n.º 1
0
static int print_socket_options(void) {
    int fd, len;
    SOCK_OPT *ptr;
    OPT_UNION val;
    char line[STRLEN];

    fd=socket(AF_INET, SOCK_STREAM, 0);

    log_raw("Socket option defaults:");
    log_raw("    %-16s%-10s%-10s%-10s%-10s",
        "Option", "Accept", "Local", "Remote", "OS default");
    for(ptr=sock_opts; ptr->opt_str; ptr++) {
        /* display option name */
        sprintf(line, "    %-16s", ptr->opt_str);
        /* display stunnel default values */
        print_option(line, ptr->opt_type, ptr->opt_val[0]);
        print_option(line, ptr->opt_type, ptr->opt_val[1]);
        print_option(line, ptr->opt_type, ptr->opt_val[2]);
        /* display OS default value */
        len = sizeof(val);
        if(getsockopt(fd, ptr->opt_level, ptr->opt_name, (void *)&val, &len)) {
            if(get_last_socket_error()!=ENOPROTOOPT) {
                log_raw("%s", line); /* dump the name and assigned values */
                sockerror("getsockopt");
                return 0; /* FAILED */
            }
            safeconcat(line, "    --    "); /* write-only value */
        } else
            print_option(line, ptr->opt_type, &val);
        log_raw("%s", line);
    }
    return 1; /* OK */
}
Exemplo n.º 2
0
void options::print_help()
{
    cout << endl << "Help menu for MCSL converter" << endl;
    cout << "\tMandatory options:" << endl;
    print_option('f',"The file containing the scheduling problem.");
    cout << "\tOptional options:" << endl;
    print_option('o',"Specify the output directory for VHDL routing tables.");
    print_option('s',"Specify the overallocation constant sigma");
    print_option('h',"Shows the help menu, I guess you know that.");
    cout << endl;

    return exit(0);
}
Exemplo n.º 3
0
void help(void)
{
	printf("usage: gammu-smsd-inject [OPTION]... MSGTYPE RECIPIENT [MESSAGE_PARAMETER]...\n");
	printf("options:\n");
	print_option("h", "help", "shows this help");
	print_option("v", "version", "shows version information");
	print_option("l", "use-log", "use logging configuration from config file");
	print_option("L", "no-use-log", "do not use logging configuration from config file (default)");
	print_option_param("c", "config", "CONFIG_FILE",
			   "defines path to config file");
	printf("\n");
	printf("MSGTYPE and it's parameters are described in man page and Gammu documentation\n");
}
Exemplo n.º 4
0
void help(void)
{
	printf("usage: gammu-smsd-monitor [OPTION]...\n");
	printf("options:\n");
	print_option("h", "help", "shows this help");
	print_option("v", "version", "shows version information");
	print_option("C", "csv", "CSV output");
	print_option_param("c", "config", "CONFIG_FILE",
			   "defines path to config file");
	print_option_param("d", "delay", "DELAY",
			   "delay in seconds between loops");
	print_option_param("l", "loops", "NUMBER",
			   "delay in seconds between loops");
}
Exemplo n.º 5
0
int main(int argc, char *argv[])
{
  region_t r;
  cap_t fs_server;

  if(argc != 2 && argc != 4) {
    printf(_("Usage: %s /x=shell_options [OPTION_NAME on/off]\n"), argv[0]);
    return 1;
  }

  if(get_process_caps("fs_op", &fs_server, NULL) < 0)
    return 1;

  {
    cap_t opts;
    struct cap_args result;

    r = region_make();
    cap_call(fs_server, r,
	     cap_args_make(cat2(r, mk_int(r, METHOD_FSOP_GET_OBJ),
				mk_string(r, argv[1])),
			   caps_empty, fds_empty),
	     &result);
    filesys_obj_free(fs_server);
    if(expect_cap1(result, &opts) < 0) {
      fprintf(stderr, _("%s: couldn't get options object\n"), argv[0]);
      return 1;
    }

    if(argc == 2) {
      print_option(r, opts, "log_summary");
      print_option(r, opts, "log_into_xterm");
      print_option(r, opts, "print_fs_tree");
      print_option(r, opts, "enable_x11");
    }
    else if(argc == 4) {
      int x;
      if(!strcmp(argv[3], "on")) x = 1;
      else if(!strcmp(argv[3], "off")) x = 0;
      else {
	fprintf(stderr, _("value `%s' not recognised\n"), argv[3]);
	return 1;
      }
      set_option(r, opts, argv[2], x);
    }
    else assert(0);
  }
  return 0;
}
Exemplo n.º 6
0
static std::ostream&
operator<<(
		  std::ostream& stream
		, const tfilter_description& fd)
{
	print_option(stream, fd.name, fd.description);
	BOOST_FOREACH(const tfilter_description::tparameter& p, fd.parameters) {
		print_option(
				  stream
				, " * " + p.name + " (" + p.type + ")"
				, p.descripton);
	}

	return stream;
}
Exemplo n.º 7
0
void show_directives(void)
{
	while(mini_next(ini)) {
		if(!ini->key) { print_section(ini); }
		else          { print_option(ini); }
	}
}
Exemplo n.º 8
0
static void
options_cmd (int func_no, cuc_func * f)
{
  int b, i;
  char tmp[30];
  char *name = prof_func[func_no].name;
  PRINTF
    ("-----------------------------------------------------------------------------\n");
  PRINTF ("|%-28s|pre/unrolled|shared|  time  |  gates |old_time|\n",
	  strstrip (tmp, name, 28));
  PRINTF ("|                    BASE    |%4i / %4i | %4i |%8i|%8.f|%8i|\n", 1,
	  1, 0, f->timings.new_time, f->timings.size, f->orig_time);
  for (b = 0; b < f->num_bb; b++)
    {
      /* Print out results */
      for (i = 1; i < f->bb[b].ntim; i++)
	{			/* First one is base option */
	  int time = f->bb[b].tim[i].new_time - f->timings.new_time;
	  double size = f->bb[b].tim[i].size - f->timings.size;
	  PRINTF ("|                   ");
	  print_option (b, i);
	  PRINTF ("      |%4i / %4i | %4i |%+8i|%+8.f|        |\n",
		  f->bb[b].tim[i].preroll, f->bb[b].tim[i].unroll,
		  f->bb[b].tim[i].nshared, time, size);
	}
    }
}
Exemplo n.º 9
0
static void urlinfo_set_params (urlinfo *u, CGIOpt opt, 
				const char *fname,
				const char *series,
				int filter)
{
    strcat(u->url, "?opt=");
    strcat(u->url, print_option(opt));

    if (fname != NULL) {
	if (opt == GRAB_FILE || opt == GRAB_FUNC ||
	    opt == GRAB_FUNC_INFO || opt == FUNC_FULLNAME) {
	    strcat(u->url, "&fname=");
	} else {
	    strcat(u->url, "&dbase=");
	}
	strcat(u->url, fname);
    }

    if (series != NULL) {
	strcat(u->url, "&series=");
	strcat(u->url, series);
    }

    if (filter > 0) {
	char fstr[8];

	sprintf(fstr, "%d", filter);
	strcat(u->url, "&filter=");
	strcat(u->url, fstr);
    }    
}
Exemplo n.º 10
0
static void
dccp_print(const void *ip, const struct xt_entry_match *match, int numeric)
{
	const struct xt_dccp_info *einfo =
		(const struct xt_dccp_info *)match->data;

	printf(" dccp");

	if (einfo->flags & XT_DCCP_SRC_PORTS) {
		print_ports("spt", einfo->spts[0], einfo->spts[1],
			einfo->invflags & XT_DCCP_SRC_PORTS,
			numeric);
	}

	if (einfo->flags & XT_DCCP_DEST_PORTS) {
		print_ports("dpt", einfo->dpts[0], einfo->dpts[1],
			einfo->invflags & XT_DCCP_DEST_PORTS,
			numeric);
	}

	if (einfo->flags & XT_DCCP_TYPE) {
		print_types(einfo->typemask,
			   einfo->invflags & XT_DCCP_TYPE,
			   numeric);
	}

	if (einfo->flags & XT_DCCP_OPTION) {
		print_option(einfo->option,
			     einfo->invflags & XT_DCCP_OPTION, numeric);
	}
}
Exemplo n.º 11
0
void print_options ( void )
{
    // Check output filedescriptor
    int          is_term = isatty ( fileno ( stdout ) );
    unsigned int entries = sizeof ( xrmOptions ) / sizeof ( *xrmOptions );
    for ( unsigned int i = 0; i < entries; ++i ) {
        if ( ( i + 1 ) < entries ) {
            if ( xrmOptions[i].value.str == xrmOptions[i + 1].value.str ) {
                continue;
            }
        }
        print_option ( &xrmOptions[i], is_term );
    }
    for ( unsigned int i = 0; i < num_extra_options; i++ ) {
        print_option ( &extra_options[i], is_term );
    }
}
Exemplo n.º 12
0
void print_options(mc_options_list_t* list) {
    uint32_t ioption;

    for (ioption = 0; ioption < list->noptions; ioption++) {
        print_option(list->options + ioption);
    }

}
Exemplo n.º 13
0
int main(int argc, char **argv){
	struct option opt;
	FILE *IN;
	char *str;
	char cc;
	int len = 0;
	/* (* option setting */
	init_option(&opt);
	get_option(argc-1, argv+1, &opt);
	if(opt.help == 1){
		help();
	}
	if(opt.check == 1){
		print_option(opt);
	}
	if((opt.help == 1)||(opt.check == 1)||(strlen(opt.file) < 1)){
		exit(0);
	}
	/* *) */
	/* (* allocation */
	if((str = malloc(sizeof(char) * opt.total_size)) == NULL){
		fprintf(stderr,"failed: malloc() -- exit.\n");
		exit(1);
	}
	/* *) */
	IN = fopen(opt.file,"r");
	if(opt.fasta == 1){
		cc = getc(IN);
		if(cc == '>'){
			while((cc = getc(IN)) != '\n'){
			}
		}else{
			fprintf(stderr,"not FASTA format.\n");
			*(str+len) = cc;
			len++;
		}
	}
	if(opt.space == 0){
		while((cc = getc(IN)) != EOF){
			if((cc != '\n')&&(cc != ' ')&&(cc != '\t')){
				*(str+len) = cc;
				len++;
			}
		}
	}else if(opt.space == 1){
		while((cc = getc(IN)) != EOF){
				*(str+len) = cc;
				len++;
		}
	}
	fclose(IN);
	if(opt.header == 0){
		print_frg(opt.segment_size, opt.gap_size, opt.offset, str);
	}else if(opt.header == 1){
		print_frg_h(opt.segment_size, opt.gap_size, opt.offset, str, opt.head, opt.count_start, opt.format);
	}
	return(0);
}
Exemplo n.º 14
0
Arquivo: asmcho.c Projeto: occho/cpuex
static void print_usage(char*name) {
	warning("\n");
	warning("USAGE\t: %s $file [$options]\n", name);
	warning("OPTIONS\t:\n");
	print_option("-o $dst_file\t: place output in file $dst_file");
	print_option("-l [$lst_file]\t: place list output in file $lst_file");
	print_option("-b $line_num\t: output binary string");
	print_option("-x $line_num\t: output hexadecimal string");
	print_option("-c $line_num\t: output coe format string");
	print_option("-p\t: pad nop for pocore");
	print_option("-h\t: print this usage information");
	print_option("-m\t: output code after expanding mnemonic");
	print_option("-q\t: don't print configure information");
	warning("\n");
}
Exemplo n.º 15
0
static void show_opts(const AVOption *opts, int per_stream)
{
    const AVOption *o;

    printf("@table @option\n");
    for (o = opts; o->name; o++) {
        if (o->type != AV_OPT_TYPE_CONST)
            print_option(opts, o, per_stream);
    }
    printf("@end table\n");
}
Exemplo n.º 16
0
void show_section(void)
{
	int in_section = (section_name[0] == '\0');
	while(mini_next(ini)) {
		if(!ini->key) {
			const char *section = ini->section ? ini->section : "";
			in_section = (strcmp(section, section_name) == 0);
		} else if(in_section) {
			print_option(ini);
		}
	}
}
Exemplo n.º 17
0
int print_options_list(OptionsListPtr options_list)
{
    if(options_list == NULL)
        return 1;

    OptionPtr opt_ptr;

    for(opt_ptr = options_list -> lh_first; opt_ptr != NULL; opt_ptr = opt_ptr -> entries.le_next)
        print_option(opt_ptr);

    return 0;
}
Exemplo n.º 18
0
/** @brief  Display usage message and options list
 */
void optparse_help(void)
{
    option_decl_t *opt = options;

    printf("Usage: %s [options] [arguments]\n\n", prg_name);
    printf("Options:\n");
    printf("  --help        display help\n");
    printf("  --version     display version information\n");
    for (opt = options; opt->name_short != 0 && opt->name_long != NULL; opt++) {
        print_option(opt);
    }
}
Exemplo n.º 19
0
void bootmenu_hook(int activity)
{
	static int next = 1, on = 1;
	static const struct option *option = options;
	static int seconds = 0;
	int tmp;

	if (activity)
		seconds = 0;
	tmp = setup->next_key(setup->user);
	if (tmp && !next) {
		print_option(option, 0);
		option++;
		if (option == options+num_options)
			option = options;
		print_option(option, 1);
		seconds = 0;
	}
	next = tmp;
	tmp = setup->enter_key(setup->user);
	if (tmp && !on) {
		do_option(option);
		option = options;
		seconds = 0;
	}
	on = tmp;
	if (setup->seconds(setup->user)) {
		int timeout;

		timeout = get_var_positive_int("boot_menu_timeout",
		    BOOT_MENU_TIMEOUT);
		if (timeout < MIN_BOOT_MENU_TIMEOUT)
			timeout = MIN_BOOT_MENU_TIMEOUT;
		if (++seconds > timeout) {
			setup->idle_action(setup->idle_action);
			seconds = 0;
		}
	}
}
Exemplo n.º 20
0
int tui_check_notice(const char *board_name)
{
	screen_move_clear(-1);
	prints("\033[m\xb2\xe9\xbf\xb4:");

	int replies, mentions;
	notice_count(&replies, &mentions);

	print_option("\xc8\xa1\xcf\xfb", NULL, 0, 0);
	print_option("\xbb\xd8\xb8\xb4", "\xc6\xaa", replies, 1);
	print_option("\xcc\xe1\xbc\xb0", "\xc6\xaa", mentions, 2);

	int choice = 0;
	if (replies)
		choice = 1;
	else if (mentions)
		choice = 2;
	prints(" [%d]: ", choice);

	char ans[2];
	int x, y;
	screen_coordinates(&x, &y);
	getdata(x, y, "", ans, sizeof(ans), true, true);

	if (*ans == '\0')
		*ans = '0' + choice;
	if (*ans == '1') {
		post_list_reply();
		brc_init(currentuser.userid, board_name);
		return FULLUPDATE;
	}
	if (*ans == '2') {
		post_list_mention();
		brc_init(currentuser.userid, board_name);
		return FULLUPDATE;
	}
	return MINIUPDATE;
}
Exemplo n.º 21
0
static size_t
dhcp_envoption1(char **env, const char *prefix,
    const struct dhcp_opt *opt, int vname, const uint8_t *od, int ol,
    const char *ifname)
{
	ssize_t len;
	size_t e;
	char *v, *val;

	if (opt->len && opt->len < ol)
		ol = opt->len;
	len = print_option(NULL, 0, opt->type, ol, od, ifname);
	if (len < 0)
		return 0;
	if (vname)
		e = strlen(opt->var) + 1;
	else
		e = 0;
	if (prefix)
		e += strlen(prefix);
	e += len + 4;
	if (env == NULL)
		return e;
	v = val = *env = malloc(e);
	if (v == NULL) {
		syslog(LOG_ERR, "%s: %m", __func__);
		return 0;
	}
	if (vname)
		v += snprintf(val, e, "%s_%s=", prefix, opt->var);
	else
		v += snprintf(val, e, "%s=", prefix);
	if (len != 0)
		print_option(v, len, opt->type, ol, od, ifname);
	return e;
}
Exemplo n.º 22
0
void
handle_suboption(unsigned char *suboptp, int subsize)
{
    unsigned char subopt = *suboptp;

    print_option(subopt);

    switch (subopt) {
    case NVT_COM_PORT_OPTION:
	handle_com_port_command(++suboptp);
	subsize--;
	break;
    default:
	sysmessage(MSG_WARNING, "suboption not supported: %d\n", subopt);
	break;
    }
}
Exemplo n.º 23
0
int main(int argc, char *argv[])
{
    SPU *spu;
    SPUOptions *opt;
    int pythonMode = 0;
    int i = 1;

    while (i < argc) {
        if (crStrcmp(argv[i], "--pythonmode") == 0) {
            pythonMode = 1;
        }
        else {
            const char *spuName = argv[i];
            int i;

            /* loop to walk up the inheritance tree */
            for (i = 0; ; i++) {
                spu = SPULoadLite( NULL, 1, spuName, NULL, NULL );

                if (i == 0) {
                    print_spu_header( spu, pythonMode );
                }

                for ( opt = &spu->options[0] ; opt->option ; opt++ )
                    print_option( opt, pythonMode );

                if (spu && spu->super_name) {
                    /* traverse up to parent SPU class to get its options */
                    spuName = spu->super_name;
                }
                else {
                    break;
                }
            }

            print_spu_footer( spu, pythonMode );

            /* How to unload the spu???
             */
        }
        i++;
    }

    return 0;
}
Exemplo n.º 24
0
static void show_bootmenu(void)
{
	const struct option *option;

	bm_printf(ANSI_CLEAR ANSI_GOTOYX "\n\n%s", TOP_ROW, 1, version_string);
	if (setup->comment)
		bm_printf(ANSI_GOTOYX "\n*** BOOT MENU (%s) ***",
		    TOP_ROW+3, 1, setup->comment);
	else
		bm_printf(ANSI_GOTOYX "\n*** BOOT MENU ***", TOP_ROW+3, 1);
	bm_printf(ANSI_GOTOYX, MENU_0_ROW, 1);

	for (option = options; option != options+num_options; option++)
		print_option(option, option == options);

	bm_printf("\n\n%s to select, %s to execute.\n",
	    setup->next_key_action, setup->enter_key_name);
}
Exemplo n.º 25
0
static void
tcp_print(const void *ip, const struct xt_entry_match *match, int numeric)
{
	const struct xt_tcp *tcp = (struct xt_tcp *)match->data;

	printf("tcp ");
	print_ports("spt", tcp->spts[0], tcp->spts[1],
		    tcp->invflags & XT_TCP_INV_SRCPT,
		    numeric);
	print_ports("dpt", tcp->dpts[0], tcp->dpts[1],
		    tcp->invflags & XT_TCP_INV_DSTPT,
		    numeric);
	print_option(tcp->option,
		     tcp->invflags & XT_TCP_INV_OPTION,
		     numeric);
	print_flags(tcp->flg_mask, tcp->flg_cmp,
		    tcp->invflags & XT_TCP_INV_FLAGS,
		    numeric);
	if (tcp->invflags & ~XT_TCP_INV_MASK)
		printf("Unknown invflags: 0x%X ",
		       tcp->invflags & ~XT_TCP_INV_MASK);
}
Exemplo n.º 26
0
int main(int argc, char *argv[])
{
	int argi;
	char buf[4096];
	struct clopt *opt;

	optparse_print(&g_options, buf, sizeof(buf));
	printf("usage: %s [options] [args]\n%s\n", argv[0], buf);

	optparse_reset(&g_options, argc, argv);
	while ( !(argi = optparse_next(&g_options, &opt)) ) {
		print_option(opt);
	}
	if ( argi < 0 ) {
		err("Error -- %s\n", g_options.errbuf);
		return -1;
	}

	for ( ; argi < argc ; ++argi )
		printf("Argument: '%s'\n", argv[argi]);

	return 0;
}
Exemplo n.º 27
0
/** check config file */
static void
checkconf(const char* cfgfile, const char* opt)
{
	struct config_file* cfg = config_create();
	if(!cfg)
		fatal_exit("out of memory");
	if(!config_read(cfg, cfgfile, NULL)) {
		/* config_read prints messages to stderr */
		config_delete(cfg);
		exit(1);
	}
	morechecks(cfg, cfgfile);
	check_mod(cfg, iter_get_funcblock());
	check_mod(cfg, val_get_funcblock());
#ifdef WITH_PYTHONMODULE
	if(strstr(cfg->module_conf, "python"))
		check_mod(cfg, pythonmod_get_funcblock());
#endif
	check_fwd(cfg);
	check_hints(cfg);
	if(opt) print_option(cfg, opt);
	else	printf("unbound-checkconf: no errors in %s\n", cfgfile);
	config_delete(cfg);
}
Exemplo n.º 28
0
ssize_t
print_option(char *s, ssize_t len, int type, int dl, const uint8_t *data,
    const char *ifname)
{
	const uint8_t *e, *t;
	uint16_t u16;
	int16_t s16;
	uint32_t u32;
	int32_t s32;
	struct in_addr addr;
	ssize_t bytes = 0;
	ssize_t l;
	char *tmp;

	if (type & RFC3397) {
		l = decode_rfc3397(NULL, 0, dl, data);
		if (l < 1)
			return l;
		tmp = malloc(l);
		if (tmp == NULL)
			return -1;
		decode_rfc3397(tmp, l, dl, data);
		l = print_string(s, len, l - 1, (uint8_t *)tmp);
		free(tmp);
		return l;
	}

#ifdef INET
	if (type & RFC3361) {
		if ((tmp = decode_rfc3361(dl, data)) == NULL)
			return -1;
		l = strlen(tmp);
		l = print_string(s, len, l - 1, (uint8_t *)tmp);
		free(tmp);
		return l;
	}

	if (type & RFC3442)
		return decode_rfc3442(s, len, dl, data);

	if (type & RFC5969)
		return decode_rfc5969(s, len, dl, data);
#endif

	if (type & STRING) {
		/* Some DHCP servers return NULL strings */
		if (*data == '\0')
			return 0;
		return print_string(s, len, dl, data);
	}

	if (type & FLAG) {
		if (s) {
			*s++ = '1';
			*s = '\0';
		}
		return 2;
	}

	/* DHCPv6 status code */
	if (type & SCODE && dl >= (int)sizeof(u16)) {
		if (s) {
			memcpy(&u16, data, sizeof(u16));
			u16 = ntohs(u16);
			l = snprintf(s, len, "%d ", u16);
			len -= l;
		} else
			l = 7;
		data += sizeof(u16);
		dl -= sizeof(u16);
		if (dl)
			l += print_option(s, len, STRING, dl, data, ifname);
		return l;
	}

	if (!s) {
		if (type & UINT8)
			l = 3;
		else if (type & UINT16) {
			l = 5;
			dl /= 2;
		} else if (type & SINT16) {
			l = 6;
			dl /= 2;
		} else if (type & UINT32) {
			l = 10;
			dl /= 4;
		} else if (type & SINT32) {
			l = 11;
			dl /= 4;
		} else if (type & ADDRIPV4) {
			l = 16;
			dl /= 4;
		}
#ifdef INET6
		else if (type & ADDRIPV6) {
			e = data + dl;
			l = 0;
			while (data < e) {
				if (l)
					l++; /* space */
				dl = ipv6_printaddr(NULL, 0, data, ifname);
				if (dl != -1)
					l += dl;
				data += 16;
			}
			return l + 1;
		}
#endif
		else if (type & BINHEX) {
			l = 2;
		} else {
			errno = EINVAL;
			return -1;
		}
		return (l + 1) * dl;
	}

	t = data;
	e = data + dl;
	while (data < e) {
		if (data != t && type != BINHEX) {
			*s++ = ' ';
			bytes++;
			len--;
		}
		if (type & UINT8) {
			l = snprintf(s, len, "%d", *data);
			data++;
		} else if (type & UINT16) {
			memcpy(&u16, data, sizeof(u16));
			u16 = ntohs(u16);
			l = snprintf(s, len, "%d", u16);
			data += sizeof(u16);
		} else if (type & SINT16) {
			memcpy(&s16, data, sizeof(s16));
			s16 = ntohs(s16);
			l = snprintf(s, len, "%d", s16);
			data += sizeof(s16);
		} else if (type & UINT32) {
			memcpy(&u32, data, sizeof(u32));
			u32 = ntohl(u32);
			l = snprintf(s, len, "%d", u32);
			data += sizeof(u32);
		} else if (type & SINT32) {
			memcpy(&s32, data, sizeof(s32));
			s32 = ntohl(s32);
			l = snprintf(s, len, "%d", s32);
			data += sizeof(s32);
		} else if (type & ADDRIPV4) {
			memcpy(&addr.s_addr, data, sizeof(addr.s_addr));
			l = snprintf(s, len, "%s", inet_ntoa(addr));
			data += sizeof(addr.s_addr);
		}
#ifdef INET6
		else if (type & ADDRIPV6) {
			dl = ipv6_printaddr(s, len, data, ifname);
			if (dl != -1)
				l = dl;
			else
				l = 0;
			data += 16;
		}
#endif
		else if (type & BINHEX) {
			l = snprintf(s, len, "%.2x", data[0]);
			data++;
		} else
			l = 0;
		len -= l;
		bytes += l;
		s += l;
	}

	return bytes;
}
Exemplo n.º 29
0
int
tel_getdata(void)
{
    int i;
    int ret;

    struct buffer *bp = Nvt.inbuff;

    unsigned char c;

    if ((ret = sock_read(Comibuf, Nvt.iosize)) <= 0)
	return -1;
    if (Debug > 2) {
	sysmessage(MSG_DEBUG,
		   "Sock_read, %d bytes: %02X %02X %02X %02X %02X %02X %02X %02X\n",
		   ret, Comibuf[0], Comibuf[1], Comibuf[2], Comibuf[3],
		   Comibuf[4], Comibuf[5], Comibuf[6], Comibuf[7]);
    }

    if (Nvt.servertype == SRV_SOCKET) {
	COPY_TO_BUFFER(bp, Comibuf, ret);
	SET_EVENT(EV_RN, EV_RNDATA, 0, 0);
	return (0);
    }

    for (i = 0; i < ret; i++) {
	c = Comibuf[i];
	switch (S_state) {
	case S_DATA:
	    if (c == IAC) {
		S_state = S_IAC;
		print_control(c);
	    }
	    else {
		PUT_BUFFER(bp, c);
/* Event EV_RNDATA will be set at end */
	    }
	    break;
	case S_IAC:
	    switch (c) {
	    case DO:
		S_state = S_DO;
		print_control(c);
		break;
	    case DONT:
		S_state = S_DONT;
		print_control(c);
		break;
	    case WILL:
		S_state = S_WILL;
		print_control(c);
		break;
	    case WONT:
		S_state = S_WONT;
		print_control(c);
		break;
	    case SB:
		S_state = S_SB;
		print_control(c);
		Suboptsize = 0;
		break;
	    case IAC:
	    default:
		S_state = S_DATA;
		PUT_BUFFER(bp, c);
		break;
	    }
	    break;
	case S_DO:
	    print_option(c);
	    S_state = S_DATA;
	    do_option(c);
	    break;
	case S_DONT:
	    print_option(c);
	    S_state = S_DATA;
	    dont_option(c);
	    break;
	case S_WILL:
	    print_option(c);
	    S_state = S_DATA;
	    will_option(c);
	    break;
	case S_WONT:
	    print_option(c);
	    S_state = S_DATA;
	    wont_option(c);
	    break;
	case S_SB:
	    if (c == IAC) {
		S_state = S_SE;
		print_control(c);
	    }
	    else {
		if (Suboptsize > SUBOPT_MAXSIZE) {
		    sysmessage(MSG_WARNING, "Suboption too large\n");
		}
		else {
		    Suboptbuf[Suboptsize++] = c;
		}
	    }
	    break;
	case S_SE:
	    if (c == SE) {
		S_state = S_DATA;
		print_control(c);
		handle_suboption(Suboptbuf, Suboptsize);
		Suboptsize = 0;
	    }
	    else {
		S_state = S_DATA;
		sysmessage(MSG_WARNING, "Suboption not terminated: %d", c);
	    }
	    break;
	}
    }
    if (bp->b_hold) {
	SET_EVENT(EV_RN, EV_RNDATA, 0, 0);
    }

    print_all();
    return (0);
}
Exemplo n.º 30
0
void
print_help(const char *basename) {
	/* usage */
	printf("Usage: %s [OPTION]... [FILE]\n\n", basename);

	/* description */
	printf("Process the Markdown in FILE (or standard input) and render it to standard output, using the Hoedown library. "
	       "Parsing and rendering can be customized through the options below. The default is to parse pure markdown and output HTML.\n\n");

	/* main options */
	printf("Main options:\n");
	print_option('n', "max-nesting=N", "Maximum level of block nesting parsed. Default is " str(DEF_MAX_NESTING) ".");
	print_option('t', "toc-level=N", "Maximum level for headers included in the TOC. Zero disables TOC (the default).");
	print_option(  0, "html", "Render (X)HTML. The default.");
	print_option(  0, "html-toc", "Render the Table of Contents in (X)HTML.");
	print_option(  0, "null", "Use a special \"null\" renderer that has no callbacks.");
	print_option('T', "time", "Show time spent in rendering.");
	print_option('i', "input-unit=N", "Reading block size. Default is " str(DEF_IUNIT) ".");
	print_option('o', "output-unit=N", "Writing block size. Default is " str(DEF_OUNIT) ".");
	print_option('h', "help", "Print this help text.");
	print_option('v', "version", "Print Hoedown version.");
	printf("\n");

	/* extensions */
	size_t i;
	size_t e;
	for (i = 0; i < count_of(categories_info); i++) {
		struct extension_category_info *category = categories_info+i;
		printf("%s (--%s%s):\n", category->label, category_prefix, category->option_name);
		for (e = 0; e < count_of(extensions_info); e++) {
			struct extension_info *extension = extensions_info+e;
			if (extension->flag & category->flags) {
				print_option(  0, extension->option_name, extension->description);
			}
		}
		printf("\n");
	}

	/* html-specific */
	printf("HTML-specific options:\n");
	for (i = 0; i < count_of(html_flags_info); i++) {
		struct html_flag_info *html_flag = html_flags_info+i;
		print_option(  0, html_flag->option_name, html_flag->description);
	}
	printf("\n");

	/* ending */
	printf("Flags and extensions can be negated by prepending 'no' to them, as in '--no-tables', '--no-span' or '--no-escape'. "
	       "Options are processed in order, so in case of contradictory options the last specified stands.\n\n");

	printf("When FILE is '-', read standard input. If no FILE was given, read standard input. Use '--' to signal end of option parsing. "
	       "Exit status is 0 if no errors occured, 1 with option parsing errors, 4 with memory allocation errors or 5 with I/O errors.\n\n");
}