client.c
author Lluís Batlle <viric@viric.name>
Thu, 20 Mar 2014 16:29:13 +0100
branchsaveflie
changeset 96 d090ddac5131
parent 86 c972d3312fbd
permissions -rw-r--r--
Fixing the build on linux, gcc linking parameters order
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
53
07500c5c53cb Adding license and web html.
viric@llimona
parents: 49
diff changeset
     1
/*
07500c5c53cb Adding license and web html.
viric@llimona
parents: 49
diff changeset
     2
    Terminal Mixer - multi-point multi-user access to terminal applications
07500c5c53cb Adding license and web html.
viric@llimona
parents: 49
diff changeset
     3
    Copyright (C) 2007  LluĂ­s Batlle i Rossell
07500c5c53cb Adding license and web html.
viric@llimona
parents: 49
diff changeset
     4
07500c5c53cb Adding license and web html.
viric@llimona
parents: 49
diff changeset
     5
    Please find the license in the provided COPYING file.
07500c5c53cb Adding license and web html.
viric@llimona
parents: 49
diff changeset
     6
*/
23
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
     7
#include <stdio.h>
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
     8
#include <stdlib.h>
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
     9
#include <sys/types.h>
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
    10
#include <sys/select.h>
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
    11
#include <unistd.h>
67
d7405e4f12e1 The timeout should be always handled. Now we use pselect in the loops.
viric@mandarina
parents: 66
diff changeset
    12
#include <signal.h>
23
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
    13
#include <errno.h>
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
    14
#include <string.h>
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
    15
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
    16
#include "main.h"
36
da427c23d755 Added dumps, telnet_filter, applied filters in tm, improved telnet experience.
viric@llimona
parents: 29
diff changeset
    17
#include "filter.h"
23
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
    18
#include "handlers.h"
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
    19
70
51e9b56b487b New client filter in raw mode (-t), where ^] closes the client.
viric@mandarina
parents: 67
diff changeset
    20
struct FilterRules *client_recv_fr = 0;
51e9b56b487b New client filter in raw mode (-t), where ^] closes the client.
viric@mandarina
parents: 67
diff changeset
    21
struct FilterRules *client_termin_fr = 0;
36
da427c23d755 Added dumps, telnet_filter, applied filters in tm, improved telnet experience.
viric@llimona
parents: 29
diff changeset
    22
24
03ddd5ab560b Moving to modules.
viric@llimona
parents: 23
diff changeset
    23
static void loop(Net_c_prepare_read_fdset net_prepare,
03ddd5ab560b Moving to modules.
viric@llimona
parents: 23
diff changeset
    24
        Net_c_process_read_fdset net_process,
03ddd5ab560b Moving to modules.
viric@llimona
parents: 23
diff changeset
    25
        Net_c_send net_send)
23
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
    26
{
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
    27
    fd_set read_set;
86
c972d3312fbd Better variable names: sigold to sigempty
lbatlle@npdl268.bpo.hp.com
parents: 84
diff changeset
    28
    sigset_t sigempty,signoalarm;
23
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
    29
    int maxfd;
24
03ddd5ab560b Moving to modules.
viric@llimona
parents: 23
diff changeset
    30
    int res;
23
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
    31
67
d7405e4f12e1 The timeout should be always handled. Now we use pselect in the loops.
viric@mandarina
parents: 66
diff changeset
    32
    /* Prepare the sigset for blocking alarm */
d7405e4f12e1 The timeout should be always handled. Now we use pselect in the loops.
viric@mandarina
parents: 66
diff changeset
    33
    sigemptyset(&signoalarm);
d7405e4f12e1 The timeout should be always handled. Now we use pselect in the loops.
viric@mandarina
parents: 66
diff changeset
    34
    sigaddset(&signoalarm, SIGALRM);
86
c972d3312fbd Better variable names: sigold to sigempty
lbatlle@npdl268.bpo.hp.com
parents: 84
diff changeset
    35
    sigemptyset(&sigempty);
67
d7405e4f12e1 The timeout should be always handled. Now we use pselect in the loops.
viric@mandarina
parents: 66
diff changeset
    36
23
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
    37
    do
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
    38
    {
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
    39
        FD_ZERO(&read_set);
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
    40
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
    41
        FD_SET(0, &read_set); /* stdin */
24
03ddd5ab560b Moving to modules.
viric@llimona
parents: 23
diff changeset
    42
        maxfd = 0;
03ddd5ab560b Moving to modules.
viric@llimona
parents: 23
diff changeset
    43
03ddd5ab560b Moving to modules.
viric@llimona
parents: 23
diff changeset
    44
        net_prepare(&read_set, &maxfd);
23
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
    45
67
d7405e4f12e1 The timeout should be always handled. Now we use pselect in the loops.
viric@mandarina
parents: 66
diff changeset
    46
        /* Prepare checking for timeout */
86
c972d3312fbd Better variable names: sigold to sigempty
lbatlle@npdl268.bpo.hp.com
parents: 84
diff changeset
    47
        sigprocmask(SIG_BLOCK, &signoalarm, 0);
67
d7405e4f12e1 The timeout should be always handled. Now we use pselect in the loops.
viric@mandarina
parents: 66
diff changeset
    48
d7405e4f12e1 The timeout should be always handled. Now we use pselect in the loops.
viric@mandarina
parents: 66
diff changeset
    49
#ifdef linux
d7405e4f12e1 The timeout should be always handled. Now we use pselect in the loops.
viric@mandarina
parents: 66
diff changeset
    50
        if (command_line.s_param.serve_eth)
84
150a622f26ea Fixing eth_proto bugs. There was no ACK working until now (SIGALARM problems).
lbatlle@npdl268.bpo.hp.com
parents: 76
diff changeset
    51
        {
150a622f26ea Fixing eth_proto bugs. There was no ACK working until now (SIGALARM problems).
lbatlle@npdl268.bpo.hp.com
parents: 76
diff changeset
    52
            int res;
67
d7405e4f12e1 The timeout should be always handled. Now we use pselect in the loops.
viric@mandarina
parents: 66
diff changeset
    53
            /* This will check if the timeout occurred,
84
150a622f26ea Fixing eth_proto bugs. There was no ACK working until now (SIGALARM problems).
lbatlle@npdl268.bpo.hp.com
parents: 76
diff changeset
    54
             * and will not do anything otherwise.
150a622f26ea Fixing eth_proto bugs. There was no ACK working until now (SIGALARM problems).
lbatlle@npdl268.bpo.hp.com
parents: 76
diff changeset
    55
               Will return false when the connection is lost. */
150a622f26ea Fixing eth_proto bugs. There was no ACK working until now (SIGALARM problems).
lbatlle@npdl268.bpo.hp.com
parents: 76
diff changeset
    56
            res = eth_proto_process_timeouts();
150a622f26ea Fixing eth_proto bugs. There was no ACK working until now (SIGALARM problems).
lbatlle@npdl268.bpo.hp.com
parents: 76
diff changeset
    57
            if (!res)
150a622f26ea Fixing eth_proto bugs. There was no ACK working until now (SIGALARM problems).
lbatlle@npdl268.bpo.hp.com
parents: 76
diff changeset
    58
            {
150a622f26ea Fixing eth_proto bugs. There was no ACK working until now (SIGALARM problems).
lbatlle@npdl268.bpo.hp.com
parents: 76
diff changeset
    59
                printf("Connection lost (no ACK received).\n");
150a622f26ea Fixing eth_proto bugs. There was no ACK working until now (SIGALARM problems).
lbatlle@npdl268.bpo.hp.com
parents: 76
diff changeset
    60
                break;
150a622f26ea Fixing eth_proto bugs. There was no ACK working until now (SIGALARM problems).
lbatlle@npdl268.bpo.hp.com
parents: 76
diff changeset
    61
            }
150a622f26ea Fixing eth_proto bugs. There was no ACK working until now (SIGALARM problems).
lbatlle@npdl268.bpo.hp.com
parents: 76
diff changeset
    62
        }
67
d7405e4f12e1 The timeout should be always handled. Now we use pselect in the loops.
viric@mandarina
parents: 66
diff changeset
    63
#endif
d7405e4f12e1 The timeout should be always handled. Now we use pselect in the loops.
viric@mandarina
parents: 66
diff changeset
    64
86
c972d3312fbd Better variable names: sigold to sigempty
lbatlle@npdl268.bpo.hp.com
parents: 84
diff changeset
    65
        res = pselect(maxfd + 1, &read_set, 0, 0, 0, &sigempty);
66
b2469563a1dc Reliable ethernet protocol. I still need pselect instead of select.
viric@mandarina
parents: 60
diff changeset
    66
#ifdef linux
b2469563a1dc Reliable ethernet protocol. I still need pselect instead of select.
viric@mandarina
parents: 60
diff changeset
    67
        if (command_line.c_param.transport == ETHERNET)
b2469563a1dc Reliable ethernet protocol. I still need pselect instead of select.
viric@mandarina
parents: 60
diff changeset
    68
            /* If there isn't a good result, we quit */
b2469563a1dc Reliable ethernet protocol. I still need pselect instead of select.
viric@mandarina
parents: 60
diff changeset
    69
            if (!eth_proto_process_timeouts())
b2469563a1dc Reliable ethernet protocol. I still need pselect instead of select.
viric@mandarina
parents: 60
diff changeset
    70
            {
84
150a622f26ea Fixing eth_proto bugs. There was no ACK working until now (SIGALARM problems).
lbatlle@npdl268.bpo.hp.com
parents: 76
diff changeset
    71
                    printf("Connection lost (no ACK received).\n");
66
b2469563a1dc Reliable ethernet protocol. I still need pselect instead of select.
viric@mandarina
parents: 60
diff changeset
    72
                    break;
b2469563a1dc Reliable ethernet protocol. I still need pselect instead of select.
viric@mandarina
parents: 60
diff changeset
    73
            }
b2469563a1dc Reliable ethernet protocol. I still need pselect instead of select.
viric@mandarina
parents: 60
diff changeset
    74
#endif
23
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
    75
        if (res == -1)
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
    76
        {
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
    77
            if (errno == EINTR)
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
    78
                continue;
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
    79
            else
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
    80
                error("Error in select()");
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
    81
        }
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
    82
24
03ddd5ab560b Moving to modules.
viric@llimona
parents: 23
diff changeset
    83
        res = net_process(&read_set);
03ddd5ab560b Moving to modules.
viric@llimona
parents: 23
diff changeset
    84
        if (res == -1) /* EOF */
03ddd5ab560b Moving to modules.
viric@llimona
parents: 23
diff changeset
    85
            break;
03ddd5ab560b Moving to modules.
viric@llimona
parents: 23
diff changeset
    86
23
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
    87
        if (FD_ISSET(0, &read_set))
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
    88
        {
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
    89
            res = read(0, stream_buffer, stream_buffer_size);
70
51e9b56b487b New client filter in raw mode (-t), where ^] closes the client.
viric@mandarina
parents: 67
diff changeset
    90
            if (client_termin_fr)
51e9b56b487b New client filter in raw mode (-t), where ^] closes the client.
viric@mandarina
parents: 67
diff changeset
    91
            {
51e9b56b487b New client filter in raw mode (-t), where ^] closes the client.
viric@mandarina
parents: 67
diff changeset
    92
                int olen;
76
5c0b9c9f9801 Fixed filter, and the client now parses ~~~ and ~~. (closing client)
viric@llimona
parents: 70
diff changeset
    93
                /* We use ostream_buffer2 for data from the
5c0b9c9f9801 Fixed filter, and the client now parses ~~~ and ~~. (closing client)
viric@llimona
parents: 70
diff changeset
    94
                 * keyboard to the tm client, because
5c0b9c9f9801 Fixed filter, and the client now parses ~~~ and ~~. (closing client)
viric@llimona
parents: 70
diff changeset
    95
                 * *_client.c use the ostream_buffer for data
5c0b9c9f9801 Fixed filter, and the client now parses ~~~ and ~~. (closing client)
viric@llimona
parents: 70
diff changeset
    96
                 * from the server to us (tm client). */
5c0b9c9f9801 Fixed filter, and the client now parses ~~~ and ~~. (closing client)
viric@llimona
parents: 70
diff changeset
    97
                hex_dump("Client prefilter", stream_buffer, res);
5c0b9c9f9801 Fixed filter, and the client now parses ~~~ and ~~. (closing client)
viric@llimona
parents: 70
diff changeset
    98
                filter_stream(client_termin_fr, ostream_buffer2, &olen,
70
51e9b56b487b New client filter in raw mode (-t), where ^] closes the client.
viric@mandarina
parents: 67
diff changeset
    99
                        stream_buffer,
51e9b56b487b New client filter in raw mode (-t), where ^] closes the client.
viric@mandarina
parents: 67
diff changeset
   100
                        res);
