funinfoput(3)

✨ funinfoput(3) ✨

okay bestie, gather round πŸ’– this one's from the SAORD Documentation corner of the funtools universe, and it's lowkey a sleeper hit. it's the FunInfoPut page, and yes it's giving "quiet side character who is actually the main character" energy. πŸŽ€


NAME

FunInfoPut β€” put information into a Funtools struct 🫢


SYNOPSIS

#include <funtools.h>

int FunInfoPut(Fun fun, int type, char *addr, ...)

DESCRIPTION

so the FunInfoPut() routine puts information into a Funtools structure. the first argument is the Fun handle from which information is to be retrieved. πŸ¦‹

after that first required argument comes a variable length list of pairs of arguments. each pair is:

  • an integer representing 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. and the routine returns the number of put actions performed. cute, right? it tells you how much it did. πŸ’…

the full list of available information is described above with the FunInfoPut() routine. and ngl, even though using this routine is expected to be uncommon, there's one situation where it's absolutely essential and it eats every time: writing multiple extensions to a single output file. πŸ‘‘


the multi-extension situation (this is the moment)

for input, multiple extensions are handled by calling FunOpen() for each extension to be processed. when you're opening multiple inputs, sometimes you'll wanna process them and then write them β€” including their header parameters β€” to a single output file. πŸ“

to do that, 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 the same effect as when a funtools handle is passed as the final argument to FunOpen(). the state of the output file gets reset so that a new extension is ready to be written. so basically the next I/O call on the output extension will output the header, as expected. slay. ✨

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. and bestie, remember to call FunFlush() to complete output of a given extension. do not forget. i'm serious. 😭


the whole algorithm, laid out

a complete example of this capability is given in the evcol example code. the central algorithm is:

  • open the output file without a reference handle
  • loop: open each input extension in turn
    • set the reference handle for output to the newly opened input extension
    • read the input rows or image and perform processing
    • write new rows or image to the output file
    • flush the output
    • close input extension
  • 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. so like, even the empty case gets its header. iconic behavior. πŸŽ€


the no-reference-handle route

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. fr fr. πŸ’œ


SEE ALSO

see funtools(7) for a list of Funtools help pages 🌈


and that's the whole vibe check, bestie β€” this page is version 1.4.5, dated April 14, 2011, from the SAORD Documentation crew, and honestly it aged like fine wine πŸ“πŸ§š stay hydrated, flush your extensions, and go write some multi-extension output files like the main character you are. πŸ’–πŸ’