static void initDefaultOptions() { GD->options.compileOut = store_string("a.out"); GD->options.localSize = systemDefaults.local K; GD->options.globalSize = systemDefaults.global K; GD->options.trailSize = systemDefaults.trail K; GD->options.goal = store_string(systemDefaults.goal); GD->options.topLevel = store_string(systemDefaults.toplevel); GD->options.initFile = store_string(systemDefaults.startup); GD->options.scriptFiles = NULL; GD->options.saveclass = store_string("none"); if ( !GD->bootsession && GD->resourceDB ) { IOSTREAM *op = SopenRC(GD->resourceDB, "$options", "$prolog", RC_RDONLY); if ( op ) { char name[MAXVARNAME]; char val[MAXVARVAL]; while( getVarFromStream(op, name, val) ) set_pl_option(name, val); Sclose(op); } } }
static void initPaths() { char plp[MAXPATHLEN]; char *symbols = NULL; /* The executable */ if ( !(symbols = findExecutable(GD->cmdline.argv[0], plp)) || !(symbols = DeRefLink(symbols, plp)) ) symbols = GD->cmdline.argv[0]; #ifdef OS2 symbols = GD->cmdline.argv[0]; #endif DEBUG(2, Sdprintf("rc-module: %s\n", symbols)); systemDefaults.home = findHome(symbols); #ifdef __WIN32__ /* we want no module but the .EXE */ symbols = findExecutable(NULL, plp); DEBUG(2, Sdprintf("Executable: %s\n", symbols)); #endif GD->paths.executable = store_string(symbols); systemDefaults.startup = store_string(PrologPath(DEFSTARTUP, plp)); GD->options.systemInitFile = defaultSystemInitFile(GD->cmdline.argv[0]); #ifdef O_XOS if ( systemDefaults.home ) { char buf[MAXPATHLEN]; _xos_limited_os_filename(systemDefaults.home, buf); systemDefaults.home = store_string(buf); } #endif }
static void initDefaultOptions(void) { GD->options.compileOut = store_string("a.out"); GD->options.stackLimit = systemDefaults.stack_limit; GD->options.tableSpace = systemDefaults.table_space; GD->options.topLevel = store_string(systemDefaults.toplevel); GD->options.initFile = store_string(systemDefaults.startup); GD->options.scriptFiles = NULL; GD->options.saveclass = store_string("none"); if ( systemDefaults.goal ) opt_append(&GD->options.goals, systemDefaults.goal); if ( !GD->bootsession && GD->resources.DB ) { IOSTREAM *op = SopenZIP(GD->resources.DB, "$prolog/options.txt", RC_RDONLY); if ( op ) { tmp_buffer name; tmp_buffer val; while( getVarFromStream(op, &name, &val) ) { set_pl_option(baseBuffer(&name, char), baseBuffer(&val, char)); discardBuffer(&name); discardBuffer(&val); } Sclose(op); } }
static void make_key(const std::string& id, const std::string& owner, Dbt& key) { key.set_data(NULL); key.set_size(0); uint32_t l = 4 + id.length() + 4 + owner.length(); void* d = (void*)::malloc(l); if(!d) return; key.set_data(d); key.set_size(l); d = store_string(id,d); d = store_string(owner,d); }
static void make_link(const std::string& lock_id,const std::string& id, const std::string& owner, Dbt& rec) { rec.set_data(NULL); rec.set_size(0); uint32_t l = 4 + lock_id.length() + 4 + id.length() + 4 + owner.length(); void* d = (void*)::malloc(l); if(!d) return; rec.set_data(d); rec.set_size(l); d = store_string(lock_id,d); d = store_string(id,d); d = store_string(owner,d); }
STORAGE_SET *socialStore(SOCIAL_DATA *data) { STORAGE_SET *set = new_storage_set(); store_string(set, "cmds", data->cmds); store_string(set, "to_char_notgt", data->to_char_notgt); store_string(set, "to_room_notgt", data->to_room_notgt); store_string(set, "to_char_self", data->to_char_self); store_string(set, "to_room_self", data->to_room_self); store_string(set, "to_char_tgt", data->to_char_tgt); store_string(set, "to_vict_tgt", data->to_vict_tgt); store_string(set, "to_room_tgt", data->to_room_tgt); store_string(set, "min_pos", posGetName(data->min_pos)); store_string(set, "max_pos", posGetName(data->max_pos)); return set; }
int save_note(note *d) { if (d->flags&NOT_READY) return 0; stack=store_int(stack,d->id); stack=store_int(stack,d->flags); stack=store_int(stack,d->date); stack=store_int(stack,d->read_count); stack=store_int(stack,d->next_sent); stack=store_string(stack,d->header); stack=store_int(stack,d->text.length); memcpy(stack,d->text.where,d->text.length); stack+=d->text.length; stack=store_string(stack,d->name); return 1; }
// // store a string in the set PyObject *PyStorageSet_storeString(PyObject *self, PyObject *args) { char *key = NULL; char *val = NULL; PYSTORE_PARSE(args, key, val, "ss"); store_string(((PyStorageSet *)self)->set, key, val); return Py_BuildValue("i", 1); }
static char * defaultSystemInitFile(char *a0) { char plp[MAXPATHLEN]; char *base = BaseName(PrologPath(a0, plp)); char buf[256]; char *s = buf; while(*base && isAlpha(*base)) *s++ = *base++; *s = EOS; if ( strlen(buf) > 0 ) return store_string(buf); return store_string("pl"); }
static char * defaultSystemInitFile(const char *a0) { char plp[MAXPATHLEN]; char *base = BaseName(PrologPath(a0, plp, sizeof(plp))); char buf[256]; char *s = buf; while( *base && (isAlpha(*base) || *base == '-') ) *s++ = *base++; *s = EOS; if ( buf[0] != EOS ) return store_string(buf); return store_string("swipl"); }
CSlice ClientJson::receive(double timeout) { auto response = client_.receive(timeout); if (!response.object) { return {}; } return store_string(from_response(std::move(response))); }
VATTR *vattr_define( char *name, int number, int flags ) { VATTR *vp; /* * Be ruthless. */ if( strlen( name ) >= VNAME_SIZE ) { name[VNAME_SIZE - 1] = '\0'; } fixcase( name ); if( !ok_attr_name( name ) ) { return ( NULL ); } if( ( vp = vattr_find( name ) ) != NULL ) { return ( vp ); } vp = ( VATTR * ) XMALLOC( sizeof( VATTR ), "vattr_define" ); vp->name = store_string( name ); vp->flags = flags; vp->number = number; hashadd( vp->name, ( int * ) vp, &mudstate.vattr_name_htab, 0 ); anum_extend( vp->number ); anum_set( vp->number, ( ATTR * ) vp ); return ( vp ); }
static void make_string(const std::string& str, Dbt& rec) { rec.set_data(NULL); rec.set_size(0); uint32_t l = 4 + str.length(); void* d = (void*)::malloc(l); if(!d) return; rec.set_data(d); rec.set_size(l); d = store_string(str,d); }
local mod_pointer mod_name_lookup (char* name, int l) /* finds complete module name */ { mod_pointer p; /* current node of the search tree */ mod_pointer* loc=&root; /* |p| will come from this location */ while ((p=*loc)!=NULL) { int l0=p->key_length; char* key=name_begin(p); switch (mod_name_cmp(name,l,key,l0)) { case less: loc=&p->llink; break; case greater: loc=&p->rlink; break; case equal: case extension: { enum mod_comparison cmp= mod_name_cmp(name+l0,l-l0,key+l0,(int)strlen(key+l0)); switch(cmp) { case less: case greater: err_print("! Incompatible module name"); print("\nName inconsistently extends <%.*s...>.\n",l0,key); return NULL; case extension: case equal: if (complete_name(p)) if (cmp==equal) return p; else { err_print("! Incompatible module name"); print("\nPrefix exists: <%s>.\n",key); return NULL; } name_begin(p)=store_string(name,l); /* install |name| in place of |key| */ free(key-1); return p; } } case prefix: err_print("! Incompatible module name"); print("\nName is a prefix of <%s%s>.\n" ,key, complete_name(p) ? "" : "..."); return NULL; /* dummy module name */ } } { (p=make_mod_node(store_string(name,l)))->key_length=l; /* prepare new node */ return *loc=p; /* install new node into tree */ } }
CSlice ClientJson::execute(Slice request) { auto r_request = to_request(request); if (r_request.is_error()) { LOG(ERROR) << "Failed to parse " << tag("request", format::escaped(request)) << " " << r_request.error(); return {}; } return store_string(from_response(Client::execute(r_request.move_as_ok()))); }
STORAGE_SET *aliasAuxDataStore(ALIAS_AUX_DATA *data) { // if we have no hashtable, return an empty set if(data->aliases == NULL || hashSize(data->aliases) == 0) return new_storage_set(); STORAGE_SET *set = new_storage_set(); STORAGE_SET_LIST *list = new_storage_list(); HASH_ITERATOR *hash_i = newHashIterator(data->aliases); const char *name = NULL; const char *cmd = NULL; store_list(set, "aliases", list); ITERATE_HASH(name, cmd, hash_i) { STORAGE_SET *alias_set = new_storage_set(); store_string(alias_set, "key", name); store_string(alias_set, "val", hashIteratorCurrentVal(hash_i)); storage_list_put(list, alias_set); }
STORAGE_SET *containerDataStore(CONTAINER_DATA *data) { STORAGE_SET *set = new_storage_set(); store_double(set, "capacity", data->capacity); store_string(set, "key", data->key); store_int (set, "pick_diff",data->pick_diff); store_int (set, "closable", data->closable); store_int (set, "closed", data->closed); store_int (set, "locked", data->locked); return set; }
static void make_record(const std::string& uid, const std::string& id, const std::string& owner, const std::list<std::string>& meta, Dbt& key, Dbt& data) { key.set_data(NULL); key.set_size(0); data.set_data(NULL); data.set_size(0); uint32_t l = 4 + uid.length(); for(std::list<std::string>::const_iterator m = meta.begin(); m != meta.end(); ++m) { l += 4 + m->length(); }; make_key(id,owner,key); void* d = (void*)::malloc(l); if(!d) { ::free(key.get_data()); key.set_data(NULL); key.set_size(0); return; }; data.set_data(d); data.set_size(l); d = store_string(uid,d); for(std::list<std::string>::const_iterator m = meta.begin(); m != meta.end(); ++m) { d = store_string(*m,d); }; }
void unload_gs(void){ //block specific store_string("Operation", "Wave", gs->wave); store_double("Operation", "DC", gs->wave_dc); store_double("Operation", "Amplitude", gs->wave_amp); store_double("Operation", "Frequency", gs->wave_freq); store_double("Operation", "DutyCycle", gs->wave_duty); store_int("Task","Priority",gs->task_prio); }
void unload_gs(void){ /* * Change this code. */ store_string("Operation", "aString", gs->aString); store_int("Operation", "anInt", gs->anInt); store_double("Operation", "aDouble", gs->aDouble); store_matrix("Operation","aMatrix",&gs->aMatrix); store_int("Task","Priority",gs->task_prio); }
STORAGE_SET *resetStore (RESET_DATA *reset) { STORAGE_SET *set = new_storage_set(); store_int (set, "type", reset->type); store_int (set, "times", reset->times); store_int (set, "chance", reset->chance); store_int (set, "max", reset->max); store_int (set, "room_max", reset->room_max); store_string(set, "arg", bufferString(reset->arg)); store_list (set, "in", gen_store_list(reset->in, resetStore)); store_list (set, "on", gen_store_list(reset->on, resetStore)); store_list (set, "then", gen_store_list(reset->then, resetStore)); return set; }
int opt_append(opt_list **l, const char *s) { opt_list *n = allocHeapOrHalt(sizeof(*n)); n->opt_val = store_string(s); n->next = NULL; while(*l) l = &(*l)->next; *l = n; return TRUE; }
order_status_input_t& order_status_input_t::operator= (const order_status_input_t& rhs) { _wh_id = rhs._wh_id; _d_id = rhs._d_id; _c_select = rhs._c_select; _c_id = rhs._c_id; _o_id = rhs._o_id; _o_ol_cnt = rhs._o_ol_cnt; if (rhs._c_last) { store_string(_c_last, rhs._c_last); } return (*this); }
payment_input_t& payment_input_t::operator= (const payment_input_t& rhs) { // copy input _home_wh_id = rhs._home_wh_id; _home_d_id = rhs._home_d_id; _v_cust_wh_selection = rhs._v_cust_wh_selection; _remote_wh_id = rhs._remote_wh_id; _remote_d_id = rhs._remote_d_id; _v_cust_ident_selection = rhs._v_cust_ident_selection; _c_id = rhs._c_id; _h_amount = rhs._h_amount; if (rhs._c_last) { store_string(_c_last, rhs._c_last); } return (*this); }
void end_post(player *p,char *str) { note *article; char *oldstack; oldstack=stack; article=(note *)p->edit_info->misc; stack=store_string(oldstack,p->edit_info->buffer); article->text.length=(int)stack-(int)oldstack; article->text.where=(char *)MALLOC(article->text.length); memcpy(article->text.where,oldstack,article->text.length); stack=oldstack; article->next_sent=news_start; news_start=article->id; news_count++; article->flags &= ~NOT_READY; article->read_count=0; tell_player(p,"Article posted....\n"); if (p->edit_info->input_copy==news_command) do_prompt(p,"News Mode >"); }
static int HandleOP(SetLoggingSocket) { int32_t portnum; krb5_socket_t sock; int ret; ret32(c, portnum); logmessage(c, __FILE__, __LINE__, 0, "logging port on peer is: %d", (int)portnum); socket_set_port((struct sockaddr *)(&c->sa), htons(portnum)); sock = socket(((struct sockaddr *)&c->sa)->sa_family, SOCK_STREAM, 0); if (sock == rk_INVALID_SOCKET) return 0; ret = connect(sock, (struct sockaddr *)&c->sa, c->salen); if (ret < 0) { logmessage(c, __FILE__, __LINE__, 0, "failed connect to log port: %s", strerror(errno)); rk_closesocket(sock); return 0; } if (c->logging) krb5_storage_free(c->logging); c->logging = krb5_storage_from_socket(sock); rk_closesocket(sock); krb5_store_int32(c->logging, eLogSetMoniker); store_string(c->logging, c->moniker); logmessage(c, __FILE__, __LINE__, 0, "logging turned on"); return 0; }
id_pointer id_lookup (char* first,char* last,int ilk) /* look up an identifier */ { int l,h; /* length and hash code of the given identifier */ if (last==NULL) last=first+(l=(int)strlen(first)); /* null-terminated string */ else l=(int)(last-first); /* compute the length */ { char* p=first; h=*p; while (++p<last) h=((h<<1)+*p)%hash_size; } { id_pointer p=hash[h]; /* the head of the hash list */ while (p!=NULL && !names_match(p,first,l,ilk)) p=p->hash_link; if (p==NULL) /* we haven't seen this identifier before */ { p=id_ptr; /* this is where the new name entry will be created */ if (id_ptr++>=id_table_end) overflow ("identifier"); name_begin(p)=store_string(first,l); if (program==cweave) init_id_name(p,ilk); p->hash_link=hash[h]; hash[h]=p; /* insert |p| at beginning of hash list */ } return p; } }
VATTR *vattr_rename( char *name, char *newname ) { VATTR *vp; fixcase( name ); if( !ok_attr_name( name ) ) { return ( NULL ); } /* * Be ruthless. */ if( strlen( newname ) >= VNAME_SIZE ) { newname[VNAME_SIZE - 1] = '\0'; } fixcase( newname ); if( !ok_attr_name( newname ) ) { return ( NULL ); } /* * We must explicitly delete and add the name to the hashtable, * * since we are changing the data. */ vp = ( VATTR * ) hashfind( name, &mudstate.vattr_name_htab ); if( vp ) { vp->name = store_string( newname ); hashdelete( name, &mudstate.vattr_name_htab ); hashadd( newname, ( int * ) vp, &mudstate.vattr_name_htab, 0 ); } return ( vp ); }
static void initPaths(int argc, const char **argv) { char plp[MAXPATHLEN]; if ( argc > 0 ) { char plp1[MAXPATHLEN]; const char *symbols = NULL; /* The executable */ if ( !(symbols = findExecutable(argv[0], plp1)) || !(symbols = DeRefLink(symbols, plp)) ) symbols = argv[0]; DEBUG(2, Sdprintf("rc-module: %s\n", symbols)); systemDefaults.home = findHome(symbols, argc, argv); #ifdef __WINDOWS__ /* we want no module but the .EXE */ GD->paths.module = store_string(symbols); symbols = findExecutable(NULL, plp); DEBUG(2, Sdprintf("Executable: %s\n", symbols)); #endif GD->paths.executable = store_string(symbols); GD->options.systemInitFile = defaultSystemInitFile(argv[0]); } else { systemDefaults.home = findHome(NULL, argc, argv); GD->options.systemInitFile = store_string("none"); #ifdef __WINDOWS__ /* we want no module but the .EXE */ GD->paths.module = store_string("libswipl.dll"); #endif } systemDefaults.startup = store_string(PrologPath(DEFSTARTUP, plp, sizeof(plp))); #ifdef O_XOS if ( systemDefaults.home ) { char buf[MAXPATHLEN]; _xos_limited_os_filename(systemDefaults.home, buf); systemDefaults.home = store_string(buf); } #endif }
static int parseCommandLineOptions(int argc0, char **argv, int *compile) { GET_LD int argc = argc0; for( ; argc > 0 && (argv[0][0] == '-' || argv[0][0] == '+'); argc--, argv++ ) { char *s = &argv[0][1]; if ( streq(s, "-" ) ) /* swipl <plargs> -- <app-args> */ { break; } if ( streq(s, "tty") ) /* +/-tty */ { if ( s[-1] == '+' ) setPrologFlagMask(PLFLAG_TTY_CONTROL); else clearPrologFlagMask(PLFLAG_TTY_CONTROL); continue; } else if ( isoption(s, "nosignals") ) { clearPrologFlagMask(PLFLAG_SIGNALS); continue; } else if ( isoption(s, "nodebug") ) { clearPrologFlagMask(PLFLAG_DEBUGINFO); continue; } else if ( streq(s, "-quiet") ) { GD->options.silent = TRUE; continue; } if ( *s == '-' ) { const char *optval; s++; if ( (optval=is_longopt(s, "pldoc")) ) { GD->options.pldoc_server = store_string(optval); } else if ( is_longopt(s, "home") ) { /* already handled */ #ifdef __WINDOWS__ } else if ( (optval=is_longopt(s, "win_app")) ) { GD->options.win_app = TRUE; #endif } else if ( (optval=is_longopt(s, "traditional")) ) { setTraditional(); } continue; /* don't handle --long=value */ } while(*s) { switch(*s) { case 'd': if (argc > 1) { prolog_debug_from_string(argv[1], TRUE); argc--, argv++; } else return -1; break; case 'p': optionList(&GD->options.search_paths); break; case 'O': GD->cmdline.optimise = TRUE; /* see initFeatures() */ break; case 'x': case 'o': optionString(GD->options.compileOut); break; case 'f': optionString(GD->options.initFile); break; case 'F': optionString(GD->options.systemInitFile); break; case 'l': case 's': optionList(&GD->options.scriptFiles); break; case 'g': optionString(GD->options.goal); break; case 't': optionString(GD->options.topLevel); break; case 'c': *compile = TRUE; break; case 'b': GD->bootsession = TRUE; break; case 'q': GD->options.silent = TRUE; break; case 'L': case 'G': case 'T': case 'A': case 'H': { uintptr_t size = memarea_limit(&s[1]); if ( size == MEMAREA_INVALID_SIZE ) return -1; switch(*s) { case 'L': GD->options.localSize = size; goto next; case 'G': GD->options.globalSize = size; goto next; case 'T': GD->options.trailSize = size; goto next; case 'H': case 'A': Sdprintf("% Warning: -%csize is no longer supported\n", *s); goto next; } } } s++; } next:; } return argc0-argc; }