/[monit]/monit/ssl.c
ViewVC logotype

Diff of /monit/ssl.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.29 by chopp, Wed Sep 3 15:29:29 2003 UTC revision 1.30 by hauk, Fri Sep 19 03:44:17 2003 UTC
# Line 1231  int recv_ssl_socket(ssl_connection *ssl, Line 1231  int recv_ssl_socket(ssl_connection *ssl,
1231    
1232    
1233  /**  /**
  * Receives a string data package though the ssl connection  
  * @param ssl ssl connection  
  * @param buffer array to hold the data  
  * @param len size of the data container  
  * @return pointer to buffer, NULL if failed  
  */  
 char *gets_ssl_socket(ssl_connection *ssl, char *buffer, int len ) {  
   
 #ifdef HAVE_OPENSSL  
   
   int i=0;  
   char c;  
   
   ASSERT(ssl);  
   ASSERT(buffer);  
   
   while(i <= len - 1) {  
   
     switch ( recv_ssl_socket(ssl, (void *) &c, 1, NET_TIMEOUT)) {  
         
     case 1:  
   
       buffer[i]=c;  
       break;  
   
     case 0:  
   
       goto eot;  
   
     default:  
   
       return NULL;  
   
     }  
   
     if (c=='\n') {  
         
       buffer[i+1]='\0';  
       goto eot;  
   
     }  
   
     i++;  
   
   }  
   
  eot:  
   
   return buffer;  
   
 #else  
       
   return NULL;  
     
 #endif  
   
 }  
   
   
 /**  
  * Sends a formated string though the ssl connection  
  * @param ssl ssl connection  
  * @param format string holding the format information  
  * @param ... data for the string  
  * @return number for characters transmitted  
  */  
 int printf_ssl_socket(ssl_connection *ssl, const char *format, ...) {  
   
 #ifdef HAVE_OPENSSL  
     
   char msg[STRLEN];  
   int len;  
   
   va_list ap;  
   
   ASSERT(ssl);  
   ASSERT(format);  
   
   va_start(ap,format);  
   len=vsnprintf(msg, STRLEN, format, ap);  
   va_end(ap);  
   
   return send_ssl_socket(ssl, msg, len);    
   
 #else  
   
   return 0;  
     
 #endif  
     
 }  
   
   
 /**  
1234   * Start SSL support library. It has to be run before the SSL support   * Start SSL support library. It has to be run before the SSL support
1235   * can be used.   * can be used.
1236   * @return TRUE, or FALSE if an error has occured.   * @return TRUE, or FALSE if an error has occured.

Legend:
Removed from v.1.29  
changed lines
  Added in v.1.30

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26