Ejemplo n.º 1
0
 void R_load_XGAPnames(char **filename,int* num_rows,int* num_cols,int* pos, char** rownames, char** colnames){
   rawfilestruct binfile;
   if(parsefile(filename[0],&binfile)){    
     uint newpos = (*pos);
     uint ncols = (*num_cols);
     uint nrows = (*num_rows);      
     uint *collengths,*rowlengths;
     collengths = getlengths(binfile,newpos,*num_cols);
     newpos = newpos+ (*num_cols);
     rowlengths = getlengths(binfile,newpos,*num_rows);
     newpos = newpos+ (*num_rows);
     cmatrix cname;
     cmatrix rname;
     newpos = newpos + getnames(&cname,binfile,newpos,*num_cols,collengths);
     newpos = newpos + getnames(&rname,binfile,newpos,*num_rows,rowlengths);
     //Rprintf("Parsed Flenames\n");
     for(uint r=0;r<nrows;r++){
       //Rprintf("%d->%s\n",r,rname[r]);
       rownames[r] = rname[r];
     }
     for(uint c=0;c<ncols;c++){
       colnames[c] = cname[c];
     }
     //Rprintf("In R mem\n");
     (*pos) = newpos;
     freematrix((void**)rname,nrows);
     freematrix((void**)cname,ncols);
     freememory(binfile);
   }else{
     Rprintf("Error opening file: %s",filename[0]);
   }
 } //R_load_XGAPnames
Ejemplo n.º 2
0
int
main(		/* read in .OBJ file and convert */
	int	argc,
	char	*argv[]
)
{
	int	donames = 0;
	int	i;

	for (i = 1; i < argc && argv[i][0] == '-'; i++)
		switch (argv[i][1]) {
		case 'o':		/* object name */
			defobj = argv[++i];
			break;
		case 'n':		/* just produce name list */
			donames++;
			break;
		case 'm':		/* use custom mapfile */
			ourmapping = getmapping(argv[++i], &qlist);
			break;
		case 'f':		/* flatten surfaces */
			flatten++;
			break;
		default:
			goto userr;
		}
	if ((i > argc) | (i < argc-1))
		goto userr;
	if (i == argc)
		inpfile = "<stdin>";
	else if (freopen(inpfile=argv[i], "r", stdin) == NULL) {
		fprintf(stderr, "%s: cannot open\n", inpfile);
		exit(1);
	}
	if (donames) {				/* scan for ids */
		getnames(stdin);
		printf("filename \"%s\"\n", inpfile);
		printf("filetype \"Wavefront\"\n");
		write_quals(&qlist, qual, stdout);
		printf("qualifier %s begin\n", qlist.qual[Q_FAC]);
		printf("[%d:%d]\n", 1, faceno);
		printf("end\n");
	} else {				/* translate file */
		printf("# ");
		printargs(argc, argv, stdout);
		convert(stdin);
	}
	if (ndegen)
		printf("# %d degenerate faces\n", ndegen);
	if (n0norm)
		printf("# %d invalid (zero) normals\n", n0norm);
	exit(0);
userr:
	fprintf(stderr, "Usage: %s [-o obj][-m mapping][-n][-f] [file.obj]\n",
			argv[0]);
	exit(1);
}
Ejemplo n.º 3
0
int main(void)
{
	int * address;
	int i;
	int names[10][20];

	for (i = 0; i <= 10; i++)
	{
		address = &names[i];
		getnames(address, i);
	}

	for (i = 0; i <= 10; i++)
	{
		printf("%s\n", names[i]);
	}

	return 0;
}
Ejemplo n.º 4
0
Archivo: init.c Proyecto: LinuxCSA/CSA
/*
 *	init_irix() - initialize the IRIX format argument list.
 */