76
5c0b9c9f9801 Fixed filter, and the client now parses ~~~ and ~~. (closing client)
viric@llimona
parents: 70
diff changeset
   101
                if (olen > 0)
5c0b9c9f9801 Fixed filter, and the client now parses ~~~ and ~~. (closing client)
viric@llimona
parents: 70
diff changeset
   102
                    net_send(ostream_buffer2, olen);
70
51e9b56b487b New client filter in raw mode (-t), where ^] closes the client.
viric@mandarina
parents: 67
diff changeset
   103
            }
51e9b56b487b New client filter in raw mode (-t), where ^] closes the client.
viric@mandarina
parents: 67
diff changeset
   104
            else
51e9b56b487b New client filter in raw mode (-t), where ^] closes the client.
viric@mandarina
parents: 67
diff changeset
   105
                net_send(stream_buffer, res);
23
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
   106
            if (res == 0) /* EOF */
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
   107
                break;
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
   108
        }
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
   109
    } while (1);
24
03ddd5ab560b Moving to modules.
viric@llimona
parents: 23
diff changeset
   110
}
23
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
   111
76
5c0b9c9f9801 Fixed filter, and the client now parses ~~~ and ~~. (closing client)
viric@llimona
parents: 70
diff changeset
   112
void filtercb_tildes(struct FilterRules *fr, const struct FFilter *ff,
70
51e9b56b487b New client filter in raw mode (-t), where ^] closes the client.
viric@mandarina
parents: 67
diff changeset
   113
        char *obuf, int *olen, const char *ibuf, int pos)
