#include <stdio.h>
#include <string.h>
#include <rms.h>

int sys$open();
int sys$connect();
int sys$find();
int sys$truncate();
int sys$disconnect();
int sys$close();

void truncate(char *s,int n)
{
   int stat;
   struct FAB myfab = cc$rms_fab;
   struct RAB myrab = cc$rms_rab;
   myfab.fab$b_fac = FAB$M_TRN;
   myfab.fab$l_fna = s;
   myfab.fab$b_fns = strlen(s);
   myrab.rab$l_fab = &myfab;
   stat = sys$open(&myfab,0,0);
   printf("stat=%d\n",stat);
   stat = sys$connect(&myrab,0,0);
   printf("stat=%d\n",stat);
   myrab.rab$b_rac=RAB$C_RFA;
   myrab.rab$w_rfa[0]=n/512+1;
   myrab.rab$w_rfa[1]=0;
   myrab.rab$w_rfa[2]=n%512;
   stat = sys$find(&myrab,0,0);
   printf("stat=%d\n",stat);
   stat = sys$truncate(&myrab,0,0);
   printf("stat=%d\n",stat);
   stat = sys$disconnect(&myrab,0,0);
   printf("stat=%d\n",stat);
   stat = sys$close(&myfab,0,0);
   printf("stat=%d\n",stat);
   return;
}

main()
{
   truncate("z.z",6);
}
