File tree 4 files changed +91
-1
lines changed 4 files changed +91
-1
lines changed Original file line number Diff line number Diff line change @@ -5,4 +5,6 @@ src/libncp.a
5
5
src /ping
6
6
src /finger
7
7
src /finser
8
+ src /telnet
9
+ src /telser
8
10
test /* .log
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ CFLAGS=-g -Wall
2
2
3
3
NCP =-L. -lncp
4
4
5
- all : ncp ping finger finser
5
+ all : ncp ping finger finser telnet telser
6
6
7
7
ncp : ncp.o imp.o
8
8
@@ -18,3 +18,9 @@ finger: finger.o libncp.a
18
18
19
19
finser : finser.o libncp.a
20
20
$(CC ) -o $@ $< $(NCP )
21
+
22
+ telnet : telnet.o libncp.a
23
+ $(CC ) -o $@ $< $(NCP )
24
+
25
+ telser : telser.o libncp.a
26
+ $(CC ) -o $@ $< $(NCP )
Original file line number Diff line number Diff line change
1
+ #include <stdio.h>
2
+ #include <errno.h>
3
+ #include <stdlib.h>
4
+ #include <unistd.h>
5
+ #include <string.h>
6
+ #include "ncp.h"
7
+
8
+ int main (int argc , char * * argv )
9
+ {
10
+ char * command ;
11
+ char reply [1000 ];
12
+ int host , connection , size ;
13
+
14
+ if (argc != 2 ) {
15
+ fprintf (stderr , "Usage: %s host\n" , argv [0 ]);
16
+ exit (1 );
17
+ }
18
+
19
+ host = atoi (argv [1 ]);
20
+
21
+ if (ncp_init (NULL ) == -1 ) {
22
+ fprintf (stderr , "NCP initializtion error: %s.\n" , strerror (errno ));
23
+ if (errno == ECONNREFUSED )
24
+ fprintf (stderr , "Is the NCP server started?\n" );
25
+ exit (1 );
26
+ }
27
+
28
+ printf ("TELNET to host %03o.\n" , host );
29
+
30
+ switch (ncp_open (host , 23 , & connection )) {
31
+ case 0 :
32
+ break ;
33
+ case -1 :
34
+ default :
35
+ fprintf (stderr , "NCP open error.\n" );
36
+ exit (1 );
37
+ case -2 :
38
+ fprintf (stderr , "Open refused.\n" );
39
+ exit (1 );
40
+ }
41
+
42
+ if (ncp_close (connection ) == -1 ) {
43
+ fprintf (stderr , "NCP close error.\n" );
44
+ exit (1 );
45
+ }
46
+ }
Original file line number Diff line number Diff line change
1
+ #include <stdio.h>
2
+ #include <errno.h>
3
+ #include <stdlib.h>
4
+ #include <unistd.h>
5
+ #include <string.h>
6
+ #include "ncp.h"
7
+
8
+ int main (int argc , char * * argv )
9
+ {
10
+ char command [1000 ];
11
+ char reply [1000 ];
12
+ int host , connection , size ;
13
+
14
+ if (argc != 1 ) {
15
+ fprintf (stderr , "Usage: %s\n" , argv [0 ]);
16
+ exit (1 );
17
+ }
18
+
19
+ if (ncp_init (NULL ) == -1 ) {
20
+ fprintf (stderr , "NCP initializtion error: %s.\n" , strerror (errno ));
21
+ if (errno == ECONNREFUSED )
22
+ fprintf (stderr , "Is the NCP server started?\n" );
23
+ exit (1 );
24
+ }
25
+
26
+ if (ncp_listen (23 , & host , & connection ) == -1 ) {
27
+ fprintf (stderr , "NCP listen error.\n" );
28
+ exit (1 );
29
+ }
30
+
31
+ if (ncp_close (connection ) == -1 ) {
32
+ fprintf (stderr , "NCP close error.\n" );
33
+ exit (1 );
34
+ }
35
+
36
+ }
You can’t perform that action at this time.
0 commit comments