cmdriver/src/CMDriver.cxx
//---------------------------------------------------------------------------------------------
// This function sends the reply. It sends the length of message before sending message 
// itself.
//---------------------------------------------------------------------------------------------
This function sends the reply. It sends the length of message before sending message
itself.
This function sends the reply . It sends the length of message before sending message itself .
static int sendReply(int socket, char const* str, char prefix = 0) {
    int len = (str != NULL) ? strlen(str) : 0;
    char *tmpBuf = NULL;
    if(prefix != 0) {
        if(len == 0) {
            tmpBuf = new char [2];
            tmpBuf[0] = prefix;
            tmpBuf[1] = 0;
            len = 1;
        } else {
            tmpBuf = new char [len + 3];
            tmpBuf[0] = prefix;
            tmpBuf[1] = '\n';
            tmpBuf[2] = 0;
            strcat(tmpBuf, str);
            len += 2;
        }
        str = tmpBuf;
    }
    if(len != 0) {
#ifdef XXX_enable_xerces_parsing
        for(int i=0;i<len;i++) {
            if(str[i]=='\\') {
                str[i]='/';
            }
        }
#endif
        SendString(socket, str);
    }
    delete [] tmpBuf;
    tmpBuf = NULL;
    return len != 0;
}
static int sendReply ( int socket , char const * str , char prefix = 0 ) { int len = ( str != NULL ) ? strlen ( str ) : 0 ; char * tmpBuf = NULL ; if ( prefix != 0 ) { if ( len == 0 ) { tmpBuf = new char [ 2 ] ; tmpBuf [ 0 ] = prefix ; tmpBuf [ 1 ] = 0 ; len = 1 ; } else { tmpBuf = new char [ len + 3 ] ; tmpBuf [ 0 ] = prefix ; tmpBuf [ 1 ] = ' \n ' ; tmpBuf [ 2 ] = 0 ; strcat ( tmpBuf , str ) ; len += 2 ; } str = tmpBuf ; } if ( len != 0 ) { #ifdef XXX_enable_xerces_parsing for ( int i = 0 ; i < len ; i ++ ) { if ( str [ i ] == ' \\ ' ) { str [ i ] = ' ' ; } } #endif SendString ( socket , str ) ; } delete [ ] tmpBuf ; tmpBuf = NULL ; return len != 0 ; }
This function sends the reply.
This function sends the reply .
// M.b. we have to add prefix // If nothing to send -> exit // Replace slashes // Delete memory, which was temporarly allocated. 