51e9b56b487b New client filter in raw mode (-t), where ^] closes the client.
viric@mandarina
parents: 67
diff changeset
   114
{
76
5c0b9c9f9801 Fixed filter, and the client now parses ~~~ and ~~. (closing client)
viric@llimona
parents: 70
diff changeset
   115
    dump_line("filtercb_tildes: '%c'\n", ibuf[pos+3]);
5c0b9c9f9801 Fixed filter, and the client now parses ~~~ and ~~. (closing client)
viric@llimona
parents: 70
diff changeset
   116
    if (ibuf[pos+3] == '.')
5c0b9c9f9801 Fixed filter, and the client now parses ~~~ and ~~. (closing client)
viric@llimona
parents: 70
diff changeset
   117
        kill(getpid(), SIGINT);
5c0b9c9f9801 Fixed filter, and the client now parses ~~~ and ~~. (closing client)
viric@llimona
parents: 70
diff changeset
   118
    else
5c0b9c9f9801 Fixed filter, and the client now parses ~~~ and ~~. (closing client)
viric@llimona
parents: 70
diff changeset
   119
    {
5c0b9c9f9801 Fixed filter, and the client now parses ~~~ and ~~. (closing client)
viric@llimona
parents: 70
diff changeset
   120
        obuf[(*olen)++] = '~';
5c0b9c9f9801 Fixed filter, and the client now parses ~~~ and ~~. (closing client)
viric@llimona
parents: 70
diff changeset
   121
        obuf[(*olen)++] = '~';
5c0b9c9f9801 Fixed filter, and the client now parses ~~~ and ~~. (closing client)
viric@llimona
parents: 70
diff changeset
   122
        obuf[(*olen)++] = '~';
5c0b9c9f9801 Fixed filter, and the client now parses ~~~ and ~~. (closing client)
viric@llimona
parents: 70
diff changeset
   123
    }
70
51e9b56b487b New client filter in raw mode (-t), where ^] closes the client.
viric@mandarina
parents: 67
diff changeset
   124
}
51e9b56b487b New client filter in raw mode (-t), where ^] closes the client.
viric@mandarina
parents: 67
diff changeset
   125
