Main Page   Class Hierarchy   Alphabetical List   Data Structures   File List   Data Fields   Globals  

sendline.c File Reference

#include "rcs_defs.hh"
#include "sendline.h"
#include "sendn.h"
#include "rcs_prnt.hh"
#include <stdlib.h>
#include <string.h>
#include "dbg_mem.h"

Include dependency graph for sendline.c:

Include dependency graph

Go to the source code of this file.

Functions

int sendline (int fd, const char *cptr, int _flags, double _timeout)

Variables

char * sendline_buffer = NULL
long sendline_buffer_size = 0


Function Documentation

int sendline int    fd,
const char *    cptr,
int    flags,
double    timeout
 

Definition at line 36 of file sendline.c.

00037 {
00038   int length;
00039   length = strlen (cptr);
00040 #if defined(MSDOS) && !defined(_Windows)
00041   if (length + 2 > sendline_buffer_size)
00042     {
00043       rcs_print_error ("Since DOS doesn't seem to handle realloc properly\n");
00044       rcs_print_error
00045         ("sending strings over %d with sendline are prohibited.",
00046          sendline_buffer_size);
00047       return (-1);
00048     }
00049 #else
00050   sendline_buffer_size = length + 18 - (length % 16);
00051   sendline_buffer = realloc (sendline_buffer, sendline_buffer_size);
00052   if (NULL == sendline_buffer)
00053     {
00054       rcs_print_error
00055         ("sendline could not allocate %d bytes for temperary buffer.\n",
00056          sendline_buffer_size);
00057       rcs_print_error ("String to send was: %s", cptr);
00058       return (-1);
00059     }
00060 #endif
00061   strcpy (sendline_buffer, cptr);
00062   strcat (sendline_buffer, "\n");
00063   rcs_print_debug (PRINT_SOCKET_WRITE_SIZE, "sendline %s to %d.\n", cptr, fd);
00064   return sendn (fd, sendline_buffer, length + 1, _flags, _timeout);
00065 }


Variable Documentation

char* sendline_buffer = NULL [static]
 

Definition at line 31 of file sendline.c.

long sendline_buffer_size = 0 [static]
 

Definition at line 32 of file sendline.c.


Generated on Sun Dec 2 15:57:54 2001 for rcslib by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001