U8 const *findCmdLineArg(char *prefix) { int pn = strlen(prefix); CMD_LINE const * cl = GetCmdLine(); int n=cl->Length; U8 const * cmdLine = &(cl->Data[0]); for(int i=0; i<n; i++, cmdLine++) if(prefix[0]==cmdLine[0]) if(strncmp(prefix,(char*)cmdLine,pn)==0) return cmdLine+pn; return NULL; }
BOOL CSZCommandLine::Execute(LPCTSTR lpszProcessName, BOOL bForceAdmin, BOOL bWaitProcess) { BOOL bRet = FALSE; PROCESS_INFORMATION processInfo; STARTUPINFO si = {sizeof(STARTUPINFO)}; CString strCmdLine; HANDLE hProcess = NULL; GetCmdLine(strCmdLine); if (bForceAdmin) { SHELLEXECUTEINFO sei = { sizeof(SHELLEXECUTEINFO) }; sei.fMask = SEE_MASK_NOCLOSEPROCESS; sei.hwnd = NULL; sei.lpVerb = _T("runas"); sei.lpFile = lpszProcessName; sei.lpParameters = (LPWSTR)(LPCWSTR)strCmdLine; sei.nShow = SW_SHOWNORMAL; bRet = ::ShellExecuteEx(&sei); hProcess = sei.hProcess; } else { bRet = ::CreateProcess( lpszProcessName, (LPWSTR)(LPCWSTR)strCmdLine, NULL, NULL, FALSE, 0, NULL, NULL, &si, &processInfo ); if (bRet) { ::CloseHandle(processInfo.hThread); hProcess = processInfo.hProcess; } } if (bRet) { if (bWaitProcess) { ::WaitForSingleObject(hProcess, INFINITE); } ::CloseHandle(hProcess); } return bRet; }
void Consumer_GetActionFromUser(uint8_t* action) { char buf[BUF_SIZE]; uint8_t defaultAction = *action; AJ_StartReadFromStdIn(); AJ_Printf("Please enter an action to perform on the recently received notification\n\t0=Nothing,\n\t1=Dismiss.\n"); AJ_Printf("Empty string or invalid input will default to %u\n", defaultAction); if (GetCmdLine(buf, BUF_SIZE)) { char stringType[4]; // Maximum decimal value for uint8_t is 255 which is 3 characters long *action = (uint8_t)atoi(buf); snprintf(stringType, 4, "%u", *action); if (!(strcmp(buf, stringType) == 0)) { //they do not match, it is not int AJ_Printf("Action is not an integer value. Defaulting to %u\n", defaultAction); *action = defaultAction; } } AJ_StopReadFromStdIn(); }
/** * A function that allows us to enter QA InputMode */ void Consumer_SetupEnv(uint8_t* inputMode, uint8_t* superAgentMode) { char* value = getenv("INPUT_MODE"); char buf[BUF_SIZE]; uint8_t defaultSuperAgentMode = *superAgentMode; if (value) { *inputMode = (uint8_t)atoi(value); } if (*inputMode) { AJ_StartReadFromStdIn(); AJ_Printf("Please enter 0=OFF or 1=ON to disable/enable SuperAgentMode. Default is %u\n", defaultSuperAgentMode); if (GetCmdLine(buf, BUF_SIZE)) { *superAgentMode = (uint8_t)atoi(buf); if (1 < *superAgentMode) { *superAgentMode = defaultSuperAgentMode; } } AJ_StopReadFromStdIn(); } }
void DoCmdFile( char *fname ) /**********************************/ /* start parsing the command */ { exe_format possible; f_handle file; size_t namelen; file_defext extension; char *namelnk; ResetCmdFile(); if( fname == NULL || *fname == '\0' ) { _ChkAlloc( fname, (10*1024) ); // arbitrarily large buffer that won't GetCmdLine( fname ); // be overflowed NewCommandSource( NULL, fname, COMMANDLINE ); } else { NewCommandSource( NULL, fname, ENVIRONMENT ); } if( IsStdOutConsole() ) { CmdFlags |= CF_TO_STDOUT; } while( *fname == ' ' ) { fname++; } if( QSysHelp( &Token.next ) ) { Help(); } if( *fname == '?' ) { Token.next = fname + 1; // skip question mark. Help(); #if defined( __UNIX__ ) } else if( *fname == '-' ) { #else } else if( *fname == '-' || *fname == '/' ) { #endif if( *(fname + 1) == '?' ) { Token.next = fname + 2; // skip /? Help(); } } if( *fname == '\0' ) { // go into interactive mode. Token.how = INTERACTIVE; Token.where = ENDOFLINE; LnkMsg( INF+MSG_PRESS_CTRL_Z, NULL ); } namelnk = GetEnvString( INIT_FILE_ENV ); file = ( namelnk != NULL ) ? FindPath( namelnk ) : NIL_FHANDLE; if( file == NIL_FHANDLE ) { namelnk = INIT_FILE_NAME; file = FindPath( namelnk ); } if( file != NIL_FHANDLE ) { fname = ChkStrDup( namelnk ); SetCommandFile( file, fname ); } if( Spawn( DoCmdParse ) ) { Ignite(); Suicide(); } GetExtraCommands(); if( !(LinkState & FMT_DECIDED) ) { /* restrict set to automatically decided ones */ #if defined( __QNX__ ) #define LAST_CHANCE ( MK_OS2_LX | MK_OS2_LE | MK_OS2_NE | MK_QNX ) #elif defined( __LINUX__ ) #define LAST_CHANCE ( MK_OS2_LX | MK_OS2_LE | MK_OS2_NE | MK_ELF ) #elif defined( __NT__ ) #define LAST_CHANCE ( MK_OS2_LX | MK_OS2_NE | MK_WINDOWS | MK_PE | MK_DOS_EXE | MK_WIN_VXD ) #else #define LAST_CHANCE ( MK_OS2_LX | MK_OS2_LE | MK_OS2_NE | MK_DOS_EXE | MK_PHAR_SIMPLE ) #endif HintFormat( LAST_CHANCE ); } else { /* restrict to a unique type */ for( possible = 1; possible != 0; possible *= 2 ) { if( FmtData.type & possible ) { FmtData.type = possible; break; } } } if( (FmtData.type & (MK_NOVELL | MK_DOS)) && (LinkFlags & INC_LINK_FLAG) ) { LnkMsg( FTL+MSG_FORMAT_BAD_OPTION, "s", "incremental" ); } #ifdef _NOVELL if( FmtData.type & MK_NOVELL ) { CmdNovFini(); } else #endif if( FmtData.type & MK_OVERLAYS ) { CmdOvlFini(); AddObjLib( "wovl.lib", LIB_PRIORITY_MIN ); // add a reference to wovl.lib } if( Name == NULL || !(CmdFlags & CF_HAVE_FILES) ) { Ignite(); LnkMsg( FTL+MSG_NO_FILES_FOUND, NULL ); } namelen = strlen( Name ); if( MapFlags & MAP_FLAG ) { if( MapFName == NULL ) { MapFName = FileName( Name, namelen, E_MAP, TRUE ); } } else { MapFlags = 0; // if main isn't set, don't set anything. } if( SymFileName == NULL && ( (CmdFlags & CF_SEPARATE_SYM) || (LinkFlags & OLD_DBI_FLAG) && (FmtData.type & MK_COM) ) ) { SymFileName = FileName( Name, namelen, E_SYM, TRUE ); } if( FmtData.make_implib && FmtData.implibname == NULL ) { if( FmtData.make_impfile ) { extension = E_LBC; } else { extension = E_LIBRARY; } FmtData.implibname = FileName( Name, namelen, extension, TRUE ); } CheckTraces(); BurnUtils(); PruneSystemList(); NumberSections(); DBIInit(); }