1: /* $Header: artio.c,v 4.3 85/05/01 11:35:39 lwall Exp $
   2:  *
   3:  * $Log:	artio.c,v $
   4:  * Revision 4.3  85/05/01  11:35:39  lwall
   5:  * Baseline for release with 4.3bsd.
   6:  *
   7:  */
   8: 
   9: #include "EXTERN.h"
  10: #include "common.h"
  11: #include "INTERN.h"
  12: #include "artio.h"
  13: 
  14: void
  15: artio_init()
  16: {
  17:     ;
  18: }
  19: 
  20: /* open an article, unless it's already open */
  21: 
  22: FILE *
  23: artopen(artnum)
  24: ART_NUM artnum;
  25: {
  26:     char artname[8];            /* filename of current article */
  27: 
  28:     if (artnum < 1)
  29:     return Nullfp;
  30:     if (openart == artnum) {        /* this article is already open? */
  31:     fseek(artfp,0L,0);      /* just get to the beginning */
  32:     return artfp;           /* and say we succeeded */
  33:     }
  34:     if (artfp != Nullfp) {      /* it was somebody else? */
  35:     fclose(artfp);          /* put them out of their misery */
  36:     openart = 0;            /* and remember them no more */
  37:     }
  38:     sprintf(artname,"%ld",(long)artnum);
  39:                     /* produce the name of the article */
  40:     if (artfp = fopen(artname,"r")) /* if we can open it */
  41:     openart = artnum;       /* remember what we did here */
  42: #ifdef LINKART
  43:     {
  44:     char tmpbuf[256];
  45:     char *s;
  46: 
  47:     if (fstat(artfp->_file,&filestat))
  48:         return artfp;
  49:     if (filestat.st_size < (sizeof tmpbuf)) {
  50:         fgets(tmpbuf,(sizeof tmpbuf),artfp);
  51:         if (*tmpbuf == '/') {   /* is a "link" to another article */
  52:         fclose(artfp);
  53:         if (s=index(tmpbuf,'\n'))
  54:             *s = '\0';
  55:         if (!(artfp = fopen(tmpbuf,"r")))
  56:             openart = 0;
  57:         else {
  58:             if (*linkartname)
  59:             free(linkartname);
  60:             linkartname = savestr(tmpbuf);
  61:         }
  62:         }
  63:         else
  64:         fseek(artfp,0L,0);      /* get back to the beginning */
  65:     }
  66:     }
  67: #endif
  68:     return artfp;           /* and return either fp or NULL */
  69: }

Defined functions

artio_init defined in line 14; used 2 times

Defined variables

FILE defined in line 22; never used
Last modified: 1985-06-21
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 590
Valid CSS Valid XHTML 1.0 Strict