Exemple #1
0
void broadcast(int id, const char *msg, int op)
{
    int i;
    struct message_t *msgptr;

    pthread_mutex_lock(&users_lock);
    for (i = 0; i < MAX_CLIENTS; i++) {
        if (users[i].active == 1 && i != id) {
            msgptr = (struct message_t*)malloc(sizeof(struct message_t));
            printf("Memory allocated: %p\n", (void*)msgptr);
            strcpy(msgptr->nick, users[id].nick);
            strcpy(msgptr->msg, msg);
            msgptr->op = op;
            ringbuf_push(&buffers[i], msgptr);
        }
    }
    pthread_mutex_unlock(&users_lock);
}
Exemple #2
0
void tx_send(uint8_t asciicode) {
    ringbuf_push(&tx_buf, asciicode);
    PIE1bits.TX1IE = 1;
}