/* * Copyright 1995, 1998 Perforce Software. * * This file is part of WebKeeper, a perforce client apache module. * * License is hereby granted to use this software and distribute it * freely, as long as this copyright notice is retained and modifications * are clearly marked. * * ALL WARRANTIES ARE HEREBY DISCLAIMED. * * $Id: //guest/matt_attaway/webkeeper/mod_webkeep2.cc#4 $ */ /* * mod_webkeep2.cc -- C++ glue between webkeeper and Perforce Client API * * ClientUserWK sits upon the Perforce ClientApi, and webKeepPrint() * makes use of ClientUserWK. The web server Apache module mod_webkeep.c * interfaces to webKeepPrint() through webkeep.h. */ # include <clientapi.h> extern "C" { # include "mod_webkeep.h" } class ClientUserWK : public ClientUser { public: ClientUserWK() : sync( 0 ), printer( NULL ) {}; void OutputInfo( char level, const char *data ) { if( sync ) return; int l = strlen( data ); int isBinary = l > 5 && strcmp( data + l - 5, "text)" ); (*printer->data)( printer, isBinary ); } void OutputError( const char *errBuf ) { (*printer->error)( printer, errBuf ); } void OutputText( const char *data, int length ) { (*printer->text)( printer, data, length ); } void OutputBinary( const char *data, int length ) { (*printer->text)( printer, data, length ); } int sync; WebKeepPrinter *printer; } ; extern "C" void webKeepPrint( WebKeepConnect *p4, char *path, WebKeepPrinter *printer ) { Error e[1]; ClientUserWK ui; ClientApi client( &ui ); // Plug in API extentions: user's closure parameter and // dispatch table. ui.printer = printer; if( p4->port ) client.SetPort( p4->port ); if( p4->user ) client.SetUser( p4->user ); if( p4->pass ) client.SetPassword( p4->pass ); if( p4->client ) client.SetClient( p4->client ); if( p4->sync ) ui.sync = 1; // Connect. client.Init( e ); if( !e->Test() ) { client.SetArgv( 1, &path ); client.Run( "print" ); client.Final( e ); } if( e->Test() ) { StrBuf buf; e->Fmt( &buf ); (*printer->error)( printer, buf.Text() ); } } extern "C" void webKeepSync( WebKeepConnect *p4, char *path, WebKeepPrinter *printer ) { Error e[1]; ClientUserWK ui; ClientApi client( &ui ); ui.printer = printer; if( p4->port ) client.SetPort( p4->port ); if( p4->user ) client.SetUser( p4->user ); if( p4->pass ) client.SetPassword( p4->pass ); if( p4->client ) client.SetClient( p4->client ); if( p4->sync ) ui.sync = 1; // Connect. client.Init( e ); if( !e->Test() ) { client.SetArgv( 1, &path ); client.Run( "sync" ); client.Final( e ); } if( e->Test() ) { StrBuf buf; e->Fmt( &buf ); (*printer->error)( printer, buf.Text() ); } } class ClientUserFileExists : public ClientUser { public: ClientUserFileExists() { fexists = 0; } void OutputInfo( char, const char * ) { fexists = 1; } void OutputError( const char * ) { fexists = 0; } void OutputText( const char *, int ) {} void OutputBinary( const char *, int ) {} int FileExists() { return fexists; } private: int fexists; }; extern "C" int webKeepFileExists( WebKeepConnect *p4, char *path ) { Error e[1]; ClientUserFileExists ui; ClientApi client( &ui ); if( p4->port ) client.SetPort( p4->port ); if( p4->user ) client.SetUser( p4->user ); if( p4->pass ) client.SetPassword( p4->pass ); if( p4->client ) client.SetClient( p4->client ); client.Init( e ); if( !e->Test() ) { client.SetArgv( 1, &path ); client.Run( "files" ); client.Final( e ); } return ui.FileExists(); } extern "C" int webKeepDirExists( WebKeepConnect *p4, char *path ) { Error e[1]; ClientUserFileExists ui; ClientApi client( &ui ); if( p4->port ) client.SetPort( p4->port ); if( p4->user ) client.SetUser( p4->user ); if( p4->pass ) client.SetPassword( p4->pass ); if( p4->client ) client.SetClient( p4->client ); client.Init( e ); if( !e->Test() ) { int length = strlen( path ); int endsInSlash = ( path[length - 1] == '/' ); /* * Since we don't have access to the Apache pool here, we will * just blank the slash out and restore it when we're done. */ if( endsInSlash ) { path[length - 1] = '\0'; } client.SetArgv( 1, &path ); client.Run( "dirs" ); client.Final( e ); if( endsInSlash ) { path[length - 1] = '/'; } } return ui.FileExists(); }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#4 | 6185 | Matt Attaway |
Update makefile to work with modern Unix systems This change switches to using g+ to link the .so instead of relying on apxs. It also cleans up some warnings. The makefile for compiling Webkeeper into Apache probably needs some work. |
||
#3 | 5913 | Matt Attaway |
Initialize sync flag in ClientUserWK constructor Webkeeper was bailing displaying binary files as text becaues the 'sync' flag was not being initialized properly. |
||
#2 | 5910 | Matt Attaway |
Another step towards conversion. Everything compiles on Windows now. Incremental checkin. |
||
#1 | 5894 | Matt Attaway | Branch Webkeeper code for Apache 2.x compatability project | ||
//guest/perforce_software/webkeeper/mod_webkeep2.cc | |||||
#3 | 805 | Stephen Vance |
Integrated changes from guest depot. Includes APACI build, static and DSO build, Apache 1.3 API, WebKeepSync, WebKeepDirectoryIndex. Also updated index page to reflect new functionality. |
||
#2 | 98 | Laura Wingerd | Pull in WebKeeper change from Perforce (@9037: new error format) | ||
#1 | 46 | Perforce maintenance | Add WebKeeper source. |