home *** CD-ROM | disk | FTP | other *** search
/ The AGA Experience 2 / agavol2.iso / software / utilities / comms / ncp / developer / source / s3run / s3run.c < prev    next >
C/C++ Source or Header  |  1994-09-23  |  860b  |  62 lines

  1. /*
  2. **    Run a program on the S3
  3. */
  4.  
  5. #include <proto/dos.h>
  6. #include <libraries/ncplib.h>
  7.  
  8. int main( int argc, char **argv )
  9. {
  10.     int rc;
  11.     char buff[ 128 ], buff2[ 4 ];
  12.     int c = 0;
  13.     char *p;
  14.  
  15.     if( argc < 2 )
  16.     {
  17.         PutStr( "Usage: S3Run remotefilename [cmdline]\n" );
  18.         return( 5 );
  19.     }
  20.  
  21.     if( argc > 2 )
  22.     {
  23.         // Acceppt \xx escapes
  24.         p = argv[ 2 ];
  25.         for( c = 0; *p; )
  26.         {
  27.             if( *p == '\\' )
  28.             {
  29.                 p++;
  30.                 if(*p=='\\' )
  31.                     buff[ c++ ] = *p++;
  32.                 else
  33.                 {
  34.                     buff2[ 0 ] = *p++;
  35.                     buff2[ 1 ] = *p++;
  36.                     buff2[ 2 ] = 0;
  37.                     stch_l( buff, &rc );
  38.                     buff[ c++ ] = rc;
  39.                 }
  40.             }
  41.             else
  42.             {
  43.                 buff[ c++ ] = *p++;
  44.             }
  45.         }
  46.     }
  47.  
  48.     rc = NCP_LinkRemoteRun( argv[ 1 ], buff, c );
  49.  
  50.     if( !rc )
  51.     {
  52.         PutStr( "S3Run: Ok\n" );
  53.         return( 0 );
  54.     }
  55.     else
  56.     {
  57.         NCP_Fault( rc, "S3Run", buff, 128 );
  58.         Printf( "NCP returned %ld (%s)\n", rc, buff );
  59.         return( 5 );
  60.     }
  61. }
  62.