2 #ifndef CISASCIIFILECOMM_H_ 3 #define CISASCIIFILECOMM_H_ 7 #include <../dataio/AsciiFile.h> 8 #include <../dataio/AsciiTable.h> 15 static unsigned _cisAsciiFilesCreated;
23 int init_ascii_file_comm(
comm_t *comm) {
26 comm->
type = ASCII_FILE_COMM;
30 cislog_error(
"init_ascii_file_comm: Failed to malloc asciiFile handle.");
34 handle[0] = asciiFile(comm->
address,
"w", NULL, NULL);
36 handle[0] = asciiFile(comm->
address,
"r", NULL, NULL);
37 comm->
handle = (
void*)handle;
38 int ret = af_open(handle);
40 cislog_error(
"init_ascii_file_comm: Could not open %s", comm->
name);
52 int new_ascii_file_address(
comm_t *comm) {
53 sprintf(comm->
name,
"temp%d", _cisAsciiFilesCreated);
54 int ret = init_ascii_file_comm(comm);
64 int free_ascii_file_comm(
comm_t *x) {
80 int ascii_file_comm_nmsg(
const comm_t x) {
99 int ascii_file_comm_send(
const comm_t x,
const char *data,
const size_t len) {
107 return af_writeline_full(file[0], data);
123 int ascii_file_comm_recv(
const comm_t x,
char **data,
size_t len,
124 const int allow_realloc) {
127 return af_readline_full(file[0], data, (
size_t*)(&len));
129 return af_readline_full_norealloc(file[0], data[0], len);
137 #define ascii_file_comm_send_nolimit ascii_file_comm_send 143 #define ascii_file_comm_recv_nolimit ascii_file_comm_recv void * handle
Pointer to handle for comm.
Definition: CommBase.h:29
Communication structure.
Definition: CommBase.h:23
char address[COMM_ADDRESS_SIZE]
Comm address.
Definition: CommBase.h:26
comm_type type
Comm type.
Definition: CommBase.h:24
int is_file
Flag specifying if the comm connects directly to a file.
Definition: CommBase.h:40
char direction[COMM_DIR_SIZE]
send or recv for direction messages will go.
Definition: CommBase.h:27
char name[COMM_NAME_SIZE]
Comm name.
Definition: CommBase.h:25
int valid
1 if communicator initialized, 0 otherwise.
Definition: CommBase.h:28
Structure containing information about an ASCII text file.
Definition: AsciiFile.h:15