2 * Copyright (C) 2000-2002, Luca Padovani <luca.padovani@cs.unibo.it>.
4 * This file is part of HelmPot, a minimal browser for HELM.
6 * HelmPot is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * HelmPot is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with HelmPot; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 * For details, see the HelmPot World-Wide-Web page,
21 * http://cs.unibo.it/helm/helmpot, or send a mail to
22 * <luca.padovani@cs.unibo.it>
33 #include <sys/types.h>
35 #include <sys/socket.h>
36 #include <netinet/in.h>
37 #include <arpa/inet.h>
44 #define BUFFER_SIZE 2048
46 PRIVATE gchar app_name[64];
48 PRIVATE struct sockaddr_in address;
51 error(const gchar* msg)
53 g_assert(msg != NULL);
54 fprintf(stderr, "%s: fatal error: %s\n", app_name, msg);
61 printf("%s - written by Luca Padovani (C) 2000.\n", app_name);
63 printf("Compiled %s %s\n", __DATE__, __TIME__);
70 timeout(gpointer user_data)
72 static gchar file_name[BUFFER_SIZE];
74 if (recv(sockfd, file_name, BUFFER_SIZE, 0) < 0) {
75 if (errno != EAGAIN && errno != EWOULDBLOCK)
76 error("error receving message");
78 GUI_load_document(file_name);
84 main(int argc, char *argv[])
86 sprintf(app_name, "HELM Pot (Plug-OuT) v%s", VERSION);
89 fprintf(stderr, "%s\n\n", app_name);
90 fprintf(stderr, "Usage: helmpot URL\n");
94 sockfd = socket(PF_INET, SOCK_DGRAM, 0);
95 if (sockfd < 0) error("could not create socket");
97 if (inet_aton("127.0.0.1", &address.sin_addr) < 0)
98 error("could not create address");
99 address.sin_port = 8778;
100 address.sin_family = PF_INET;
102 if (bind(sockfd, &address, sizeof(address)) < 0) {
103 if (sendto(sockfd, argv[1], strlen(argv[1]), 0, &address, sizeof(address)) < 0)
104 error("could not send message");
109 if (fcntl(sockfd, F_SETFL, O_NONBLOCK) < 0)
110 error("could not set the socket to non-block mode");
112 GUI_init(&argc, &argv, app_name, 500, 600, timeout, 500);
114 GUI_load_document(argv[1]);
118 GUI_unload_document();