24
03ddd5ab560b Moving to modules.
viric@llimona
parents: 23
diff changeset
   126
int client()
03ddd5ab560b Moving to modules.
viric@llimona
parents: 23
diff changeset
   127
{
03ddd5ab560b Moving to modules.
viric@llimona
parents: 23
diff changeset
   128
    Net_c_prepare_read_fdset net_prepare_read_fdset;
03ddd5ab560b Moving to modules.
viric@llimona
parents: 23
diff changeset
   129
    Net_c_process_read_fdset net_process_read_fdset;
03ddd5ab560b Moving to modules.
viric@llimona
parents: 23
diff changeset
   130
    Net_c_send net_send;
03ddd5ab560b Moving to modules.
viric@llimona
parents: 23
diff changeset
   131
36
da427c23d755 Added dumps, telnet_filter, applied filters in tm, improved telnet experience.
viric@llimona
parents: 29
diff changeset
   132
    /* Prepare the filter */
da427c23d755 Added dumps, telnet_filter, applied filters in tm, improved telnet experience.
viric@llimona
parents: 29
diff changeset
   133
    {
da427c23d755 Added dumps, telnet_filter, applied filters in tm, improved telnet experience.
viric@llimona
parents: 29
diff changeset
   134
        struct FFilter *ff;
70
51e9b56b487b New client filter in raw mode (-t), where ^] closes the client.
viric@mandarina
parents: 67
diff changeset
   135
        client_recv_fr = new_filter_rules();
36
da427c23d755 Added dumps, telnet_filter, applied filters in tm, improved telnet experience.
viric@llimona
parents: 29
diff changeset
   136
        ff = new_ftelnet();
70
51e9b56b487b New client filter in raw mode (-t), where ^] closes the client.
viric@mandarina
parents: 67
diff changeset
   137
        add_ffilter(client_recv_fr, ff);
51e9b56b487b New client filter in raw mode (-t), where ^] closes the client.
viric@mandarina
parents: 67
diff changeset
   138
        if (command_line.c_param.raw_mode)
51e9b56b487b New client filter in raw mode (-t), where ^] closes the client.
viric@mandarina
parents: 67
diff changeset
   139
        {
51e9b56b487b New client filter in raw mode (-t), where ^] closes the client.
viric@mandarina
parents: 67
diff changeset
   140
            client_termin_fr = new_filter_rules();
76
5c0b9c9f9801 Fixed filter, and the client now parses ~~~ and ~~. (closing client)
viric@llimona
parents: 70
diff changeset
   141
            ff = new_ftildes();
5c0b9c9f9801 Fixed filter, and the client now parses ~~~ and ~~. (closing client)
viric@llimona
parents: 70
diff changeset
   142
            ff->callback = filtercb_tildes;
70
51e9b56b487b New client filter in raw mode (-t), where ^] closes the client.
viric@mandarina
parents: 67
diff changeset
   143
            add_ffilter(client_termin_fr, ff);
51e9b56b487b New client filter in raw mode (-t), where ^] closes the client.
viric@mandarina
parents: 67
diff changeset
   144
        }
36
da427c23d755 Added dumps, telnet_filter, applied filters in tm, improved telnet experience.
viric@llimona
parents: 29
diff changeset
   145
    }
da427c23d755 Added dumps, telnet_filter, applied filters in tm, improved telnet experience.
viric@llimona
parents: 29
diff changeset
   146
