/usr/share/doc/libjcifs-java/examples/PipeTalk.java is in libjcifs-java-doc 1.3.19-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | import jcifs.smb.SmbNamedPipe;
import java.io.OutputStream;
import java.io.InputStream;
import java.io.IOException;
public class PipeTalk {
static class ReceiverThread extends Thread {
InputStream in;
byte[] buf = new byte[20];
int n;
ReceiverThread( InputStream in ) {
this.in = in;
}
public void run() {
try {
while(( n = in.read( buf )) != -1 ) {
System.out.println( new String( buf, 0, n ));
}
} catch( IOException ioe ) {
ioe.printStackTrace();
}
}
}
public static void main( String argv[] ) throws Exception {
SmbNamedPipe pipe = new SmbNamedPipe( argv[0], SmbNamedPipe.PIPE_TYPE_RDWR );
InputStream in = pipe.getNamedPipeInputStream();
OutputStream out = pipe.getNamedPipeOutputStream();
ReceiverThread rt = new ReceiverThread( in );
rt.start();
StringBuffer sb = new StringBuffer();
String msg;
int c;
while(( c = System.in.read() ) != -1 ) {
if( c == '\n' ) {
msg = sb.toString();
if( msg.startsWith( "exi" )) {
break;
}
System.out.println( sb.toString() );
out.write( msg.getBytes() );
sb.setLength( 0 );
} else {
sb.append( (char)c );
}
}
in.close();
out.close();
}
}
|