コード例 #1
0
ファイル: app2.c プロジェクト: prashant-r/Xinu
/*------------------------------------------------------------------------
 *  app2  -  prints PID of current process
 *------------------------------------------------------------------------
 */
process app2()
{

    kprintf("\n The PID for %s is %d",getpname(getpid()), getpid());
    resume(create(app3, 1024, 48, "app3", 0, NULL));
    sleep(5);
    kprintf("\n The PID for %s is %d and it's parent is %d",getpname(getpid()), getpid(), getppid());
    return OK;
}
コード例 #2
0
ファイル: nyx.c プロジェクト: tuanmasterit/audacity
// Restore the symbol values to their original value and remove any added
// symbols.
LOCAL void nyx_restore_obarray()
{
   LVAL obvec = getvalue(obarray);
   int i;

   // Scan all obarray vectors
   for (i = 0; i < HSIZE; i++) {
      LVAL last = NULL;
      LVAL dcon;

      // Scan all elements
      for (dcon = getelement(obvec, i); dcon; dcon = cdr(dcon)) {
         LVAL dsym = car(dcon);
         char *name = (char *)getstring(getpname(dsym));
         LVAL scon;

         // Ignore *OBARRAY* since setting it causes the input array to be
         // truncated.
         if (strcmp(name, "*OBARRAY*") == 0) {
            continue;
         }

         // Ignore *SCRATCH* since it's allowed to be updated
         if (strcmp(name, "*SCRATCH*") == 0) {
            continue;
         }

         // Find the symbol in the original obarray.
         for (scon = getelement(nyx_obarray, hash(name, HSIZE)); scon; scon = cdr(scon)) {
            LVAL ssym = car(scon);

            // If found, then set the current symbols value to the original.
            if (strcmp(name, (char *)getstring(getpname(ssym))) == 0) {
               setvalue(dsym, nyx_dup_value(getvalue(ssym)));
               setplist(dsym, nyx_dup_value(getplist(ssym)));
               setfunction(dsym, nyx_dup_value(getfunction(ssym)));
               break;
            }
         }

         // If we didn't find the symbol in the original obarray, then it must've
         // been added and must be removed from the current obarray.
         if (scon == NULL) {
            if (last) {
               rplacd(last, cdr(dcon));
            }
            else {
               setelement(obvec, i, cdr(dcon));
            }
         }

         // Must track the last dcon for symbol removal
         last = dcon;
      }
   }
}
コード例 #3
0
ファイル: xlsubr.c プロジェクト: jhbadger/xlispstat
/* xlgetfname - get a filename */
LVAL xlgetfname(V)
{
    LVAL name;

    /* get the next argument */
    name = xlgetarg();

    /* get the filename string */
#ifdef FILETABLE
    if (streamp(name) && getfile(name) > CONSOLE)
        /* "Steal" name from file stream */
        name = cvstring(filetab[getfile(name)].tname);
    else
#endif
    if (symbolp(name))
	name = getpname(name);
    else if (!stringp(name))
	xlbadtype(name);

    if (getslength(name) >= FNAMEMAX)
        xlerror("file name too long", name);

    /* return the name */
    return (name);
}
コード例 #4
0
ファイル: linalg.c プロジェクト: jhbadger/xlispstat
LVAL xsbasekernelsmooth(V)
{
  LVAL x, y, xs, ys, targ;
  int n, ns, error, ktype;
  double *dx, *dy, *dxs, *dys, width;

  n = getfixnum(xlgafixnum());
  x = xlgetarg();
  y = xlgetarg();
  ns = getfixnum(xlgafixnum());
  xs = xlgetarg();
  ys = xlgetarg();
  width = makefloat(xlgetarg());
  targ = xlgasymbol();
  xllastarg();

  dx = getlinalgdvec(0, n, x);
  dy = null(y) ? NULL : getlinalgdvec(0, n, y);
  dxs = getlinalgdvec(0, ns, xs);
  dys = getlinalgdvec(0, ns, ys);

  switch (getstring(getpname(targ))[0]) {
  case 'U': ktype = 'U'; break;
  case 'T': ktype = 'T'; break;
  case 'G': ktype = 'G'; break;
  default:  ktype = 'B'; break;
  }

  error = kernel_smooth(dx, dy, n, width, NULL, NULL, dxs, dys, ns, ktype);

  return error ? s_true : NIL;
}
コード例 #5
0
ファイル: xlsym.c プロジェクト: AaronFae/VimProject
/* xlenter - enter a symbol into the obarray */
LVAL xlenter(char *name)
{
    LVAL sym,array;
    int i;

    /* check for nil */
    if (strcmp(name,"NIL") == 0)
        return (NIL);

    /* check for symbol already in table */
    array = getvalue(obarray);
    i = hash(name,HSIZE);
    for (sym = getelement(array,i); sym; sym = cdr(sym))
        if (strcmp(name,(char *) getstring(getpname(car(sym)))) == 0)
            return (car(sym));

    /* make a new symbol node and link it into the list */
    xlsave1(sym);
    sym = consd(getelement(array,i));
    rplaca(sym,xlmakesym(name));
    setelement(array,i,sym);
    xlpop();

    /* return the new symbol */
    return (car(sym));
}
コード例 #6
0
ファイル: xlsym.c プロジェクト: 8l/csolve
/* xlenter - enter a symbol into the obarray */
NODE *xlenter(char *name,int type)
{
    NODE ***oldstk,*sym __HEAPIFY,*array;
    int i;

    /* check for nil */
    if (strcmp(name,"NIL") == 0)
	return (NIL);

    /* check for symbol already in table */
    array = getvalue(obarray);
    i = hash(name,HSIZE);
    for (sym = getelement(array,i); sym; sym = cdr(sym))
	if (strcmp(name,getstring(getpname(car(sym)))) == 0)
	    return (car(sym));

    /* make a new symbol node and link it into the list */
    oldstk = xlsave1(&sym);
    sym = consd(getelement(array,i));
    rplaca(sym,xlmakesym(name,type));
    setelement(array,i,sym);
    xlstack = oldstk;

    /* return the new symbol */
    return (car(sym));
}
コード例 #7
0
ファイル: xlstr.c プロジェクト: AkiraShirase/audacity
/* xstring - return a string consisting of a single character */
LVAL xstring(void)
{
    LVAL arg;

    /* get the argument */
    arg = xlgetarg();
    xllastarg();

    /* make sure its not NIL */
    if (null(arg))
        xlbadtype(arg);

    /* check the argument type */
    switch (ntype(arg)) {
    case STRING:
        return (arg);
    case SYMBOL:
        return (getpname(arg));
    case CHAR:
        buf[0] = (int)getchcode(arg);
        buf[1] = '\0';
        return (cvstring(buf));
    case FIXNUM:
        buf[0] = getfixnum(arg);
        buf[1] = '\0';
        return (cvstring(buf));
    default:
        xlbadtype(arg);
        return NIL; /* never happens */
    }
}
コード例 #8
0
ファイル: inj_main.c プロジェクト: alhazred/onarm
static void
sev_send(void *arg, nvlist_t *msg)
{
	if ((errno = sysevent_evc_publish(arg, EC_FM, ESC_FM_ERROR,
	    "com.sun", getpname(), msg, EVCH_SLEEP)) != 0)
		warn("failed to send event");
}
コード例 #9
0
ファイル: xlbfun.c プロジェクト: AaronFae/VimProject
/* xgensym - generate a symbol */
LVAL xgensym(void)
{
    char sym[STRMAX+11]; /* enough space for prefix and number */
    LVAL x;

    /* get the prefix or number */
    if (moreargs()) {
        x = xlgetarg();
        switch (ntype(x)) {
        case SYMBOL:
                x = getpname(x);
        case STRING:
                strncpy(gsprefix, (char *) getstring(x),STRMAX);
                gsprefix[STRMAX] = '\0';
                break;
        case FIXNUM:
                gsnumber = getfixnum(x);
                break;
        default:
                xlerror("bad argument type",x);
        }
    }
    xllastarg();

    /* create the pname of the new symbol */
    sprintf(sym,"%s%d",gsprefix,gsnumber++);

    /* make a symbol with this print name */
    return (xlmakesym(sym));
}
コード例 #10
0
ファイル: partial_tuple.c プロジェクト: andan342/SciSPARQL
oidtype read_partial_tuple(bindtype env, oidtype tag, oidtype x, oidtype stream) 
{ // Standard reader
	int size = 0, fills = 0, j = 0, k = 0;
	oidtype res, x0;
	struct ptcell *dres;
	
	//Pass 1: compute sizes
	x0 = x;
	while (x0 != nil) {
		if (hd(x) == nil) fills++;
		size++;
		x0 = tl(x0);
	}

	// Allocate PT
	res = alloc_partial_tuple(size - fills, fills);
	dres = dr(res, ptcell);

	//Pass 2: fill PT with values and blanks
	x0 = x;
	while (x0 != nil) {
		if (symbolp(hd(x0)) && strcmp(getpname(hd(x0)), "*") == 0) {			
			dres->fill[j].pos = k;
			dres->fill[j].pendingOps = 0;
			a_setelem(dres->tuple, k, nil, FALSE);
			j++;
		} else a_setelem(dres->tuple, k, hd(x0), FALSE);
		k++;
		x0 = tl(x0);
	}

	return res;
}
コード例 #11
0
ファイル: xlprin.c プロジェクト: ruthmagnus/audacity
/* putclosure - output a closure */
LOCAL void putclosure(LVAL fptr, LVAL val)
{
    LVAL name;
    if (name = getname(val))
        sprintf(buf,"#<Closure-%s: #",getstring(getpname(name)));
    else
        strcpy(buf,"#<Closure: #");
    xlputstr(fptr,buf);
    sprintf(buf,AFMT,val);
    xlputstr(fptr,buf);
    xlputc(fptr,'>');
    /*
        xlputstr(fptr,"\nName:   "); xlprint(fptr,getname(val),TRUE);
        xlputstr(fptr,"\nType:   "); xlprint(fptr,gettype(val),TRUE);
        xlputstr(fptr,"\nLambda: "); xlprint(fptr,getlambda(val),TRUE);
        xlputstr(fptr,"\nArgs:   "); xlprint(fptr,getargs(val),TRUE);
        xlputstr(fptr,"\nOargs:  "); xlprint(fptr,getoargs(val),TRUE);
        xlputstr(fptr,"\nRest:   "); xlprint(fptr,getrest(val),TRUE);
        xlputstr(fptr,"\nKargs:  "); xlprint(fptr,getkargs(val),TRUE);
        xlputstr(fptr,"\nAargs:  "); xlprint(fptr,getaargs(val),TRUE);
        xlputstr(fptr,"\nBody:   "); xlprint(fptr,getbody(val),TRUE);
        xlputstr(fptr,"\nEnv:    "); xlprint(fptr,closure_getenv(val),TRUE);
        xlputstr(fptr,"\nFenv:   "); xlprint(fptr,getfenv(val),TRUE);
    */
}
コード例 #12
0
ファイル: fl_wrapper.c プロジェクト: OpenSDE/opensde-nopast
/* invert the order by recursion. there will be only one recursion tree
 * so we can use a static var for managing the last ent */
