Esempio n. 1
0
void LshttpdMain::parseOpt(int argc, char *argv[])
{
    const char *opts = "cdnv";
    int c;
    char achCwd[512];
    getServerRootFromExecutablePath(argv[0], achCwd, 512);
    opterr = 0;
    while ((c = getopt(argc, argv, opts)) != EOF)
    {
        switch (c)
        {
        case 'c':
            m_noCrashGuard = 1;
            break;
        case 'd':
            m_noDaemon = 1;
            m_noCrashGuard = 1;
            break;
        case 'n':
            m_noDaemon = 1;
            break;
        case 'v':
            printf("%s\n", HttpServerVersion::getVersion());
            exit(0);
            break;
        case '?':
            break;

        default:
            printf("?? getopt returned character code -%o ??\n", c);
        }
    }
}
Esempio n. 2
0
int LshttpdMain::getServerRoot( int argc, char * argv[] )
{
    char achServerRoot[MAX_PATH_LEN];

    char pServerRootEnv[2][20] = {"LSWS_HOME", "LSHTTPD_HOME"};
    for( int i = 0; i < 2; ++i )
    {
        const char * pRoot = getenv( pServerRootEnv[i] );
        if ( pRoot )
        {
            if ( testServerRoot( pRoot ) == 0 )
            {
                return 0;
            }
        }
    }
    if ( getServerRootFromExecutablePath( argv[0],
                achServerRoot, MAX_PATH_LEN ) == 0 )
    {
        if ( testServerRoot( achServerRoot ) == 0 )
        {
            return 0;
        }
    }
    if ( guessCommonServerRoot() == 0 )
        return 0;
    return -1;
}