/[gcl]/gcl/o/file.d
ViewVC logotype

Diff of /gcl/o/file.d

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

revision 1.21.4.1.2.1 by camm, Fri Sep 5 21:31:43 2003 UTC revision 1.21.4.1.2.2 by camm, Tue Sep 9 16:55:12 2003 UTC
# Line 32  Foundation, 675 Mass Ave, Cambridge, MA Line 32  Foundation, 675 Mass Ave, Cambridge, MA
32  #include <string.h>  #include <string.h>
33  #include <stdlib.h>  #include <stdlib.h>
34  #include <unistd.h>  #include <unistd.h>
35    #include <sys/types.h>
36    #include <sys/stat.h>
37    
38  #define IN_FILE  #define IN_FILE
39  #include "include.h"  #include "include.h"
# Line 368  object if_exists, if_does_not_exist; Line 370  object if_exists, if_does_not_exist;
370                AGAIN:                AGAIN:
371                  if (fp == NULL) {                  if (fp == NULL) {
372                          if (sSAallow_gzipped_fileA->s.s_dbind != sLnil)                          if (sSAallow_gzipped_fileA->s.s_dbind != sLnil)
373                            { char buf[256];                            {
374                              sprintf(buf,"%s.gz",fname);                              struct stat ss;
375                              fp = fopen(buf,"r");                              char buf[256];
376                              if (fp)                              if (snprintf(buf,sizeof(buf),"%s.gz",fname)<=0)
377                                {                                FEerror("Cannot write .gz filename",0);
378  #ifdef NO_MKSTEMP                              if (!stat(fname,&ss)) {
379                                  char *tmp;                                FILE *pp;
380  #else                                int n;
381                                  char tmp[200];                                if (!(fp=tmpfile()))
382  #endif                                  FEerror("Cannot create temporary file",0);
383                                  char command [500];                                if (snprintf(buf,sizeof(buf),"zcat %s.gz",fname)<=0)
384                                  fclose(fp);                                  FEerror("Cannot write zcat pipe name",0);
385  #ifdef NO_MKSTEMP                                if (!(pp=popen(buf,"r")))
386                                  tmp = tmpnam(0);                                  FEerror("Cannot open zcat pipe",0);
387  #else                                while((n=fread(buf,1,sizeof(buf),pp)))
388                                  snprintf(tmp,sizeof(tmp),"uzipXXXXXX");                                  if (!fwrite(buf,1,n,fp))
389                                  mkstemp(tmp); /* fixme: catch errors */                                    FEerror("Cannot write pipe output to temporary file",0);
390  #endif                                if (pclose(pp)<0)
391                                  unzipped = make_simple_string(tmp);                                  FEerror("Cannot close zcat pipe",0);
392                                  sprintf(command,"gzip -dc %s > %s",buf,tmp);                                goto AGAIN;
393                                  fp = 0;                              }
394                                  if (0 == system(command))                            }
395                                    {                                
396                                      fp = fopen(tmp,"r");  /*                          fp = fopen(buf,"r"); */
397                                      if (fp)  /*                          if (fp) */
398                                        goto AGAIN;  /*                            {  */
399                                      /* should not get here */  /* #ifdef NO_MKSTEMP */
400                                      else { unlink(tmp);}}  /*                              char *tmp; */
401                                }}  /* #else */
402    /*                              char tmp[200]; */
403    /* #endif */
404    /*                              char command [500]; */
405    /*                              fclose(fp); */
406    /* #ifdef NO_MKSTEMP */
407    /*                              tmp = tmpnam(0); */
408    /* #else */
409    /*                              snprintf(tmp,sizeof(tmp),"uzipXXXXXX"); */
410                                    /* mkstemp(tmp); */ /* fixme: catch errors */
411    /* #endif */
412    /*                              unzipped = make_simple_string(tmp); */
413    /*                              sprintf(command,"gzip -dc %s > %s",buf,tmp); */
414    /*                              fp = 0; */
415    /*                              if (0 == system(command)) */
416    /*                                { */
417    /*                                  fp = fopen(tmp,"r"); */
418    /*                                  if (fp)  */
419    /*                                    goto AGAIN; */
420    /*                                  /\* should not get here *\/ */
421    /*                                  else { unlink(tmp);}} */
422    /*                            }} */
423                          if (if_does_not_exist == sKerror)                          if (if_does_not_exist == sKerror)
424                                  cannot_open(fn);                                  cannot_open(fn);
425                          else if (if_does_not_exist == sKcreate) {                          else if (if_does_not_exist == sKcreate) {

Legend:
Removed from v.1.21.4.1.2.1  
changed lines
  Added in v.1.21.4.1.2.2

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