/** configure attributes for this GeoImage through dictionary */ void GeoImage::configure(ArgDict & dict) { #define copyarg(name) if (dict.contains(name)) insert(name,dict[name]); copyarg("geoNorth"); copyarg("geoSouth"); copyarg("geoWest"); copyarg("geoEast"); copyarg("type"); copyarg("fle"); copyarg("x_res"); copyarg("y_res"); copyarg("size_x"); copyarg("size_y"); MLParser::setFloat(geoNorth_, this, "geoNorth"); MLParser::setFloat(geoSouth_, this, "geoSouth"); MLParser::setFloat(geoWest_, this, "geoWest"); MLParser::setFloat(geoEast_, this, "geoEast"); if (!contains("type")) insert("type", new QString("not set")); if (!contains("file")) insert("file", new QString("not set")); if (!contains("dir")) insert("dir", new QString("")); if (!contains("x_res")) insert("x_res", new QString("not set")); if (!contains("y_res")) insert("y_res", new QString("not set")); if (!contains("size_x")) insert("size_x", new QString("not set")); if (!contains("size_y")) insert("size_y", new QString("not set")); #undef copyarg }
void mtnexec_initjob(MTNJOB *job, ARG arg) { static int id = 0; memset(job, 0, sizeof(MTNJOB)); job->id = id++; job->uid = getuid(); job->gid = getgid(); job->cid = -1; job->lim = ctx->cpu_lim; job->conv = ctx->conv; job->args = copyarg(ctx->cmdargs); job->argl = copyarg(arg); job->exit = -1; job->cid = -1; }
/* create directory and file ACL's */ static void make_acls(struct windows_acl_info *w) { char *ptr; char buf[8192]; acl_t acl; /* set defaults if none specified */ if (w->flags & WA_RESET) { if (w->owner_entry == NULL) setarg(&w->owner_entry, WA_ENTRY_OWNER); if (w->group_entry == NULL) setarg(&w->group_entry, WA_ENTRY_GROUP); if (w->everyone_entry == NULL) setarg(&w->everyone_entry, WA_ENTRY_EVERYONE); } /* create an acl string */ ptr = &buf[0]; if (w->owner_entry != NULL) copyarg(&ptr, w->owner_entry); if (w->group_entry != NULL) copyarg(&ptr, w->group_entry); if (w->everyone_entry != NULL) copyarg(&ptr, w->everyone_entry); /* turn our acl string into an acl */ if ((acl = acl_from_text(buf)) == NULL) err(EX_OSERR, "acl_from_text() failed"); /* create a directory acl */ if (w->flags & WA_DIRECTORIES) { if ((w->dacl = acl_dup(acl)) == NULL) err(EX_OSERR, "acl_dup() failed"); } /* create a file acl */ if (w->flags & WA_FILES) { if ((w->facl = acl_dup(acl)) == NULL) err(EX_OSERR, "acl_dup() failed"); remove_inherit_flags(&w->facl); } acl_free(acl); }
/* define string .ds .as */ void r_ds(Rune *cmd) { Rune *name, *line, *p; name = copyarg(); line = readline(CopyMode); if(name == nil || line == nil){ free(name); return; } p = line; if(*p == '"') p++; if(cmd[0] == 'd') ds(name, p); else as(name, p); free(name); free(line); }
MTNJOB *copyjob(MTNJOB *dst, MTNJOB *src) { if(dst){ memcpy(dst, src, sizeof(MTNJOB)); dst->std = copyarg(src->std); dst->cmd = newstr(src->cmd); dst->echo = newstr(src->echo); dst->args = copyarg(src->args); dst->argl = copyarg(src->argl); dst->argc = copyarg(src->argc); dst->putarg = copyarg(src->putarg); dst->getarg = copyarg(src->getarg); dst->svr = cpsvr(src->svr); dst->cct = 0; dst->pstat = NULL; } return(dst); }
/* * Process a dot line. The dot has been read. */ void dotline(int dot) { int argc, i; Rune *a, *argv[1+MAXARG]; /* * Read request/macro name */ a = copyarg(); if(a == nil || a[0] == 0){ free(a); getrune(); /* \n */ return; } argv[0] = a; /* * Check for .if, .ie, and others with special parsing. */ for(i=0; i<nraw; i++){ if(runestrcmp(raw[i].name, a) == 0){ raw[i].f(raw[i].name); free(a); return; } } /* * Read rest of line in copy mode, invoke regular request. */ a = readline(ArgMode); if(a == nil){ free(argv[0]); return; } argc = 1+parseargs(a, argv+1); for(i=0; i<nreq; i++){ if(runestrcmp(req[i].name, argv[0]) == 0){ if(req[i].argc != -1){ if(argc < 1+req[i].argc){ warn("not enough arguments for %C%S", dot, req[i].name); free(argv[0]); free(a); return; } if(argc > 1+req[i].argc) warn("too many arguments for %C%S", dot, req[i].name); } req[i].f(argc, argv); free(argv[0]); free(a); return; } } /* * Invoke user-defined macros. */ runmacro(dot, argc, argv); free(argv[0]); free(a); }
int ifeval(void) { int c, cc, neg, nc; Rune line[MaxLine], *p, *e, *q; Rune *a; while((c = getnext()) == ' ' || c == '\t') ; neg = 0; while(c == '!'){ neg = !neg; c = getnext(); } if('0' <= c && c <= '9'){ ungetnext(c); a = copyarg(); c = (eval(a)>0) ^ neg; free(a); return c; } switch(c){ case ' ': case '\n': ungetnext(c); return !neg; case 'o': /* odd page */ case 't': /* troff */ case 'h': /* htmlroff */ while((c = getrune()) != ' ' && c != '\t' && c != '\n' && c >= 0) ; return 1 ^ neg; case 'n': /* nroff */ case 'e': /* even page */ while((c = getnext()) != ' ' && c != '\t' && c != '\n' && c >= 0) ; return 0 ^ neg; } /* string comparison 'string1'string2' */ p = line; e = p+nelem(line); nc = 0; q = nil; while((cc=getnext()) >= 0 && cc != '\n' && p<e){ if(cc == c){ if(++nc == 2) break; q = p; } *p++ = cc; } if(cc != c){ ungetnext(cc); return 0; } if(nc < 2){ return 0; } *p = 0; return (q-line == p-(q+1) && memcmp(line, q+1, (q-line)*sizeof(Rune))==0) ^ neg; }
/* * This registers a new binary format, it recognises the syntax * ':name:type:offset:magic:mask:interpreter:' * where the ':' is the IFS, that can be chosen with the first char */ static int proc_write_register(struct file *file, const char *buffer, unsigned long count, void *data) { const char *sp; char del, *dp; struct binfmt_entry *e; int memsize, cnt = count - 1, err; /* some sanity checks */ err = -EINVAL; if ((count < 11) || (count > 256)) goto _err; err = -ENOMEM; memsize = sizeof(struct binfmt_entry) + count; if (!(e = (struct binfmt_entry *) kmalloc(memsize, GFP_USER))) goto _err; err = 0; sp = buffer + 1; del = buffer[0]; dp = (char *)e + sizeof(struct binfmt_entry); e->proc_name = copyarg(&dp, &sp, &cnt, del, 0, &err); /* we can use bit 3 of type for ext/magic flag due to the nice encoding of E and M */ if ((*sp & ~('E' | 'M')) || (sp[1] != del)) err = -EINVAL; else e->flags = (*sp++ & (ENTRY_MAGIC | ENTRY_ENABLED)); cnt -= 2; sp++; e->offset = 0; while (cnt-- && isdigit(*sp)) e->offset = e->offset * 10 + *sp++ - '0'; if (*sp++ != del) err = -EINVAL; e->magic = copyarg(&dp, &sp, &cnt, del, (e->flags & ENTRY_MAGIC), &err); e->size = dp - e->magic; e->mask = copyarg(&dp, &sp, &cnt, del, 1, &err); if (e->mask && ((dp - e->mask) != e->size)) err = -EINVAL; e->interpreter = copyarg(&dp, &sp, &cnt, del, 0, &err); e->id = free_id++; /* more sanity checks */ if (err || !(!cnt || (!(--cnt) && (*sp == '\n'))) || (e->size < 1) || ((e->size + e->offset) > (BINPRM_BUF_SIZE - 1)) || !(e->proc_name) || !(e->interpreter) || entry_proc_setup(e)) goto free_err; write_lock(&entries_lock); e->next = entries; entries = e; write_unlock(&entries_lock); err = count; _err: return err; free_err: kfree(e); err = -EINVAL; goto _err; }