void KCmdLineArgs::saveAppArgs( QDataStream &ds) { if (!s->parsed) s->parseAllArgs(); // Remove Qt and KDE options. s->removeArgs("qt"); s->removeArgs("kde"); s->removeArgs("kuniqueapp"); ds << s->mCwd; uint count = s->argsList ? s->argsList->count() : 0; ds << count; if (!count) return; KCmdLineArgsList::Iterator args; for(args = s->argsList->begin(); args != s->argsList->end(); ++args) { ds << (*args)->d->id; (*args)->d->save(ds); } }
void KCmdLineArgs::loadAppArgs( QDataStream &ds) { s->parsed = true; // don't reparse argc/argv! // Remove Qt and KDE options. s->removeArgs("qt"); s->removeArgs("kde"); s->removeArgs("kuniqueapp"); KCmdLineArgsList::Iterator args; if ( s->argsList ) { for(args = s->argsList->begin(); args != s->argsList->end(); ++args) { (*args)->clear(); } } if (ds.atEnd()) return; QByteArray qCwd; ds >> qCwd; s->mCwd = qCwd; uint count; ds >> count; while(count--) { QByteArray id; ds >> id; Q_ASSERT( s->argsList ); bool found = false; for(args = s->argsList->begin(); args != s->argsList->end(); ++args) { if ((*args)->d->id == id) { (*args)->d->load(ds); found = true; break; } } if (!found) { kWarning() << "Argument definitions for" << id << "not found!"; // The next ds >> id will do nonsensical things... } } s->parsed = true; }
QVRVNCViewer::QVRVNCViewer(int& argc, char* argv[]) : _wantExit(false), _argc(argc), _argv(argv), _vncClient(NULL), _vncWidth(0), _vncHeight(0) { _qvrApp = this; bool haveScreenDef = false; bool haveValidScreenDef = false; for (int i = 1; i < _argc; i++) { if (strcmp(_argv[i], "--wall") == 0 && i < _argc - 1) { haveScreenDef = true; haveValidScreenDef = parseWall(_argv[i + 1], _screenWall); _screenType = screenTypeWall; removeArgs(_argc, _argv, i, 2); } else if (strncmp(_argv[i], "--wall=", 7) == 0) { haveScreenDef = true; haveValidScreenDef = parseWall(_argv[i] + 7, _screenWall); _screenType = screenTypeWall; removeArgs(_argc, _argv, i, 1); } else if (strcmp(_argv[i], "--cylinder") == 0 && i < _argc - 1) { haveScreenDef = true; haveValidScreenDef = parseCylinder(_argv[i + 1], _screenCylinder); _screenType = screenTypeCylinder; removeArgs(_argc, _argv, i, 2); } else if (strncmp(_argv[i], "--cylinder=", 11) == 0) { haveScreenDef = true; haveValidScreenDef = parseCylinder(_argv[i] + 11, _screenCylinder); _screenType = screenTypeCylinder; removeArgs(_argc, _argv, i, 1); } } if (!haveScreenDef) std::cerr << "No screen geometry given; using default wall" << std::endl; else if (!haveValidScreenDef) std::cerr << "Screen geometry invalid; falling back to default wall" << std::endl; if (!haveScreenDef || !haveValidScreenDef) { _screenType = screenTypeWall; _screenWall[0] = -1.0f; _screenWall[1] = -1.0f + QVRObserverConfig::defaultEyeHeight; _screenWall[2] = -3.0f; _screenWall[3] = +1.0f; _screenWall[4] = -1.0f + QVRObserverConfig::defaultEyeHeight; _screenWall[5] = -3.0f; _screenWall[6] = -1.0f; _screenWall[7] = +1.0f + QVRObserverConfig::defaultEyeHeight; _screenWall[8] = -3.0f; } }
void TSHPath::RemoveArgs(LPTSTR pszPath) { static TModuleProcV1<LPTSTR> removeArgs(GetModule(), RemoveArgsStr); removeArgs(pszPath); }
static void processTunnelArgs(char **remoteHost, int *remotePort, int localPort, int *pargc, char **argv, int tunnelArgIndex) { char *pdisplay; if (tunnelArgIndex >= *pargc - 1) usage(); pdisplay = strchr(argv[*pargc - 1], ':'); if (pdisplay == NULL || pdisplay == argv[*pargc - 1]) usage(); *pdisplay++ = '\0'; if (strspn(pdisplay, "-0123456789") != strlen(pdisplay)) usage(); *remotePort = atoi(pdisplay); if (*remotePort < 100) *remotePort += SERVER_PORT_OFFSET; sprintf(lastArgv, "localhost::%d", localPort); *remoteHost = argv[*pargc - 1]; argv[*pargc - 1] = lastArgv; removeArgs(pargc, argv, tunnelArgIndex, 1); }
int OSPExampleViewer::parseCommandLine(int &ac, const char **&av) { for (int i = 1; i < ac; i++) { const std::string arg = av[i]; if (arg == "--fullscreen") { fullscreen = true; removeArgs(ac, av, i, 1); --i; } else if (arg == "--motionSpeed") { motionSpeed = atof(av[i + 1]); removeArgs(ac, av, i, 2); --i; } else if (arg == "--searchText") { initialTextForNodeSearch = av[i + 1]; removeArgs(ac, av, i, 2); --i; } } return 0; }
bool CmdWhere::onServer(DebuggerProxy &proxy) { if (m_type == KindOfWhereAsync) { m_stacktrace = createAsyncStacktrace(); } else { m_stacktrace = g_vmContext->debugBacktrace(false, true, false); if (!m_stackArgs) { removeArgs(); } } return proxy.sendToClient(this); }
static void processViaArgs(char **gatewayHost, char **remoteHost, int *remotePort, int localPort, int *pargc, char **argv, int tunnelArgIndex) { char *colonPos; int len, portOffset; int disp; if (tunnelArgIndex >= *pargc - 2) usage(); colonPos = strchr(argv[*pargc - 1], ':'); if (colonPos == NULL) { /* No colon -- use default port number */ *remotePort = SERVER_PORT_OFFSET; } else { *colonPos++ = '\0'; len = strlen(colonPos); portOffset = SERVER_PORT_OFFSET; if (colonPos[0] == ':') { /* Two colons -- interpret as a port number */ colonPos++; len--; portOffset = 0; } if (!len || strspn(colonPos, "-0123456789") != len) { usage(); } disp = atoi(colonPos); if (portOffset != 0 && disp >= 100) portOffset = 0; *remotePort = disp + portOffset; } sprintf(lastArgv, "localhost::%d", localPort); *gatewayHost = argv[tunnelArgIndex + 1]; if (argv[*pargc - 1][0] != '\0') *remoteHost = argv[*pargc - 1]; argv[*pargc - 1] = lastArgv; removeArgs(pargc, argv, tunnelArgIndex, 2); }
void GLUTAPIENTRY glutInit(int *argcp, char **argv) { char *display = NULL; char *str, *geometry = NULL; #ifdef OLD_VMS struct timeval6 unused; #else struct timeval unused; #endif int i; if (__glutDisplay) { __glutWarning("glutInit being called a second time."); return; } /* Determine temporary program name. */ str = strrchr(argv[0], '/'); if (str == NULL) { __glutProgramName = argv[0]; } else { __glutProgramName = str + 1; } /* Make private copy of command line arguments. */ __glutArgc = *argcp; __glutArgv = (char **) malloc(__glutArgc * sizeof(char *)); if (!__glutArgv) __glutFatalError("out of memory."); for (i = 0; i < __glutArgc; i++) { __glutArgv[i] = __glutStrdup(argv[i]); if (!__glutArgv[i]) __glutFatalError("out of memory."); } /* determine permanent program name */ str = strrchr(__glutArgv[0], '/'); if (str == NULL) { __glutProgramName = __glutArgv[0]; } else { __glutProgramName = str + 1; } /* parse arguments for standard options */ for (i = 1; i < __glutArgc; i++) { if (!strcmp(__glutArgv[i], "-display")) { #if defined(_WIN32) __glutWarning("-display option not supported by Win32 GLUT."); #endif if (++i >= __glutArgc) { __glutFatalError( "follow -display option with X display name."); } display = __glutArgv[i]; removeArgs(argcp, &argv[1], 2); } else if (!strcmp(__glutArgv[i], "-geometry")) { if (++i >= __glutArgc) { __glutFatalError( "follow -geometry option with geometry parameter."); } geometry = __glutArgv[i]; removeArgs(argcp, &argv[1], 2); } else if (!strcmp(__glutArgv[i], "-direct")) { #if defined(_WIN32) __glutWarning("-direct option not supported by Win32 GLUT."); #endif if (!__glutTryDirect) __glutFatalError( "cannot force both direct and indirect rendering."); __glutForceDirect = GL_TRUE; removeArgs(argcp, &argv[1], 1); } else if (!strcmp(__glutArgv[i], "-indirect")) { #if defined(_WIN32) __glutWarning("-indirect option not supported by Win32 GLUT."); #endif if (__glutForceDirect) __glutFatalError( "cannot force both direct and indirect rendering."); __glutTryDirect = GL_FALSE; removeArgs(argcp, &argv[1], 1); } else if (!strcmp(__glutArgv[i], "-iconic")) { __glutIconic = GL_TRUE; removeArgs(argcp, &argv[1], 1); } else if (!strcmp(__glutArgv[i], "-gldebug")) { __glutDebug = GL_TRUE; removeArgs(argcp, &argv[1], 1); } else if (!strcmp(__glutArgv[i], "-sync")) { #if defined(_WIN32) __glutWarning("-sync option not supported by Win32 GLUT."); #endif synchronize = GL_TRUE; removeArgs(argcp, &argv[1], 1); } else { /* Once unknown option encountered, stop command line processing. */ break; } } #if defined(__OS2__) __glutOpenOS2Connection(display); #elif defined(_WIN32) __glutOpenWin32Connection(display); #else __glutOpenXConnection(display); #endif if (geometry) { int flags, x, y, width, height; /* Fix bogus "{width|height} may be used before set" warning */ width = 0; height = 0; flags = XParseGeometry(geometry, &x, &y, (unsigned int *) &width, (unsigned int *) &height); if (WidthValue & flags) { /* Careful because X does not allow zero or negative width windows */ if (width > 0) __glutInitWidth = width; } if (HeightValue & flags) { /* Careful because X does not allow zero or negative height windows */ if (height > 0) __glutInitHeight = height; } glutInitWindowSize(__glutInitWidth, __glutInitHeight); if (XValue & flags) { if (XNegative & flags) x = DisplayWidth(__glutDisplay, __glutScreen) + x - __glutSizeHints.width; /* Play safe: reject negative X locations */ if (x >= 0) __glutInitX = x; } if (YValue & flags) { if (YNegative & flags) y = DisplayHeight(__glutDisplay, __glutScreen) + y - __glutSizeHints.height; /* Play safe: reject negative Y locations */ if (y >= 0) __glutInitY = y; } glutInitWindowPosition(__glutInitX, __glutInitY); } __glutInitTime(&unused); /* check if GLUT_FPS env var is set */ { const char *fps = getenv("GLUT_FPS"); if (fps) { sscanf(fps, "%d", &__glutFPS); if (__glutFPS <= 0) __glutFPS = 5000; /* 5000 milliseconds */ } } }
bool KShortUriFilter::filterUri( KUriFilterData& data ) const { /* * Here is a description of how the shortURI deals with the supplied * data. First it expands any environment variable settings and then * deals with special shortURI cases. These special cases are the "smb:" * URL scheme which is very specific to KDE, "#" and "##" which are * shortcuts for man:/ and info:/ protocols respectively. It then handles * local files. Then it checks to see if the URL is valid and one that is * supported by KDE's IO system. If all the above checks fails, it simply * lookups the URL in the user-defined list and returns without filtering * if it is not found. TODO: the user-defined table is currently only manually * hackable and is missing a config dialog. */ KUrl url = data.uri(); QString cmd = data.typedString(); // WORKAROUND: Allow the use of '@' in the username component of a URL since // other browsers such as firefox in their infinite wisdom allow such blatant // violations of RFC 3986. BR# 69326/118413. if (cmd.count(QLatin1Char('@')) > 1) { const int lastIndex = cmd.lastIndexOf(QLatin1Char('@')); // Percent encode all but the last '@'. QString encodedCmd = QUrl::toPercentEncoding(cmd.left(lastIndex), ":/"); encodedCmd += cmd.mid(lastIndex); KUrl u (encodedCmd); if (u.isValid()) { cmd = encodedCmd; url = u; } } const bool isMalformed = !url.isValid(); QString protocol = url.protocol(); kDebug(7023) << cmd; // Fix misparsing of "foo:80", QUrl thinks "foo" is the protocol and "80" is the path. // However, be careful not to do that for valid hostless URLs, e.g. file:///foo! if (!protocol.isEmpty() && url.host().isEmpty() && !url.path().isEmpty() && cmd.contains(':') && !KProtocolInfo::protocols().contains(protocol)) { protocol.clear(); } //kDebug(7023) << "url=" << url << "cmd=" << cmd << "isMalformed=" << isMalformed; if (!isMalformed && (protocol.length() == 4) && (protocol != QLatin1String("http")) && (protocol[0]=='h') && (protocol[1]==protocol[2]) && (protocol[3]=='p')) { // Handle "encrypted" URLs like: h++p://www.kde.org url.setProtocol( QLatin1String("http")); setFilteredUri( data, url); setUriType( data, KUriFilterData::NetProtocol ); return true; } // TODO: Make this a bit more intelligent for Minicli! There // is no need to make comparisons if the supplied data is a local // executable and only the argument part, if any, changed! (Dawit) // You mean caching the last filtering, to try and reuse it, to save stat()s? (David) const QString starthere_proto = QL1S("start-here:"); if (cmd.indexOf(starthere_proto) == 0 ) { setFilteredUri( data, KUrl("system:/") ); setUriType( data, KUriFilterData::LocalDir ); return true; } // Handle MAN & INFO pages shortcuts... const QString man_proto = QL1S("man:"); const QString info_proto = QL1S("info:"); if( cmd[0] == '#' || cmd.indexOf( man_proto ) == 0 || cmd.indexOf( info_proto ) == 0 ) { if( cmd.left(2) == QL1S("##") ) cmd = QL1S("info:/") + cmd.mid(2); else if ( cmd[0] == '#' ) cmd = QL1S("man:/") + cmd.mid(1); else if ((cmd==info_proto) || (cmd==man_proto)) cmd+='/'; setFilteredUri( data, KUrl( cmd )); setUriType( data, KUriFilterData::Help ); return true; } // Detect UNC style (aka windows SMB) URLs if ( cmd.startsWith( QLatin1String( "\\\\") ) ) { // make sure path is unix style cmd.replace('\\', '/'); cmd.prepend( QLatin1String( "smb:" ) ); setFilteredUri( data, KUrl( cmd )); setUriType( data, KUriFilterData::NetProtocol ); return true; } bool expanded = false; // Expanding shortcut to HOME URL... QString path; QString ref; QString query; QString nameFilter; if (KUrl::isRelativeUrl(cmd) && QDir::isRelativePath(cmd)) { path = cmd; //kDebug(7023) << "path=cmd=" << path; } else { if (url.isLocalFile()) { //kDebug(7023) << "hasRef=" << url.hasRef(); // Split path from ref/query // but not for "/tmp/a#b", if "a#b" is an existing file, // or for "/tmp/a?b" (#58990) if( ( url.hasRef() || !url.query().isEmpty() ) && !url.path().endsWith(QL1S("/")) ) // /tmp/?foo is a namefilter, not a query { path = url.path(); ref = url.ref(); //kDebug(7023) << "isLocalFile set path to " << stringDetails( path ); //kDebug(7023) << "isLocalFile set ref to " << stringDetails( ref ); query = url.query(); if (path.isEmpty() && url.hasHost()) path = '/'; } else { path = cmd; //kDebug(7023) << "(2) path=cmd=" << path; } } } if( path[0] == '~' ) { int slashPos = path.indexOf('/'); if( slashPos == -1 ) slashPos = path.length(); if( slashPos == 1 ) // ~/ { path.replace ( 0, 1, QDir::homePath() ); } else // ~username/ { const QString userName (path.mid( 1, slashPos-1 )); KUser user (userName); if( user.isValid() && !user.homeDir().isEmpty()) { path.replace (0, slashPos, user.homeDir()); } else { if (user.isValid()) { setErrorMsg(data, i18n("<qt><b>%1</b> does not have a home folder.</qt>", userName)); } else { setErrorMsg(data, i18n("<qt>There is no user called <b>%1</b>.</qt>", userName)); } setUriType( data, KUriFilterData::Error ); // Always return true for error conditions so // that other filters will not be invoked !! return true; } } expanded = true; } else if ( path[0] == '$' ) { // Environment variable expansion. if ( sEnvVarExp.indexIn( path ) == 0 ) { QByteArray exp = qgetenv( path.mid( 1, sEnvVarExp.matchedLength() - 1 ).toLocal8Bit().data() ); if(! exp.isNull()) { path.replace( 0, sEnvVarExp.matchedLength(), QString::fromLocal8Bit(exp.constData()) ); expanded = true; } } } if ( expanded || cmd.startsWith( '/' ) ) { // Look for #ref again, after $ and ~ expansion (testcase: $QTDIR/doc/html/functions.html#s) // Can't use KUrl here, setPath would escape it... const int pos = path.indexOf('#'); if ( pos > -1 ) { const QString newPath = path.left( pos ); if ( QFile::exists( newPath ) ) { ref = path.mid( pos + 1 ); path = newPath; //kDebug(7023) << "Extracted ref: path=" << path << " ref=" << ref; } } } bool isLocalFullPath = (!path.isEmpty() && path[0] == '/'); // Checking for local resource match... // Determine if "uri" is an absolute path to a local resource OR // A local resource with a supplied absolute path in KUriFilterData const QString abs_path = data.absolutePath(); const bool canBeAbsolute = (protocol.isEmpty() && !abs_path.isEmpty()); const bool canBeLocalAbsolute = (canBeAbsolute && abs_path[0] =='/' && !isMalformed); bool exists = false; /*kDebug(7023) << "abs_path=" << abs_path << "protocol=" << protocol << "canBeAbsolute=" << canBeAbsolute << "canBeLocalAbsolute=" << canBeLocalAbsolute << "isLocalFullPath=" << isLocalFullPath;*/ KDE_struct_stat buff; if ( canBeLocalAbsolute ) { QString abs = QDir::cleanPath( abs_path ); // combine absolute path (abs_path) and relative path (cmd) into abs_path int len = path.length(); if( (len==1 && path[0]=='.') || (len==2 && path[0]=='.' && path[1]=='.') ) path += '/'; //kDebug(7023) << "adding " << abs << " and " << path; abs = QDir::cleanPath(abs + '/' + path); //kDebug(7023) << "checking whether " << abs << " exists."; // Check if it exists if( KDE::stat( abs, &buff ) == 0 ) { path = abs; // yes -> store as the new cmd exists = true; isLocalFullPath = true; } } if (isLocalFullPath && !exists && !isMalformed) { exists = ( KDE::stat( path, &buff ) == 0 ); if ( !exists ) { // Support for name filter (/foo/*.txt), see also KonqMainWindow::detectNameFilter // If the app using this filter doesn't support it, well, it'll simply error out itself int lastSlash = path.lastIndexOf( '/' ); if ( lastSlash > -1 && path.indexOf( ' ', lastSlash ) == -1 ) // no space after last slash, otherwise it's more likely command-line arguments { QString fileName = path.mid( lastSlash + 1 ); QString testPath = path.left( lastSlash + 1 ); if ( ( fileName.indexOf( '*' ) != -1 || fileName.indexOf( '[' ) != -1 || fileName.indexOf( '?' ) != -1 ) && KDE::stat( testPath, &buff ) == 0 ) { nameFilter = fileName; //kDebug(7023) << "Setting nameFilter to " << nameFilter; path = testPath; exists = true; } } } } //kDebug(7023) << "path =" << path << " isLocalFullPath=" << isLocalFullPath << " exists=" << exists; if( exists ) { KUrl u; u.setPath(path); //kDebug(7023) << "ref=" << stringDetails(ref) << " query=" << stringDetails(query); u.setRef(ref); u.setQuery(query); if (!KAuthorized::authorizeUrlAction( QLatin1String("open"), KUrl(), u)) { // No authorization, we pretend it's a file will get // an access denied error later on. setFilteredUri( data, u ); setUriType( data, KUriFilterData::LocalFile ); return true; } // Can be abs path to file or directory, or to executable with args bool isDir = S_ISDIR( buff.st_mode ); if( !isDir && access ( QFile::encodeName(path).data(), X_OK) == 0 ) { //kDebug(7023) << "Abs path to EXECUTABLE"; setFilteredUri( data, u ); setUriType( data, KUriFilterData::Executable ); return true; } // Open "uri" as file:/xxx if it is a non-executable local resource. if( isDir || S_ISREG( buff.st_mode ) ) { //kDebug(7023) << "Abs path as local file or directory"; if ( !nameFilter.isEmpty() ) u.setFileName( nameFilter ); setFilteredUri( data, u ); setUriType( data, ( isDir ) ? KUriFilterData::LocalDir : KUriFilterData::LocalFile ); return true; } // Should we return LOCAL_FILE for non-regular files too? kDebug(7023) << "File found, but not a regular file nor dir... socket?"; } if( data.checkForExecutables()) { // Let us deal with possible relative URLs to see // if it is executable under the user's $PATH variable. // We try hard to avoid parsing any possible command // line arguments or options that might have been supplied. QString exe = removeArgs( cmd ); //kDebug(7023) << "findExe with" << exe; if (!KStandardDirs::findExe( exe ).isNull() ) { //kDebug(7023) << "EXECUTABLE exe=" << exe; setFilteredUri( data, KUrl::fromPath( exe )); // check if we have command line arguments if( exe != cmd ) setArguments(data, cmd.right(cmd.length() - exe.length())); setUriType( data, KUriFilterData::Executable ); return true; } } // Process URLs of known and supported protocols so we don't have // to resort to the pattern matching scheme below which can possibly // slow things down... if ( !isMalformed && !isLocalFullPath && !protocol.isEmpty() ) { //kDebug(7023) << "looking for protocol " << protocol; if ( KProtocolInfo::isKnownProtocol( protocol ) ) { setFilteredUri( data, url ); if ( protocol == QL1S("man") || protocol == QL1S("help") ) setUriType( data, KUriFilterData::Help ); else setUriType( data, KUriFilterData::NetProtocol ); return true; } } // Short url matches if ( !cmd.contains( ' ' ) ) { // Okay this is the code that allows users to supply custom matches for // specific URLs using Qt's regexp class. This is hard-coded for now. // TODO: Make configurable at some point... Q_FOREACH(const URLHint& hint, m_urlHints) { if (hint.regexp.indexIn(cmd) == 0) { //kDebug(7023) << "match - prepending" << (*it).prepend; const QString cmdStr = hint.prepend + cmd; KUrl url(cmdStr); if (KProtocolInfo::isKnownProtocol(url)) { setFilteredUri( data, url ); setUriType( data, hint.type ); return true; } } } // No protocol and not malformed means a valid short URL such as kde.org or // [email protected]. However, it might also be valid only because it lacks // the scheme component, e.g. www.kde,org (illegal ',' before 'org'). The // check below properly deciphers the difference between the two and sends // back the proper result. if (protocol.isEmpty() && isPotentialShortURL(cmd)) { QString urlStr = data.defaultUrlScheme(); if (urlStr.isEmpty()) urlStr = m_strDefaultUrlScheme; const int index = urlStr.indexOf(QL1C(':')); if (index == -1 || !KProtocolInfo::isKnownProtocol(urlStr.left(index))) urlStr += QL1S("://"); urlStr += cmd; KUrl url (urlStr); if (url.isValid()) { setFilteredUri(data, url); setUriType(data, KUriFilterData::NetProtocol); } else if (KProtocolInfo::isKnownProtocol(url.protocol())) { setFilteredUri(data, data.uri()); setUriType(data, KUriFilterData::Error); } return true; } }
void glutInit (int *argcp, char **argv) { int i, nomouse = 0, nokeyboard = 0, usestdin = 0; int RequiredWidth = 0, RequiredHeight; char *fbdev; stack_t stack; struct sigaction sa; /* parse out args */ for (i = 1; i < *argcp;) { if (!strcmp(argv[i], "-geometry")) { REQPARAM("geometry"); if(sscanf(argv[i+1], "%dx%d", &RequiredWidth, &RequiredHeight) != 2) { fprintf(stderr,"Please specify geometry as widthxheight\n"); exit(0); } removeArgs(argcp, &argv[i], 2); } else if (!strcmp(argv[i], "-bpp")) { REQPARAM("bpp"); if(sscanf(argv[i+1], "%d", &DesiredDepth) != 1) { fprintf(stderr, "Please specify a parameter for bpp\n"); exit(0); } removeArgs(argcp, &argv[i], 2); } else if (!strcmp(argv[i], "-vt")) { REQPARAM("vt"); if(sscanf(argv[i+1], "%d", &CurrentVT) != 1) { fprintf(stderr, "Please specify a parameter for vt\n"); exit(0); } removeArgs(argcp, &argv[i], 2); } else if (!strcmp(argv[i], "-mousespeed")) { REQPARAM("mousespeed"); if(sscanf(argv[i+1], "%lf", &MouseSpeed) != 1) { fprintf(stderr, "Please specify a mouse speed, eg: 2.5\n"); exit(0); } removeArgs(argcp, &argv[i], 2); } else if (!strcmp(argv[i], "-nomouse")) { nomouse = 1; removeArgs(argcp, &argv[i], 1); } else if (!strcmp(argv[i], "-nokeyboard")) { nokeyboard = 1; removeArgs(argcp, &argv[i], 1); } else if (!strcmp(argv[i], "-stdin")) { usestdin = 1; removeArgs(argcp, &argv[i], 1); } else if (!strcmp(argv[i], "-gpmmouse")) { #ifdef HAVE_GPM GpmMouse = 1; #else fprintf(stderr, "gpm support not compiled\n"); exit(0); #endif removeArgs(argcp, &argv[i], 1); } else if (!strcmp(argv[i], "--")) { removeArgs(argcp, &argv[i], 1); break; } else i++; } gettimeofday(&StartTime, 0); atexit(Cleanup); /* set up SIGSEGV to use alternate stack */ stack.ss_flags = 0; stack.ss_size = SIGSTKSZ; if(!(stack.ss_sp = malloc(SIGSTKSZ))) sprintf(exiterror, "Failed to allocate alternate stack for SIGSEGV!\n"); sigaltstack(&stack, NULL); sa.sa_handler = CrashHandler; sa.sa_flags = SA_ONSTACK; sigemptyset(&sa.sa_mask); sigaction(SIGSEGV, &sa, NULL); signal(SIGINT, CrashHandler); signal(SIGTERM, CrashHandler); signal(SIGABRT, CrashHandler); if(nomouse == 0) InitializeMouse(); if(nokeyboard == 0) InitializeVT(usestdin); fbdev = getenv("FRAMEBUFFER"); if(fbdev) { #ifdef MULTIHEAD if(!sscanf(fbdev, "/dev/fb%d", &FramebufferIndex)) if(!sscanf(fbdev, "/dev/fb/%d", &FramebufferIndex)) sprintf(exiterror, "Could not determine Framebuffer index!\n"); #endif } else { static char fb[128]; struct fb_con2fbmap confb; int fd = open("/dev/fb0", O_RDWR); FramebufferIndex = 0; confb.console = CurrentVT; if(ioctl(fd, FBIOGET_CON2FBMAP, &confb) != -1) FramebufferIndex = confb.framebuffer; sprintf(fb, "/dev/fb%d", FramebufferIndex); fbdev = fb; close(fd); } /* open the framebuffer device */ FrameBufferFD = open(fbdev, O_RDWR); if (FrameBufferFD < 0) { sprintf(exiterror, "Error opening %s: %s\n", fbdev, strerror(errno)); exit(0); } /* get the fixed screen info */ if (ioctl(FrameBufferFD, FBIOGET_FSCREENINFO, &FixedInfo)) { sprintf(exiterror, "error: ioctl(FBIOGET_FSCREENINFO) failed: %s\n", strerror(errno)); exit(0); } /* get the variable screen info */ if (ioctl(FrameBufferFD, FBIOGET_VSCREENINFO, &OrigVarInfo)) { sprintf(exiterror, "error: ioctl(FBIOGET_VSCREENINFO) failed: %s\n", strerror(errno)); exit(0); } /* operate on a copy */ VarInfo = OrigVarInfo; /* set the depth, resolution, etc */ if(RequiredWidth) if(!ParseFBModes(RequiredWidth, RequiredWidth, RequiredHeight, RequiredHeight, 0, MAX_VSYNC)) { sprintf(exiterror, "No mode (%dx%d) found in "FBMODES"\n", RequiredWidth, RequiredHeight); exit(0); } Initialized = 1; }