static	int
init_irix(int argc, char **argv)
{
	int	c;
	char	*optstring = "a:D:g:j:p:u:M:n:cdefhJlmorst";

	/*  Process options. */
	while ((c = getopt(argc, argv, optstring)) != EOF) {
		switch (c) {

	 	/*  Process the report selection options. */
		case 'c':		/* command report */
			c_opt++;
			break;
		case 'f':		/* command flow report */
			f_opt++;
			break;
		case 'o':		/* other command report */
			o_opt++;
			break;
		case 's':		/* summary report */
			s_opt++;
			break;

	 	/*  Process the record selection options. */
		case 'a':		/* select by array session ID */
			a_opt++;
			sscanf(optarg, "%llx", &s_ash);
			break;

		case 'g':		/* select by group ID */
			g_opt++;
			if (optarg[0] >= '0' && optarg[0] <= '9') {
				sscanf(optarg, "%d", &s_gid);

			} else {	/* ASCII */
				if ((s_gid = name_to_gid(optarg)) == -1) {
					acct_err(ACCT_ABORT,
					       _("An unknown Group name '%s' was given on the -g parameter."),
						optarg);
				}
			}
			break;

		case 'j':		/* select by job ID */
			j_opt++;
			sscanf(optarg, "%llx", &s_jid);
			break;

		case 'M':			/* select by positioning */
			M_opt++;
			if ((M_optargc = getoptlst(optarg, &M_optargv))
					== -1) {
				acct_err(ACCT_ABORT,
				       _("An error was returned from routine '%s' for the (-%s) option '%s'."),
					"getoptlst()",
					"M", optarg);
			}
			break;

		case 'n':		/* select by command names */
			n_opt++;
			if ((n_optargc = getoptlst(optarg, &n_optargv))
					== -1) {
				acct_err(ACCT_ABORT,
				       _("An error was returned from routine '%s' for the (-%s) option '%s'."),
					"getoptlst()",
					"n", optarg);
			}
			names = getnames(n_optargc, n_optargv);
			free(n_optargv);
			break;

		case 'p':		/* select by project ID */
			p_opt++;
			if (optarg[0] >= '0' && optarg[0] <= '9') {
				sscanf(optarg, "%lld", &s_prid);

			} else {	/* ASCII */
				if ((s_prid = name_to_prid(optarg)) == -1) {
					acct_err(ACCT_ABORT,
					       _("An unknown Project name '%s' was given on the -p parameter."),
						optarg);
				}
			}
			break;

		case 'u':		/* select by user ID */
			u_opt++;
			if (optarg[0] >= '0' && optarg[0] <= '9') {
				sscanf(optarg, "%d", &s_uid); /* numeric */

			} else {	/* ASCII */
				if ((s_uid = name_to_uid(optarg)) == -1) {
					acct_err(ACCT_ABORT,
					       _("An unknown User name '%s' was given on the -u parameter."),
						optarg);
				}
			}
			break;

	 	/*  Process the report modification options. */
		case 'd':		/* daemon report */
			d_opt++;
			break;
		case 'e':		/* extended summary report */
			e_opt++;
			break;
		case 'h':		/* hiwater report */
			h_opt++;
			break;
		case 'J':
			J_opt++;	/* select all special pacct */
			break;
		case 'l':		/* long report (-{B c f} only) */
			l_opt++;
			break;

	 	/*  Process the remaining options. */
		case 'D':		/* debug option */
			D_opt++;
			db_flag = atoi(optarg);
			if ((db_flag < 1) || (db_flag > 4)) {
				acct_err(ACCT_FATAL,
				       _("The (-%s) option's argument, '%s', is invalid."),
					"D", optarg);
				Nerror("Option -D valid values are 1 to 4\n");
				usage();
			}
			Ndebug("Debugging option set to level %d\n", db_flag);
			break;
		case 'm':		/* mark position */
			m_opt++;
			break;
		case 'r':		/* raw mode */
			r_opt++;
			break;
		case 't':		/* terminate job accounting */
			t_opt++;
			break;

		default:
			usage();
		}
	}

	/*  Verify the selected options - must be used with report options. */
	if (!c_opt && !f_opt && !o_opt && !s_opt){
		if (a_opt) {
		    acct_err(ACCT_ABORT,
		      _("The (-%s) option must be used with the (-%s) option."),
			 "a", "{c f o s}");
		}
		if (g_opt) {
                    acct_err(ACCT_ABORT,
                      _("The (-%s) option must be used with the (-%s) option."),
			 "g", "{c f o s}");
                }
		if (j_opt) {
                    acct_err(ACCT_ABORT,
                      _("The (-%s) option must be used with the (-%s) option."),
			 "j", "{c f o s}");
                }
		if (n_opt) {
                    acct_err(ACCT_ABORT,
                      _("The (-%s) option must be used with the (-%s) option."),
			 "n", "{c f o s}");
                }
		if (p_opt) {
                    acct_err(ACCT_ABORT,
                      _("The (-%s) option must be used with the (-%s) option."),
			 "p", "{c f o s}");
                }
		if (u_opt) {
                    acct_err(ACCT_ABORT,
                      _("The (-%s) option must be used with the (-%s) option."),
			 "u", "{c f o s}");
                }
		if (d_opt) {
                    acct_err(ACCT_ABORT,
                      _("The (-%s) option must be used with the (-%s) option."),
			 "d", "{c f o s}");
                }
		if (r_opt) {
                    acct_err(ACCT_ABORT,
                      _("The (-%s) option must be used with the (-%s) option."),
			 "r", "{c f o s}");
                }

	/*  and -m is NOT used with the report options. */
	} else if (m_opt) {
	    acct_err(ACCT_ABORT,
		_("The (-%s) option cannot be selected when issuing a report."),
			"m");
	}

	/*  Insure -m is NOT with t. */
	if (t_opt && m_opt) {
		acct_err(ACCT_ABORT,
		   _("The (-%s) and the (-%s) options are mutually exclusive."),
			"m", "t");
	}

	/*  Insure -o is NOT with c. */
	if (o_opt && c_opt) {
		acct_err(ACCT_ABORT,
		   _("The (-%s) and the (-%s) options are mutually exclusive."),
			"o", "c");
	}

	/*  Insure -e is with {s}. */
	if (e_opt && !(s_opt) ) {
		acct_err(ACCT_ABORT,
		      _("The (-%s) option must be used with the (-%s) option."),
			"e", "s");
	}

	/*  Insure -h is with l and c. */
	if (h_opt && !(c_opt && l_opt)) {
		acct_err(ACCT_ABORT,
		      _("The (-%s) option must be used with the (-%s) option."),
			"h", "c and l");
	}

	/*  Insure -l is with -{ c f} */
	if (l_opt && !(c_opt || f_opt)) {
		acct_err(ACCT_ABORT,
		      _("The (-%s) option must be used with the (-%s) option."),
			"l", "{c f}");
	}

	/*  Insure -M is with -{c}. */
	if (M_opt && !c_opt) {
		acct_err(ACCT_ABORT,
		      _("The (-%s) option must be used with the (-%s) option."),
			"M", "c");
	}

	return(0);
}