static void addptree(int *txtpos, char *cmdtxt, int pid, int basepid)
{
	static char l[512] = "";
	char *p;

	if (!pid || pid == basepid) return;

	addptree(txtpos, cmdtxt, pid2ppid(pid), basepid);

	p = getpname(pid);

	if ( strcmp(l, p) )
		*txtpos += snprintf(cmdtxt+*txtpos, 4096-*txtpos, "%s%s",
				*txtpos ? "." : "", getpname(pid));
	else
		*txtpos += snprintf(cmdtxt+*txtpos, 4096-*txtpos, "*");

	strcpy(l, p);
}
コード例 #13
0
ファイル: test.c プロジェクト: daicun/tencryption
int main(int argc, char const *argv[])
{
    fprintf(stderr, "te system test:\n");
    fprintf(stderr, "......usb state: %d\n", usb_connector_state());
    fprintf(stderr, "...........puid: %d\n", getpuid());
    fprintf(stderr, "...........paid: %d\n", getpaid());
    fprintf(stderr, "...........pdid: %d\n", getpdid());
    fprintf(stderr, "..........panme: %s\n", getpname());
    while (1);
    return 0;
}
コード例 #14
0
ファイル: xlbfun.c プロジェクト: AaronFae/VimProject
/* xsymname - get the print name of a symbol */
LVAL xsymname(void)
{
    LVAL sym;

    /* get the symbol */
    sym = xlgasymbol();
    xllastarg();

    /* return the print name */
    return (getpname(sym));
}
コード例 #15
0
ファイル: inj_main.c プロジェクト: alhazred/onarm
static int
usage(void)
{
	(void) fprintf(stderr, "Usage: %s [-nqv] [-c chan] [file]\n"
	    "\t-c  specify alternate channel to use for publication\n"
	    "\t-n  compile program but do not inject any events\n"
	    "\t-q  enable quiet mode (silence status messages)\n"
	    "\t-v  enable verbose output (display event details)\n",
	    getpname());

	return (E_USAGE);
}
コード例 #16
0
ファイル: nyx.c プロジェクト: tuanmasterit/audacity
// Make a copy of the original obarray, leaving the original in place
LOCAL void nyx_save_obarray()
{
   LVAL newarray;
   int i;

   // This provide permanent protection for nyx_obarray as we do not want it
   // to be garbage-collected.
   xlprot1(nyx_obarray);
   nyx_obarray = getvalue(obarray);

   // Create and set the new vector.  This allows us to use xlenter() to
   // properly add the new symbol.  Probably slower than adding directly,
   // but guarantees proper hashing.
   newarray = newvector(HSIZE);
   setvalue(obarray, newarray);

   // Scan all obarray vectors
   for (i = 0; i < HSIZE; i++) {
      LVAL sym;

      // Scan all elements
      for (sym = getelement(nyx_obarray, i); sym; sym = cdr(sym)) {
         LVAL syma = car(sym);
         char *name = (char *) getstring(getpname(syma));
         LVAL nsym = xlenter(name);

         // Ignore *OBARRAY* since there's no need to copy it
         if (strcmp(name, "*OBARRAY*") == 0) {
            continue;
         }

         // Ignore *SCRATCH* since it's allowed to be updated
         if (strcmp(name, "*SCRATCH*") == 0) {
            continue;
         }

         // Duplicate the symbol's values
         setvalue(nsym, nyx_dup_value(getvalue(syma)));
         setplist(nsym, nyx_dup_value(getplist(syma)));
         setfunction(nsym, nyx_dup_value(getfunction(syma)));
      }
   }

   // Swap the obarrays, so that the original is put back into service
   setvalue(obarray, nyx_obarray);
   nyx_obarray = newarray;
}
コード例 #17
0
ファイル: bungettest.c プロジェクト: flimberger/sysprog
int
main(int argc, char *argv[])
{
	int c;
	size_t i;
	Buffer *buf;

	errno = 0;

	setpname(argv[0]);
	if (argc < 2)
		die(2, "usage: %s file", getpname());

	if ((c = open(argv[1], O_RDONLY)) == -1)
		die(1, "failed to open file %s:", argv[1]);

	if ((buf = makebuf(512)) == NULL)
		die(1, "allocating buffer failed:");

	if (initbuf(buf, c, O_RDONLY) == EOF)
		die(1, "initializing buffer failed:");

	i = 0;
	while ((c = bgetchar(buf)) != EOF) {
		if (i == 511 || i == 512 || i == 513) {
			if (bungetchar(buf) == EOF) {
				die(1, "bungetchar failed at char %lu", i);
				break;
			}

			if ((c = bgetchar(buf)) == EOF)
				break;
		}
		putc(c, stdout);
		i++;
	}

	if (errno != 0)
		die(1, "bgetchar failed at char %lu:", i);

	fprintf(stderr, "reached end of input file %s\n", argv[1]);
	fprintf(stderr, "%lu bytes read\n", i);
	bclose(buf);

	exit(0);
}
コード例 #18
0
ファイル: dump.c プロジェクト: andreiw/polaris
static int
print_usage(FILE *fp, int verbose)
{
	(void) fprintf(fp, "Usage: %s [-dfhlsSt] [-u file] file\n", getpname());

	if (verbose) {
		(void) fprintf(fp,
		    "\t-d  dump data object section\n"
		    "\t-f  dump function section\n"
		    "\t-h  dump file header\n"
		    "\t-l  dump label table\n"
		    "\t-s  dump string table\n"
		    "\t-S  dump statistics\n"
		    "\t-t  dump type section\n"
		    "\t-u  save uncompressed CTF to a file\n");
	}

	return (E_USAGE);
}
コード例 #19
0
ファイル: xlbfun.c プロジェクト: AaronFae/VimProject
/* xhash - compute the hash value of a string or symbol */
LVAL xhash(void)
{
    unsigned char *str;
    LVAL len,val;
    int n;

    /* get the string and the table length */
    val = xlgetarg();
    len = xlgafixnum(); n = (int)getfixnum(len);
    xllastarg();

    /* get the string */
    if (symbolp(val))
        str = getstring(getpname(val));
    else if (stringp(val))
        str = getstring(val);
    else {
        xlerror("bad argument type",val);
        str = NULL;
    }

    /* return the hash index */
    return (cvfixnum((FIXTYPE)hash((char *) str, n)));
}
コード例 #20
0
ファイル: poolbind.c プロジェクト: AlainODea/illumos-gate
int
main(int argc, char *argv[])
{
	char c;
	int i;
	idtype_t idtype = P_PID;
	char *idstr = "pid";
	char *pool_name = NULL;
	uint_t flags = 0;
	int status;

	(void) getpname(argv[0]);
	(void) setlocale(LC_ALL, "");
	(void) textdomain(TEXT_DOMAIN);

	while ((c = getopt(argc, argv, OPTS)) != EOF) {
		switch (c) {
		case 'Q':
			if (flags & (qFLAG | iFLAG | pFLAG))
				usage();
			flags |= QFLAG;
			break;
		case 'e':
			if (flags & (iFLAG | qFLAG | QFLAG))
				usage();
			flags |= eFLAG;
			break;
		case 'i':
			for (i = 0; idtypes[i].str != NULL; i++) {
				if (strcmp(optarg, idtypes[i].str) == 0) {
					idtype = idtypes[i].idtype;
					idstr = idtypes[i].str;
					break;
				}
			}
			if ((flags & (iFLAG | qFLAG | QFLAG)) ||
			    idtypes[i].str == NULL)
				usage();
			flags |= iFLAG;
			break;
		case 'p':
			if (flags & (pFLAG | qFLAG | QFLAG))
				usage();
			flags |= pFLAG;
			pool_name = optarg;
			break;
		case 'q':
			if (flags & (pFLAG | iFLAG | QFLAG))
				usage();
			flags |= qFLAG;
			break;
		case '?':
		default:
			usage();
		}
	}

	argc -= optind;
	argv += optind;

	if (flags & eFLAG && pool_name == NULL)
		usage();
	if (argc < 1 || (flags & (pFLAG | qFLAG | QFLAG)) == 0)
		usage();

	/*
	 * Check to see that the pools facility is enabled
	 */
	if (pool_get_status(&status) != PO_SUCCESS)
		die((ERR_OPEN_DYNAMIC), get_errstr());
	if (status == POOL_DISABLED)
		die((ERR_OPEN_DYNAMIC), strerror(ENOTACTIVE));

	if (flags & eFLAG)
		exec_cmd(pool_name, argv);
		/*NOTREACHED*/
	else
		process_ids(pool_name, flags, idtype, idstr, argc, argv);

	return (error);
}
コード例 #21
0
ファイル: main.c プロジェクト: alhazred/onarm
int
main(int argc, char *argv[])
{
	const char *pname = getpname(argv[0]);

	u_longlong_t minf;
	struct stat st;
	int c;
	int dflag = 0;			/* for checking in use during -d ops */
	int dcmode = DC_CURRENT;	/* kernel settings override unless -u */
	int modified = 0;		/* have we modified the dump config? */
	char *minfstr = NULL;		/* string value of -m argument */
	dumpconf_t dc;			/* current configuration */

	(void) setlocale(LC_ALL, "");
	(void) textdomain(TEXT_DOMAIN);

	/*
	 * Take an initial lap through argv hunting for -r root-dir,
	 * so that we can chroot before opening the configuration file.
	 * We also handle -u and any bad options at this point.
	 */
	while (optind < argc) {
		while ((c = getopt(argc, argv, OPTS)) != (int)EOF) {
			if (c == 'r' && chroot(optarg) == -1)
				die(gettext("failed to chroot to %s"), optarg);
			else if (c == 'u')
				dcmode = DC_OVERRIDE;
			else if (c == '?') {
				(void) fprintf(stderr, gettext(USAGE), pname);
				return (E_USAGE);
			}
		}

		if (optind < argc) {
			warn(gettext("illegal argument -- %s\n"), argv[optind]);
			(void) fprintf(stderr, gettext(USAGE), pname);
			return (E_USAGE);
		}
	}

	if (geteuid() != 0)
		die(gettext("you must be root to use %s\n"), pname);

	/*
	 * If no config file exists yet, we're going to create an empty one,
	 * so set the modified flag to force writing out the file.
	 */
	if (access(PATH_CONFIG, F_OK) == -1)
		modified++;

	/*
	 * Now open and read in the initial values from the config file.
	 * If it doesn't exist, we create an empty file and dc is
	 * initialized with the default values.
	 */
	if (dconf_open(&dc, PATH_DEVICE, PATH_CONFIG, dcmode) == -1)
		return (E_ERROR);

	/*
	 * Take another lap through argv, processing options and
	 * modifying the dumpconf_t as appropriate.
	 */
	for (optind = 1; optind < argc; optind++) {
		while ((c = getopt(argc, argv, OPTS)) != (int)EOF) {
			switch (c) {
			case 'c':
				if (dconf_str2content(&dc, optarg) == -1)
					return (E_USAGE);
				modified++;
				break;
			case 'd':
				if (dconf_str2device(&dc, optarg) == -1)
					return (E_USAGE);
				dflag++;
				modified++;
				break;

			case 'm':
				minfstr = optarg;
				break;

			case 'n':
				dc.dc_enable = DC_OFF;
				modified++;
				break;

			case 's':
				if (stat(optarg, &st) == -1 ||
				    !S_ISDIR(st.st_mode)) {
					warn(gettext("%s is missing or not a "
					    "directory\n"), optarg);
					return (E_USAGE);
				}

				if (dconf_str2savdir(&dc, optarg) == -1)
					return (E_USAGE);
				modified++;
				break;

			case 'y':
				dc.dc_enable = DC_ON;
				modified++;
				break;
			}
		}
	}

	if (minfstr != NULL) {
		if (minfree_compute(dc.dc_savdir, minfstr, &minf) == -1)
			return (E_USAGE);
		if (minfree_write(dc.dc_savdir, minf) == -1)
			return (E_ERROR);
	}

	if (dcmode == DC_OVERRIDE) {
		/*
		 * In override mode, we try to force an update.  If this
		 * fails, we re-load the kernel configuration and write that
		 * out to the file in order to force the file in sync.
		 *
		 * We allow the file to be read-only but print a warning to the
		 * user that indicates it hasn't been updated.
		 */
		if (dconf_update(&dc, 0) == -1)
			(void) dconf_getdev(&dc);
		if (dc.dc_readonly)
			warn(gettext("kernel settings updated, but "
			    "%s is read-only\n"), PATH_CONFIG);
		else if (dconf_write(&dc) == -1)
			return (E_ERROR);

	} else if (modified) {
		/*
		 * If we're modifying the configuration, then try
		 * to update it, and write out the file if successful.
		 */
		if (dc.dc_readonly) {
			warn(gettext("failed to update settings: %s is "
			    "read-only\n"), PATH_CONFIG);
			return (E_ERROR);
		}

		if (dconf_update(&dc, dflag) == -1 ||
		    dconf_write(&dc) == -1)
			return (E_ERROR);
	}

	if (dcmode == DC_CURRENT)
		dconf_print(&dc, stdout);

	if (dconf_close(&dc) == -1)
		warn(gettext("failed to close configuration file"));

	return (E_SUCCESS);
}
コード例 #22
0
ファイル: symtabtest.c プロジェクト: flimberger/sysprog
int
main(int argc, char *argv[])
{
	Symtab *symtab;
	Symbol *sym;

	setpname(argv[0]);
	if (argc > 1)
		fprintf(stderr, "%s: unused arguments\n", getpname());

	if ((symtab = makesymtab(0)) == NULL)
		die(1, "failed to allocate symbol table:");

	if ((sym = storesym(symtab, "foo")) == NULL)
		die(1, "failed to insert lexem \"foo\":");
	sym->symtype = S_IDENT;

	if ((sym = storesym(symtab, "bar")) == NULL)
		die(1, "failed to insert lexem \"bar\":");
	sym->symtype = S_IDENT;

	if ((sym = storesym(symtab, "baz")) == NULL)
		die(1, "failed to insert lexem \"baz\":");
	sym->symtype = S_IDENT;

	if ((sym = findsym(symtab, "foo")) == NULL)
		die(1, "couldn't find lexem \"foo\":");
	if (sym->symtype != S_IDENT)
		die(1, "symtype of \"foo\" is not S_IDENT");
	sym->symtype = S_INTCONST;

	if ((sym = findsym(symtab, "bar")) == NULL)
		die(1, "couldn't find lexem \"bar\":");
	if (sym->symtype != S_IDENT)
		die(1, "%s: symtype of \"bar\" is not S_IDENT");
	sym->symtype = S_INTCONST;

	if ((sym = findsym(symtab, "baz")) == NULL)
		die(1, "couldn't find lexem \"baz\":");
	if (sym->symtype != S_IDENT)
		die(1, "symtype of \"baz\" is not S_IDENT");
	sym->symtype = S_INTCONST;

	if ((sym = findsym(symtab, "foo")) == NULL)
		die(1, "couldn't find lexem \"foo\":");
	if (sym->symtype != S_INTCONST)
		die(1, "symtype of \"foo\" is not S_INTCONST");

	if ((sym = findsym(symtab, "bar")) == NULL)
		die(1, "couldn't find lexem \"bar\":");
	if (sym->symtype != S_INTCONST)
		die(1, "symtype of \"bar\" is not S_INTCONST");

	if ((sym = findsym(symtab, "baz")) == NULL)
		die(1, "couldn't find lexem \"baz\":");
	if (sym->symtype != S_INTCONST)
		die(1, "symtype of \"baz\" is not S_INTCONST");

	freesymtab(symtab);

	return 0;
}
コード例 #23
0
ファイル: xlprin.c プロジェクト: ruthmagnus/audacity
/* xlprint - print an xlisp value */
void xlprint(LVAL fptr, LVAL vptr, int flag)
{
    LVAL nptr,next;
    int n,i;

    /* print nil */
    if (vptr == NIL) {
        putsymbol(fptr,"NIL",flag);
        return;
    }

    /* check value type */
    switch (ntype(vptr)) {
    case SUBR:
        putsubr(fptr,"Subr",vptr);
        break;
    case FSUBR:
        putsubr(fptr,"FSubr",vptr);
        break;
    case CONS:
        xlputc(fptr,'(');
        for (nptr = vptr; nptr != NIL; nptr = next) {
            xlprint(fptr,car(nptr),flag);
            if (next = cdr(nptr))
                if (consp(next))
                    xlputc(fptr,' ');
                else {
                    xlputstr(fptr," . ");
                    xlprint(fptr,next,flag);
                    break;
                }
        }
        xlputc(fptr,')');
        break;
    case SYMBOL:
        putsymbol(fptr,(char *) getstring(getpname(vptr)),flag);
        break;
    case FIXNUM:
        putfixnum(fptr,getfixnum(vptr));
        break;
    case FLONUM:
        putflonum(fptr,getflonum(vptr));
        break;
    case CHAR:
        putchcode(fptr,getchcode(vptr),flag);
        break;
    case STRING:
        if (flag)
            putqstring(fptr,vptr);
        else
            putstring(fptr,vptr);
        break;
    case STREAM:
        putatm(fptr,"File-Stream",vptr);
        break;
    case USTREAM:
        putatm(fptr,"Unnamed-Stream",vptr);
        break;
    case OBJECT:
        putatm(fptr,"Object",vptr);
        break;
    case VECTOR:
        xlputc(fptr,'#');
        xlputc(fptr,'(');
        for (i = 0, n = getsize(vptr); n-- > 0; ) {
            xlprint(fptr,getelement(vptr,i++),flag);
            if (n) xlputc(fptr,' ');
        }
        xlputc(fptr,')');
        break;
    case CLOSURE:
        putclosure(fptr,vptr);
        break;
    case EXTERN:
        if (getdesc(vptr)) {
            (*(getdesc(vptr)->print_meth))(fptr, getinst(vptr));
        }
        break;
    case FREE_NODE:
        putatm(fptr,"Free",vptr);
        break;
    default:
        putatm(fptr,"Foo",vptr);
        break;
    }
}
コード例 #24
0
ファイル: pooladm.c プロジェクト: AlainODea/illumos-gate
int
main(int argc, char *argv[])
{
	char c;
	pool_conf_t *conf = NULL;
	const char *static_conf_loc;

	(void) getpname(argv[0]);
	(void) setlocale(LC_ALL, "");
	(void) textdomain(TEXT_DOMAIN);


	while ((c = getopt(argc, argv, "cdensx")) != EOF) {
		switch (c) {
		case 'c':	/* Create (or modify) system configuration */
			Cflag++;
			break;
		case 'd':	/* Disable the pools facility */
			Dflag++;
			break;
		case 'e':	/* Enable the pools facility */
			Eflag++;
			break;
		case 'n':	/* Don't actually do anything */
			Nflag++;
			break;
		case 's':	/* Update the submitted configuration */
			Sflag++;
			break;
		case 'x':	/* Delete current system configuration */
			Xflag++;
			break;
		case '?':
		default:
			usage();
			/*NOTREACHED*/
		}
	}

	/*
	 * Not all flags can be used at the same time.
	 */
	if ((Cflag || Sflag || Dflag || Eflag) && Xflag)
		usage();

	if ((Dflag || Eflag) && (Cflag || Sflag || Xflag))
		usage();

	if (Dflag && Eflag)
		usage();

	argc -= optind;
	argv += optind;

	if (! (Cflag || Sflag)) {
		if (argc != 0)
			usage();
	} else {
		if (argc == 0)
			static_conf_loc = pool_static_location();
		else if (argc == 1)
			static_conf_loc = argv[0];
		else
			usage();
	}

	if (!Nflag && (Cflag + Dflag + Eflag + Xflag != 0) &&
	    !priv_ineffect(PRIV_SYS_RES_CONFIG))
		die(gettext(ERR_PERMISSIONS));

	if (Dflag) {
		if (pool_set_status(POOL_DISABLED) != PO_SUCCESS)
			die(gettext(ERR_DISABLE));
	} else if (Eflag) {
		if (pool_set_status(POOL_ENABLED) != PO_SUCCESS) {
			if (errno == EEXIST)
				die(gettext(ERR_ENABLE
				    ": System has active processor sets\n"));
			else
				die(gettext(ERR_ENABLE));
		}
	} else {
		if ((conf = pool_conf_alloc()) == NULL)
			die(gettext(ERR_NOMEM));

		if (Cflag + Sflag + Xflag == 0) {
			/*
			 * No flags means print current system configuration
			 */
			config_print(conf);
		} else if (!Nflag && Xflag) {
			/*
			 * Destroy active pools configuration and
			 * remove the state file.
			 */
			config_destroy(conf);
		} else {
			/*
			 * Commit a new configuration.
			 */
			if (Cflag)
				config_commit(conf, static_conf_loc);
			else {
				/*
				 * Dump the dynamic state to the
				 * specified location
				 */
				if (!Nflag && Sflag) {
					if (pool_conf_open(conf,
					    pool_dynamic_location(), PO_RDONLY)
					!= PO_SUCCESS)
						die(gettext(ERR_OPEN_DYNAMIC),
						get_errstr());
					if (pool_conf_export(conf,
					    static_conf_loc, POX_NATIVE) !=
					    PO_SUCCESS)
						die(gettext(ERR_EXPORT_DYNAMIC),
						static_conf_loc, get_errstr());
					(void) pool_conf_close(conf);
				}
			}
		}
		pool_conf_free(conf);
	}
	return (E_PO_SUCCESS);
}