work for the MacCvs integration

This commit is contained in:
aubonbeurre 2001-03-24 01:04:54 +00:00
parent 4a4a22a165
commit ff9290494f
5 changed files with 81 additions and 11 deletions

View File

@ -2,7 +2,11 @@ lsh_new
lsh_delete lsh_delete
lsh_yield lsh_yield
lsh_read lsh_read
lsh_canread
lsh_write lsh_write
lsh_canwrite
lsh_getprefsd lsh_getprefsd
lsh_current lsh_current
lsh_running lsh_running
lsh_init
lsh_terminate

View File

@ -97,6 +97,11 @@ extern "C" void GUSIwithTTYSockets()
GUSIDeviceRegistry::Instance()->AddDevice(GUSITTYDevice::Instance()); GUSIDeviceRegistry::Instance()->AddDevice(GUSITTYDevice::Instance());
} }
extern "C" void GUSIwithoutTTYSockets()
{
GUSIDeviceRegistry::Instance()->RemoveDevice(GUSITTYDevice::Instance());
}
/* /*

View File

@ -61,6 +61,7 @@ extern char *applname;
extern char *defargstr; extern char *defargstr;
extern void ssh2_init(); extern void ssh2_init();
extern void ssh2_terminate();
extern void ssh2_sched(); extern void ssh2_sched();
extern void close_all_files(); extern void close_all_files();
@ -555,7 +556,7 @@ int InstallTTY(int id, void *ctx)
*/ */
void RemoveTTY(int fd, void *ctx) void RemoveTTY(int fd, void *ctx)
{ {
#pragma unused (id, ctx) #pragma unused (fd, ctx)
} }
/* /*
@ -1236,6 +1237,19 @@ int lsh_read(lshctx *ctx, void *buffer, long inbytes)
} }
int lsh_canread(lshctx *ctx)
{
lshcontext *context = (lshcontext *)ctx->context;
long outbytes = 0;
if ( context && context->_gConsoleOutBufLen )
{
outbytes = context->_gConsoleOutBufLen;
}
return outbytes;
}
/* /*
* lsh_write * lsh_write
*/ */
@ -1266,6 +1280,19 @@ long lsh_write(lshctx *ctx, const void *buffer, long inbytes)
return outbytes; return outbytes;
} }
int lsh_canwrite(lshctx *ctx)
{
lshcontext *context = (lshcontext *)ctx->context;
long outbytes = 0;
if ( context && context->_gConsoleInBufLen )
{
outbytes = context->_gConsoleInBufLen;
}
return outbytes;
}
/* /*
* lsh_getprefsd * lsh_getprefsd
*/ */
@ -1305,6 +1332,16 @@ Boolean lsh_running(lshctx *ctx)
return ctx->pthread != NULL; return ctx->pthread != NULL;
} }
void lsh_init(void)
{
ssh2_init();
}
void lsh_terminate(void)
{
ssh2_terminate();
}
/* /*
* __lsh_initialize * __lsh_initialize
*/ */

View File

@ -144,12 +144,20 @@ int lsh_read(lshctx *ctx, void *buffer, long inbytes);
long lsh_write(lshctx *ctx, const void *buffer, long inbytes); long lsh_write(lshctx *ctx, const void *buffer, long inbytes);
int lsh_canread(lshctx *ctx);
int lsh_canwrite(lshctx *ctx);
char *lsh_getprefsd(); char *lsh_getprefsd();
lshctx *lsh_current(); lshctx *lsh_current();
Boolean lsh_running(lshctx *ctx); Boolean lsh_running(lshctx *ctx);
void lsh_init(void);
void lsh_terminate(void);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -16,8 +16,10 @@ extern "C" {
#endif #endif
void GUSIwithTTYSockets(); void GUSIwithTTYSockets();
void GUSIwithoutTTYSockets();
void ssh2_init(); void ssh2_init();
void ssh2_terminate();
void add_one_file(struct lshcontext *context, int fd); void add_one_file(struct lshcontext *context, int fd);
void remove_one_file(struct lshcontext *context, int fd); void remove_one_file(struct lshcontext *context, int fd);
@ -27,9 +29,13 @@ void remove_one_file(struct lshcontext *context, int fd);
#endif #endif
/* /*
GusiMSLWriteConsole sWriteConsole = 0L; * - This project is intended to work with MacCvs (http://www.cvsgui.org)
GusiMSLWriteConsole sInConsole = 0L; * - It exports the lsh program as a shared library, thanks to Jean-Pierre.
*/ * - The lsh API is hooked up to the cvs shared library of cvs and provide
* the SSH2 authentication.
*
* Questions : alexandre parenteau (aubonbeurre@hotmail.com)
*/
static void myGusiMSLAddFile(int fd) static void myGusiMSLAddFile(int fd)
{ {
@ -51,9 +57,10 @@ static void myGusiMSLRemoveFile(int fd)
* ssh2_init * ssh2_init
*/ */
static Boolean sGUSISetup = false;
void ssh2_init() void ssh2_init()
{ {
static Boolean sGUSISetup = false;
if ( !sGUSISetup ) { if ( !sGUSISetup ) {
@ -61,13 +68,22 @@ void ssh2_init()
GusiMSLSetAddFile(myGusiMSLAddFile); GusiMSLSetAddFile(myGusiMSLAddFile);
GusiMSLSetRemoveFile(myGusiMSLRemoveFile); GusiMSLSetRemoveFile(myGusiMSLRemoveFile);
/*
sWriteConsole = GusiMSLGetWriteConsole();
sInConsole = GusiMSLGetInConsole();
GusiMSLSetWriteConsole(WriteCharsToConsole); sGUSISetup = true;
GusiMSLSetInConsole(ReadCharsFromConsole);
*/
} }
} }
void ssh2_terminate()
{
static Boolean sGUSISetup = false;
if ( sGUSISetup ) {
GUSIwithoutTTYSockets();
GusiMSLSetAddFile(0L);
GusiMSLSetRemoveFile(0L);
sGUSISetup = false;
}
}