static int priv_encdec_stub(const char *name, int (*func)(int flen, const unsigned char *from, unsigned char *to, RSA *rsa, int padding), struct expbuf_t *buf) { unsigned char *from, to[4096]; size_t flen; size_t key_index, padding; RSA *rsa; int ret; if ((from = expbuf_shift_bytes(buf, &flen)) == NULL || expbuf_shift_num(buf, &key_index) != 0 || expbuf_shift_num(buf, &padding) != 0) { errno = 0; warnf("%s: failed to parse request", name); return -1; } if ((rsa = daemon_get_rsa(key_index)) == NULL) { errno = 0; warnf("%s: invalid key index:%zu\n", name, key_index); return -1; } ret = func((int)flen, from, to, rsa, (int)padding); expbuf_dispose(buf); expbuf_push_num(buf, ret); expbuf_push_bytes(buf, to, ret > 0 ? ret : 0); return 0; }
static int parse_opt(mem_region_t *mr, const char *opt) { assert(mr); assert(opt); if (!strncmp(opt, "bf:", 3)) { /* buffer size */ char *p; mr->bufsize = strtoul(opt + 3, &p, 0); if (*p == 'K') mr->bufsize *= 1024; else if (*p == 'M') mr->bufsize *= 1024 * 1024; else if (*p) return -1; } else if (!strncmp(opt, "bl:", 3)) { /* flash block map */ if (flash_parse_map(mr, opt + 3) < 0) { warnf("unable to parse flash block map `%s'\n", opt); return -1; } } else{ warnf("unrecognized memory map option `%s'\n", opt); return -1; } return 0; }
UBOOL FFileManagerWindows::InternalMove( const TCHAR* Dest, const TCHAR* Src, UBOOL Replace, UBOOL EvenIfReadOnly, UBOOL Attributes ) { MakeDirectory(*FFilename(Dest).GetPath(), TRUE); INT Result = MoveFileExW(Src,Dest, MOVEFILE_REPLACE_EXISTING | MOVEFILE_WRITE_THROUGH); if( !Result ) { // If the move failed, throw a warning but retry before we throw an error DWORD error = GetLastError(); warnf( NAME_Warning, TEXT("MoveFileExW was unable to move '%s' to '%s', retrying... (GetLastE-r-r-o-r: %d)"), Src, Dest, error ); // Wait just a little bit (i.e. a totally arbitrary amount)... Sleep(500); // Try again Result = MoveFileExW(Src, Dest, MOVEFILE_REPLACE_EXISTING | MOVEFILE_WRITE_THROUGH); if( !Result ) { error = GetLastError(); warnf( NAME_Error, TEXT("Error moving file '%s' to '%s' (GetLastError: %d)"), Src, Dest, error ); } else { warnf( NAME_Warning, TEXT("MoveFileExW recovered during retry!") ); } } return (Result != 0); }
/** * Constructor, initializing all member variables. It also reads .ini settings and caches them and creates the * database connection object and attempts to connect if bUseTaskPerfMemDatabase is set. */ FTaskPerfMemDatabase::FTaskPerfMemDatabase() : FTaskDatabase() { #if !UDK // Read the ini settings and store them in the struct to aid debugging. GConfig->GetBool(TEXT("TaskPerfMemDatabase"), TEXT("bUseTaskPerfMemDatabase" ), bUseTaskPerfMemDatabase, GEngineIni); // Only do work if task tracking is enabled. if( bUseTaskPerfMemDatabase == TRUE ) { // only attempt to get the data when we want to use the TaskPerfMemDatabase verify(GConfig->GetString( TEXT("TaskPerfMemDatabase"), TEXT("ConnectionString"), ConnectionString, GEngineIni )); verify(GConfig->GetString( TEXT("TaskPerfMemDatabase"), TEXT("RemoteConnectionIP"), RemoteConnectionIP, GEngineIni )); verify(GConfig->GetString( TEXT("TaskPerfMemDatabase"), TEXT("RemoteConnectionStringOverride"), RemoteConnectionStringOverride, GEngineIni )); // Create the connection object; needs to be deleted via "delete". Connection = FDataBaseConnection::CreateObject(); // Try to open connection to DB - this is a synchronous operation. if( Connection->Open( *ConnectionString, *RemoteConnectionIP, *RemoteConnectionStringOverride ) == TRUE ) { warnf(NAME_DevDataBase,TEXT("Connection to \"%s\" or \"%s\" succeeded"), *ConnectionString, *RemoteConnectionIP); } // Connection failed :( else { warnf(NAME_DevDataBase,TEXT("Connection to \"%s\" or \"%s\" failed"), *ConnectionString, *RemoteConnectionIP); // Only delete object - no need to close as connection failed. delete Connection; Connection = NULL; } } #endif //#if !UDK }
static int sign_stub(struct expbuf_t *buf) { unsigned char *m, sigret[4096]; size_t type, m_len, key_index; RSA *rsa; unsigned siglen = 0; int ret; if (expbuf_shift_num(buf, &type) != 0 || (m = expbuf_shift_bytes(buf, &m_len)) == NULL || expbuf_shift_num(buf, &key_index) != 0) { errno = 0; warnf("%s: failed to parse request", __FUNCTION__); return -1; } if ((rsa = daemon_get_rsa(key_index)) == NULL) { errno = 0; warnf("%s: invalid key index:%zu", __FUNCTION__, key_index); return -1; } ret = RSA_sign((int)type, m, (unsigned)m_len, sigret, &siglen, rsa); expbuf_dispose(buf); expbuf_push_num(buf, ret); expbuf_push_bytes(buf, sigret, ret == 1 ? siglen : 0); return 0; }
/* create a local file for writing, return TRUE on success */ bool tool_create_output_file(struct OutStruct *outs) { struct GlobalConfig *global = outs->config->global; FILE *file; if(!outs->filename || !*outs->filename) { warnf(global, "Remote filename has no length!\n"); return FALSE; } if(outs->is_cd_filename) { /* don't overwrite existing files */ file = fopen(outs->filename, "rb"); if(file) { fclose(file); warnf(global, "Refusing to overwrite %s: %s\n", outs->filename, strerror(EEXIST)); return FALSE; } } /* open file for writing */ file = fopen(outs->filename, "wb"); if(!file) { warnf(global, "Failed to create the file %s: %s\n", outs->filename, strerror(errno)); return FALSE; } outs->s_isreg = TRUE; outs->fopened = TRUE; outs->stream = file; outs->bytes = 0; outs->init = 0; return TRUE; }
int qatom_main(int argc, char **argv) { enum qatom_atom { _EXPLODE=0, _COMPARE, _PRINT } action = _EXPLODE; const char *format = QATOM_FORMAT; depend_atom *atom; depend_atom *atomc; int i; while ((i = GETOPT_LONG(QATOM, qatom, "")) != -1) { switch (i) { case 'F': format = optarg; break; case 'c': action = _COMPARE; break; case 'p': action = _PRINT; break; COMMON_GETOPTS_CASES(qatom) } } if (argc == optind) qatom_usage(EXIT_FAILURE); if (action == _COMPARE && (argc - optind) % 2) err("compare needs even number of arguments"); for (i = optind; i < argc; ++i) { atom = atom_explode(argv[i]); if (atom == NULL) { warnf("invalid atom: %s\n", argv[i]); continue; } switch (action) { case _COMPARE: i++; atomc = atom_explode(argv[i]); if (atomc == NULL) { warnf("invalid atom: %s\n", argv[i]); break; } printf("%s %s ", atom_to_string(atom), booga[atom_compare(atom, atomc)]); printf("%s\n", atom_to_string(atomc)); atom_implode(atomc); break; case _EXPLODE: qatom_printf(format, atom, verbose); putchar('\n'); break; case _PRINT: printf("%s\n", atom_to_string(atom)); break; } atom_implode(atom); } return EXIT_SUCCESS; }
/** * Constructor, initializing all member variables. It also reads .ini settings and caches them and creates the * database connection object and attempts to connect if bUseTaskPerfTracking is set. */ FTaskPerfTracker::FTaskPerfTracker() : FTaskDatabase() , bUseTaskPerfTracking(FALSE) , TimeSpentTalkingWithDB(0) { #if !UDK // Read the ini settings and store them in the struct to aid debugging. GConfig->GetBool(TEXT("TaskPerfTracking"), TEXT("bUseTaskPerfTracking" ), bUseTaskPerfTracking, GEngineIni); // Only do work if task tracking is enabled. if( bUseTaskPerfTracking ) { // only attempt to get the data when we want to use the TaskPerfTracking verify(GConfig->GetString( TEXT("TaskPerfTracking"), TEXT("ConnectionString"), ConnectionString, GEngineIni )); verify(GConfig->GetString( TEXT("TaskPerfTracking"), TEXT("RemoteConnectionIP"), RemoteConnectionIP, GEngineIni )); verify(GConfig->GetString( TEXT("TaskPerfTracking"), TEXT("RemoteConnectionStringOverride"), RemoteConnectionStringOverride, GEngineIni )); // Track time spent talking with DB to ensure we don't introduce nasty stalls. SCOPE_SECONDS_COUNTER(TimeSpentTalkingWithDB); // Create the connection object; needs to be deleted via "delete". Connection = FDataBaseConnection::CreateObject(); // Try to open connection to DB - this is a synchronous operation. if( Connection->Open( *ConnectionString, *RemoteConnectionIP, *RemoteConnectionStringOverride ) == TRUE ) { warnf(NAME_DevDataBase,TEXT("Connection to \"%s\" or \"%s\" succeeded"), *ConnectionString, *RemoteConnectionIP); // Create format string for calling procedure. FormatString = FString(TEXT("EXEC BEGINRUN ")); #if _DEBUG FormatString += TEXT(" @ConfigName='DEBUG', "); #elif FINAL_RELEASE_DEBUGCONSOLE FormatString += TEXT(" @ConfigName='FINAL_RELEASE_DEBUGCONSOLE', "); #elif FINAL_RELEASE FormatString += TEXT(" @ConfigName='FINAL_RELEASE', "); #else FormatString += TEXT(" @ConfigName='RELEASE', "); #endif FormatString += FString(TEXT("@GameName='")) + GGameName + TEXT("', @MachineName='") + appComputerName() + TEXT("', "); FormatString += FString(TEXT("@CmdLine='")) + appCmdLine() + TEXT("', @UserName='******', "); FormatString += FString(TEXT("@TaskDescription='%s', @TaskParameter='%s', @Changelist=")) + appItoa(GBuiltFromChangeList); } // Connection failed :( else { warnf(NAME_DevDataBase,TEXT("Connection to \"%s\" or \"%s\" failed"), *ConnectionString, *RemoteConnectionIP); // Only delete object - no need to close as connection failed. delete Connection; Connection = NULL; } } #endif //#if !UDK }
int tool_sockopt_cb(void *userdata, curl_socket_t curlfd, curlsocktype purpose) { struct Configurable *config = userdata; int onoff = 1; /* this callback is only used if we ask for keepalives on the connection */ #if defined(TCP_KEEPIDLE) || defined(TCP_KEEPINTVL) int keepidle = (int)config->alivetime; #endif switch(purpose) { case CURLSOCKTYPE_IPCXN: if(setsockopt(curlfd, SOL_SOCKET, SO_KEEPALIVE, (void *)&onoff, sizeof(onoff)) < 0) { /* don't abort operation, just issue a warning */ SET_SOCKERRNO(0); warnf(config, "Could not set SO_KEEPALIVE!\n"); return 0; } else { if(config->alivetime) { #ifdef TCP_KEEPIDLE if(setsockopt(curlfd, IPPROTO_TCP, TCP_KEEPIDLE, (void *)&keepidle, sizeof(keepidle)) < 0) { /* don't abort operation, just issue a warning */ SET_SOCKERRNO(0); warnf(config, "Could not set TCP_KEEPIDLE!\n"); return 0; } #endif #ifdef TCP_KEEPINTVL if(setsockopt(curlfd, IPPROTO_TCP, TCP_KEEPINTVL, (void *)&keepidle, sizeof(keepidle)) < 0) { /* don't abort operation, just issue a warning */ SET_SOCKERRNO(0); warnf(config, "Could not set TCP_KEEPINTVL!\n"); return 0; } #endif #if !defined(TCP_KEEPIDLE) || !defined(TCP_KEEPINTVL) warnf(config, "Keep-alive functionality somewhat crippled due to " "missing support in your operating system!\n"); #endif } } break; default: break; } return 0; }
/** * Looks at the parameters and displays help based upon those parameters * * @param CmdLine the string containing the parameters for the commandlet */ INT UHelpCommandlet::Main(const FString& CmdLine) { TArray<FString> Params; TArray<FString> Ignored; // Parse the command line into an array of strings ParseCommandLine(*CmdLine,Params,Ignored); // Validate the number of params passed in if (Params.Num() >= 1) { // Load everything up so we can find both native and script classes LoadAllClasses(); warnf(TEXT("")); // Check for either "list" or "commandletname" if (Params.Num() == 1) { // Check for listing all commandlets if (appStricmp(TEXT("list"),*Params(0)) == 0) { ListAllCommandlets(); } else { // Try to load the commandlet so we can get the help info UClass* TheClass = LoadCommandlet(*Params(0)); if (TheClass != NULL) { DumpCommandletInfo(TheClass->GetDefaultObject<UCommandlet>()); } } } // Must be the webhelp option else { // Try to load the commandlet so we can get the URL info UClass* TheClass = LoadCommandlet(*Params(1)); if (TheClass != NULL) { // Get the default object so we can look at its props UCommandlet* DefObject = TheClass->GetDefaultObject<UCommandlet>(); if (DefObject->HelpWebLink.Len() > 0) { // Open a browser to the site specified in the default properties appLaunchURL(*DefObject->HelpWebLink); } } } } else { warnf(TEXT("\r\nUsage:\r\n\r\n%s"),*HelpUsage); } return 0; }
/** * Returns the set of column names for this Recordset. This is useful for determining * what you can actually ask the record set for without having to hard code those ahead of time. */ virtual TArray<FDatabaseColumnInfo> GetColumnNames() const { TArray<FDatabaseColumnInfo> Retval; if( !ADORecordSet->BOF || !ADORecordSet->ADOEOF ) { ADORecordSet->MoveFirst(); for( SWORD i = 0; i < ADORecordSet->Fields->Count; ++i ) { _bstr_t bstrName = ADORecordSet->Fields->Item[i]->Name; _variant_t varValue = ADORecordSet->Fields->Item[i]->Value; ADODB::DataTypeEnum DataType = ADORecordSet->Fields->Item[i]->Type; FDatabaseColumnInfo NewInfo; NewInfo.ColumnName = FString((TCHAR*)_bstr_t(bstrName)); // from http://www.w3schools.com/ado/prop_field_type.asp#datatypeenum switch( DataType ) { case ADODB::adInteger: case ADODB::adBigInt: NewInfo.DataType = DBT_INT; break; case ADODB::adSingle: case ADODB::adDouble: NewInfo.DataType = DBT_FLOAT; break; case ADODB::adWChar: case ADODB::adVarWChar: NewInfo.DataType = DBT_STRING; break; default: warnf( NAME_DevDataBase, TEXT("Unable to find a EDataBaseUE3Types (%s) from DODB::DataTypeEnum DataType: %d "), *NewInfo.ColumnName, static_cast<INT>(DataType) ); NewInfo.DataType = DBT_UNKOWN; break; } Retval.AddItem( NewInfo ); } } // here for debugging as this code is new. for( INT i = 0; i < Retval.Num(); ++ i ) { warnf( TEXT( "ColumnName %d: Name: %s Type: %d"), i, *Retval(i).ColumnName, static_cast<INT>(Retval(i).DataType) ); } return Retval; }
/* scan a directory for Mach-O files and print when we find one */ static int scanmacho_dir(const char *path) { register DIR *dir; register struct dirent *dentry; struct stat st_top, st; char buf[__PAX_UTILS_PATH_MAX]; size_t pathlen = 0, len = 0; int ret = 0; /* make sure path exists */ if (lstat(path, &st_top) == -1) { if (be_verbose > 2) printf("%s: does not exist\n", path); return 1; } /* ok, if it isn't a directory, assume we can open it */ if (!S_ISDIR(st_top.st_mode)) return scanmacho_file(path, &st_top); /* now scan the dir looking for fun stuff */ if ((dir = opendir(path)) == NULL) { warnf("could not opendir %s: %s", path, strerror(errno)); return 1; } if (be_verbose > 1) printf("%s: scanning dir\n", path); pathlen = strlen(path); while ((dentry = readdir(dir))) { if (!strcmp(dentry->d_name, ".") || !strcmp(dentry->d_name, "..")) continue; len = (pathlen + 1 + strlen(dentry->d_name) + 1); if (len >= sizeof(buf)) { warnf("Skipping '%s': len > sizeof(buf); %lu > %lu\n", path, (unsigned long)len, (unsigned long)sizeof(buf)); continue; } snprintf(buf, sizeof(buf), "%s%s%s", path, (path[pathlen-1] == '/') ? "" : "/", dentry->d_name); if (lstat(buf, &st) != -1) { if (S_ISREG(st.st_mode)) ret = scanmacho_file(buf, &st); else if (dir_recurse && S_ISDIR(st.st_mode)) { if (dir_crossmount || (st_top.st_dev == st.st_dev)) ret = scanmacho_dir(buf); } } } closedir(dir); return ret; }
static unsigned parse_relax(const char *str) { char *copy = strdup(str); assert(copy); unsigned mask = 0; char *token = strtok(copy, ","); while (token != NULL) { if (strcmp(token, "prefer-explicit") == 0) mask |= RELAX_PREFER_EXPLICT; else if (strcmp(token, "locally-static") == 0) mask |= RELAX_LOCALLY_STATIC; else if (strcmp(token, "generic-static") == 0) { warnf("relax option 'generic-static' is deprecated: use " "'locally-static' instead"); mask |= RELAX_LOCALLY_STATIC; } else if (strcmp(token, "universal-bound") == 0) mask |= RELAX_UNIVERSAL_BOUND; else if (strcmp(token, "pure-files") == 0) mask |= RELAX_PURE_FILES; else fatal("invalid relax option '%s'", token); token = strtok(NULL, ","); } free(copy); return mask; }
/** * Trys to load the UClass for the commandlet that was requested * * @param CommandletName the name of the commandlet to load */ static UClass* LoadCommandlet(const TCHAR* CommandletName) { // Try to find the UClass for the commandlet (works for all but script classes) UClass* Class = FindObject<UClass>(ANY_PACKAGE,CommandletName,FALSE); // Don't accept classes that are not commandlets... if (!Class->IsChildOf(UCommandlet::StaticClass())) { Class = NULL; } // Name mangle by appending Commandlet FString AppendedName(CommandletName); AppendedName += TEXT("Commandlet"); if (Class == NULL) { Class = FindObject<UClass>(ANY_PACKAGE,*AppendedName,FALSE); // Don't accept classes that are not commandlets... if (!Class->IsChildOf(UCommandlet::StaticClass())) { Class = NULL; } } // Let the user know that the commandlet wasn't found if (Class == NULL) { warnf(TEXT("Failed to load commandlet %s"),CommandletName); } return Class; }
char *target_gets(target_context_t *tc, char *s, int size) { unsigned char c; char *p = s; assert(tc); assert(s); assert(size >= 0); if (!size--) return s; while (size--) { ssize_t nread = xread(tc->portfd, &c, 1); if(nread == ERROR_VALUE) break; if(nread == 0) break; //timeout if (c == '\r') ++size; else *p++ = c; if (c == '\n') break; } *p = '\0'; /* report error lines */ if (ok_or_ng(s) < 0) warnf("from target: %s", s); return s; }
int target_get_response(target_context_t *tc) { char buf [LINE_LENGTH]; assert(tc); switch (ok_or_ng(target_gets(tc, buf, sizeof buf))) { case 1: msg("target: +OK\n"); break; case 2: msg("target: +GO\n"); break; case 0: #ifndef WIN32 warn("target didn't respond with +OK or -NG\n"); warnf("unknown response `%s'\n", buf); #endif return -1; case -1: /* warning message is generated by target_gets() */ return -1; default: assert(0); return -1; } return 0; }
const char *execute(S32 argc, const char *argv[]) { #ifdef TORQUE_MULTITHREAD if(isMainThread()) { #endif Namespace::Entry *ent; StringTableEntry funcName = StringTable->insert(argv[0]); ent = Namespace::global()->lookup(funcName); if(!ent) { warnf(ConsoleLogEntry::Script, "%s: Unknown command.", argv[0]); // Clean up arg buffers, if any. STR.clearFunctionOffset(); return ""; } return ent->execute(argc, argv, &gEvalState); #ifdef TORQUE_MULTITHREAD } else { SimConsoleThreadExecCallback cb; SimConsoleThreadExecEvent *evt = new SimConsoleThreadExecEvent(argc, argv, false, &cb); Sim::postEvent(Sim::getRootGroup(), evt, Sim::getCurrentTime()); return cb.waitForResult(); } #endif }
static bool link_find_native_library(lib_t lib, tree_t unit, FILE *deps) { #ifdef ENABLE_NATIVE ident_t name = tree_ident(unit); char *so_name = xasprintf("_%s.so", istr(name)); lib_mtime_t so_mt; if (!lib_stat(lib, so_name, &so_mt)) { free(so_name); return false; } lib_mtime_t unit_mt = lib_mtime(lib, name); if (unit_mt > so_mt) { warnf("unit %s has stale native shared library", istr(name)); free(so_name); return false; } if (deps != NULL) { char path[PATH_MAX]; lib_realpath(lib, so_name, path, sizeof(path)); fprintf(deps, "%s\n", path); } free(so_name); return true; #else // ENABLE_NATIVE return false; #endif // ENABLE_NATIVE }
/** * Executes the passed in command on the database. The caller is responsible for deleting * the created RecordSet. * * @param CommandString Command to execute * @param RecordSet Reference to recordset pointer that is going to hold result * * @return TRUE if execution was successful, FALSE otherwise */ virtual UBOOL Execute( const TCHAR* CommandString, FDataBaseRecordSet*& RecordSet ) { // Initialize return value. RecordSet = NULL; try { // Create instance of record set. ADODB::_RecordsetPtr ADORecordSet = NULL; ADORecordSet.CreateInstance(__uuidof(ADODB::Recordset) ); // Execute the passed in command on the record set. The recordset returned will be in open state so you can call Get* on it directly. ADORecordSet->Open( CommandString, _variant_t((IDispatch *) DataBaseConnection), ADODB::adOpenStatic, ADODB::adLockReadOnly, ADODB::adCmdText ); // Create record set from returned data. RecordSet = new FADODataBaseRecordSet( ADORecordSet ); } catch(_com_error &Error) { // Log error and return. This will not log if called before appInit due to use of debugf. TCHAR* ErrorDescription = (TCHAR*) Error.Description(); warnf(NAME_DevDataBase,TEXT("Failure executing command [%s] [%s]"),CommandString,ErrorDescription); // Delete record set if it has already been created. delete RecordSet; RecordSet = NULL; } return RecordSet != NULL; }
bool CConfigManager::getConfig(const char* name, CConfigTable& table) { CGuard guard(m_mutex); int ret = applySuccess; if (strcmp(name, "All") == 0) { table = m_configAll; tracef("CConfigManager::getConfig get all Configs.\n"); return true; } if(m_configDefault[name].type() == Json::nullValue) { warnf("CConfigManager::getConfig '%s', but default config is not set yet!\n", name); // 直接返回,不做默认配置替换和配置校验 table = m_configAll[name]; return table.type() != Json::nullValue; } table = m_configAll[name]; tracepoint(); infof("name is [%s]\n", name); //std::cout << table << std::endl; return table.type() != Json::nullValue; }
void dumpeasysrc(struct Configurable *config) { struct curl_slist *ptr; char *o = config->libcurl; if(o) { FILE *out; bool fopened = FALSE; if(strcmp(o, "-")) { out = fopen(o, "wt"); fopened = TRUE; } else out = stdout; if(!out) warnf(config, "Failed to open %s to write libcurl code!\n", o); else { int i; const char *c; for(i=0; ((c = srchead[i]) != '\0'); i++) fprintf(out, "%s\n", c); /* Declare variables used for complex setopt values */ for(ptr=easysrc_decl; ptr; ptr = ptr->next) fprintf(out, " %s\n", ptr->data); /* Set up complex values for setopt calls */ if(easysrc_data) { fprintf(out, "\n"); for(ptr=easysrc_data; ptr; ptr = ptr->next) fprintf(out, " %s\n", ptr->data); } fprintf(out, "\n"); for(ptr=easysrc_code; ptr; ptr = ptr->next) { if(ptr->data[0]) { fprintf(out, " %s\n", ptr->data); } else { fprintf(out, "\n"); } } for(ptr=easysrc_clean; ptr; ptr = ptr->next) fprintf(out, " %s\n", ptr->data); for(i=0; ((c = srcend[i]) != '\0'); i++) fprintf(out, "%s\n", c); if(fopened) fclose(out); } } easysrc_free(); }
int ftpcccmethod(struct Configurable *config, const char *str) { if(curlx_raw_equal("passive", str)) return CURLFTPSSL_CCC_PASSIVE; if(curlx_raw_equal("active", str)) return CURLFTPSSL_CCC_ACTIVE; warnf(config, "unrecognized ftp CCC method '%s', using default\n", str); return CURLFTPSSL_CCC_PASSIVE; }
static int shell_cmd_watch(ClientData cd, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { const char *help = "watch - Trace changes to a signal\n" "\n" "Usage: watch SIGNALS...\n" "\n" "Prints a message every time an update occurs to a signal listed." "\n" "Examples:\n" " watch [signals {clk}] Trace updates to all signals named clk\n"; if (show_help(objc, objv, help)) return TCL_OK; if (objc == 1) { warnf("nothing to watch (try -help for usage)"); return TCL_OK; } hash_t *decl_hash = (hash_t *)cd; for (int i = 1; i < objc; i++) { int length; if (Tcl_ListObjLength(interp, objv[i], &length) != TCL_OK) return TCL_ERROR; for (int j = 0; j < length; j++) { Tcl_Obj *obj; if (Tcl_ListObjIndex(interp, objv[i], j, &obj) != TCL_OK) return TCL_ERROR; const char *str = Tcl_GetString(obj); tree_t t = hash_get(decl_hash, ident_new(str)); if (t == NULL) return tcl_error(interp, "object not found: %s", str); if (t == NULL) return tcl_error(interp, "object not found: %s", str); else if (tree_kind(t) != T_SIGNAL_DECL) return tcl_error(interp, "not a signal: %s", str); else if (type_is_array(tree_type(t))) return tcl_error(interp, "only scalar signals may be watched"); // TODO: make this work for arrays slave_watch_msg_t msg = { .index = tree_index(t) }; slave_post_msg(SLAVE_WATCH, &msg, sizeof(msg)); } } return TCL_OK; }
/** * Loads all of the code packages completely (for script classes). Then iterates * through the UClass-es finding all commandlets and dumping information on them */ static void ListAllCommandlets(void) { warnf(TEXT("%-40s %s"),TEXT("Commandlet"),TEXT("Description")); warnf(TEXT("--------------------------------------------------------------------------------")); // Now iterate through all UClass-es looking for commandlets for (TObjectIterator<UClass> It; It; ++It) { UCommandlet* DefObject = Cast<UCommandlet>(It->GetDefaultObject()); if (DefObject != NULL) { // Ignore commandlets that can't be created if (It->HasAnyClassFlags(CLASS_Abstract) == FALSE) { const FString& Name = GetCommandletName(DefObject); warnf(TEXT("%-40s - %s"),*Name,*DefObject->HelpDescription); } } } }
long delegation(struct Configurable *config, char *str) { if(curlx_raw_equal("none", str)) return CURLGSSAPI_DELEGATION_NONE; if(curlx_raw_equal("policy", str)) return CURLGSSAPI_DELEGATION_POLICY_FLAG; if(curlx_raw_equal("always", str)) return CURLGSSAPI_DELEGATION_FLAG; warnf(config, "unrecognized delegation method '%s', using none\n", str); return CURLGSSAPI_DELEGATION_NONE; }
static mem_type_t region_type(const char *type_name) { if (!strcmp(type_name, "FLA")) return MEMTYPE_FLASH; if (!strcmp(type_name, "RAM")) return MEMTYPE_RAM; if (!strcmp(type_name, "ROM")) return MEMTYPE_ROM; warnf("unrecognized region type `%s'\n", type_name); return MEMTYPE_INVALID; }
int ftpfilemethod(struct Configurable *config, const char *str) { if(curlx_raw_equal("singlecwd", str)) return CURLFTPMETHOD_SINGLECWD; if(curlx_raw_equal("nocwd", str)) return CURLFTPMETHOD_NOCWD; if(curlx_raw_equal("multicwd", str)) return CURLFTPMETHOD_MULTICWD; warnf(config, "unrecognized ftp file method '%s', using default\n", str); return CURLFTPMETHOD_MULTICWD; }
int ftpcccmethod(struct OperationConfig *config, const char *str) { if(curl_strequal("passive", str)) return CURLFTPSSL_CCC_PASSIVE; if(curl_strequal("active", str)) return CURLFTPSSL_CCC_ACTIVE; warnf(config->global, "unrecognized ftp CCC method '%s', using default\n", str); return CURLFTPSSL_CCC_PASSIVE; }
static void *daemon_conn_thread(void *_sock_fd) { int sock_fd = (int)((char *)_sock_fd - (char *)NULL); struct expbuf_t buf = {}; unsigned char auth_token[NEVERBLEED_AUTH_TOKEN_SIZE]; /* authenticate */ if (read_nbytes(sock_fd, &auth_token, sizeof(auth_token)) != 0) { warnf("failed to receive authencication token from client"); goto Exit; } if (memcmp(auth_token, daemon_auth_token, NEVERBLEED_AUTH_TOKEN_SIZE) != 0) { warnf("client authentication failed"); goto Exit; } while (1) { char *cmd; if (expbuf_read(&buf, sock_fd) != 0) { if (errno != 0) warnf("read error"); break; } if ((cmd = expbuf_shift_str(&buf)) == NULL) { errno = 0; warnf("failed to parse request"); break; } if (strcmp(cmd, "priv_enc") == 0) { if (priv_enc_stub(&buf) != 0) break; } else if (strcmp(cmd, "priv_dec") == 0) { if (priv_dec_stub(&buf) != 0) break; } else if (strcmp(cmd, "sign") == 0) { if (sign_stub(&buf) != 0) break; } else if (strcmp(cmd, "load_key") == 0) { if (load_key_stub(&buf) != 0) break; } else if (strcmp(cmd, "setuidgid") == 0) { if (setuidgid_stub(&buf) != 0) break; } else { warnf("unknown command:%s", cmd); break; } if (expbuf_write(&buf, sock_fd) != 0) { warnf(errno != 0 ? "write error" : "connection closed by client"); break; } expbuf_dispose(&buf); } Exit: expbuf_dispose(&buf); close(sock_fd); return NULL; }
static int shell_cmd_unwatch(ClientData cd, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { const char *help = "unwatch - Stop tracing signals\n" "\n" "Usage: unwatch SIGNALS...\n" "\n" "Clears any watch callback on SIGNALS. Note this will also stop any\n" "VCD or other waveform capture for these signals.\n" "\n" "Examples:\n" " watch [signals {clk}] Stop tracing updates to clk\n"; if (show_help(objc, objv, help)) return TCL_OK; if (objc == 1) { warnf("nothing to unwatch (try -help for usage)"); return TCL_OK; } hash_t *decl_hash = (hash_t *)cd; // TODO: refactor this code to avoid duplication with "watch" and "show" for (int i = 1; i < objc; i++) { int length; if (Tcl_ListObjLength(interp, objv[i], &length) != TCL_OK) return TCL_ERROR; for (int j = 0; j < length; j++) { Tcl_Obj *obj; if (Tcl_ListObjIndex(interp, objv[i], j, &obj) != TCL_OK) return TCL_ERROR; const char *str = Tcl_GetString(obj); tree_t t = hash_get(decl_hash, ident_new(str)); if (t == NULL) return tcl_error(interp, "object not found: %s", str); else if (tree_kind(t) != T_SIGNAL_DECL) return tcl_error(interp, "not a signal: %s", str); slave_unwatch_msg_t msg = { .index = tree_index(t) }; slave_post_msg(SLAVE_UNWATCH, &msg, sizeof(msg)); } } return TCL_OK; }