Back to index

avfs  1.0.1
Classes | Defines | Functions
send.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  avfs_out_message_segment
struct  avfs_out_message
struct  avfs_in_message_segment
struct  avfs_in_message

Defines

#define MAXSEG   10

Functions

int __av_read_message (int sock, struct avfs_in_message *msg)
int __av_write_message (int sock, struct avfs_out_message *msg)

Class Documentation

struct avfs_out_message_segment

Definition at line 12 of file send.h.

Class Members
const void * buf
unsigned int len
struct avfs_out_message

Definition at line 17 of file send.h.

Class Members
unsigned int num
struct avfs_in_message_segment

Definition at line 22 of file send.h.

Class Members
void * buf
unsigned int len
struct avfs_in_message

Definition at line 27 of file send.h.

Class Members
unsigned int num

Define Documentation

#define MAXSEG   10

Definition at line 10 of file send.h.


Function Documentation

int __av_read_message ( int  sock,
struct avfs_in_message msg 
)

Definition at line 124 of file send.c.

{
    unsigned int lengths[MAXSEG];
    struct buffer buf;
    int i;

    init_buffer(&buf, sock);
    read_buffer(&buf, (void *) lengths, sizeof(int) * MAXSEG);

    for(i = 0; i < MAXSEG; i++) {
        msg->seg[i].len = lengths[i];
        if(lengths[i] != 0) {
            if(msg->seg[i].buf == NULL)
                msg->seg[i].buf = malloc(lengths[i]);
            
            read_buffer(&buf, msg->seg[i].buf, msg->seg[i].len);
        }
    }
    
    return buf.error;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int __av_write_message ( int  sock,
struct avfs_out_message msg 
)

Definition at line 147 of file send.c.

{
    int i;
    unsigned int lengths[MAXSEG];
    struct buffer buf;

    for(i = 0; i < MAXSEG; i++) {
        if(i < msg->num)
            lengths[i] = msg->seg[i].len;
        else
            lengths[i] = 0;
    }

    init_buffer(&buf, sock);

    write_buffer(&buf, (void *) lengths, sizeof(int) * MAXSEG);
    
    for(i = 0; i < msg->num; i++)
        write_buffer(&buf, msg->seg[i].buf, msg->seg[i].len);

    flush_buffer(&buf);

    return buf.error;
}

Here is the call graph for this function:

Here is the caller graph for this function: