Skip to content

AFNI/NIfTI Server

Sections
Personal tools
You are here: Home » AFNI » Documentation

Doxygen Source Code Documentation


Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Search  

close.c

Go to the documentation of this file.
00001 #include "stdlib.h"
00002 #include "f2c.h"
00003 #include "fio.h"
00004 #ifdef KR_headers
00005 integer f_clos(a) cllist *a;
00006 #else
00007 #undef abs
00008 #undef min
00009 #undef max
00010 #include "stdlib.h"
00011 #ifdef NON_UNIX_STDIO
00012 #ifndef unlink
00013 #define unlink remove
00014 #endif
00015 #else
00016 #ifdef MSDOS
00017 #include "io.h"
00018 #else
00019 #ifdef __cplusplus
00020 extern "C" int unlink(const char*);
00021 #else
00022 extern int unlink(const char*);
00023 #endif
00024 #endif
00025 #endif
00026 
00027 integer f_clos(cllist *a)
00028 #endif
00029 {       unit *b;
00030 
00031         if(a->cunit >= MXUNIT) return(0);
00032         b= &f__units[a->cunit];
00033         if(b->ufd==NULL)
00034                 goto done;
00035         if (!a->csta)
00036                 if (b->uscrtch == 1)
00037                         goto Delete;
00038                 else
00039                         goto Keep;
00040         switch(*a->csta) {
00041                 default:
00042                 Keep:
00043                 case 'k':
00044                 case 'K':
00045                         if(b->uwrt == 1)
00046                                 t_runc((alist *)a);
00047                         if(b->ufnm) {
00048                                 fclose(b->ufd);
00049                                 free(b->ufnm);
00050                                 }
00051                         break;
00052                 case 'd':
00053                 case 'D':
00054                 Delete:
00055                         if(b->ufnm) {
00056                                 fclose(b->ufd);
00057                                 unlink(b->ufnm); /*SYSDEP*/
00058                                 free(b->ufnm);
00059                                 }
00060                 }
00061         b->ufd=NULL;
00062  done:
00063         b->uend=0;
00064         b->ufnm=NULL;
00065         return(0);
00066         }
00067  void
00068 #ifdef KR_headers
00069 f_exit()
00070 #else
00071 f_exit(void)
00072 #endif
00073 {       int i;
00074         static cllist xx;
00075         if (!xx.cerr) {
00076                 xx.cerr=1;
00077                 xx.csta=NULL;
00078                 for(i=0;i<MXUNIT;i++)
00079                 {
00080                         xx.cunit=i;
00081                         (void) f_clos(&xx);
00082                 }
00083         }
00084 }
00085  int
00086 #ifdef KR_headers
00087 flush_()
00088 #else
00089 flush_(void)
00090 #endif
00091 {       int i;
00092         for(i=0;i<MXUNIT;i++)
00093                 if(f__units[i].ufd != NULL && f__units[i].uwrt)
00094                         fflush(f__units[i].ufd);
00095 return 0;
00096 }
 

Powered by Plone

This site conforms to the following standards: