Beispiel #1
0
static Line *
enumerated_block(Paragraph *top, int clip, MMIOT *f, int list_class)
{
    ParagraphRoot d = { 0, 0 };
    Paragraph *p;
    Line *q = top->text, *text;
    int para = 0, z;

    while (( text = q )) {
	
	p = Pp(&d, text, LISTITEM);
	text = listitem(p, clip, f->flags, 0);

	p->down = compile(p->text, 0, f);
	p->text = 0;

	if ( para && p->down ) p->down->align = PARA;

	if ( (q = skipempty(text)) == 0
			     || islist(q, &clip, f->flags, &z) != list_class )
	    break;

	if ( para = (q != text) ) {
	    Line anchor;

	    anchor.next = text;
	    ___mkd_freeLineRange(&anchor, q);

	    if ( p->down ) p->down->align = PARA;
	}
    }
    top->text = 0;
    top->down = T(d);
    return text;
}
Beispiel #2
0
Datei: map.c Projekt: caomw/grass
SYMBOL *mapop(int op, SYMBOL * map1, SYMBOL * map2)
{
    SYMBOL *func, *arglist, *res = NULL;
    char buf[32];

    sprintf(buf, "map_op_func_%c", op);

    func = getsym(buf);
    if (!func) {
	G_warning(_("No function defined to perform map %c map"), op);
	parseerror = 1;
    }
    else {
	res = (SYMBOL *) listitem(sizeof(SYMBOL));
	symcpy(res, func);
	res->next = NULL;
	func = res;
	arglist = (SYMBOL *) listapp(NULL, (LIST *) map1);
	arglist = (SYMBOL *) listapp((LIST *) arglist, (LIST *) map2);

	res = mapfunc(func, arglist);
    }

    /* free map1/map2 ?    only if they have no name? */

    return res;
}
Beispiel #3
0
Datei: map.c Projekt: caomw/grass
SYMBOL *mapfunc(SYMBOL * func, SYMBOL * arglist)
{
    SYMBOL *sym;
    MAP *res = NULL;
    int argc = -1;

    if (!func || !func->v.p || func->type != st_mfunc) {
	parseerror = 1;
	G_warning(_("Can't call bad map-function"));
    }
    else
	argc = listcnt((LIST *) arglist);

    if (argc == 0 && (!func->proto || !*func->proto))
	res = (*(m_func) func->v.p) ();
    else if (argc == 1 && !strcmp(func->proto, "m"))
	res = (*(m_func_m) func->v.p) (arglist->v.p);
    else if (argc == 2 && !strcmp(func->proto, "mm"))
	res = (*(m_func_mm) func->v.p) (arglist->v.p, arglist->next->v.p);
    else {
	G_warning(_("Bad arguments to mapfunc %s (argc = %d)"), func->name,
		  argc);
	parseerror = 1;
    }

    listdelall((LIST *) func, freesym);
    listdelall((LIST *) arglist, freesym);

    sym = (SYMBOL *) listitem(sizeof(SYMBOL));
    sym->type = st_map;
    sym->v.p = res;

    return sym;
}
Beispiel #4
0
int
main(int argc, char *argv[])
{
	int i,j, items=0;

	/*
	 * Go through the arguments and count how many non-option args.
	 */
	for (i=1; i<argc; i++) {
		if (argv[i][0]!='-') {
			items++;
		}
	}

	/*
	 * Now go through the options for real, processing them.
	 */
	for (i=1; i<argc; i++) {
		if (argv[i][0]=='-') {
			/*
			 * This word is an option.
			 * Process all the option characters in it.
			 */
			for (j=1; argv[i][j]; j++) {
				option(argv[i][j]);
			}
		}
		else {
			/*
			 * This word isn't an option; list it.
			 */
			listitem(argv[i], items>1);
		}
	}

	/*
	 * If no filenames were specified to list, list the current
	 * directory.
	 */
	if (items==0) {
		listitem(".", 0);
	}

	return 0;
}
Beispiel #5
0
static Line *
definition_block(Paragraph *top, int clip, MMIOT *f, int kind)
{
    ParagraphRoot d = { 0, 0 };
    Paragraph *p;
    Line *q = top->text, *text = 0, *labels;
    int z, para;

    while (( labels = q )) {

        if ( (q = isdefinition(labels, &z, &kind)) == 0 )
            break;

        if ( (text = skipempty(q->next)) == 0 )
            break;

        if (( para = (text != q->next) ))
            ___mkd_freeLineRange(q, text);

        q->next = 0;
        if ( kind == 1 /* discount dl */ )
            for ( q = labels; q; q = q->next ) {
                CLIP(q->text, 0, 1);
                UNCHECK(q);
                S(q->text)--;
            }

dd_block:
        p = Pp(&d, text, LISTITEM);

        text = listitem(p, clip, f->flags, (kind==2) ? is_extra_dd : 0);
        p->down = compile(p->text, 0, f);
        p->text = labels;
        labels = 0;

        if ( para && p->down ) p->down->align = PARA;

        if ( (q = skipempty(text)) == 0 )
            break;

        if (( para = (q != text) )) {
            Line anchor;

            anchor.next = text;
            ___mkd_freeLineRange(&anchor,q);
            text = q;

        }

        if ( kind == 2 && is_extra_dd(q) )
            goto dd_block;
    }
    top->text = 0;
    top->down = T(d);
    return text;
}
Beispiel #6
0
Datei: map.c Projekt: caomw/grass
static MAP *map_op_func_plus(MAP * m, MAP * n)
{
    char namebuf[128];

    G_message(_("Performing map %s + %s"), m->name, n->name);
    sprintf(namebuf, "%s.%s", m->name, n->name);
    m = (MAP *) listitem(sizeof(MAP));
    m->name = strdup(namebuf);
    return m;
}
Beispiel #7
0
Datei: map.c Projekt: caomw/grass
static MAP *test2map(MAP * m, MAP * n)
{
    char namebuf[128];

    G_message(_("Performing 2 arg map function on maps %s and %s"), m->name,
	      n->name);
    sprintf(namebuf, "%s.%s", m->name, n->name);
    m = (MAP *) listitem(sizeof(MAP));
    m->name = strdup(namebuf);
    return m;
}
Beispiel #8
0
/***************************************************************************
 * Test function only
 */
