Ignore:
Timestamp:
Nov 22, 2009, 1:41:45 PM (11 years ago)
Author:
Jean-Yves Lamoureux
Message:
  • Added preliminary OSX support (by support I mean it barely compiles)
  • Moved client's send commands to client.c
File:
1 edited

Legend:

Unmodified
Added
Removed
  • neercs/trunk/src/client.c

    r3986 r3996  
    6262}
    6363
     64int send_event(caca_event_t ev, struct screen_list *screen_list)
     65{
     66   
     67    enum caca_event_type t;
     68   
     69    t = caca_get_event_type(&ev);
     70   
     71    if (t & CACA_EVENT_KEY_PRESS)
     72    {
     73        char buf[16];
     74        int bytes;
     75        bytes =
     76        snprintf(buf, sizeof(buf) - 1, "KEY %d",
     77                 caca_get_event_key_ch(&ev));
     78        buf[bytes] = '\0';
     79        debug("Sending key press to server: %s", buf);
     80        debug("Sending '%s', %d bytes\n", buf, strlen(buf));
     81        return write(screen_list->socket[SOCK_SERVER], buf, strlen(buf)+1) <= 0;
     82    }
     83    else if (t & CACA_EVENT_RESIZE)
     84    {
     85       
     86        char buf[32];
     87        int bytes;
     88        bytes = snprintf(buf, sizeof(buf) - 1, "RESIZE %10d %10d",
     89                         caca_get_event_resize_width(&ev),
     90                         caca_get_event_resize_height(&ev));
     91        buf[bytes] = '\0';
     92        debug("Sending '%s', %d bytes\n", buf, strlen(buf));
     93        return write(screen_list->socket[SOCK_SERVER], buf, strlen(buf)+1) <= 0;
     94    }
     95    else if (t & CACA_EVENT_QUIT)
     96        return write(screen_list->socket[SOCK_SERVER], "QUIT",
     97                     strlen("QUIT")) <= 0;
     98   
     99    return 0;
     100}
     101
     102int send_delay(struct screen_list *screen_list)
     103{
     104    debug("Sending DELAY\n");
     105    char buf[18];
     106    int bytes;
     107    bytes = snprintf(buf, sizeof(buf) - 1, "DELAY %10d", screen_list->delay);
     108    buf[bytes] = '\0';
     109    return write(screen_list->socket[SOCK_SERVER], buf, strlen(buf)) <= 0;
     110}
    64111
    65112
     
    90137        {
    91138            buf[n] = 0;
    92             debug("Received from server: %s", buf);
     139            debug("Received from server: '%s' (%d bytes)", buf, n);
    93140            if (!strncmp("DETACH", buf, 6))
    94141            {
Note: See TracChangeset for help on using the changeset viewer.