Example #1
0
P4ClientAPI::P4ClientAPI( lua_State *L )
	: L( L )
	, specMgr( L )
	, ui( L, &specMgr )
{
	debug = 0;
	server2 = 0;
	depth = 0;
	exceptionLevel = 2;
	maxResults = 0;
	maxScanRows = 0;
	maxLockTime = 0;
	prog = "unnamed p4lua script";
	apiLevel = atoi( P4Tag::l_client );
	enviro = new Enviro;

//	cb.client = this;

	InitFlags();

	// Enable form parsing
	client.SetProtocol( "specstring", "" );

    //
    // Load the current working directory, and any P4CONFIG file in place
    //
	HostEnv henv;
	StrBuf cwd;

	henv.GetCwd( cwd, enviro );
	if( cwd.Length() )
		enviro->Config( cwd );

	//
	// Load the current ticket file. Start with the default, and then
	// override it if P4TICKETS is set.
	//
	const char *t;

  	henv.GetTicketFile( ticketFile );

	if( t = enviro->Get( "P4TICKETS" ) ) {
		ticketFile = t;
	}

    // 
    // Do the same for P4CHARSET
    //
    
    const char *lc;
    if( ( lc = enviro->Get( "P4CHARSET" )) ) {
        SetCharset(lc);
    }
}
Example #2
0
P4ClientApi::P4ClientApi( lua_State *L )
	: L( L )
	, specMgr( L )
	, ui( L, &specMgr )
	, keepAliveRef( LUA_NOREF )
{
	initCount = 0;
	debug = 0;
	server2 = 0;
	depth = 0;
	exceptionLevel = 2;
	maxResults = 0;
	maxScanRows = 0;
	maxLockTime = 0;
	apiLevel = atoi( P4Tag::l_client );
	enviro = new Enviro;
	prog = "unnamed p4lua script";
	cb.client = this;

	// Enable form parsing, and set tagged mode on by default
	mode |= M_PARSE_FORMS + M_TAGGED ;
	client.SetProtocol( "specstring", "" );

	//
	// Load any P4CONFIG file
	//
	HostEnv henv;
	StrBuf cwd;

	henv.GetCwd( cwd, enviro );
	if( cwd.Length() )
		enviro->Config( cwd );

	//
	// Load the current ticket file. Start with the default, and then
	// override it if P4TICKETS is set.
	//
	const char *t;

  	henv.GetTicketFile( ticketFile );

	if( t = enviro->Get( "P4TICKETS" ) )
		ticketFile = t;

	//
	// Load the current P4CHARSET if set.
	//
	if( client.GetCharset().Length() )
		SetCharset( client.GetCharset().Text() );
}