home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume8 / libhoward / part08 / mfopen.c < prev    next >
C/C++ Source or Header  |  1989-10-01  |  2KB  |  72 lines

  1. /*
  2.  * mfopen - try to open file and report errors with malf
  3.  */
  4.  
  5. #ifndef lint
  6. static char _cpyrgt[] = "Copyright 1989 Howard Lee Gayle";
  7. #endif lint
  8.  
  9. /*
  10.  * This program is free software; you can redistribute it and/or modify
  11.  * it under the terms of the GNU General Public License version 1,
  12.  * as published by the Free Software Foundation.
  13.  *
  14.  * This program is distributed in the hope that it will be useful,
  15.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17.  * GNU General Public License for more details.
  18.  *
  19.  * You should have received a copy of the GNU General Public License
  20.  * along with this program; if not, write to the Free Software
  21.  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  22.  */
  23.  
  24. #include <stdio.h>
  25. #include <howard/port.h>
  26. #include <howard/version.h>
  27.  
  28. MODVER ("@(#)$Header: mfopen.c,v 1.5 89/08/13 15:07:38 howard Exp $");
  29.  
  30. #include <howard/malf.h>
  31. #include <howard/registers.i>
  32.  
  33. PUBLIC streamT mfopen (n, m)
  34. bStrT n; /* File name.*/
  35. bStrT m; /* Mode string.*/
  36.  
  37. /* Function:
  38.  *    Attempt to open the file.  On error call malf1().
  39.  * Algorithm:
  40.  *    Call fopen().
  41.  * Returns:
  42.  *    On success, the streamT for the opened file.  No return on error.
  43.  * Notes:
  44.  *    
  45.  */
  46. {
  47. R1 streamT s = fopen (S(n), S(m)); /* Stream.*/
  48.  
  49. if (NULSTRM == s) malf1 ("%s: Can not open mode %s", n, m);
  50. return (s);
  51. }
  52.  
  53. #ifdef TEST
  54. #include <howard/usage.h>
  55.  
  56. MAINVER ("@(#)$Header: mfopen.c,v 1.5 89/08/13 15:07:38 howard Exp $");
  57. USAGE ("filename mode");
  58.  
  59. PUBLIC int main (argc, argv)
  60. int    argc; /* Number of arguments.*/
  61. bStrT *argv; /* Points to array of argument strings.*/
  62. {
  63. if (3 != argc) usage();
  64. (void) mfopen (argv[1], argv[2]);
  65. exit (SUCCESS);
  66.  
  67. #ifdef lint
  68. return (SUCCESS);
  69. #endif
  70. }
  71. #endif
  72.