1 /* ivac.c -- main ivac file
3 * author: hackbard@hackdaworld.dyndns.org
4 * frank.zirkelbach@physik.uni-augsburg.de
6 * Copyright (C) 2004 Frank Zirkelbach
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 int main(int argc,char **argv) {
32 /* set username (futur: read from config or entered later) */
33 strcpy(ivac.username,"hackbard");
35 /* set event timeout */
36 ivac.event.timeout.tv_sec=IVAC_S_SEC;
37 ivac.event.timeout.tv_usec=IVAC_S_USEC;
39 /* set listen port (futur: read from config or entered later) */
40 network_set_listen_port(&(ivac.net),IVAC_LISTEN_PORT);
43 event_init(&(ivac.event));
46 input_init(&(ivac.input));
49 network_init(&(ivac.net));
51 /* add listening port + stdin to (read) event system */
52 event_math(ivac.net.l_fd,&(ivac.event),READ,ADD);
53 event_math(0,&(ivac.event),READ,ADD);
55 /* start event system - callbacks used: ivac_event_cb + ivac_regular_cb */
56 event_start(&(ivac.event),(void *)&ivac,ivac_event_cb,ivac_regular_cb);
61 int ivac_event_cb(t_event *event,void *ptr) {
68 if(FD_ISSET(ivac->net.l_fd,&(event->rfds))) {
69 /* manage incoming + send info */
70 channel=network_manage_incoming(&(ivac->net));
71 event_math(ivac->net.connection[channel].fd,event,READ,ADD);
72 send_info(channel,&(ivac->net),ivac->username);
76 for(channel=0;channel<MAX_CONNECTIONS;channel++)
77 if(ivac->net.connection[channel].status&C_ESTABL)
78 if(FD_ISSET(ivac->net.connection[channel].fd,&(event->rfds)))
79 receive_info(channel,&(ivac->net));
81 /* user interaction */
82 if(FD_ISSET(0,&(event->rfds))) input_get_char(ivac);
87 int ivac_regular_cb(t_event *event,void *ptr) {
89 /* usual jobs like audio & video transmit ... */