File: lin_main.c

package info (click to toggle)
clif 0.90.2-3
  • links: PTS
  • area: main
  • in suites: slink
  • size: 4,336 kB
  • ctags: 2,815
  • sloc: ansic: 29,914; yacc: 4,338; lex: 644; makefile: 373; sh: 48
file content (68 lines) | stat: -rw-r--r-- 1,196 bytes parent folder | download | duplicates (7)
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
56
57
58
59
60
61
62
63
64
65
66
67
68
#include <stdio.h>
#include <rpc/rpc.h>
#include "lin.h"

#define O_RDONLY 00
#define O_WRONLY 01

main(argc,argv)
     int argc;
     char **argv;
{
  CLIENT *cl;
  int *result;
  static int i;
  static short *vysl;
  static remote_o_struct ros;
  static remote_r_w_struct rrws,*res;

  if(argc<3)
    {
      fprintf(stderr,"usage: host device\n");
      exit(0);
    }
  
  if((cl = clnt_create(argv[1],REMOTEDEVICE,REMOTEVERS,"tcp")) == NULL)
    {
      clnt_pcreateerror(argv[1]);
      exit(1);
    }
  
  ros.device=argv[2];
  ros.flags=O_RDONLY;
  if((result=remote_open_1(&ros,cl)) == NULL)
    {
      clnt_perror(cl,argv[1]);
      exit(1);
    }
  if(*result == -1)
    {
      printf("bad open\n");
      exit(1);
    }
  rrws.fd = *result;
  rrws.bytes = 2;


  for(i=0;i<100000;i++)
    {
        if((res=remote_read_1(&rrws,cl)) == NULL)
	  {
	    clnt_perror(cl,argv[1]);
	    exit(1);
	  }
        if(res->bytes == -1)
          {
            printf("bad read\n");
	    exit(1);
          }
        vysl = (short *)res->buf;
	printf("%d %x\n",*vysl,*vysl);
      }

  if((result=remote_close_1(&rrws.fd,cl)) == NULL)
    {
      clnt_perror(cl,argv[1]);
      exit(1);
    }
}