Structure of information for output to a file line by line.
More...
#include <PsiInterface.h>
|
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.
|
|
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:
- 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
- Prepare: Allocate space for lines. char line[PSI_MSG_MAX];
- 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 }
- Cleanup. Call functions to deallocate structures and close files. cleanup_pafi(&fin);
Output Usage:
- 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
- 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");
- Send EOF message when done to close the file. ret = af_send_eof(fout);
- Cleanup. Call functions to deallocate structures and close files. cleanup_pafo(&fout);
The documentation for this struct was generated from the following file:
- /home/ubuntu/langmm/cis_iterface/cis_interface/interface/PsiInterface.h