int
XvideoAuthorizeRequest(ClientPtr client, ExtensionEntry *ext)
{
    unsigned short  opcode = StandardMinorOpcode(client);
    ClientPolicyPtr policy = ClientGetPolicyRec(client);
    int             port   = RequestPort(opcode, client->requestBuffer);
     

    if (port < 0) {
        PolicyTrace("client %p (pid %u exe '%s') requested Xv %s",
                    client, policy->pid, policy->exe, RequestName(opcode));
    }
    else {
        PolicyTrace("client %p (pid %u exe '%s') requested Xv %s (port %d)",
                    client, policy->pid, policy->exe,
                    RequestName(opcode), port);
    }


    return Success;
}
Пример #2
0
void FindSeeder(struct file_info* file, int chunk, char* request, int requester) {
    
    //fprintf(stderr, "[DBG] %s, %d, %d, %d\n", file->name, file->chunks, chunk, file->seeders);
    
    struct seeder_info* p;
    
    if (chunk > file->chunks) {
        Response(requester, CHNK_ERR, request);
    }
    
    for (p = &(file->seeders)[chunk]; p != NULL; p = p->next) {
        if (p->busy == false) {
            break;
        }
    }
    if (p == NULL) {
        Response(requester, NO_SEED, request);
    }    
    
    else {
        char peerID[INT_LEN];
        memset(peerID, '\0', INT_LEN);
        itoa(requester, peerID);
        strncpy(request+REQ_LEN+NAME_SIZE+INT_LEN, peerID, INT_LEN);
        if (RequestPort(p, request) != 0) {
            p->busy = true;
            Response(requester, NO_SEED, request);
        }
        else {
            p->busy = true;
            p->nextBusy = busyChunks->nextBusy;
            busyChunks->nextBusy = p;
        }
    }
    
}