29
91286c3ecebc Added getopt, and some things got based on parameters.
viric@llimona
parents: 26
diff changeset
   147
    if (command_line.c_param.transport == UNIX)
91286c3ecebc Added getopt, and some things got based on parameters.
viric@llimona
parents: 26
diff changeset
   148
        /* Will be 'tcp', 'ether', ... */
24
03ddd5ab560b Moving to modules.
viric@llimona
parents: 23
diff changeset
   149
    {
03ddd5ab560b Moving to modules.
viric@llimona
parents: 23
diff changeset
   150
        c_unix_connect_socket();
03ddd5ab560b Moving to modules.
viric@llimona
parents: 23
diff changeset
   151
        net_prepare_read_fdset = c_unix_prepare_read_fdset;
03ddd5ab560b Moving to modules.
viric@llimona
parents: 23
diff changeset
   152
        net_process_read_fdset = c_unix_process_read_fdset;
03ddd5ab560b Moving to modules.
viric@llimona
parents: 23
diff changeset
   153
        net_send = c_unix_send;
49
1cead94cfd99 Fixing a few bugs. The program runs well in Linux and Mac OS X.
viric@llimona
parents: 43
diff changeset
   154
    }
1cead94cfd99 Fixing a few bugs. The program runs well in Linux and Mac OS X.
viric@llimona
parents: 43
diff changeset
   155
#ifdef linux
1cead94cfd99 Fixing a few bugs. The program runs well in Linux and Mac OS X.
viric@llimona
parents: 43
diff changeset
   156
    else if (command_line.c_param.transport == ETHERNET)
43
625794738afc Added first attempt for an ethernet protocol. Even not tried.
viric@llimona
parents: 36
diff changeset
   157
    {
625794738afc Added first attempt for an ethernet protocol. Even not tried.
viric@llimona
parents: 36
diff changeset
   158
        c_eth_init();
625794738afc Added first attempt for an ethernet protocol. Even not tried.
viric@llimona
parents: 36
diff changeset
   159
        net_prepare_read_fdset = c_eth_prepare_read_fdset;
625794738afc Added first attempt for an ethernet protocol. Even not tried.
viric@llimona
parents: 36
diff changeset
   160
        net_process_read_fdset = c_eth_process_read_fdset;
625794738afc Added first attempt for an ethernet protocol. Even not tried.
viric@llimona
parents: 36
diff changeset
   161
        net_send = c_eth_send_to_connected;
24
03ddd5ab560b Moving to modules.
viric@llimona
parents: 23
diff changeset
   162
    }
49
1cead94cfd99 Fixing a few bugs. The program runs well in Linux and Mac OS X.
viric@llimona
parents: 43
diff changeset
   163
#endif /* linux */
24
03ddd5ab560b Moving to modules.
viric@llimona
parents: 23
diff changeset
   164
29
91286c3ecebc Added getopt, and some things got based on parameters.
viric@llimona
parents: 26
diff changeset
   165
    if (command_line.c_param.raw_mode)
91286c3ecebc Added getopt, and some things got based on parameters.
viric@llimona
parents: 26
diff changeset
   166
        prepare_user_terminal();
26
96920c3707b3 Unix sockets version works! Well, signals don't. :)
viric@llimona
parents: 24
diff changeset
   167
24
03ddd5ab560b Moving to modules.
viric@llimona
parents: 23
diff changeset
   168
    loop(net_prepare_read_fdset, net_process_read_fdset, net_send);
03ddd5ab560b Moving to modules.
viric@llimona
parents: 23
diff changeset
   169
29
91286c3ecebc Added getopt, and some things got based on parameters.
viric@llimona
parents: 26
diff changeset
   170
    if (command_line.c_param.raw_mode)
91286c3ecebc Added getopt, and some things got based on parameters.
viric@llimona
parents: 26
diff changeset
   171
        restore_user_terminal();
26
96920c3707b3 Unix sockets version works! Well, signals don't. :)
viric@llimona
parents: 24
diff changeset
   172
23
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
   173
    return 0;
b3e6c6ffc69c Moving the client out.
viric@llimona
parents:
diff changeset
   174
}