Example #1
0
static void cancel_voice(client_t *c, srs_ccl_voice_t *req)
{
    mrp_debug("received voice cancel request from native client #%d", c->id);

    client_cancel_voice(c->c, req->id);
    reply_status(c, req->reqno, SRS_STATUS_OK, "OK");
}
Example #2
0
static void request_voice(client_t *c, srs_req_voice_t *req)
{
    const char *msg     = req->msg;
    const char *voice   = req->voice;
    double      rate    = req->rate;
    double      pitch   = req->pitch;
    int         timeout = req->timeout;
    int         events  = req->events;
    uint32_t    reqid;

    mrp_debug("received voice render request from native client #%d", c->id);

    reqid = client_render_voice(c->c, msg, voice, rate, pitch, timeout, events);

    if (reqid != SRS_VOICE_INVALID)
        reply_render(c, req->reqno, reqid);
    else
        reply_status(c, req->reqno, SRS_STATUS_FAILED, "failed");
}
void processRequest(char *request, int fd, struct logInformation *logInfo)
{
    char command[BUFFERLENGTH];
    char argument[BUFFERLENGTH];
    
    // parse the command and argument from the request
    if (sscanf(request, "%s%s", command, argument) != 2)
        return;
    
    sanitize(argument);
    //printf("sanitized version is %s\n", argument);
    
    // get the quoted first line of the request and store it in the log structure
    int size = 0;
    char *requestPointer = request;
    while (*requestPointer != '\r' && *requestPointer != '\n')
    {
        size++;
        requestPointer++;
    }
    logInfo->quotedFirstLineOfRequest = malloc((size+3) * sizeof(char));
    strcpy(logInfo->quotedFirstLineOfRequest, "\"");
    strncat(logInfo->quotedFirstLineOfRequest, request, size);
    strcat(logInfo->quotedFirstLineOfRequest, "\"");
    
    if (strcmp(command, "GET") == 0 || strcmp(command, "POST") == 0)
    {
        if (strcmp(argument, "status") == 0)
        {
            reply_status(fd, logInfo);
        }
        else if (strcmp(getFileNameExtension(argument), "cgi") == 0) // cgi script request
        {
            reply_cgi(argument, fd, logInfo);
        }
        else if (doesNotExist(argument))
        {    
            reply_404(argument, fd, logInfo);
        }
        else if (isDirectory(argument))
        {
            // check if the directory contains an index.html file
            char *path = malloc(strlen(argument) + strlen("index.html") + 2);
            strcpy(path, argument);
            strcat(path, "/");
            strcat(path, "index.html");
            if (doesNotExist(path))
            {
                reply_ls(argument, fd, logInfo); // if index.html does not exist then list the contents of the directory
            }    
            else // otherwise cat index.html
            {
                reply_cat(path, fd, logInfo);
            }
            free(path);
        }
        else
        {
            reply_cat(argument, fd, logInfo);
        }
    }
    else
    {
        reply_notImplemented(fd, logInfo);
    }
}