home *** CD-ROM | disk | FTP | other *** search
/ vsiftp.vmssoftware.com / VSIPUBLIC@vsiftp.vmssoftware.com.tar / FREEWARE / FREEWARE40.ZIP / flistfrontend / src / canopen.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-10-21  |  1.2 KB  |  55 lines

  1. #ifndef NO_IDENT
  2. static char *Id = "$Id: canopen.c,v 1.6 1995/10/21 18:25:53 tom Exp $";
  3. #endif
  4.  
  5. /*
  6.  * Title:    canopen.c
  7.  * Author:    Thomas E. Dickey
  8.  * Created:    18 Sep 1984
  9.  * Last update:    18 Sep 1984
  10.  *
  11.  * Function:    Verify that a given file can be opened (for input).  This is
  12.  *        a more stringent test-for-existence, which is used in FLIST to
  13.  *        verify that a command-file is present and usable.
  14.  *
  15.  * Parameters:    name_    => name-string to use
  16.  *
  17.  * Returns:    Zero iff we can open file.
  18.  *
  19.  * Patch:    Should consider extending this function to testing other types
  20.  *        of file-open.
  21.  */
  22.  
  23. #include    <starlet.h>
  24. #include    <rms.h>
  25. #include    <stsdef.h>
  26.  
  27. #include    "rmsinit.h"
  28. #include    "canopen.h"
  29.  
  30. #define    check(f)    status = (f);\
  31.             if (!$VMS_STATUS_SUCCESS(status)) goto failed;
  32.  
  33. int    canopen (char *name_)
  34. {
  35.     struct    FAB    fab;
  36.     struct    NAM    nam;
  37.     char    esa[NAM$C_MAXRSS],    /* expanded by SYS$PARSE    */
  38.         rsa[NAM$C_MAXRSS];    /* result from SYS$SEARCH    */
  39.     unsigned status;
  40.  
  41.     rmsinit_fab (&fab, &nam, 0, name_);
  42.     rmsinit_nam (&nam, rsa, esa);
  43.  
  44.     fab.fab$b_fac |= FAB$M_GET;
  45.  
  46.     check(sys$parse(&fab));
  47.     check(sys$search(&fab));
  48.     check(sys$open(&fab));
  49.     check(sys$close(&fab));
  50.     status = 0;
  51.  
  52. failed:
  53.     return (status);
  54. }
  55.