CSpace::CSpace(int64 ParentID, int64 ChildID) :m_ValidateModule(NULL),m_PrivateValidata(NULL) { m_ID = -1; //ParentID PushInt(-1); //Space ID PushString(_T("")); //Space Name PushInt(LOCAL_SPACE);//Space Type tstring Fingerprint; PushString(Fingerprint); //Space Fingerprint ePipeline Property; CreateDefaultProerty(Property); //Space Property; PushPipe(Property); ePipeline OwnerInfo; CreateDefaultOwnerInfo(OwnerInfo); //Space OwnerList PushPipe(OwnerInfo); if(!Load(ParentID,ChildID)){ m_ID = -1; }; }
/* ** email address obfuscation */ char *obfuscate_email_address(char *address) { char sbuf[10]; struct Push buf; int at_mailbox=1; char *sentinel; if (!set_email_address_obfuscation){ return address; } sentinel=strlen(address)+address; INIT_PUSH(buf); while (address<sentinel){ if (*address=='@'){ PushString(&buf,"@"); at_mailbox=0; }else{ if(!at_mailbox){ sprintf(sbuf,"&#%04d;",*address); PushString(&buf,sbuf); }else{ sbuf[0]=*address; sbuf[1]=0x0; PushString(&buf,sbuf); } } address++; } RETURN_PUSH(buf); }
int LuaScriptUtilities::PushStringAttribute( lua_State* const luaVM, const Ogre::String attributeValue, const Ogre::String attributeName, const int tableIndex) { PushString(luaVM, attributeName); PushString(luaVM, attributeValue); lua_settable(luaVM, tableIndex); return 1; }
/* * Manual page at function.def */ INT16 CGEN_PUBLIC CFunction::OnGet() { // Delegate to running function // ------------------------------------ FNC_DELEGATE OnGet(); // Use a weird macro (see function.def) // Initialize // ------------------------------------ CDlpObject* iCont = GetActiveInstance(); // Determine field container const char* lpsId = GetNextToken(TRUE); // Determine field name // Validate // ------------------------------------ DLPASSERT(iCont); // Check set target if (!dlp_strlen(lpsId)) // If no field name committed return IERROR(this,FNC_EXPECT,"field identifier after -get",0,0); // Error SWord* lpWrd = iCont->FindWord(lpsId,WL_TYPE_FIELD); // Find field in container if (!lpWrd) // If not found { // >> iCont = this; // Use this instance as container lpWrd = FindWord(lpsId,WL_TYPE_FIELD); // And seek again } // << if (!lpWrd) return IERROR(this,ERR_NOTFIELD,lpsId,0,0); // If still not found --> Error // Push field value // ------------------------------------ switch (lpWrd->ex.fld.nType) // Branch for field variable type { // >> case T_BOOL : { PushLogic ( *( BOOL*)lpWrd->lpData); break; }// - Boolean case T_UCHAR : { PushNumber (CMPLX(*( UINT8*)lpWrd->lpData)); break; }// - Unsigned character case T_CHAR : { PushNumber (CMPLX(*( INT8*)lpWrd->lpData)); break; }// - Signed character case T_USHORT : { PushNumber (CMPLX(*( UINT16*)lpWrd->lpData)); break; }// - Unsigned short integer case T_SHORT : { PushNumber (CMPLX(*( INT16*)lpWrd->lpData)); break; }// - Signed short integer case T_UINT : { PushNumber (CMPLX(*( UINT32*)lpWrd->lpData)); break; }// - Unsigned integer case T_INT : { PushNumber (CMPLX(*( INT32*)lpWrd->lpData)); break; }// - Signed integer case T_ULONG : { PushNumber (CMPLX(*( UINT64*)lpWrd->lpData)); break; }// - Unsigned long integer case T_LONG : { PushNumber (CMPLX(*( INT64*)lpWrd->lpData)); break; }// - Signed long integer case T_FLOAT : { PushNumber (CMPLX(*( FLOAT32*)lpWrd->lpData)); break; }// - Single precision floating point case T_DOUBLE : { PushNumber (CMPLX(*( FLOAT64*)lpWrd->lpData)); break; }// - Double precision floating point case T_COMPLEX : { PushNumber ( *(COMPLEX64*)lpWrd->lpData); break; }// - Double precision complex floating point case T_INSTANCE: { PushInstance(*(CDlpObject**) lpWrd->lpData); break; }// - Instance case T_TEXT : /* Fall through */ // - Text (deprecated type!) case T_CSTRING : /* Fall through */ // - Constant string case T_STRING : { PushString(*(char**) lpWrd->lpData); break; }// - String default : { // - Other types if (lpWrd->ex.fld.nType > 0 && lpWrd->ex.fld.nType <= 256) // Character array? PushString((char*)lpWrd->lpData); // Push value else // Type unknown! DLPASSERT(FMSG("Unknown field type")); // Error } // << } // << return O_K; // Done. }
void Std_Joinchars(VM* vm) { Object* obj = PopArrayObject(vm); if(obj->array.length == 0) { PushString(vm, ""); return; } char* str = alloca(obj->array.length + 1); for(int i = 0; i < obj->array.length; ++i) str[i] = (char)obj->array.members[i]->number; str[obj->array.length] = '\0'; PushString(vm, str); }
void prim_timefmt(PRIM_PROTOTYPE) { time_t lt = 0; CHECKOP(2); oper2 = POP(); /* integer: time */ oper1 = POP(); /* string: format */ if (oper1->type != PROG_STRING) abort_interp("Invalid argument (1)"); if (!oper1->data.string) abort_interp("Illegal NULL string (1)"); if (oper2->type != PROG_INTEGER) abort_interp("Invalid argument (2)"); lt = (time_t) oper2->data.number; time_tm = localtime(<); if (!time_tm) abort_interp("Out of range time argument"); if (!strftime(buf, BUFFER_LEN, oper1->data.string->data, time_tm)) abort_interp("Operation would result in overflow."); CHECKOFLOW(1); CLEAR(oper1); CLEAR(oper2); PushString(buf); }
void prim_version(PRIM_PROTOTYPE) { CHECKOP(0); CHECKOFLOW(1); PushString(VERSION); }
void OutNvramStack(void) { InitPushCRC(); uint i; for (i=0; i<4000; i++) PushChar(0); InitPushCRC(); PUSH_VALUE(NVRAM_BEGIN) PUSH_VALUE(NVRAM_END) PUSH_VALUE(dwNVRAM_BYTES) PushChar(0x0D); PushChar(0x0A); PushLongAsString((ulong)100*(NVRAM_END-NVRAM_BEGIN)/(dwNVRAM_BYTES-NVRAM_BEGIN)); PushString("%"); PushChar(0x0D); PushChar(0x0A); PushChar(0x0D); PushChar(0x0A); #include "../generated/out_nvram.txt" Output(4000); }
void Std_Tostring(VM* vm) { Object* obj = PopObject(vm); char buf[128]; switch(obj->type) { case OBJ_NULL: sprintf(buf, "null"); break; case OBJ_STRING: PushString(vm, obj->string.raw); return; case OBJ_NUMBER: sprintf(buf, "%g", obj->number); break; case OBJ_ARRAY: sprintf(buf, "array(%i)", obj->array.length); break; case OBJ_FUNC: sprintf(buf, "func %s", obj->func.isExtern ? vm->externNames[obj->func.index] : vm->functionNames[obj->func.index]); break; case OBJ_DICT: sprintf(buf, "dict(%i)", obj->dict.numEntries); break; } PushString(vm, buf); }
int LuaScriptUtilities::PushErrorMessageAndDie( lua_State* const luaVM, const Ogre::String& message) { PushString(luaVM, message); lua_error(luaVM); return 0; }
unsigned int Load(const char* filename) { _origin.clear(); _origin_rev.clear(); _max_id = 0; const std::string header("String #"); const std::string header_next(" is "); const char splitter = '~'; std::ifstream fin(filename); std::string line; unsigned int index = INDEX_INVALID; std::string content; std::stringstream ss(content); while(std::getline(fin, line)) { //not including the \n if( line.length() >= header.length() && line.substr(0, header.length()) == header) { if(index != INDEX_INVALID) { PushString(ss, splitter, index); } int pos = line.find_first_of(splitter); std::string index_str = line.substr(header.length(), pos - header_next.length() - header.length()); index = atoi(index_str.c_str()); ss << line.substr(pos + 1); } else if(index != INDEX_INVALID) { ss << std::endl; ss << line; } } if(index != INDEX_INVALID) { PushString(ss, splitter, index); } return _max_id; }
void PushString( std::stringstream &ss, const char splitter, unsigned int index ) { std::string result = ss.str(); int splitter_pos = result.find_last_of(splitter); PushString(index, splitter_pos < 0 ? result : result.substr(0, splitter_pos)); ss.str(std::string()); }
static char *msgsperfolder_label(char *frmptr, int subdir_no) { register char *aptr; char dtstr[DATESTRLEN]; char c; struct Push buff; INIT_PUSH(buff); aptr = frmptr; while ((c = *aptr++)) { if (c == '%') { switch (*aptr++) { case '%': /* Add the % character */ PushByte(&buff, '%'); continue; case 'd': /* directory number, starting at 0 */ sprintf(dtstr, "%d", subdir_no); PushString(&buff, dtstr); continue; case 'D': /* directory number, starting with 1 */ sprintf(dtstr, "%d", subdir_no + 1); PushString(&buff, dtstr); continue; case 'm': /* number of first message in directory */ sprintf(dtstr, "%d", set_msgsperfolder * subdir_no); PushString(&buff, dtstr); continue; case 'M': /* number of last message possible */ sprintf(dtstr, "%d", set_msgsperfolder * (subdir_no + 1) - 1); PushString(&buff, dtstr); continue; default: PushString(&buff, "%?"); continue; } /* end switch */ } PushByte(&buff, c); } /* end while */ RETURN_PUSH(buff); }
void ICACHE_FLASH_ATTR WebSocketTickInternal() { switch( curhttp->state_deets ) { case 4: //Has key full HTTP header, etc. wants response. START_PACK; PushString( "HTTP/1.1 101 Switching Protocols\r\nUpgrade: websocket\r\nConnection: Upgrade\r\nSec-WebSocket-Accept: " ); PushString( curhttp->pathbuffer + (MAX_PATHLEN-WS_RETKEY_SIZEM1) ); PushString( "\r\n\r\n" ); EndTCPWrite( curhttp->socket ); curhttp->state_deets = 5; curhttp->keep_alive = 0; break; case 5: WebSocketTick(); break; } }
void prim_version(PRIM_PROTOTYPE) { char temp[256]; CHECKOP(0); CHECKOFLOW(1); sprintf(temp, "%s(ProtoMUCK%s)", VERSION, PROTOBASE); PushString(temp); }
/* * Manual page at function.def */ INT16 CGEN_PUBLIC CFunction::Prompt(const char* lpsMessage) { char sBuf[L_SSTR+1]; printf(lpsMessage); printf("> "); if(fgets(sBuf,L_SSTR,stdin) == NULL) return NOT_EXEC; for (char* tx = &sBuf[dlp_strlen(sBuf)-1]; *tx; tx--) if (*tx=='\n' || *tx=='\r') *tx='\0'; else break; PushString(sBuf); return O_K; }
int LuaScriptUtilities::PushDataTypeAttribute( lua_State* const luaVM, void* const rawPointer, const Ogre::String& attributeName, const RawScriptType type, const int tableIndex) { PushString(luaVM, attributeName); PushDataType(luaVM, rawPointer, type); lua_settable(luaVM, tableIndex); return 1; }
void prim_nextprop(PRIM_PROTOTYPE) { /* dbref pname -- pname */ char *pname; char exbuf[BUFFER_LEN]; CHECKOP(2); oper2 = POP(); /* pname */ oper1 = POP(); /* dbref */ if (mlev < 3) abort_interp("Permission denied."); if (oper2->type != PROG_STRING) abort_interp("String required. (2)"); if (oper1->type != PROG_OBJECT) abort_interp("Dbref required. (1)"); if (!valid_object(oper1)) abort_interp("Invalid dbref. (1)"); ref = oper1->data.objref; (void) strcpyn(buf, sizeof(buf), DoNullInd(oper2->data.string)); CLEAR(oper1); CLEAR(oper2); { char *tmpname; pname = next_prop_name(ref, exbuf, sizeof(exbuf), buf); #ifdef LOG_PROPS log2file("props.log", "#%d (%d) NEXTPROP: o=%d n=\"%s\" on=\"%s\"", program, pc->line, ref, pname, buf); #endif while (pname && !prop_read_perms(ProgUID, ref, pname, mlev)) { tmpname = next_prop_name(ref, exbuf, sizeof(exbuf), pname); #ifdef LOG_PROPS log2file("props.log", "#%d (%d) NEXTPROP: o=%d n=\"%s\" on=\"%s\"", program, pc->line, ref, tmpname, pname); #endif pname = tmpname; } } if (pname) { PushString(pname); } else { PushNullStr; } }
/* escape: 1==on 0==off */ char *i18n_utf2numref(char *instr,int escape){ char *ucs,*headofucs; size_t len; struct Push buff; char strbuf[10]; INIT_PUSH(buff); if (!set_i18n){ PushString(&buff,instr); RETURN_PUSH(buff); } headofucs=ucs=i18n_convstring(instr, "UTF-8", "UCS-2BE", &len); unsigned int p; int i = (int) len; for(; i > 0; i-=2){ p=(unsigned char)*ucs*256+(unsigned char)*(ucs+1); if (p<128){ /* keep ASCII characters human readable */ if (escape){ switch (p){ case '<': PushString(&buff, "<"); break; case '>': PushString(&buff, ">"); break; case '&': PushString(&buff, "&"); break; case '\"': PushString(&buff, """); break; case '\'': PushString(&buff, "'"); break; default: PushByte(&buff,p); } }else{ PushByte(&buff,p); } }else{ snprintf(strbuf,10,"&#%04d;",p); PushString(&buff,strbuf); } ucs+=2; } free(headofucs); RETURN_PUSH(buff); }
void prim_fread(PRIM_PROTOTYPE) { FILE *fh; char *filename; double offset; char tempchr[2]; int result; CHECKOP(2); oper1 = POP(); oper2 = POP(); if (getuid() == 0 ) abort_interp("Muck is running under root privs, file prims disabled."); if (mlev < LBOY) abort_interp("BOY primitive only."); if(oper1->type != PROG_INTEGER) abort_interp("Arguement 1 is not an integer."); if(oper1->data.number < 0 ) abort_interp("Arguement 1 is a negative number."); if(oper2->type != PROG_STRING) abort_interp("Arguement 2 is not a string."); if(!oper2->data.string) abort_interp("Argueemnt 2 is a null string."); offset = oper1->data.number; filename = oper2->data.string->data; #ifdef SECURE_FILE_PRIMS if (!(valid_name(filename))) abort_interp( "Invalid file name."); if ( strchr( filename, '$' ) == NULL ) filename = set_directory(filename); else filename = parse_token( filename ); if ( filename == NULL ) abort_interp( "Invalid shortcut used." ); #endif fh = fopen(filename, "r"); if (fh == NULL) { result = 0; } else { fseek(fh, offset, SEEK_SET); tempchr[0] = (char) fgetc(fh); tempchr[1] = '\0'; fclose(fh); sprintf(buf, "%s", tempchr); result = 1; if(tp_log_files) log2filetime("logs/files", "#%d by %s FREAD: %s \n", program, unparse_object(player, player), oper2->data.string->data); if ( tempchr[0] == EOF ) result = 0; } CLEAR(oper1); CLEAR(oper2); if( result ) PushString(buf); else PushNullStr; }
void prim_prettylock(PRIM_PROTOTYPE) { const char *ptr; CHECKOP(1); oper1 = POP(); /* lock: lock */ if (oper1->type != PROG_LOCK) abort_interp("Invalid argument"); ptr = unparse_boolexp(ProgUID, oper1->data.lock, 1); CHECKOFLOW(1); CLEAR(oper1); PushString(ptr); }
void prim_ftostr(PRIM_PROTOTYPE) { CHECKOP(1); oper1 = POP(); if ( oper1->type == PROG_INTEGER ) { oper1->type = PROG_FLOAT; oper1->data.fnumber = oper1->data.number; } if (oper1->type != PROG_FLOAT) abort_interp("Non-float argument. (1)"); sprintf(buf, "%#g", oper1->data.fnumber); CLEAR(oper1); PushString(buf); }
void TestStringSizeIs() { std::string file = "..\\Ch14\\data\\count-size"; std::vector<std::string> vec; PushString(file, vec); for (const auto& v : vec) { std::cout << v << " "; } std::cout << std::endl; for (size_t i = 1; i != 10; i++) { StringSizeIs ssi(i); std::cout << "The count of " << i << " size words is: " << count_if(vec.begin(), vec.end(), ssi) << std::endl; } }
void CLuaFile::PushParameter(const char *pString) { if (m_pLua == 0) return; if (StrIsInteger(pString)) { PushInteger(str_toint(pString)); } else if (StrIsFloat(pString)) { PushInteger(str_tofloat(pString)); } else { PushString(pString); } }
void prim_sysparm(PRIM_PROTOTYPE) { const char *ptr; CHECKOP(1); oper1 = POP(); /* string: system parm name */ if (oper1->type != PROG_STRING) abort_interp("Invalid argument."); if (oper1->data.string) { ptr = tune_get_parmstring(oper1->data.string->data, TUNE_MLEV(player)); } else { ptr = ""; } CHECKOFLOW(1); CLEAR(oper1); PushString(ptr); }
void prim_error_str(PRIM_PROTOTYPE) { int loop; CHECKOP(1); oper1 = POP(); if (oper1->type != PROG_STRING && oper1->type != PROG_INTEGER) abort_interp("Invalid argument type. (1)"); if (!err_init) init_err_val(); if (oper1->type == PROG_INTEGER) { if ((oper1->data.number < 0) || (oper1->data.number >= ERROR_NUM)) { result = -1; } else { result = oper1->data.number; } } else { if (!oper1->data.string) { result = -1; } else { loop = 0; result = strlen(oper1->data.string->data); for (loop = 0; loop < result; loop++) buf[loop] = toupper(oper1->data.string->data[loop]); result = -1; loop = 0; while (loop < ERROR_NUM) { if (!strcmp(buf, err_defs[loop].error_name)) { result = loop; break; } else { loop++; } } } } CLEAR(oper1); if (result == -1) { PushNullStr; } else { PushString(err_defs[result].error_string); } }
void Std_Strcat(VM* vm) { const char* a = PopString(vm); const char* b = PopString(vm); int la = strlen(a); int lb = strlen(b); char* newString = alloca(la + lb + 1); if(!newString) { fprintf(stderr, "Out of stack space when alloca'ing\n"); exit(1); } strcpy(newString, a); strcpy(newString + la, b); PushString(vm, newString); }
void prim_ftostrc(PRIM_PROTOTYPE) { CHECKOP(1); oper1 = POP(); if (oper1->type == PROG_INTEGER) { oper1->type = PROG_FLOAT; oper1->data.fnumber = oper1->data.number; } if (oper1->type != PROG_FLOAT) abort_interp("Non-float argument. (1)"); snprintf(buf,sizeof(buf), "%.15g", oper1->data.fnumber); if (!strchr(buf, '.') && !strchr(buf, 'e') && !strchr(buf, 'n')) { strcatn(buf, sizeof(buf), ".0"); } CLEAR(oper1); PushString(buf); }
void prim_conport(PRIM_PROTOTYPE) { /* int -- char * */ char *pname; CHECKOP(1); oper1 = POP(); if (mlev < LMAGE) abort_interp("Mage prim"); if (oper1->type != PROG_INTEGER) abort_interp("Argument not an integer (1)"); result = oper1->data.number; if ((result < 1) || (result > pcount())) abort_interp("Invalid connection number (1)"); pname = pport(result); CHECKOFLOW(1); CLEAR(oper1); PushString(pname); }
void prim_timefmt(PRIM_PROTOTYPE) { CHECKOP(2); oper2 = POP(); /* integer: time */ oper1 = POP(); /* string: format */ if (oper1->type != PROG_STRING) abort_interp("Invalid argument (1)"); if (oper1->data.string == (struct shared_string *) NULL) abort_interp("Illegal NULL string (1)"); if (oper2->type != PROG_INTEGER) abort_interp("Invalid argument (2)"); time_tm = localtime((time_t *) (&(oper2->data.number))); if (!format_time(buf, BUFFER_LEN, oper1->data.string->data, time_tm)) abort_interp("Operation would result in overflow"); CHECKOFLOW(1); CLEAR(oper1); CLEAR(oper2); PushString(buf); }