3 #include <../dataio/AsciiFile.h> 4 #include <../dataio/AsciiTable.h> 7 #ifndef CISASCIIFILECOMM_H_ 8 #define CISASCIIFILECOMM_H_ 11 static unsigned _cisAsciiFilesCreated;
19 int init_ascii_file_comm(
comm_t *comm) {
22 comm->
type = ASCII_FILE_COMM;
26 cislog_error(
"init_ascii_file_comm: Failed to malloc asciiFile handle.");
30 handle[0] = asciiFile(comm->
address,
"w", NULL, NULL);
32 handle[0] = asciiFile(comm->
address,
"r", NULL, NULL);
33 comm->
handle = (
void*)handle;
34 int ret = af_open(handle);
36 cislog_error(
"init_ascii_file_comm: Could not open %s", comm->
name);
48 int new_ascii_file_address(
comm_t *comm) {
49 sprintf(comm->
name,
"temp%d", _cisAsciiFilesCreated);
50 int ret = init_ascii_file_comm(comm);
60 int free_ascii_file_comm(
comm_t *x) {
76 int ascii_file_comm_nmsg(
const comm_t x) {
95 int ascii_file_comm_send(
const comm_t x,
const char *data,
const size_t len) {
103 return af_writeline_full(file[0], data);
119 int ascii_file_comm_recv(
const comm_t x,
char **data,
size_t len,
120 const int allow_realloc) {
123 return af_readline_full(file[0], data, (
size_t*)(&len));
125 return af_readline_full_norealloc(file[0], data[0], len);
133 #define ascii_file_comm_send_nolimit ascii_file_comm_send 139 #define ascii_file_comm_recv_nolimit ascii_file_comm_recv void * handle
Pointer to handle for comm.
Definition: CommBase.h:25
Communication structure.
Definition: CommBase.h:19
char address[COMM_ADDRESS_SIZE]
Comm address.
Definition: CommBase.h:22
comm_type type
Comm type.
Definition: CommBase.h:20
int is_file
Flag specifying if the comm connects directly to a file.
Definition: CommBase.h:36
char direction[COMM_DIR_SIZE]
send or recv for direction messages will go.
Definition: CommBase.h:23
char name[COMM_NAME_SIZE]
Comm name.
Definition: CommBase.h:21
int valid
1 if communicator initialized, 0 otherwise.
Definition: CommBase.h:24
Structure containing information about an ASCII text file.
Definition: AsciiFile.h:11