File: 002_test_open.c

package info (click to toggle)
cowdancer 0.73
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 752 kB
  • ctags: 269
  • sloc: ansic: 3,822; sh: 481; makefile: 191; cpp: 6
file content (29 lines) | stat: -rwxr-xr-x 427 bytes parent folder | download | duplicates (6)
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
/*BINFMTC:
open test */
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>

void writeandclose(int a)
{
  write(a,"abc",3);
  close(a);
}

int main(int argc, char** argv)
{
  /* test that the three args work. */
  int a,b,c;
  
  if(argc < 4)
    exit(1);
  
  a=open(argv[1], O_RDONLY);
  b=open(argv[2], O_WRONLY);
  c=open(argv[3], O_RDWR);
  writeandclose(a);
  writeandclose(b);
  writeandclose(c);

  return 0;
}