示例#1
0
void FileHash_handler(char *request)
{
    memset(response, 0, sizeof(response));
    char *request_data = NULL;
    char delim[] = " \n";
    request_data = strtok(request,delim);
    request_data = strtok(NULL,delim);
    if(request_data == NULL)
    {
        error = 1;
        sprintf(response,"ERROR: Wrong Format");
    }
    while(request_data != NULL)
    {
        if(strcmp(request_data,"CheckAll") == 0)
        {
            request_data = strtok(NULL,delim);

            if(request_data != NULL)
            {
                error = 1;
                sprintf(response,"ERROR: Wrong Format. The correct format is:\nFileHash CheckAll");
                return;
            }
            else
            {
                handleCheckAll();
            }

        }
        else if(strcmp(request_data,"Verify") == 0)
        {
            request_data = strtok(NULL,delim);
            if(request_data == NULL)
            {
                error = 1;
                sprintf(response,"ERROR: Wrong Format. The correct format is:\nFileHash Verify <filename>");
                return;
            }
            char *filename = request_data;
            request_data = strtok(NULL,delim);
            if(request_data != NULL)
            {
                error = 1;
                sprintf(response,"ERROR: Wrong Format. The correct format is:\nFileHash Verify <filename>");
                return;
            }
            else
                handleVerify(filename);
        }
    }
}
示例#2
0
void FileHash_handler(char *request)
{
    char *request_data = NULL;
    request_data = strtok(request,delim);
    request_data = strtok(NULL,delim);
    if(request_data == NULL)
    {
        error = 1;
        sprintf(response,"ERROR: Wrong Format\n");
    }
    while(request_data != NULL)
    {
        if(strcmp(request_data,"--checkall") == 0)
        {
            request_data = strtok(NULL,delim);

            if(request_data != NULL)
            {
                error = 1;
                sprintf(response,"ERROR: Wrong Format. The correct format is:\nFileHash --checkall\n");
                return;
            }
            else
            {
                handleCheckAll();
            }

        }
        else if(strcmp(request_data,"--verify") == 0)
        {
            request_data = strtok(NULL,delim);
            if(request_data == NULL)
            {
                error = 1;
                sprintf(response,"ERROR: Wrong Format. The correct format is:\nFileHash --verify <filename>\n");
                return;
            }
            char *filename = request_data;
            request_data = strtok(NULL,delim);
            if(request_data != NULL)
            {
                error = 1;
                sprintf(response,"ERROR: Wrong Format. The correct format is:\nFileHash --verify <filename>\n");
                return;
            }
            else
                handleVerify(filename);
        }
    }
}