Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

funflush(3) [debian man page]

funflush(3)							SAORD Documentation						       funflush(3)

NAME
FunFlush - flush data to output file SYNOPSIS
#include <funtools.h> void FunFlush(Fun fun, char *plist) DESCRIPTION
The FunFlush routine will flush data to a FITS output file. In particular, it can be called after all rows have been written (using the FunTableRowPut() routine) in order to add the null padding that is required to complete a FITS block. It also should be called after com- pletely writing an image using FunImagePut() or after writing the final row of an image using FunTableRowPut(). The plist (i.e., parameter list) argument is a string containing one or more comma-delimited keyword=value parameters. If the plist string contains the parameter "copy=remainder" and the file was opened with a reference file, which, in turn, was opened for extension copying (i.e. the input FunOpen() mode also was "c" or "C"), then FunFlush also will copy the remainder of the FITS extensions from the input ref- erence file to the output file. This normally would be done only at the end of processing. Note that FunFlush() is called with "copy=remainder" in the mode string by FunClose(). This means that if you close the output file before the reference input file, it is not necessary to call FunFlush() explicitly, unless you are writing more than one extension. See the evmerge example code. However, it is safe to call FunFlush() more than once without fear of re-writing either the padding or the copied extensions. In addition, if FunFlush() is called on an output file with the plist set to "copy=reference" and if the file was opened with a reference file, the reference extension is written to the output file. This mechanism provides a simple way to copy input extensions to an output file without processing the former. For example, in the code fragment below, an input extension is set to be the reference file for a newly opened output extension. If that reference extension is not a binary table, it is written to the output file: /* process each input extension in turn */ for(ext=0; ;ext++){ /* get new extension name */ sprintf(tbuf, "%s[%d]", argv[1], ext); /* open input extension -- if we cannot open it, we are done */ if( !(ifun=FunOpen(tbuf, "r", NULL)) ) break; /* make the new extension the reference handle for the output file */ FunInfoPut(ofun, FUN_IFUN, &ifun, 0); /* if its not a binary table, just write it out */ if( !(s=FunParamGets(ifun, "XTENSION", 0, NULL, &got)) || strcmp(s, "BINTABLE")){ if( s ) free(s); FunFlush(ofun, "copy=reference"); FunClose(ifun); continue; } else{ /* process binary table */ .... } } SEE ALSO
See funtools(7) for a list of Funtools help pages version 1.4.2 January 2, 2008 funflush(3)

Check Out this Related Man Page

funinfoput(3)							SAORD Documentation						     funinfoput(3)

NAME
FunInfoPut - put information into a Funtools struct SYNOPSIS
#include <funtools.h> int FunInfoPut(Fun fun, int type, char *addr, ...) DESCRIPTION
The FunInfoPut() routine puts information into a Funtools structure. The first argument is the Fun handle from which information is to be retrieved. After this first required argument comes a variable length list of pairs of arguments. Each pair consists of an integer repre- senting the type of information to store and the address of the new information to store in the struct. The variable list is terminated by a 0. The routine returns the number of put actions performed. The full list of available information is described above with the FunInfoPut() routine. Although use of this routine is expected to be uncommon, there is one important situation in which it plays an essential part: writing multiple extensions to a single output file. For input, multiple extensions are handled by calling FunOpen() for each extension to be processed. When opening multiple inputs, it some- times is the case that you will want to process them and then write them (including their header parameters) to a single output file. To accomplish this, you open successive input extensions using FunOpen() and then call FunInfoPut() to set the Funtools reference handle of the output file to that of the newly opened input extension: /* open a new input extension */ ifun=FunOpen(tbuf, "r", NULL)) ) /* make the new extension the reference handle for the output file */ FunInfoPut(ofun, FUN_IFUN, &ifun, 0); Resetting FUN_IFUN has same effect as when a funtools handle is passed as the final argument to FunOpen(). The state of the output file is reset so that a new extension is ready to be written. Thus, the next I/O call on the output extension will output the header, as expected. For example, in a binary table, after resetting FUN_IFUN you can then call FunColumnSelect() to select the columns for output. When you then call FunImagePut() or <A HREF="./library.html#funtablerowput">FunTableRowPut(), a new extension will be written that contains the header parameters from the reference extension. Remember to call FunFlush() to complete output of a given extension. A complete example of this capability is given in the evcol example code. The central algorithm is: o open the output file without a reference handle o loop: open each input extension in turn o set the reference handle for output to the newly opened input extension o read the input rows or image and perform processing o write new rows or image to the output file o flush the output o close input extension o close output file Note that FunFlush() is called after processing each input extension in order to ensure that the proper padding is written to the output file. A call to FunFlush() also ensures that the extension header is written to the output file in the case where there are no rows to output. If you wish to output a new extension without using a Funtools reference handle, you can call FunInfoPut() to reset the FUN_OPS value directly. For a binary table, you would then call FunColumnSelect() to set up the columns for this new extension. /* reset the operations performed on this handle */ int ops=0; FunInfoPut(ofun, FUN_OPS, &ops, 0); FunColumnSelect(fun, sizeof(EvRec), NULL, "MYCOL", "J", "w", FUN_OFFSET(Ev, mycol), NULL); Once the FUN_OPS variable has been reset, the next I/O call on the output extension will output the header, as expected. SEE ALSO
See funtools(7) for a list of Funtools help pages version 1.4.2 January 2, 2008 funinfoput(3)
Man Page