int main(void) { char* var="abc"; char* val="cde"; char buffer[10]; LONG len; printf("test setvar '%s'\n", val); if (SetVar(var, val, strlen(val), 0) == DOSFALSE) printf("error setvar\n"); if ((len = GetVar(var, buffer, sizeof(buffer), 0)) < 0) printf("error getvar %d\n", len); printf("test getvar '%s'\n", buffer); val=""; printf("test1 setvar '%s'\n", val); if (SetVar(var, val, strlen(val), 0) == DOSFALSE) printf("error setvar\n"); if ((len = GetVar(var, buffer, sizeof(buffer), 0)) < 0) printf("error getvar %d\n", len); printf("test1 getvar '%s'\n", buffer); val="abc"; printf("test2 setvar '%s'\n", val); if (SetVar(var, val, strlen(val), 0) == DOSFALSE) printf("error setvar\n"); if ((len = GetVar(var, buffer, sizeof(buffer), 0)) < 0) printf("error getvar %d\n", len); printf("test2 getvar '%s'\n", buffer); val=""; printf("test3 setvar '%s'\n", val); if (SetVar(var, val, strlen(val), 0) == DOSFALSE) printf("error setvar\n"); if ((len = GetVar(var, buffer, sizeof(buffer), 0)) < 0) printf("error getvar %d\n", len); printf("test3 getvar '%s'\n", buffer); val=""; printf("test4 setvar '%s'\n", val); if (SetVar(var, val, strlen(val), 0) == DOSFALSE) printf("error setvar\n"); if ((len = GetVar(var, buffer, sizeof(buffer), 0)) < 0) printf("error getvar %d\n", len); printf("test4 getvar '%s'\n", buffer); return 0; }
int IDriveCloseFileWrite(TFileStore *FS, STREAM *S) { char *Tempstr=NULL, *Error=NULL, *ptr; ListNode *Vars=NULL; HTTPInfoStruct *Info; int result=FALSE, val; Info=(HTTPInfoStruct *) FS->Extra; if (Info) { Tempstr=MCopyStr(Tempstr,"\r\n--",STREAMGetValue(S,"Boundary"),"--\r\n",NULL); STREAMWriteLine(Tempstr,S); STREAMFlush(S); HTTPTransact(Info); /* <?xml version="1.0" encoding="UTF-8"?> <tree message="SUCCESS"> <item filename="autoget.c" filesize="27620" lmd="1969/12/31 16:00:00" message="SUCCESS"/> </tree> */ val=HTTPReadDocument(S, &Tempstr); if (Settings.Flags & FLAG_VERBOSE) printf("\n%s\n",Tempstr); Vars=ListCreate(); IDriveParseResponse(Tempstr, Vars); Tempstr=CopyStr(Tempstr,GetVar(Vars,"message")); if (strcmp(Tempstr,"SUCCESS")==0) { val=atoi(STREAMGetValue(S,"Transfer-Size")); if (val==atoi(GetVar(Vars,"filesize"))) result=TRUE; else result=ERR_INTERRUPTED; } else { SetVar(FS->Vars,"Error",GetVar(Vars,"desc")); result=ERR_CUSTOM; } } DestroyString(Tempstr); return(result); }
int OAuthRefresh(OAUTH *Ctx, const char *URL) { char *Tempstr=NULL, *Args=NULL; const char *ptr; int result; /* POST, GET client_id (integer) : Your app's client_id (obtained during app registration) client_id and client_secrect can be provided via HTTP Basic Authentication see http://tools.ietf.org/html/rfc6750#section-2.1 POST, GET client_secret (string) : Your app's client_secret (obtained during app registration) client_id and client_secrect can be provided via HTTP Basic Authentication see http://tools.ietf.org/html/rfc6750#section-2.1 POST, GET grant_type (string) : The value must be refresh_token POST, GET refresh_token (string) : required */ ptr=GetVar(Ctx->Vars, "client_id"); if (StrValid(ptr)) { Tempstr=HTTPQuote(Tempstr, ptr); Args=MCopyStr(Args,"client_id=",Tempstr,NULL); } ptr=GetVar(Ctx->Vars, "client_secret"); if (StrValid(ptr)) { Tempstr=HTTPQuote(Tempstr, ptr); Args=MCatStr(Args,"&client_secret=",Tempstr,NULL); } if (StrValid(Ctx->RefreshToken)) { Tempstr=HTTPQuote(Tempstr, Ctx->RefreshToken); Args=MCatStr(Args,"&refresh_token=",Tempstr,NULL); } Args=MCatStr(Args,"&grant_type=refresh_token",NULL); result=OAuthGrant(Ctx, URL, Args); DestroyString(Tempstr); DestroyString(Args); return(result); }
int IDriveLoadDir(TFileStore *FS, char *InPattern, ListNode *Items, int Flags) { int result; char *Tempstr=NULL, *XML=NULL; char *TagName=NULL, *TagData=NULL, *ptr; TFileInfo *FI; HTTPInfoStruct *Info; ListNode *Vars; Tempstr=MCopyStr(Tempstr,"https://",FS->Host,"/evs/browseFolder?uid=",FS->Logon,"&pwd=",FS->Passwd,"&p=",FS->CurrDir,NULL); FS->S=HTTPMethod("POST",Tempstr,"","","","",0); Tempstr=STREAMReadDocument(Tempstr, FS->S, TRUE); ptr=XMLGetTag(Tempstr,NULL,&TagName,&TagData); while (ptr) { if (strcmp(TagName,"item")==0) { FI=IDriveReadFileEntry(TagData); if (Items) ListAddNamedItem(Items,FI->Name,FI); } ptr=XMLGetTag(ptr,NULL,&TagName,&TagData); } STREAMClose(FS->S); FS->S=NULL; Tempstr=MCopyStr(Tempstr,"https://",FS->Host,"/evs/getAccountQuota?uid=",FS->Logon,"&pwd=",FS->Passwd,NULL); FS->S=HTTPMethod("POST",Tempstr,"","","","",0); Tempstr=STREAMReadDocument(Tempstr, FS->S, TRUE); Vars=ListCreate(); IDriveParseResponse(Tempstr,Vars); FS->BytesAvailable=strtod(GetVar(Vars,"totalquota"),NULL); FS->BytesUsed=strtod(GetVar(Vars,"usedquota"),NULL); ListDestroy(Vars,DestroyString); DestroyString(TagName); DestroyString(TagData); DestroyString(Tempstr); DestroyString(XML); return(TRUE); }
ConfVarString* ConfVarTable::GetStr(const string_t &name, const string_t &def) { std::pair<ConfVar*, bool> p = GetVar(name, ConfVar::typeString); if( !p.second ) p.first->AsStr()->Set(def); return p.first->AsStr(); }
ConfVarBool* ConfVarTable::GetBool(const string_t &name, bool def) { std::pair<ConfVar*, bool> p = GetVar(name, ConfVar::typeBoolean); if( !p.second ) p.first->AsBool()->Set(def); return p.first->AsBool(); }
// Based on Dave Laundon's simplified process_string AString GetNsisString(const AString &s) { AString res; for (int i = 0; i < s.Length();) { unsigned char nVarIdx = s[i++]; if (nVarIdx > NS_CODES_START && i + 2 <= s.Length()) { int nData = s[i++] & 0x7F; unsigned char c1 = s[i++]; nData |= (((int)(c1 & 0x7F)) << 7); if (nVarIdx == NS_SHELL_CODE) res += GetShellString(c1); else if (nVarIdx == NS_VAR_CODE) res += GetVar(nData); else if (nVarIdx == NS_LANG_CODE) res += "NS_LANG_CODE"; } else if (nVarIdx == NS_SKIP_CODE) { if (i < s.Length()) res += s[i++]; } else // Normal char res += (char)nVarIdx; } return res; }
STREAM *InternalCopyOpenDest(TTransferContext *Ctx, TFileInfo *SrcFI, TFileInfo *DestFI) { STREAM *S; char *ptr; int val=0; //For the destination we are writing the file into the current directory, so never use a full path //use the name of the source file as the path if (Ctx->CmdFlags & FLAG_CMD_EXTN_TEMP) DestFI->Path=PathChangeExtn(DestFI->Path, SrcFI->Name, GetVar(Ctx->Vars,"TransferTempExtn")); else DestFI->Path=CopyStr(DestFI->Path, SrcFI->Name); DestFI->Permissions=CopyStr(DestFI->Permissions,TransferDecidePermissions(SrcFI)); ptr=GetVar(Ctx->Vars,"ContentType"); if (StrLen(ptr)) DestFI->MediaType=CopyStr(DestFI->MediaType,ptr); else FileStoreGetFileType(Ctx->SrcFS, DestFI); val=OPEN_WRITE; if (Ctx->CmdFlags & FLAG_CMD_PUBLIC) val |= OPEN_PUBLIC; if ( (Ctx->CmdFlags & FLAG_CMD_RESUME) && (Ctx->SrcFS->Features & FS_RESUME_TRANSFERS) && (Ctx->DestFS->Features & FS_RESUME_TRANSFERS) ) val |= OPEN_RESUME; S=Ctx->DestFS->OpenFile(Ctx->DestFS,DestFI, val); return(S); }
// Read settings void font_read_settings(font_data *data) { char buf[80],*ptr; struct IBox dims; // Get environment variable if (GetVar("dopus/Font Viewer",buf,sizeof(buf),GVF_GLOBAL_ONLY)<=0) return; // Get pointer to buffer ptr=buf; // Parse settings read_parse_set(&ptr,(UWORD *)&dims.Left); read_parse_set(&ptr,(UWORD *)&dims.Top); read_parse_set(&ptr,(UWORD *)&dims.Width); read_parse_set(&ptr,(UWORD *)&dims.Height); // Got valid size? if (dims.Height>0) { // Clear character coordinates data->win_dims.char_dim.Top=0; data->win_dims.char_dim.Left=0; data->win_dims.char_dim.Width=0; data->win_dims.char_dim.Height=0; // Set absolute coordinates data->win_dims.fine_dim=dims; } }
/* ' @remarks This function reads the Npc.dat file */ int EncontrarCant(int NpcIndex, int ObjIndex) { int retval; /* '*************************************************** */ /* 'Author: Unknown */ /* 'Last Modification: 03/09/08 */ /* 'Last Modification By: Marco Vanotti (Marco) */ /* ' - 03/09/08 EncontrarCant now returns 0 if the npc doesn't have it (Marco) */ /* '*************************************************** */ /* 'Devuelve la cantidad original del obj de un npc */ std::string ln; std::string npcfile; int i; npcfile = GetDatPath(DATPATH::NPCs); for (i = (1); i <= (MAX_INVENTORY_SLOTS); i++) { ln = GetVar(npcfile, "NPC" + vb6::CStr(Npclist[NpcIndex].Numero), "Obj" + vb6::CStr(i)); if (ObjIndex == vb6::val(ReadField(1, ln, 45))) { retval = (int) vb6::val(ReadField(2, ln, 45)); return retval; } } retval = 0; return retval; }
void clConsole::ExecuteBinding( const int Key, const bool KeyState ) { if ( !FKeyBindings[Key].empty() ) { if ( LStr::IsFirstChar( FKeyBindings[Key], '+' ) ) { // The "+" command is processed separatly and doesn't need to be registred LString VarName = FKeyBindings[Key].substr( 1, FKeyBindings[Key].length() - 1 ); clCVar* CVar = GetVar( VarName ); CVar->SetBool( KeyState ); } else { if ( KeyState ) { SendCommand( FKeyBindings[Key] ); } } } // autorelease mouse wheel if ( ( Key == LK_WHEELUP || Key == LK_WHEELDOWN ) && ( KeyState ) ) { ExecuteBinding( Key, false ); } }
One<Builder> MakeBuild::CreateBuilder(Host *host) { SetupDefaultMethod(); VectorMap<String, String> bm = GetMethodVars(method); String builder = bm.Get("BUILDER", "GCC"); int q = BuilderMap().Find(builder); if(q < 0) { PutConsole("Invalid builder " + builder); ConsoleShow(); return NULL; } One<Builder> b = (*BuilderMap().Get(builder))(); b->host = host; b->compiler = bm.Get("COMPILER", ""); b->include = SplitDirs(GetVar("UPP") + ';' + bm.Get("INCLUDE", "") + ';' + add_includes); const Workspace& wspc = GetIdeWorkspace(); for(int i = 0; i < wspc.GetCount(); i++) { const Package& pkg = wspc.GetPackage(i); for(int j = 0; j < pkg.include.GetCount(); j++) b->include.Add(SourcePath(wspc[i], pkg.include[j].text)); } b->libpath = SplitDirs(bm.Get("LIB", "")); b->debug_options = bm.Get("DEBUG_OPTIONS", ""); b->release_options = bm.Get("RELEASE_OPTIONS", ""); b->release_size_options = bm.Get("RELEASE_SIZE_OPTIONS", ""); b->debug_link = bm.Get("DEBUG_LINK", ""); b->release_link = bm.Get("RELEASE_LINK", ""); b->script = bm.Get("SCRIPT", ""); b->main_conf = !!main_conf.GetCount(); return b; }
String MakeBuild::OutDir(const Index<String>& cfg, const String& package, const VectorMap<String, String>& bm, bool use_target) { Index<String> excl; excl.Add(bm.Get("BUILDER", "GCC")); excl.Add("MSC"); LocalHost().AddFlags(excl); Vector<String> x; bool dbg = cfg.Find("DEBUG_FULL") >= 0 || cfg.Find("DEBUG_MINIMAL") >= 0; if(cfg.Find("DEBUG") >= 0) { excl.Add("BLITZ"); if(cfg.Find("BLITZ") < 0) x.Add("NOBLITZ"); } else if(dbg) x.Add("RELEASE"); if(use_target) excl.Add("MAIN"); for(int i = 0; i < cfg.GetCount(); i++) if(excl.Find(cfg[i]) < 0) x.Add(cfg[i]); Sort(x); for(int i = 0; i < x.GetCount(); i++) x[i] = InitCaps(x[i]); String outdir = GetVar("OUTPUT"); if(output_per_assembly) outdir = AppendFileName(outdir, GetVarsName()); if(!use_target) outdir = AppendFileName(outdir, package); outdir = AppendFileName(outdir, GetFileTitle(method) + "." + Join(x, ".")); outdir = Filter(outdir, CharFilterSlash); return outdir; }
void DoCommand(const std::string& newline, User* user, Channel *chan, const std::string &original_line) { std::string result; result.reserve(newline.length()); for (unsigned int i = 0; i < newline.length(); i++) { char c = newline[i]; if ((c == '$') && (i + 1 < newline.length())) { if (isdigit(newline[i+1])) { int len = ((i + 2 < newline.length()) && (newline[i+2] == '-')) ? 3 : 2; std::string var = newline.substr(i, len); result.append(GetVar(var, original_line)); i += len - 1; } else if (newline.substr(i, 5) == "$nick") { result.append(user->nick); i += 4; } else if (newline.substr(i, 5) == "$host") { result.append(user->host); i += 4; } else if (newline.substr(i, 5) == "$chan") { if (chan) result.append(chan->name); i += 4; } else if (newline.substr(i, 6) == "$ident") { result.append(user->ident); i += 5; } else if (newline.substr(i, 6) == "$vhost") { result.append(user->dhost); i += 5; } else result.push_back(c); } else result.push_back(c); } irc::tokenstream ss(result); std::vector<std::string> pars; std::string command, token; ss.GetToken(command); while (ss.GetToken(token)) { pars.push_back(token); } ServerInstance->Parser->CallHandler(command, pars, user); }
// SaveIfNeeded void SavedVariableBank::SaveIfNeeded() { // Basically, force save if the player collected a star if(GM_STAR_COUNT > GetVar(SPECIAL_SAVE_STR)) { SetVar(SPECIAL_SAVE_STR, GM_STAR_COUNT); WriteBank(); } }
char* test_serect() { loadtable(); SetVar(test,100); GetVar(outputpool,100); return outputpool; }
ConfVarArray* ConfVarTable::GetArray(const string_t &name, void (*init)(ConfVarArray*)) { std::pair<ConfVar*, bool> p = GetVar(name, ConfVar::typeArray); if( !p.second && init ) init(p.first->AsArray()); return p.first->AsArray(); }
PVideoFrame __stdcall Write::GetFrame(int n, IScriptEnvironment* env) { //changed to call write AFTER the child->GetFrame PVideoFrame tmpframe = child->GetFrame(n, env); if (linecheck<0) return tmpframe; //do nothing here when writing only start or end AVSValue prev_last = env->GetVar("last"); // Store previous last AVSValue prev_current_frame = GetVar(env, "current_frame"); // Store previous current_frame env->SetVar("last",(AVSValue)child); // Set implicit last (to avoid recursive stack calls?) env->SetVar("current_frame",n); if (Write::DoEval(env)) { Write::FileOut(env); } env->SetVar("last",prev_last); // Restore implicit last env->SetVar("current_frame",prev_current_frame); // Restore current_frame return tmpframe; };
ConfVarTable* ConfVarTable::GetTable(const string_t &name, void (*init)(ConfVarTable*)) { std::pair<ConfVar*, bool> p = GetVar(name, ConfVar::typeTable); if( !p.second && init ) init(p.first->AsTable()); return p.first->AsTable(); }
char *LibUsefulGetValue(char *Name) { if (! LibUsefulSettings) LibUsefulInitSettings(); if (!StrLen(Name)) return(""); return(GetVar(LibUsefulSettings,Name)); }
static void DiaProductsRetrieve(t_dia_req *preq, t_dia_rspparam *par, ...) { DIA_LOCAL_VAR(); (void)updatecont; (void)updateelem; (void)tmp; (void)parseflags; sprintf(target,"%s%s/%s/containers/products/contentInstances/%s/content", GetHostTarget(), SCL_ROOT_APP, GetVar("w_ipuid"), ProductsGetRefFromId(preq->rq_dev)); if (par == NULL) { // REQUEST retry: DIA_RETRIEVE_REQUEST(DiaProductsRetrieve); return; } // RESPONSE DIA_RETRIEVE_RESPONSE(DiaProductsError,DiaProductsError,DiaProductsOk); }
int OAuthSave(OAUTH *Ctx, const char *Path) { STREAM *S; const char *Fields[]= {"client_id","client_secret","access_token","refresh_token",NULL}; const char *ptr; char *Tempstr=NULL; int i; if (! StrValid(Path)) { if (! StrValid(Ctx->SavePath)) return(FALSE); S=STREAMOpen(Ctx->SavePath,"aEL"); } else S=STREAMOpen(Path,"aEL"); if (S) { Tempstr=MCopyStr(Tempstr, "'", Ctx->Name,"' ",NULL); for (i=0; Fields[i] !=NULL; i++) { ptr=GetVar(Ctx->Vars,Fields[i]); if (StrValid(ptr)) Tempstr=MCatStr(Tempstr, Fields[i], "='", ptr, "' ",NULL); } Tempstr=CatStr(Tempstr,"\n"); STREAMWriteLine(Tempstr, S); STREAMClose(S); } DestroyString(Tempstr); return(TRUE); }
STREAM *InternalCopyOpenSource(TTransferContext *Ctx, TFileInfo *SrcFI) { STREAM *S; char *ptr; int val=0; //Specify the DESTINATION size in the source, for use in 'resume' transfers if (Ctx->DestFS->GetFileSize) SrcFI->ResumePoint=Ctx->DestFS->GetFileSize(Ctx->DestFS, SrcFI->Name); //Set version info if getting a particular version of file ptr=GetVar(Ctx->Vars,"Version"); SetVar(SrcFI->Vars,"Version,",ptr); if ( (Ctx->CmdFlags & FLAG_CMD_RESUME) && (Ctx->SrcFS->Features & FS_RESUME_TRANSFERS) && (Ctx->DestFS->Features & FS_RESUME_TRANSFERS) ) val |= OPEN_RESUME; S=Ctx->SrcFS->OpenFile(Ctx->SrcFS,SrcFI, val); //OPEN SOURCE DONE //Construct 'write' args. THESE ARE ARGS TO OPEN THE DEST FILE if (S) { ptr=STREAMGetValue(S,"filesize"); if (StrLen(ptr)) SrcFI->Size=atoi(ptr); else if (Ctx->SrcFS->GetFileSize) SrcFI->Size=Ctx->SrcFS->GetFileSize(Ctx->SrcFS, SrcFI->Path); } return(S); }
ConfVarNumber* ConfVarArray::GetNum(size_t index, int def) { std::pair<ConfVar*, bool> p = GetVar(index, ConfVar::typeNumber); if( !p.second ) p.first->AsNum()->SetInt(def); return p.first->AsNum(); }
//This accepts a single pattern to match against. If that includes a space, it is thought to be a filename //with a space in. To supply multiple patterns look at "ProcessPutFiles" below. int ProcessCreateFile(TFileStore *FS, char *Name, ListNode *Vars) { TFileInfo *FI; int result; char *ptr; STREAM *S; TTransferContext *Ctx; FI=FileInfoCreate(Name, Name, FTYPE_FILE, 0, 0); ptr=GetVar(Vars,"ContentType"); if (StrLen(ptr)) FI->MediaType=CopyStr(FI->MediaType,ptr); else FileStoreGetFileType(FS, FI); S=FS->OpenFile(FS, FI, OPEN_WRITE); result=FS->CloseFile(FS,S); if (result != TRANSFER_OKAY) { Ctx=TransferContextCreate(NULL, FS, 0, 0, Vars); HandleTransferResult(Ctx,FI, result); TransferContextDestroy(Ctx); } FileInfoDestroy(FI); return(result); }
ConfVarBool* ConfVarArray::GetBool(size_t index, bool def) { std::pair<ConfVar*, bool> p = GetVar(index, ConfVar::typeBoolean); if( !p.second ) p.first->AsBool()->Set(def); return p.first->AsBool(); }
void HMACSetup(HashratCtx *Ctx) { char *Tempstr=NULL, *ptr; STREAM *S; ptr=GetVar(Ctx->Vars,"EncryptionKey"); if (StrLen(ptr)==0) { if (isatty(0)) { write(1, "Enter HMAC Key: ",16); S=STREAMFromFD(0); Tempstr=STREAMReadLine(Tempstr,S); StripTrailingWhitespace(Tempstr); SetVar(Ctx->Vars,"EncryptionKey",Tempstr); ptr=Tempstr; STREAMDisassociateFromFD(S); } //By now we must have an encryption key! if (! StrLen(ptr)) { write(1,"ERROR: No HMAC Key given!\n",27); exit(2); } } DestroyString(Tempstr); }
ConfVarString* ConfVarArray::GetStr(size_t index, const string_t &def) { std::pair<ConfVar*, bool> p = GetVar(index, ConfVar::typeString); if( !p.second ) p.first->AsStr()->Set(def); return p.first->AsStr(); }
CFXCrossFade::CFXCrossFade() { DefineVar("Alpha", CVarFloat::CLASSNAME); DefineVar("Blend Mode", CVarCombo::CLASSNAME); // Add combo options ((CVarCombo*)GetVar("Blend Mode"))->AddOption("Mult"); ((CVarCombo*)GetVar("Blend Mode"))->AddOption("Add"); // Set default alpha value. // The desired one would have been a linear change from 0.0 to 1.0 but since we don't // know the effect time range at this point yet, we can't do that. ((CVarFloat*)GetVar("Alpha"))->SetConstant(0.5f); }
ConfVarNumber* ConfVarTable::GetNum(const string_t &name, int def) { std::pair<ConfVar*, bool> p = GetVar(name, ConfVar::typeNumber); if( !p.second ) p.first->AsNum()->SetInt(def); return p.first->AsNum(); }