/[pspp]/pspp/src/file-handle.q
ViewVC logotype

Diff of /pspp/src/file-handle.q

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.13 by blp, Tue Mar 1 08:16:15 2005 UTC revision 1.14 by blp, Sat Mar 12 20:22:18 2005 UTC
# Line 48  struct file_handle Line 48  struct file_handle
48    
49      int open_cnt;               /* 0=not open, otherwise # of openers. */      int open_cnt;               /* 0=not open, otherwise # of openers. */
50      const char *type;           /* If open, type of file. */      const char *type;           /* If open, type of file. */
51      const char *open_mode;      /* "[rw][se]". */      const char open_mode[3];    /* "[rw][se]". */
52      void *aux;                  /* Aux data pointer for owner if any. */      void *aux;                  /* Aux data pointer for owner if any. */
53    };    };
54    
# Line 210  create_file_handle (const char *handle_n Line 210  create_file_handle (const char *handle_n
210    handle->tab_width = 4;    handle->tab_width = 4;
211    handle->open_cnt = 0;    handle->open_cnt = 0;
212    handle->type = NULL;    handle->type = NULL;
   handle->open_mode = NULL;  
213    handle->aux = NULL;    handle->aux = NULL;
214    file_handles = handle;    file_handles = handle;
215    
# Line 254  mode_name (const char *mode) Line 253  mode_name (const char *mode)
253     modes the void * will necessarily be null only if no other     modes the void * will necessarily be null only if no other
254     sharers are active.     sharers are active.
255    
256     If successful, references to type and mode are retained, so     If successful, a reference to type is retained, so it should
257     they should probably be string literals. */     probably be a string literal. */
258  void **  void **
259  fh_open (struct file_handle *h, const char *type, const char *mode)  fh_open (struct file_handle *h, const char *type, const char *mode)
260  {  {
# Line 268  fh_open (struct file_handle *h, const ch Line 267  fh_open (struct file_handle *h, const ch
267    
268    if (h->open_cnt != 0)    if (h->open_cnt != 0)
269      {      {
270        if (strcmp (h->type, type))        if (strcmp (h->type, type))
271          msg (SE, _("Can't open %s as a %s because it is "          {
272                     "already open as a %s"),            msg (SE, _("Can't open %s as a %s because it is "
273               handle_get_name (h), type, h->type);                       "already open as a %s"),
274        else if (strcmp (h->open_mode, mode))                 handle_get_name (h), type, h->type);
275          msg (SE, _("Can't open %s as a %s for %s because it is "            return NULL;
276                     "already open for %s"),          }
277               handle_get_name (h), type,        else if (strcmp (h->open_mode, mode))
278               mode_name (mode), mode_name (h->open_mode));          {
279              msg (SE, _("Can't open %s as a %s for %s because it is "
280                         "already open for %s"),
281                   handle_get_name (h), type,
282                   mode_name (mode), mode_name (h->open_mode));
283              return NULL;
284            }
285        else if (h->open_mode[1] == 'e')        else if (h->open_mode[1] == 'e')
286          msg (SE, _("Can't re-open %s as a %s for %s"),          {
287               handle_get_name (h), type, mode_name (mode));            msg (SE, _("Can't re-open %s as a %s for %s"),
288                   handle_get_name (h), type, mode_name (mode));
289              return NULL;
290            }
291      }      }
292    else    else
293      {      {
294        h->type = type;        h->type = type;
295        h->open_mode = mode;        strcpy (h->open_mode, mode);
296        assert (h->aux == NULL);        assert (h->aux == NULL);
297      }      }
298    h->open_cnt++;    h->open_cnt++;
# Line 310  fh_close (struct file_handle *h, const c Line 318  fh_close (struct file_handle *h, const c
318    if (h->open_cnt == 0)    if (h->open_cnt == 0)
319      {      {
320        h->type = NULL;        h->type = NULL;
       h->open_mode = NULL;  
321        h->aux = NULL;        h->aux = NULL;
322      }      }
323    return h->open_cnt;    return h->open_cnt;

Legend:
Removed from v.1.13  
changed lines
  Added in v.1.14

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26