Exemplo n.º 1
0
int main(int argc, char **argv)
{
  char mytext[MAXLEN];
  char code0[8];
  int n;
  int s=0;
  char *t;
  char *q;
    
  while (fgets(mytext, MAXLEN, stdin))  {
    n=strlen(mytext);
    while (n>0 && isspace(mytext[n-1])) mytext[--n]='\0';
    t=mytext;
    while (isspace(*t)) t++;

    if (strncmp(t,"-- BEGIN",8) == 0) s=1;
    if (strncmp(t,"-- END",6) == 0) s=0;
 
    if (s>0 && *t && *t != '-') {
      q=strtok(t," \t\n");
      strncpy(code0,q,4);
      code0[4]='\0';
      q=strtok(NULL," \t\n");
      while (q && *q) {
        outlist(code0,q);
        q=strtok(NULL," \t\n");
      }
    }
  }
 
  return 0;
}
Exemplo n.º 2
0
std::vector<std::string> softlist_parser::parse_attributes(const char **attributes, const T &attrlist)
{
	std::vector<std::string> outlist(std::distance(std::begin(attrlist), std::end(attrlist)));

	// iterate over attribute/value pairs
	for( ; attributes[0]; attributes += 2)
	{
		auto iter = std::begin(attrlist);

		// look for a match among the attributes provided
		for (std::size_t index = 0; iter != std::end(attrlist); ++index, ++iter)
		{
			if (strcmp(attributes[0], *iter) == 0)
			{
				// if found, set the corresponding output entry to the value
				outlist[index] = attributes[1];
				break;
			}
		}

		// if not found, report an unknown attribute
		if (iter == std::end(attrlist))
			unknown_attribute(attributes[0]);
	}

	return outlist;
}
Exemplo n.º 3
0
void elimlink(linktyp **lpp)
/* Tar bort, avallokerar och NULL-ställer länken */
{
   outlist(*lpp);
   free(*lpp);
   *lpp = NULL;
}
Exemplo n.º 4
0
int main()
{
    double s[N]={85,76,69,85,91,72,64,87},ave;
    STREC *h;
    h=creat(s);
    outlist(h);
    ave=fun(h);
    printf("ave= %6.3f\n", ave);
    return 0;
}
Exemplo n.º 5
0
void
main(int argc, char *argv[]) {
    p3dc_NODE *n;
    p3dc_LIST	nodelist = {NULL, NULL, P3DC_UNKNOWN, P3DC_LIST_SORTED, NULL };
    int i;

    i = 0;
    printf("View the file list003.log for results.\n");
    p3dc_log_open(argc > 1 ? argv[1] : "list003.log");
    p3dc_log("Node test start.\n");
    while (colors[i] != NULL) {
        n = p3dc_new_node(NULL, colors[i], 0);
        if (n) {
            p3dc_log("Inserting node %s\n", colors[i]);
            p3dc_add_node(&nodelist, n, P3DC_LIST_BYNAME, n->name);
        }
        i++;
    }
    p3dc_rbprint_list(&nodelist);
    outlist(&nodelist);
    i = 0;
    while(tests[i] != NULL) {
        n = p3dc_get_node(&nodelist, P3DC_NODE_BYNAME, tests[i]);
        if (n == NULL) {
            p3dc_log("TEST FAILED. Could not locate %s\n", tests[i]);
            continue;
        }
        p3dc_remove_node(&nodelist, P3DC_NODE_THIS, n);
        p3dc_log("Deleted %s. New list :\n", tests[i]);
        p3dc_rbprint_list(&nodelist);
        outlist(&nodelist);
        // p3dc_free_node(n);
        i++;
    }
    exit(0);
}
Exemplo n.º 6
0
int
main(int argc, char **argv)
{
	char buf[BUFSIZ];

	fp = stdin;
	tf = stdout;
	setbuf(stdout, buf);
	while (argc > 1 && argv[1][0] == '-') {
		switch (argv[1][1]) {
		case 'a':
			aspect = atof(&argv[1][2]);
			break;
		case 'e':
			erase = 0;
			break;
		case 'o':
			outlist(&argv[1][2]);
			break;
		case 'd':
			dbg = atoi(&argv[1][2]);
			if (dbg == 0) dbg = 1;
			break;
		case 'w':	/* no wait at bottom of page */
			nowait = 1;
			break;
		}
		argc--;
		argv++;
	}

	if (argc <= 1)
		conv(stdin);
	else
		while (--argc > 0) {
			if (strcmp(*++argv, "-") == 0)
				fp = stdin;
			else if ((fp = fopen(*argv, "r")) == NULL)
				error(FATAL, "can't open %s", *argv);
			conv(fp);
			fclose(fp);
		}
	done();
	/*NOTREACHED*/
	return 0;
}
Exemplo n.º 7
0
std::vector<std::vector<std::string> > splitStringVector(
                                         const std::vector<std::string> &inlist,
                                         char separator)
{
  std::vector<std::vector<std::string> > outlist(inlist.size());
  for(uint i=0;i<inlist.size();i++) {
    splitString(inlist[i], separator, outlist[i]);
//    int lastpos=0;
//    int pos=0;
//    while(pos!=-1) {
//        pos = inlist[i].find_first_of(separator,lastpos);
//        outlist[i].push_back(inlist[i].substr(lastpos,pos-lastpos));
//        lastpos=pos+1;
//    }
  }
  return outlist;
}
Exemplo n.º 8
0
void
t_page(int n)	/* do whatever new page functions */
{
	int m, i;
	char buf[1024], *bp;

	pgnum[np++] = n;
	pgadr[np] = ftell(fp);
	if (np > npmax)
		npmax = np;
	if (output == 0) {
		output = in_olist(n);
		t_init(1);
		return;
	}
	/* have just printed something, and seen p<n> for next one */
	putpage();
	fflush(stdout);
	if (nowait)
		return;

  next:
	for (bp = buf; (*bp = readch()); )
		if (*bp++ == '\n' || bp >= &buf[sizeof buf - 1])
			break;
	*bp = 0;
	switch (buf[0]) {
	case 0:
		done();
		break;
	case '\n':
		output = in_olist(n);
		t_init(1);
		return;
	case '!':
		callunix(&buf[1]);
		fputs("!\n", stderr);
		break;
	case 'e':
		erase = 1 - erase;
		break;
	case 'w':
		wflag = 1 - wflag;
		break;
	case 'a':
		aspect = atof(&buf[1]);
		break;
	case '-':
	case 'p':
		m = atoi(&buf[1]) + 1;
		if (fp == stdin) {
			fputs("you can't; it's not a file\n", stderr);
			break;
		}
		if (np - m <= 0) {
			fputs("too far back\n", stderr);
			break;
		}
		np -= m;
		fseek(fp, pgadr[np], 0);
		output = 1;
		t_init(1);
		return;
	case '0': case '1': case '2': case '3': case '4':
	case '5': case '6': case '7': case '8': case '9':
		m = atoi(&buf[0]);
		for (i = 0; i < npmax; i++)
			if (m == pgnum[i])
				break;
		if (i >= npmax || fp == stdin) {
			fputs("you can't\n", stderr);
			break;
		}
		np = i + 1;
		fseek(fp, pgadr[np], 0);
		output = 1;
		t_init(1);
		return;
	case 'o':
		outlist(&buf[1]);
		output = 0;
		t_init(1);
		return;
	case '?':
		fputs("!cmd	unix cmd\n", stderr);
		fputs("p	print this page again\n", stderr);
		fputs("-n	go back n pages\n", stderr);
		fputs("n	print page n (previously printed)\n", stderr);
		fputs("o...	set the -o output list to ...\n", stderr);
		fputs("en	n=0 -> don't erase; n=1 -> erase\n", stderr);
		fputs("an	sets aspect ratio to n\n", stderr);
		break;
	default:
		fputs("?\n", stderr);
		break;
	}
	goto next;
}