static ANY *mkstring(void *a)
{
    ANY *str;

    str = (ANY *) listitem(sizeof(ANY));
    str->type = st_str;
    str->any = (char *)strdup(a);
    str->refcnt = 1;
    fprintf(stdout, "\t%s\n", (char *)a);

    return str;
}
Beispiel #9
0
Datei: map.c Projekt: caomw/grass
/*************************************************************************
 * This function represents a built-in map function.
 * Should probably go to another file
 */
static MAP *testmap(MAP * m)
{
    char namebuf[128];

    /*
     * The map name always exists, as it represents data on disk, but
     * might be a temporary name, when it should not be displayed
     * (should it?).
     */
    G_message(_("Performing 1 arg map function on map %s"), m->name);
    sprintf(namebuf, "t-%s", m->name);
    m = (MAP *) listitem(sizeof(MAP));
    m->name = strdup(namebuf);
    return m;
}
Beispiel #10
0
LIST *listdup(LIST * head, cpyfunc cpy, size_t size)
{
    LIST *newhead = NULL, *last = NULL, *item, *elt;

    for (item = head; item; item = item->next) {
	elt = listitem(size);
	if (cpy)
	    (*cpy) (elt, item);
	if (!newhead)
	    newhead = last = elt;
	else {
	    last->next = elt;
	    last = elt;
	}
    }

    return newhead;
}
Beispiel #11
0
Datei: map.c Projekt: caomw/grass
static void find_maps(void)
{
    char *gisdbase, *location, *mapset;
    char basepath[4096], subdirpath[4096], path[4096];
    DIR *dir, *subdir;
    struct dirent *ent, *subent;

    gisdbase = getenv("GISDBASE");
    if (!gisdbase)
	gisdbase = ".";

    location = getenv("LOCATION_NAME");
    if (!location)
	location = ".";

    mapset = getenv("MAPSET");
    if (!mapset)
	mapset = ".";

    /*
     * Now, if I'm not in grass, I can simulate the existence of a vector
     * map creating a directory vector with one subdirectory for each `map'
     * having a file `head'
     */

    sprintf(basepath, "%s/%s/%s/vector", gisdbase, location, mapset);
    dir = opendir(basepath);
    if (!dir)
	return;

    while ((ent = readdir(dir)) != NULL) {
	struct stat buf;

	if (!strcmp(ent->d_name, ".") || !strcmp(ent->d_name, ".."))
	    continue;

	strcpy(path, basepath);
	strcat(path, "/");
	strcat(path, ent->d_name);

	if (stat(path, &buf))
	    continue;
	if (S_ISDIR(buf.st_mode)) {
	    strcpy(subdirpath, path);
	    subdir = opendir(subdirpath);
	    if (!subdir)
		continue;
	    while ((subent = readdir(subdir)) != NULL) {
		if (!strcmp(subent->d_name, ".") ||
		    !strcmp(subent->d_name, ".."))
		    continue;
		if (!strcmp(subent->d_name, "head")) {
		    MAP *map;
		    SYMBOL *sym;

		    map = (MAP *) listitem(sizeof(MAP));
		    map->name = strdup(ent->d_name);
		    map->refcnt++;
		    sym = putsym(map->name);
		    sym->type = sym->itype = st_map;
		    sym->v.p = map;
		}
	    }
	    closedir(subdir);
	}
    }
    closedir(dir);
}
Beispiel #12
0
void front_panel_gpio_test(int fdttyS1)
{
	int test_over = 0;

	while (!test_over) {
		unsigned char rbuf[256];
		int i;
		listitem();

		if (scanf("%d", &i) == 0) {
			scanf("%*[\n]");
			getchar();
			continue;
		}

		switch (i) {
		case 1:
			rbuf[0] = 0xC0;
			rbuf[1] = 0xFA;
			rbuf[2] = 0x04;
			rbuf[3] = 0xA1;
			rbuf[4] = 0xA2;
			rbuf[5] = 0xA3;
			rbuf[6] = 0xA4;

			rbuf[0] = 0x30;
			rbuf[1] = 0x31;
			rbuf[2] = 0x32;
			rbuf[3] = 0x33;
			rbuf[4] = 0x34;
			rbuf[5] = 0x35;
			rbuf[6] = 0x36;

			write(fdttyS1, rbuf, 7);
			break;
		case 2:
			rbuf[0] = 0xC0;
			rbuf[1] = 0xFC;
			rbuf[2] = 0x04;
			rbuf[3] = 0xA1;
			rbuf[4] = 0xA2;
			rbuf[5] = 0xA3;
			rbuf[6] = 0xA4;

			write(fdttyS1, rbuf, 7);
			break;
		case 3:				//Set Pin Direction
			rbuf[0] = 0xC0;
			rbuf[1] = 0x13;
			rbuf[2] = 0x00;
			write(fdttyS1, rbuf, 3);
			break;
		case 4:
			test_over = 1;
			break;
		case 5:
			break;
		default:
			break;
		}
	}
}