cmdriver/src/CMDriver.cxx
//---------------------------------------------------------------------------------------------
// This function will process given ClearCase command with it's arguments and will 
// send the reply
//---------------------------------------------------------------------------------------------
This function will process given ClearCase command with it's arguments and will
send the reply
This function will process given ClearCase command with it ' s arguments and will send the reply
int ProcessClearCaseCommand(ClientDescriptor* client, char **args) {
    char	command[1024];
#ifdef XXX_enable_xerces_parsing
    char*	reply = NULL;
#else
    static char const empty[] = "";
    char* reply = new char[sizeof(empty)];
    strcpy(reply, empty);
#endif
    if(strcmp(args[0],REGISTER_CMD)==0) {
        nClients++;
        sendReply(client->m_ClientSocket,"done");
        _DBG(fprintf(log_fd,"ClearCase %s :done\n",args[0]));
        return 1;
    }
    if(strcmp(args[0],UNREGISTER_CMD)==0) {
        nClients--;
        if(nClients < 1 && work_forever == 0) {
            do_shutdown = 1;
        }
        sendReply(client->m_ClientSocket,"done");
        _DBG(fprintf(log_fd,"ClearCase %s :done\n",args[0]));
    }
    if(strcmp(args[0],UNCHECKOUT_CMD)==0) {
        sprintf(command,"cleartool.exe uncheckout -rm \"%s\"",args[1]);
        if(runCommand(command,&reply)!=0)
            sendReply(client->m_ClientSocket,"Error");
        sendReply(client->m_ClientSocket,reply);
        delete reply;
        _DBG(fprintf(log_fd,"ClearCase %s :done\n",command));
        return 1;
    }
    if(strcmp(args[0],CHECKOUT_CMD)==0) {
        if(args[2] != NULL && args[2][0] != 0)
            sprintf(command,"cleartool.exe checkout -c %s -unreserved \"%s\"",args[2],args[1]);
        else 
            sprintf(command,"cleartool.exe checkout -nc -unreserved \"%s\"",args[1]);
        if(runCommand(command,&reply)!=0)
            sendReply(client->m_ClientSocket,"Error");
        sendReply(client->m_ClientSocket,reply);
        delete reply;
        _DBG(fprintf(log_fd,"ClearCase %s :done\n",command));
        return 1;
    }
    if(strcmp(args[0],CHECKIN_CMD)==0) {
        if(args[2] != NULL && args[2][0] != 0)
            sprintf(command,"cleartool.exe checkin -c %s \"%s\"",args[2],args[1]);
        else
            sprintf(command,"cleartool.exe checkin -nc \"%s\"",args[1]);
        if(runCommand(command,&reply)!=0)
            sendReply(client->m_ClientSocket,"Error");
        sendReply(client->m_ClientSocket,reply);
        delete reply;
        _DBG(fprintf(log_fd,"ClearCase %s :done\n",command));
        return 1;
    }
    if(strcmp(args[0],RESERVE_CMD)==0) {
        if(args[2] != NULL && args[2][0] != 0)
            sprintf(command,"cleartool.exe reserve -c %s \"%s\"",args[2],args[1]);
        else
            sprintf(command,"cleartool.exe reserve -nc \"%s\"",args[1]);
        if(runCommand(command,&reply)!=0)
            sendReply(client->m_ClientSocket,"Error");
        sendReply(client->m_ClientSocket,reply);
        delete reply;
        _DBG(fprintf(log_fd,"ClearCase %s :done\n",command));
        return 1;
    }
    if(strcmp(args[0],UNRESERVE_CMD)==0) {
        if(args[2] != NULL && args[2][0] != 0)
            sprintf(command,"cleartool.exe unreserve -c %s \"%s\"",args[2],args[1]);
        else 
            sprintf(command,"cleartool.exe unreserve -nc %s",args[1]);
        if(runCommand(command,&reply)!=0)
            sendReply(client->m_ClientSocket,"Error");
        sendReply(client->m_ClientSocket,reply);
        delete reply;
        _DBG(fprintf(log_fd,"ClearCase %s :done\n",command));
        return 1;
    }
    if(strcmp(args[0],LOCALLIST_CMD)==0) {
        sprintf(command,"cleartool.exe lspriv -co -short -invob \"%s\"",args[1]);
        if(runCommand(command,&reply,args[1])!=0)
            sendReply(client->m_ClientSocket,"Error");
        sendReply(client->m_ClientSocket,reply);
        delete reply;
        _DBG(fprintf(log_fd,"ClearCase %s :done\n",command));
        return 1;
    }
    sendReply(client->m_ClientSocket,"ClearCase :unknown command");
    _DBG(fprintf(log_fd,"ClearCase Unknown command %s.\n",args[0]));
    return 0;
}
int ProcessClearCaseCommand ( ClientDescriptor * client , char * * args ) { char command [ 1024 ] ; #ifdef XXX_enable_xerces_parsing char * reply = NULL ; #else static char const empty [ ] = " " ; char * reply = new char [ sizeof ( empty ) ] ; strcpy ( reply , empty ) ; #endif if ( strcmp ( args [ 0 ] , REGISTER_CMD ) == 0 ) { nClients ++ ; sendReply ( client -> m_ClientSocket , " " ) ; _DBG ( fprintf ( log_fd , " \n " , args [ 0 ] ) ) ; return 1 ; } if ( strcmp ( args [ 0 ] , UNREGISTER_CMD ) == 0 ) { nClients -- ; if ( nClients < 1 && work_forever == 0 ) { do_shutdown = 1 ; } sendReply ( client -> m_ClientSocket , " " ) ; _DBG ( fprintf ( log_fd , " \n " , args [ 0 ] ) ) ; } if ( strcmp ( args [ 0 ] , UNCHECKOUT_CMD ) == 0 ) { sprintf ( command , " \" \" " , args [ 1 ] ) ; if ( runCommand ( command , & reply ) != 0 ) sendReply ( client -> m_ClientSocket , " " ) ; sendReply ( client -> m_ClientSocket , reply ) ; delete reply ; _DBG ( fprintf ( log_fd , " \n " , command ) ) ; return 1 ; } if ( strcmp ( args [ 0 ] , CHECKOUT_CMD ) == 0 ) { if ( args [ 2 ] != NULL && args [ 2 ] [ 0 ] != 0 ) sprintf ( command , " \" \" " , args [ 2 ] , args [ 1 ] ) ; else sprintf ( command , " \" \" " , args [ 1 ] ) ; if ( runCommand ( command , & reply ) != 0 ) sendReply ( client -> m_ClientSocket , " " ) ; sendReply ( client -> m_ClientSocket , reply ) ; delete reply ; _DBG ( fprintf ( log_fd , " \n " , command ) ) ; return 1 ; } if ( strcmp ( args [ 0 ] , CHECKIN_CMD ) == 0 ) { if ( args [ 2 ] != NULL && args [ 2 ] [ 0 ] != 0 ) sprintf ( command , " \" \" " , args [ 2 ] , args [ 1 ] ) ; else sprintf ( command , " \" \" " , args [ 1 ] ) ; if ( runCommand ( command , & reply ) != 0 ) sendReply ( client -> m_ClientSocket , " " ) ; sendReply ( client -> m_ClientSocket , reply ) ; delete reply ; _DBG ( fprintf ( log_fd , " \n " , command ) ) ; return 1 ; } if ( strcmp ( args [ 0 ] , RESERVE_CMD ) == 0 ) { if ( args [ 2 ] != NULL && args [ 2 ] [ 0 ] != 0 ) sprintf ( command , " \" \" " , args [ 2 ] , args [ 1 ] ) ; else sprintf ( command , " \" \" " , args [ 1 ] ) ; if ( runCommand ( command , & reply ) != 0 ) sendReply ( client -> m_ClientSocket , " " ) ; sendReply ( client -> m_ClientSocket , reply ) ; delete reply ; _DBG ( fprintf ( log_fd , " \n " , command ) ) ; return 1 ; } if ( strcmp ( args [ 0 ] , UNRESERVE_CMD ) == 0 ) { if ( args [ 2 ] != NULL && args [ 2 ] [ 0 ] != 0 ) sprintf ( command , " \" \" " , args [ 2 ] , args [ 1 ] ) ; else sprintf ( command , " " , args [ 1 ] ) ; if ( runCommand ( command , & reply ) != 0 ) sendReply ( client -> m_ClientSocket , " " ) ; sendReply ( client -> m_ClientSocket , reply ) ; delete reply ; _DBG ( fprintf ( log_fd , " \n " , command ) ) ; return 1 ; } if ( strcmp ( args [ 0 ] , LOCALLIST_CMD ) == 0 ) { sprintf ( command , " \" \" " , args [ 1 ] ) ; if ( runCommand ( command , & reply , args [ 1 ] ) != 0 ) sendReply ( client -> m_ClientSocket , " " ) ; sendReply ( client -> m_ClientSocket , reply ) ; delete reply ; _DBG ( fprintf ( log_fd , " \n " , command ) ) ; return 1 ; } sendReply ( client -> m_ClientSocket , " " ) ; _DBG ( fprintf ( log_fd , " \n " , args [ 0 ] ) ) ; return 0 ; }
This function will process given ClearCase command with it's arguments and will
send the reply
This function will process given ClearCase command with it ' s arguments and will send the reply
// Un Check Out command // Check Out command // Check In command // Reserv command // Unreserv command // "get private list of checked out files" command // We do not know this command 