cis_config
Public Attributes | List of all members
psiAsciiFileOutput_t Struct Reference

Structure of information for output to a file line by line. More...

#include <PsiInterface.h>

Public Attributes

int _valid
 Indicates if the structure was succesfully initialized.
 
const char * _name
 Path to local file or name of output channel.
 
int _type
 0 for local file, 1 for output channel.
 
asciiFile_t _file
 Associated output handler for local files.
 
psiOutput_t _psi
 Associated output handler for output channel.
 

Detailed Description

Structure of information for output to a file line by line.

File IO

Handle I/O from/to a local or remote file line by line.

Input Usage:

  1. One-time: Create file interface by providing either a channel name or a path to a local file. psiAsciiFileInput_t fin = psiAsciiFileInput("file_channel", 1); // channel psiAsciiFileInput_t fin = psiAsciiFileInput("/local/file.txt", 0); // local file
  2. Prepare: Allocate space for lines. char line[PSI_MSG_MAX];
  3. Receive each line, terminating when receive returns -1 (EOF or channel closed). int ret = 1; while (ret > 0) { ret = af_recv_line(fin, line, PSI_MSG_MAX); Do something with the line }
  4. Cleanup. Call functions to deallocate structures and close files. cleanup_pafi(&fin);

Output Usage:

  1. One-time: Create file interface by providing either a channel name or a path to a local file. psiAsciiFileOutput_t fout = psiAsciiFileOutput("file_channel", 1); // channel psiAsciiFileOutput_t fout = psiAsciiFileOutput("/local/file.txt", 0); // local file
  2. Send lines to the file. If return value is not 0, the send was not succesfull. int ret; ret = af_send_line(fout, "Line 1\n"); ret = af_send_line(fout, "Line 2\n");
  3. Send EOF message when done to close the file. ret = af_send_eof(fout);
  4. Cleanup. Call functions to deallocate structures and close files. cleanup_pafo(&fout);

The documentation for this struct was generated from the following file: