File tree 3 files changed +41
-1
lines changed
3 files changed +41
-1
lines changed Original file line number Diff line number Diff line change @@ -5,4 +5,5 @@ src/libncp.a
5
5
src /ping
6
6
src /finger
7
7
src /finser
8
+ src /telser
8
9
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 telser
6
6
7
7
ncp : ncp.o imp.o
8
8
@@ -18,3 +18,6 @@ finger: finger.o libncp.a
18
18
19
19
finser : finser.o libncp.a
20
20
$(CC ) -o $@ $< $(NCP )
21
+
22
+ telser : finser.o libncp.a
23
+ $(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 [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