Beispiel #1
0
static void print_ve()
{
	int i, idx;

	/* If sort order != veid (already sorted by) */
	if (g_sort_field) {
		qsort(veinfo, n_veinfo, sizeof(struct Cveinfo),
			field_names[g_sort_field].sort_fn);
	}
	if (!(!show_hdr || fmt_json))
		print_hdr();
	if (fmt_json)
		printf("[");
	for (i = 0; i < n_veinfo; i++) {
		if (sort_rev)
			idx = n_veinfo - i - 1;
		else
			idx = i;
		if (veinfo[idx].hide)
			continue;
		if (only_stopped_ve && veinfo[idx].status == VE_RUNNING)
			continue;
		if (fmt_json)
			print_one_ve_json(&veinfo[idx]);
		else
			print_one_ve(&veinfo[idx]);
	}
	if (fmt_json)
		printf("\n]\n");
}
Beispiel #2
0
void print_err()
{
    print_hdr();
    puts("<h1>ERROR IN DATA</h1>");
    print_end();
    exit(2);
}
Beispiel #3
0
int test_wnd(char **wnd, void *pkt, uint32_t seq){
    int err;
    pkt = malloc(MAX_PKT_SIZE);
    make_pkt(pkt, ACK, advwin, NULL, 0);
    print_hdr((struct xtcphdr*)pkt);
    err = add_to_wnd(seq, pkt, (const char **)wnd);
    if(err < 0) {
        _DEBUG("%s\n", "ERROR");
        free(wnd);
        return err;
    }
    print_wnd((const char**)wnd);
    return 0;
}
Beispiel #4
0
static void
print_nodes(const char *be_name, boolean_t dsets, boolean_t snaps,
    boolean_t parsable, be_node_list_t *be_nodes)
{
	struct hdr_info hdr;
	enum be_fmt be_fmt  = BE_FMT_DEFAULT;

	if (dsets)
		be_fmt |= BE_FMT_DATASET;
	if (snaps)
		be_fmt |= BE_FMT_SNAPSHOT;

	if (!parsable) {
		init_hdr_cols(be_fmt, &hdr);
		count_widths(be_fmt, &hdr, be_nodes);
		print_hdr(&hdr);
	}

	if (be_fmt == BE_FMT_DEFAULT)
		print_be_nodes(be_name, parsable, &hdr, be_nodes);
	else
		print_fmt_nodes(be_name, be_fmt, parsable, &hdr, be_nodes);
}
Beispiel #5
0
void
or_gdf(void)
{
  if (_is_ncname(elements[0]))
    {
      char *dataset = NULL, *tmp = NULL, *exe, *exedot;
      if ((dataset = strrchr(project, '/')))
	{
	  extern const char *oodroot;
	  tmp = malloc(strlen(oodroot) + strlen(project) + strlen(dataset) + 7);
	  sprintf(tmp, "%s/%s%s.xml", oodroot, project, dataset);
	  exe = malloc(strlen(tmp)+1);
	  strcpy(exe, tmp);
	  exedot = strrchr(exe, '.');
	  strcpy(exedot+1, "sh");
	  if (!access(exe, R_OK|X_OK))
	    {
	      execl("/bin/sh", "sh", exe, elements[0], NULL);
	      do404();
	    }
	  else
	    {
	      if (elements[1] && !strcmp(elements[1], "xml"))
		{
		  print_hdr_xml();
		  execl("/bin/sh", "sh", "/home/oracc/bin/gdf-entry.sh", tmp, elements[0], "xml", NULL);
		}
	      else if (!elements[1] || !strcmp(elements[1], "html"))
		{
		  print_hdr();
		  execl("/bin/sh", "sh", "/home/oracc/bin/gdf-entry.sh", tmp, elements[0], NULL);
		}
	    }
	}
    }
  do404();
}
Beispiel #6
0
int main(int argc, char **argv)
{
	struct lnstat_file *lnstat_files;
	const char *basename;
	int i, c;
	int interval = DEFAULT_INTERVAL;
	int hdr = 2;
	enum {
		MODE_DUMP,
		MODE_JSON,
		MODE_NORMAL,
	} mode = MODE_NORMAL;
	unsigned long count = 1;
	struct table_hdr *header;
	static struct field_params fp;
	int num_req_files = 0;
	char *req_files[LNSTAT_MAX_FILES];

	/* backwards compatibility mode for old tools */
	basename = strrchr(argv[0], '/');
	if (basename)
		basename += 1;	  /* name after slash */
	else
		basename = argv[0]; /* no slash */

	if (!strcmp(basename, "rtstat")) {
		/* rtstat compatibility mode */
		req_files[0] = "rt_cache";
		num_req_files = 1;
	} else if (!strcmp(basename, "ctstat")) {
		/* ctstat compatibility mode */
		req_files[0] = "ip_conntrack";
		num_req_files = 1;
	}

	while ((c = getopt_long(argc, argv,"Vc:djf:h?i:k:s:w:",
				opts, NULL)) != -1) {
		int len = 0;
		char *tmp, *tok;

		switch (c) {
		case 'c':
			count = strtoul(optarg, NULL, 0);
			break;
		case 'd':
			mode = MODE_DUMP;
			break;
		case 'j':
			mode = MODE_JSON;
			break;
		case 'f':
			req_files[num_req_files++] = strdup(optarg);
			break;
		case '?':
		case 'h':
			usage(argv[0], 0);
			break;
		case 'i':
			sscanf(optarg, "%u", &interval);
			break;
		case 'k':
			tmp = strdup(optarg);
			if (!tmp)
				break;
			for (tok = strtok(tmp, ",");
			     tok;
			     tok = strtok(NULL, ",")) {
				if (fp.num >= MAX_FIELDS) {
					fprintf(stderr, 
						"WARN: too many keys"
						" requested: (%d max)\n",
						MAX_FIELDS);
					break;
				}
				fp.params[fp.num++].name = tok;
			}
			break;
		case 's':
			sscanf(optarg, "%u", &hdr);
			break;
		case 'w':
			tmp = strdup(optarg);
			if (!tmp)
				break;
			i = 0;
			for (tok = strtok(tmp, ",");
			     tok;
			     tok = strtok(NULL, ",")) {
				len  = strtoul(tok, NULL, 0);
				if (len > FIELD_WIDTH_MAX)
					len = FIELD_WIDTH_MAX;
				fp.params[i].print.width = len;
				i++;
			}
			if (i == 1) {
				for (i = 0; i < MAX_FIELDS; i++)
					fp.params[i].print.width = len;
			}
			break;
		default:
			usage(argv[0], 1);
			break;
		}
	}

	lnstat_files = lnstat_scan_dir(PROC_NET_STAT, num_req_files,
				       (const char **) req_files);

	switch (mode) {
	case MODE_DUMP:
		lnstat_dump(stderr, lnstat_files);
		break;

	case MODE_NORMAL:
	case MODE_JSON:
		if (!map_field_params(lnstat_files, &fp, interval))
			exit(1);

		header = build_hdr_string(lnstat_files, &fp, 80);
		if (!header)
			exit(1);

		if (interval < 1 )
			interval = 1;

		for (i = 0; i < count; i++) {
			lnstat_update(lnstat_files);
			if (mode == MODE_JSON)
				print_json(stdout, lnstat_files, &fp);
			else {
				if  ((hdr > 1 &&
				      (! (i % 20))) || (hdr == 1 && i == 0))
					print_hdr(stdout, header);
				print_line(stdout, lnstat_files, &fp);
			}
			fflush(stdout);
			if (i < count - 1)
				sleep(interval);
		}
		break;
	}

	return 1;
}
Beispiel #7
0
static void ublimage_print_header(const void *ptr)
{
	struct ubl_header *ubl_hdr = (struct ubl_header *) ptr;

	print_hdr(ubl_hdr);
}
Beispiel #8
0
/** The get-recrod command */
int cmd_get_record (int argc, const char *argv[]) {
    if (OPTIONS.tenant[0] == 0) {
        fprintf (stderr, "%% No tenantid provided\n");
        return 1;
    }
    if (OPTIONS.host[0] == 0) {
        fprintf (stderr, "%% No hostid provided\n");
        return 1;
    }

    var *apires = api_get ("/%s/host/%s", OPTIONS.tenant, OPTIONS.host);
    
    if (OPTIONS.json) {
        var_dump (apires, stdout);
        var_free (apires);
        return 0;
    }
    
    #define Arr(x) var_get_array_forkey(apires,x)
    #define Vint(x) var_get_int_forkey(apires,x)
    #define Vstr(x) var_get_str_forkey(apires,x)
    #define Vfrac(x) var_get_double_forkey(apires,x)
    #define VDint(x,y) var_get_int_forkey(var_get_dict_forkey(apires,x),y)
    #define VDstr(x,y) var_get_str_forkey(var_get_dict_forkey(apires,x),y)
    #define VDfrac(x,y) var_get_double_forkey(var_get_dict_forkey(apires,x),y)
    #define VAfrac(x,y) var_get_double_atindex(var_get_array_forkey(apires,x),y)
    #define Vdone(x) var_delete_key(apires,x)
    /* -------------------------------------------------------------*/
    print_hdr ("HOST");
    print_value ("UUID", "%s", OPTIONS.host);
    print_value ("Hostname", "%s", Vstr("hostname"));
    print_value ("Address", "%s", VDstr("agent","ip"));
    print_value ("Status", "\033[1m%s\033[0m", Vstr("status"));
    
    print_array ("Problems", Arr("problems"));
    
    Vdone("hostname");
    Vdone("agent");
    Vdone("status");
    Vdone("problems");
    
    char uptimestr[128];
    uint64_t uptime = Vint("uptime"); Vdone("uptime");
    uint64_t u_days = uptime / 86400ULL;
    uint64_t u_hours = (uptime - (86400 * u_days)) / 3600ULL;
    uint64_t u_mins = (uptime - (86400 * u_days) - (3600 * u_hours)) / 60ULL;
    uint64_t u_sec = uptime % 60;
    
    if (u_days) {
        sprintf (uptimestr, "%llu day%s, %llu:%02llu:%02llu", u_days,
                 (u_days==1)?"":"s", u_hours, u_mins, u_sec);
    }
    else if (u_hours) {
        sprintf (uptimestr, "%llu:%02llu:%02llu", u_hours, u_mins, u_sec);
    }
    else {
        sprintf (uptimestr, "%llu minute%s, %llu second%s",
                 u_mins, (u_mins==1)?"":"s", u_sec, (u_sec==1)?"":"s");
    }
    
    print_value ("Uptime","%s",uptimestr);
    print_value ("OS/Hardware","%s %s (%s)", VDstr("os","kernel"),
                 VDstr("os","version"), VDstr("os","arch"));
    const char *dist = VDstr("os","distro");
    if (dist) print_value ("Distribution", "%s", dist);
    Vdone("os");
    
    /* -------------------------------------------------------------*/
    print_hdr ("RESOURCES");
    print_value ("Processes","\033[1m%llu\033[0m "
                             "(\033[1m%llu\033[0m running, "
                             "\033[1m%llu\033[0m stuck)",
                             VDint("proc","total"),
                             VDint("proc","run"),
                             VDint("proc","stuck"));
    Vdone("proc");
 
     print_value ("Load Average", "\033[1m%6.2f\033[0m / "
                                  "\033[1m%6.2f\033[0m / "
                                  "\033[1m%6.2f\033[0m",
                 VAfrac ("loadavg",0), VAfrac ("loadavg", 1),
                 VAfrac ("loadavg",2));
    Vdone ("loadavg");

    char cpubuf[128];
    sprintf (cpubuf, "\033[1m%6.2f \033[0m%%", Vfrac("pcpu"));
    
    char meter[32];
    strcpy (meter, "-[                      ]+");
    
    double iowait = VDfrac("io","pwait");
    double pcpu = Vfrac("pcpu"); Vdone("pcpu");
    double level = 4.5;
    
    int pos = 2;
    while (level < 100.0 && pos < 22) {
        if (level < pcpu) meter[pos++] = '#';
        else meter[pos++] = ' ';
        level += 4.5;
    }
    
    
    print_value ("CPU", "%-40s %s", cpubuf, meter);
    if (iowait>0.001) print_value ("CPU iowait", 
                                   "\033[1m%6.2f %%\033[0m", iowait);
    print_value ("Available RAM", "\033[1m%.2f\033[0m MB",
                 ((double)VDint("mem","total"))/1024.0);
    print_value ("Free RAM", "\033[1m%.2f\033[0m MB",
                 ((double)VDint("mem","free"))/1024.0);
    
    print_value ("Network in/out", "\033[1m%i\033[0m Kb/s "
                                   "(\033[1m%i\033[0m pps) / "
                                   "\033[1m%i\033[0m Kb/s "
                                   "(\033[1m%i\033[0m pps)",
                                   VDint("net","in_kbs"),
                                   VDint("net","in_pps"),
                                   VDint("net","out_kbs"),
                                   VDint("net","out_pps"));
    
    print_value ("Disk i/o", "\033[1m%i\033[0m rdops / "
                             "\033[1m%i\033[0m wrops",
                 VDint("io","rdops"), VDint("io","wrops"));
    
    Vdone("mem");
    Vdone("net");
    Vdone("io");
    Vdone("badness");

    print_values (apires, NULL);
    
    /* -------------------------------------------------------------*/
    print_hdr ("PROCESS LIST");
    
    const char *top_hdr[] = {"USER","PID","CPU","MEM","NAME",NULL};
    const char *top_fld[] = {"user","pid","pcpu","pmem","name",NULL};
    columnalign top_align[] = {CA_L, CA_R, CA_R, CA_R, CA_L, CA_NULL};
    vartype top_tp[] =
        {VAR_STR,VAR_INT,VAR_DOUBLE,VAR_DOUBLE,VAR_STR,VAR_NULL};
    int top_wid[] = {15, 7, 9, 9, 0, 0};
    int top_div[] = {0, 0, 0, 0, 0, 0};
    const char *top_suf[] = {"",""," %", " %", "", NULL};
    
    var *v_top = var_get_array_forkey (apires, "top");
    print_table (v_top, top_hdr, top_fld, 
                 top_align, top_tp, top_wid, top_suf, top_div);
    
    Vdone("top");
    /* -------------------------------------------------------------*/
    print_hdr ("STORAGE");
    
    const char *df_hdr[] = {"DEVICE","SIZE","FS","USED","MOUNTPOINT",NULL};
    const char *df_fld[] = {"device","size","fs","pused","mount",NULL};
    columnalign df_aln[] = {CA_L,CA_R,CA_L,CA_R,CA_L,CA_NULL};
    vartype df_tp[] = {VAR_STR,VAR_INT,VAR_STR,VAR_DOUBLE,VAR_STR,VAR_NULL};
    int df_wid[] = {12, 14, 6, 8, 0};
    int df_div[] = {0, (1024), 0, 0, 0, 0};
    const char *df_suf[] = {""," GB", "", " %", "", ""};
    
    var *v_df = var_get_array_forkey (apires, "df");
    
    /*print_generic_table (v_df);*/
    
    print_table (v_df, df_hdr, df_fld,
                 df_aln, df_tp, df_wid, df_suf, df_div);
    
    Vdone("df");
    
    /** Print any remaining table data */
    print_tables (apires);
        
    printf ("---------------------------------------------"
            "-----------------------------------\n");

    var_free (apires);
    print_done();
    return 0;    
}
Beispiel #9
0
int main()
{

    struct tm t1;
    struct tm t2;
//    struct tm *ct1,*ct2;
    char *s=getenv("REQUEST_METHOD");
    char *endptr;
    int i;
    unsigned int contentlength;
    char buff[10000];
    char a,b;
    const char *len1 = getenv("CONTENT_LENGTH");

/*
    printf("Content-Type: text/html\n\n");
    printf( "<HTML><HEAD><TITLE>Environment</TITLE></HEAD>\n");
    printf( "<BODY>\n");
    printf( "Your request is: %s<BR><br>\n",getenv("REQUEST_STRING"));
    printf( "Variables:<BR>\n");
    printf( "<I><B>REQUEST_METHOD</B></I>=%s<br>\n",getenv("REQUEST_METHOD"));
    printf( "<I><B>QUERY_STRING</B></I>=%s<br>\n",getenv("QUERY_STRING"));
    printf( "<I><B>CONTENT_LENGTH</B></I>=%s<br>\n",getenv("CONTENT_LENGTH"));
    printf( "<I><B>CONTENT_TYPE</B></I>=%s<br>\n",getenv("CONTENT_TYPE"));
    printf( "<I><B>GATEWAY_INTERFACE</B></I>=%s<br>\n",getenv("GATEWAY_INTERFACE"));
    printf( "<I><B>REMOTE_ADDR</B></I>=%s<br>\n",getenv("REMOTE_ADDR"));
    printf( "<I><B>REMOTE_HOST</B></I>=%s<br>\n",getenv("REMOTE_HOST"));
    printf( "<I><B>SCRIPT_NAME</B></I>=%s<br>\n",getenv("SCRIPT_NAME"));
    printf( "<I><B>SCRIPT_FILENAME</B></I>=%s<br>\n",getenv("SCRIPT_FILENAME"));
    printf( "<I><B>SERVER_NAME</B></I>=%s<br>\n",getenv("SERVER_NAME"));
    printf( "<I><B>SERVER_PORT</B></I>=%s<br>\n",getenv("SERVER_PORT"));
    printf( "<I><B>SERVER_PROTOCOL</B></I>=%s<br>\n",getenv("SERVER_PROTOCOL"));
    printf( "<I><B>SERVER_SOFTWARE</B></I>=%s<br>\n",getenv("SERVER_SOFTWARE"));
    printf( "<I><B>HTTP_ACCEPT</B></I>=%s<br>\n",getenv("HTTP_ACCEPT"));
    printf( "<I><B>HTTP_USER_AGENT</B></I>=%s<br>\n",getenv("HTTP_USER_AGENT"));
    printf( "</BODY></HTML>\n");
				    			    		    
    exit(2);
*/
    
    if(s!=NULL)
    {
	if(strcmp(s,"GET")==0)
	{
	    strcpy(buff,getenv("QUERY_STRING"));
	}else
	if(strcmp(s,"POST")==0)
	{
	    contentlength=strtol(len1, &endptr, 10);
	    fread(buff, contentlength, 1, stdin); 
	}
	ParseInput(buff);
    }

    if (InputCount!=10) print_err();

    print_hdr();

    t1.tm_mday=atoi(InputValues[0]);
    t1.tm_mon=atoi(InputValues[1])-1;
    t1.tm_year=atoi(InputValues[2])-1900;
    t1.tm_hour=atoi(InputValues[3]);
    t1.tm_min=atoi(InputValues[4]);
    t1.tm_sec=0;
    t2.tm_mday=atoi(InputValues[5]);
    t2.tm_mon=atoi(InputValues[6])-1;
    t2.tm_year=atoi(InputValues[7])-1900;
    t2.tm_hour=atoi(InputValues[8]);
    t2.tm_min=atoi(InputValues[9]);
    t2.tm_sec=59;

    time1=mktime(&t1);
    time2=mktime(&t2);


/*
	ct1 = gmtime(&time1);
	
	printf("ct1 y=%d m=%d d=%d h=%d mm=%d <br>\n",ct1->tm_year,ct1->tm_mon,ct1->tm_mday,ct1->tm_hour,ct1->tm_min);


	ct2 = gmtime(&time2);
	
	printf("ct2 y=%d m=%d d=%d h=%d mm=%d<br>\n",ct2->tm_year,ct2->tm_mon,ct2->tm_mday,ct2->tm_hour,ct2->tm_min);
*/

    printf("<h3>Statistics for %02d:%02d:%02d %02d:%02d - %02d:%02d:%02d %02d:%02d</h2><hr>\n",
    t1.tm_mday,t1.tm_mon+1,t1.tm_year+1900,t1.tm_hour,t1.tm_min,
    t2.tm_mday,t2.tm_mon+1,t2.tm_year+1900,t2.tm_hour,t2.tm_min);

//    printf("<h2>Statistics for %s - %s</h2><hr>\n",asctime(&t1),asctime(&t2));

//    printf("%d<br>",time1);
//    printf("%d",time2);

    read_cfg();

    qsort(entries,count,sizeof(s_entry),traf_comparer);
    puts("<h3>Sorted by traffic</h2>");
    print_results(1);

/* 


    qsort(entries,count,sizeof(s_entry),name_comparer);
    puts("<h3>Sorted by user name</h2>");
    print_results(2);

*/

    qsort(entries,count,sizeof(s_entry),ip_comparer);
    puts("<h3>Sorted by ip address</h2>");
    print_results(1);

    qsort(entries,count,sizeof(s_entry),name_comparer);
    puts("<h3>Statistics by date and time</h2>");
    print_stat_by_date_time();
    print_end();
        
    return 0;
}
Beispiel #10
0
static void
print_fmt_nodes(const char *be_name, enum be_fmt be_fmt, boolean_t parsable,
    be_node_list_t *nodes)
{
	char buf[64];
	char datetime[DT_BUF_LEN];
	struct hdr_info *hdr = NULL;
	be_node_list_t	*cur_be;

	hdr = hdrs + be_fmt;
	init_hdr_cols(be_fmt, hdr);
	count_widths(be_fmt, hdr, nodes);

	if (!parsable)
		print_hdr(hdr);

	for (cur_be = nodes; cur_be != NULL; cur_be = cur_be->be_next_node) {
		char active[3] = "-\0";
		int ai = 0;
		const char *datetime_fmt = "%F %R";
		const char *name = cur_be->be_node_name;
		const char *mntpt = cur_be->be_mntpt;
		uint64_t used = cur_be->be_space_used;
		time_t creation = cur_be->be_node_creation;
		struct tm *tm;

		if (be_name != NULL && strcmp(be_name, name) != 0)
			continue;

		if (!parsable)
			(void) printf("%-s\n", name);
		else
			active[0] = '\0';

		tm = localtime(&creation);
		(void) strftime(datetime, DT_BUF_LEN, datetime_fmt, tm);

		if (cur_be->be_active)
			active[ai++] = 'N';
		if (cur_be->be_active_on_boot)
			active[ai] = 'R';

		nicenum(used, buf, sizeof (buf));
		if (be_fmt & BE_FMT_DATASET)
			if (parsable)
				(void) printf("%s;%s;%s;%s;%llu;%s;%ld\n",
				    cur_be->be_node_name,
				    cur_be->be_root_ds,
				    active,
				    (cur_be->be_mounted ? mntpt: ""),
				    used,
				    cur_be->be_policy_type,
				    creation);
			else
				(void) printf("   %-*s %-*s %-*s %-*s %-*s "
				    "%-*s\n",
				    hdr->cols[0].width-3, cur_be->be_root_ds,
				    hdr->cols[1].width, active,
				    hdr->cols[2].width, (cur_be->be_mounted ?
				    mntpt: "-"),
				    hdr->cols[3].width, buf,
				    hdr->cols[4].width, cur_be->be_policy_type,
				    hdr->cols[5].width, datetime);

		if (be_fmt & BE_FMT_SNAPSHOT)
			print_be_snapshots(cur_be, hdr, parsable);
	}
}
Beispiel #11
0
int main(int argc,char *argv[]) {
  FILE *fpA;
  FILE *fpB;
  FILE *fpC;
  int c;  
  unsigned int alpha=0xff;

  if (argc !=1) sscanf(argv[1],"%x",&alpha);

  fpA=fopen("paltable.c","w");
  fpB=fopen("stdkey.h","w");
  fprintf(stderr,"making spectra.\n");
  make_reg();
  fprintf(stderr,"making color bars.\n");
  make_root();
  make_out_reg(256,17,256);
  fprintf(stderr,"printing palette table.\n");
  print_reg(fpA,"KeyPalReg",256);
  print_reg_hdr(fpB,"KeyPalReg",256);
  fprintf(stderr,"printing rgb tables.\n");
  make_map(256);
  print_map(fpA,"KeyLinear",256,alpha);
  print_hdr(fpB,"KeyLinear",256);

  fpC=fopen("linear-mag.key","w");
  fprintf(fpC,"# linear magnitude\n");
  fprintf(fpC,"%d\n",256);
  for (c=0;c<256;c++) 
    fprintf(fpC,"%.2x%.2x%.2x%.2x\n",alpha,mag[c][0],mag[c][1],mag[c][2]);
  fclose(fpC);

  fpC=fopen("linear-sgn.key","w");
  fprintf(fpC,"# linear signed\n");
  fprintf(fpC,"%d\n",256);
  for (c=0;c<256;c++) 
    fprintf(fpC,"%.2x%.2x%.2x%.2x\n",alpha,sgn[c][0],sgn[c][1],sgn[c][2]);
  fclose(fpC);


  make_map(20);
  print_map(fpA,"KeyTwentyBlk",20,alpha);
  print_hdr(fpB,"KeyTwentyBlk",20); 

  fpC=fopen("twentyblk-mag.key","w");
  fprintf(fpC,"# twentyblk magnitude\n");
  fprintf(fpC,"%d\n",20);
  for (c=0;c<20;c++) 
    fprintf(fpC,"%.2x%.2x%.2x%.2x\n",alpha,mag[c][0],mag[c][1],mag[c][2]);
  fclose(fpC);

  fpC=fopen("twentyblk-sgn.key","w");
  fprintf(fpC,"# twentyblk signed\n");
  fprintf(fpC,"%d\n",20);
  for (c=0;c<20;c++) 
    fprintf(fpC,"%.2x%.2x%.2x%.2x\n",alpha,sgn[c][0],sgn[c][1],sgn[c][2]);
  fclose(fpC);

  make_map(10);
  print_map(fpA,"KeyTenBlk",10,alpha);
  print_hdr(fpB,"KeyTenBlk",10); 

  fpC=fopen("tenblk-mag.key","w");
  fprintf(fpC,"# tenblk magnitude\n");
  fprintf(fpC,"%d\n",10);
  for (c=0;c<10;c++) 
    fprintf(fpC,"%.2x%.2x%.2x%.2x\n",alpha,mag[c][0],mag[c][1],mag[c][2]);
  fclose(fpC);

  fpC=fopen("tenblk-sgn.key","w");
  fprintf(fpC,"# tenblk signed\n");
  fprintf(fpC,"%d\n",10);
  for (c=0;c<10;c++) 
    fprintf(fpC,"%.2x%.2x%.2x%.2x\n",alpha,sgn[c][0],sgn[c][1],sgn[c][2]);
  fclose(fpC);

  make_map(5);
  print_map(fpA,"KeyFiveBlk",5,alpha);
  print_hdr(fpB,"KeyFiveBlk",5);

  fpC=fopen("fiveblk-mag.key","w");
  fprintf(fpC,"# fiveblk magnitude\n");
  fprintf(fpC,"%d\n",256);
  for (c=0;c<5;c++) 
    fprintf(fpC,"%.2x%.2x%.2x%.2x\n",alpha,mag[c][0],mag[c][1],mag[c][2]);
  fclose(fpC);

  fpC=fopen("fiveblk-sgn.key","w");
  fprintf(fpC,"# fiveblk signed\n");
  fprintf(fpC,"%d\n",256);
  for (c=0;c<5;c++) 
    fprintf(fpC,"%.2x%.2x%.2x%.2x\n",alpha,sgn[c][0],sgn[c][1],sgn[c][2]);
  fclose(fpC);

  make_cmap(256);
  print_cmap(fpA,"KeyLinearC",256);
  print_chdr(fpB,"KeyLinearC",256);
  
  make_cmap(20);
  print_cmap(fpA,"KeyTwentyblkC",20);
  print_chdr(fpB,"KeyTwentyBlkC",20);
  
  make_cmap(10);
  print_cmap(fpA,"KeyTenBlkC",10);
  print_chdr(fpB,"KeyTenBlkC",10); 
  make_cmap(5);
  print_cmap(fpA,"KeyFiveBlkC",5);
  print_chdr(fpB,"KeyFiveBlkC",5);

  fclose(fpA);
  fclose(fpB);
  return 0;
}