using simple strings for colors in config.h
[surf.git] / surf.c
1 /* See LICENSE file for copyright and license details.
2  *
3  * To understand surf, start reading main().
4  */
5 #include <X11/X.h>
6 #include <X11/Xatom.h>
7 #include <gtk/gtk.h>
8 #include <gdk/gdkx.h>
9 #include <gdk/gdk.h>
10 #include <gdk/gdkkeysyms.h>
11 #include <string.h>
12 #include <unistd.h>
13 #include <getopt.h>
14 #include <stdlib.h>
15 #include <stdio.h>
16 #include <webkit/webkit.h>
17 #include <glib/gstdio.h>
18
19 #define LENGTH(x) (sizeof x / sizeof x[0])
20
21 Display *dpy;
22 Atom urlprop;
23 typedef union Arg Arg;
24 union Arg {
25         const gboolean b;
26         const int i;
27         const unsigned int ui;
28         const void *v;
29 } ;
30
31 typedef struct Client {
32         GtkWidget *win, *scroll, *vbox, *urlbar, *searchbar, *indicator;
33         WebKitWebView *view;
34         WebKitDownload *download;
35         gchar *title;
36         gint progress;
37         struct Client *next;
38 } Client;
39
40 typedef struct Cookie {
41         char *name;
42         char *value;
43         char *domain;
44         char *path;
45         struct Cookie *next;
46 } Cookie;
47
48 typedef enum {
49     BROWSER = 0x0001,
50     SEARCHBAR = 0x0010,
51     URLBAR = 0x0100,
52     ALWAYS = ~0,
53 } KeyFocus;
54
55 typedef struct {
56         guint mod;
57         guint keyval;
58         void (*func)(Client *c, const Arg *arg);
59         const Arg arg;
60         KeyFocus focus;
61 } Key;
62
63 SoupCookieJar *cookiejar;
64 SoupSession *session;
65 Client *clients = NULL;
66 Cookie *cookies = NULL;
67 gboolean embed = FALSE;
68 gboolean showxid = FALSE;
69 gboolean ignore_once = FALSE;
70 extern char *optarg;
71 extern int optind;
72
73 static void cleanup(void);
74 static void proccookies(SoupMessage *m, Client *c);
75 static void clipboard(Client *c, const Arg *arg);
76 static void destroyclient(Client *c);
77 static void destroywin(GtkWidget* w, Client *c);
78 static void die(char *str);
79 static void download(WebKitDownload *o, GParamSpec *pspec, Client *c);
80 static void drawindicator(Client *c);
81 static gboolean exposeindicator(GtkWidget *w, GdkEventExpose *e, Client *c);
82 static gboolean initdownload(WebKitWebView *view, WebKitDownload *o, Client *c);
83 static gchar *geturi(Client *c);
84 static void hidesearch(Client *c, const Arg *arg);
85 static void hideurl(Client *c, const Arg *arg);
86 static gboolean keypress(GtkWidget* w, GdkEventKey *ev, Client *c);
87 static void linkhover(WebKitWebView* page, const gchar* t, const gchar* l, Client *c);
88 static void loadcommit(WebKitWebView *view, WebKitWebFrame *f, Client *c);
89 static void loadstart(WebKitWebView *view, WebKitWebFrame *f, Client *c);
90 static void loadfile(Client *c, const gchar *f);
91 static void loaduri(Client *c, const Arg *arg);
92 static void navigate(Client *c, const Arg *arg);
93 static Client *newclient();
94 static WebKitWebView *newwindow(WebKitWebView  *v, WebKitWebFrame *f, Client *c);
95 static void pasteurl(GtkClipboard *clipboard, const gchar *text, gpointer d);
96 static GdkFilterReturn processx(GdkXEvent *xevent, GdkEvent *event, gpointer d);
97 static void print(Client *c, const Arg *arg);
98 static void progresschange(WebKitWebView *view, gint p, Client *c);
99 static void request(SoupSession *s, SoupMessage *m, Client *c);
100 static void reload(Client *c, const Arg *arg);
101 static void rereadcookies();
102 static void setcookie(char *name, char *val, char *dom, char *path, long exp);
103 static void setup();
104 static void titlechange(WebKitWebView* view, WebKitWebFrame* frame,
105                 const gchar* title, Client *c);
106 static void searchtext(Client *c, const Arg *arg);
107 static void showsearch(Client *c, const Arg *arg);
108 static void showurl(Client *c, const Arg *arg);
109 static void stop(Client *c, const Arg *arg);
110 static void titlechange(WebKitWebView* view, WebKitWebFrame* frame, const gchar* title, Client *c);
111 static void usage();
112 static void update(Client *c, const gchar *title);
113 static void zoom(Client *c, const Arg *arg);
114
115 #include "config.h"
116
117 void
118 cleanup(void) {
119         while(clients)
120                 destroyclient(clients);
121 }
122
123 void
124 proccookies(SoupMessage *m, Client *c) {
125         GSList *l;
126         SoupCookie *co;
127         long t;
128
129         rereadcookies();
130         for (l = soup_cookies_from_response(m); l; l = l->next){
131                 co = (SoupCookie *)l->data;
132                 t = co->expires ?  soup_date_to_time_t(co->expires) : 0;
133                 setcookie(co->name, co->value, co->domain, co->value, t);
134         }
135         g_slist_free(l);
136 }
137
138 void
139 clipboard(Client *c, const Arg *arg) {
140         gboolean paste = *(gboolean *)arg;
141         if(paste)
142                 gtk_clipboard_request_text(gtk_clipboard_get(GDK_SELECTION_PRIMARY), pasteurl, c);
143         else
144                 gtk_clipboard_set_text(gtk_clipboard_get(GDK_SELECTION_PRIMARY), webkit_web_view_get_uri(c->view), -1);
145 }
146
147 void
148 destroyclient(Client *c) {
149         Client *p;
150
151         gtk_widget_destroy(GTK_WIDGET(webkit_web_view_new()));
152         gtk_widget_destroy(c->scroll);
153         gtk_widget_destroy(c->urlbar);
154         gtk_widget_destroy(c->searchbar);
155         gtk_widget_destroy(c->vbox);
156         gtk_widget_destroy(c->win);
157         for(p = clients; p && p->next != c; p = p->next);
158         if(p)
159                 p->next = c->next;
160         else
161                 clients = c->next;
162         free(c);
163         if(clients == NULL)
164                 gtk_main_quit();
165 }
166
167 void
168 destroywin(GtkWidget* w, Client *c) {
169         destroyclient(c);
170 }
171
172 void
173 die(char *str) {
174         fputs(str, stderr);
175         exit(EXIT_FAILURE);
176 }
177
178 void
179 drawindicator(Client *c) {
180         GtkWidget *w;
181         gint width;
182         GdkGC *gc;
183         gchar *uri;
184         GdkColor fg;
185
186
187         uri = geturi(c);
188         w = c->indicator;
189         width = c->progress * w->allocation.width / 100;
190
191         gc = gdk_gc_new(w->window);
192
193         gdk_color_parse(strstr(uri, "https://") == uri ?
194                         progress_trust : progress, &fg);
195         gdk_gc_set_rgb_fg_color(gc, &fg);
196         gdk_draw_rectangle(w->window,
197                         w->style->bg_gc[GTK_WIDGET_STATE(w)],
198                         TRUE,
199                         0, 0, w->allocation.width, w->allocation.height);
200         gdk_draw_rectangle(w->window,
201                         gc,
202                         TRUE,
203                         0, 0, width, w->allocation.height);
204         g_object_unref(gc);/*g_free(gc);*/
205 }
206
207 gboolean
208 exposeindicator(GtkWidget *w, GdkEventExpose *e, Client *c) {
209         drawindicator(c);
210         return TRUE;
211 }
212
213 void
214 download(WebKitDownload *o, GParamSpec *pspec, Client *c) {
215         WebKitDownloadStatus status;
216
217         status = webkit_download_get_status(c->download);
218         if(status == WEBKIT_DOWNLOAD_STATUS_STARTED || status == WEBKIT_DOWNLOAD_STATUS_CREATED) {
219                 c->progress = (int)(webkit_download_get_progress(c->download)*100);
220         }
221         update(c, NULL);
222 }
223
224 gboolean
225 initdownload(WebKitWebView *view, WebKitDownload *o, Client *c) {
226         const gchar *home, *filename;
227         gchar *uri, *path, *html;
228
229         stop(c, NULL);
230         c->download = o;
231         home = g_get_home_dir();
232         filename = webkit_download_get_suggested_filename(o);
233         path = g_build_filename(home, ".surf", "dl", 
234                         filename, NULL);
235         uri = g_strconcat("file://", path, NULL);
236         webkit_download_set_destination_uri(c->download, uri);
237         c->progress = 0;
238         g_free(uri);
239         html = g_strdup_printf("Download <b>%s</b>...", filename);
240         webkit_web_view_load_html_string(c->view, html,
241                         webkit_download_get_uri(c->download));
242         g_signal_connect(c->download, "notify::progress", G_CALLBACK(download), c);
243         g_signal_connect(c->download, "notify::status", G_CALLBACK(download), c);
244         webkit_download_start(c->download);
245         update(c, filename);
246         g_free(html);
247         return TRUE;
248 }
249
250 gchar *
251 geturi(Client *c) {
252         gchar *uri;
253
254         if(!(uri = (gchar *)webkit_web_view_get_uri(c->view)))
255                 uri = g_strdup("about:blank");
256         return uri;
257 }
258
259 void
260 hidesearch(Client *c, const Arg *arg) {
261         gtk_widget_hide(c->searchbar);
262         gtk_widget_grab_focus(GTK_WIDGET(c->view));
263 }
264
265 void
266 hideurl(Client *c, const Arg *arg) {
267         gtk_widget_hide(c->urlbar);
268         gtk_widget_grab_focus(GTK_WIDGET(c->view));
269 }
270
271 gboolean
272 keypress(GtkWidget* w, GdkEventKey *ev, Client *c) {
273         unsigned int i, focus;
274         gboolean processed = FALSE;
275
276         if(ev->type != GDK_KEY_PRESS)
277                 return FALSE;
278         if(GTK_WIDGET_HAS_FOCUS(c->searchbar))
279                 focus = SEARCHBAR;
280         else if(GTK_WIDGET_HAS_FOCUS(c->urlbar))
281                 focus = URLBAR;
282         else
283                 focus = BROWSER;
284         for(i = 0; i < LENGTH(keys); i++) {
285                 if(focus & keys[i].focus && ev->keyval == keys[i].keyval &&
286                                 (ev->state == keys[i].mod || ev->state & keys[i].mod)
287                                 && keys[i].func) {
288                         keys[i].func(c, &(keys[i].arg));
289                         processed = TRUE;
290                 }
291         }
292         return processed;
293 }
294
295 void
296 linkhover(WebKitWebView* page, const gchar* t, const gchar* l, Client *c) {
297         if(l)
298                 gtk_window_set_title(GTK_WINDOW(c->win), l);
299         else
300                 update(c, NULL);
301 }
302
303 void
304 loadcommit(WebKitWebView *view, WebKitWebFrame *f, Client *c) {
305         gchar *uri;
306
307         ignore_once = TRUE;
308         uri = geturi(c);
309         XChangeProperty(dpy, GDK_WINDOW_XID(GTK_WIDGET(c->win)->window), urlprop,
310                         XA_STRING, 8, PropModeReplace, (unsigned char *)uri,
311                         strlen(uri) + 1);
312 }
313
314 void
315 loadstart(WebKitWebView *view, WebKitWebFrame *f, Client *c) {
316         c->progress = 0;
317         update(c, NULL);
318 }
319
320 void
321 loadfile(Client *c, const gchar *f) {
322         GIOChannel *chan = NULL;
323         GError *e = NULL;
324         GString *code;
325         gchar *line, *uri;
326         Arg arg;
327
328         if(strcmp(f, "-") == 0) {
329                 chan = g_io_channel_unix_new(STDIN_FILENO);
330                 if (chan) {
331                         code = g_string_new("");
332                         while(g_io_channel_read_line(chan, &line, NULL, NULL,
333                                                 &e) == G_IO_STATUS_NORMAL) {
334                                 g_string_append(code, line);
335                                 g_free(line);
336                         }
337                         webkit_web_view_load_html_string(c->view, code->str,
338                                         "file://.");
339                         g_io_channel_shutdown(chan, FALSE, NULL);
340                         g_string_free(code, TRUE);
341                 }
342                 arg.v = uri = g_strdup("stdin");
343         }
344         else {
345                 arg.v = uri = g_strdup_printf("file://%s", f);
346                 loaduri(c, &arg);
347         }
348         update(c, uri);
349         g_free(uri);
350 }
351
352 void
353 loaduri(Client *c, const Arg *arg) {
354         gchar *u;
355         const gchar *uri = (gchar *)arg->v;
356         if(!uri)
357                 uri = gtk_entry_get_text(GTK_ENTRY(c->urlbar));
358         u = g_strrstr(uri, "://") ? g_strdup(uri)
359                 : g_strdup_printf("http://%s", uri);
360         webkit_web_view_load_uri(c->view, u);
361         c->progress = 0;
362         update(c, u);
363         g_free(u);
364 }
365
366 void
367 navigate(Client *c, const Arg *arg) {
368         gint steps = *(gint *)arg;
369         webkit_web_view_go_back_or_forward(c->view, steps);
370 }
371
372 Client *
373 newclient(void) {
374         Client *c;
375         if(!(c = calloc(1, sizeof(Client))))
376                 die("Cannot malloc!\n");
377         /* Window */
378         if(embed) {
379                 c->win = gtk_plug_new(0);
380         }
381         else {
382                 c->win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
383                 gtk_window_set_wmclass(GTK_WINDOW(c->win), "surf", "surf");
384         }
385         gtk_window_set_default_size(GTK_WINDOW(c->win), 800, 600);
386         g_signal_connect(G_OBJECT(c->win), "destroy", G_CALLBACK(destroywin), c);
387         g_signal_connect(G_OBJECT(c->win), "key-press-event", G_CALLBACK(keypress), c);
388
389         /* VBox */
390         c->vbox = gtk_vbox_new(FALSE, 0);
391
392         /* scrolled window */
393         c->scroll = gtk_scrolled_window_new(NULL, NULL);
394         gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(c->scroll),
395                         GTK_POLICY_NEVER, GTK_POLICY_NEVER);
396
397         /* webview */
398         c->view = WEBKIT_WEB_VIEW(webkit_web_view_new());
399         g_signal_connect(G_OBJECT(c->view), "title-changed", G_CALLBACK(titlechange), c);
400         g_signal_connect(G_OBJECT(c->view), "load-progress-changed", G_CALLBACK(progresschange), c);
401         g_signal_connect(G_OBJECT(c->view), "load-committed", G_CALLBACK(loadcommit), c);
402         g_signal_connect(G_OBJECT(c->view), "load-started", G_CALLBACK(loadstart), c);
403         g_signal_connect(G_OBJECT(c->view), "hovering-over-link", G_CALLBACK(linkhover), c);
404         g_signal_connect(G_OBJECT(c->view), "create-web-view", G_CALLBACK(newwindow), c);
405         g_signal_connect(G_OBJECT(c->view), "download-requested", G_CALLBACK(initdownload), c);
406         g_signal_connect_after(session, "request-started", G_CALLBACK(request), c);
407
408         /* urlbar */
409         c->urlbar = gtk_entry_new();
410         gtk_entry_set_has_frame(GTK_ENTRY(c->urlbar), FALSE);
411
412         /* searchbar */
413         c->searchbar = gtk_entry_new();
414         gtk_entry_set_has_frame(GTK_ENTRY(c->searchbar), FALSE);
415
416         /* indicator */
417         c->indicator = gtk_drawing_area_new();
418         gtk_widget_set_size_request(c->indicator, 0, 2);
419         g_signal_connect (G_OBJECT (c->indicator), "expose_event",
420                         G_CALLBACK (exposeindicator), c);
421
422         /* downloadbar */
423
424         /* Arranging */
425         gtk_container_add(GTK_CONTAINER(c->scroll), GTK_WIDGET(c->view));
426         gtk_container_add(GTK_CONTAINER(c->win), c->vbox);
427         gtk_container_add(GTK_CONTAINER(c->vbox), c->scroll);
428         gtk_container_add(GTK_CONTAINER(c->vbox), c->searchbar);
429         gtk_container_add(GTK_CONTAINER(c->vbox), c->urlbar);
430         gtk_container_add(GTK_CONTAINER(c->vbox), c->indicator);
431
432         /* Setup */
433         gtk_box_set_child_packing(GTK_BOX(c->vbox), c->urlbar, FALSE, FALSE, 0, GTK_PACK_START);
434         gtk_box_set_child_packing(GTK_BOX(c->vbox), c->searchbar, FALSE, FALSE, 0, GTK_PACK_START);
435         gtk_box_set_child_packing(GTK_BOX(c->vbox), c->indicator, FALSE, FALSE, 0, GTK_PACK_START);
436         gtk_box_set_child_packing(GTK_BOX(c->vbox), c->scroll, TRUE, TRUE, 0, GTK_PACK_START);
437         gtk_widget_grab_focus(GTK_WIDGET(c->view));
438         gtk_widget_hide_all(c->searchbar);
439         gtk_widget_hide_all(c->urlbar);
440         gtk_widget_show(c->vbox);
441         gtk_widget_show(c->indicator);
442         gtk_widget_show(c->scroll);
443         gtk_widget_show(GTK_WIDGET(c->view));
444         gtk_widget_show(c->win);
445         gdk_window_set_events(GTK_WIDGET(c->win)->window, GDK_ALL_EVENTS_MASK);
446         gdk_window_add_filter(GTK_WIDGET(c->win)->window, processx, c);
447         webkit_web_view_set_full_content_zoom(c->view, TRUE);
448         c->download = NULL;
449         c->title = NULL;
450         c->next = clients;
451         clients = c;
452         if(showxid)
453                 printf("%u\n", (unsigned int)GDK_WINDOW_XID(GTK_WIDGET(c->win)->window));
454         return c;
455 }
456
457 WebKitWebView *
458 newwindow(WebKitWebView  *v, WebKitWebFrame *f, Client *c) {
459         Client *n = newclient();
460         return n->view;
461 }
462
463  
464 void
465 pasteurl(GtkClipboard *clipboard, const gchar *text, gpointer d) {
466         Arg arg = {.v = text };
467         if(text != NULL)
468                 loaduri((Client *) d, &arg);
469 }
470
471 GdkFilterReturn
472 processx(GdkXEvent *e, GdkEvent *event, gpointer d) {
473         Client *c = (Client *)d;
474         XPropertyEvent *ev;
475         Atom adummy;
476         int idummy;
477         unsigned long ldummy;
478         unsigned char *buf = NULL;
479         Arg arg;
480
481         if(((XEvent *)e)->type == PropertyNotify) {
482                 ev = &((XEvent *)e)->xproperty;
483                 if(ev->atom == urlprop && ev->state == PropertyNewValue) {
484                         if(ignore_once)
485                                ignore_once = FALSE;
486                         else {
487                                 XGetWindowProperty(dpy, ev->window, urlprop, 0L, BUFSIZ, False, XA_STRING,
488                                         &adummy, &idummy, &ldummy, &ldummy, &buf);
489                                 arg.v = buf;
490                                 loaduri(c, &arg);
491                                 XFree(buf);
492                         }
493                         return GDK_FILTER_REMOVE;
494                 }
495         }
496         return GDK_FILTER_CONTINUE;
497 }
498
499 void
500 print(Client *c, const Arg *arg) {
501         webkit_web_frame_print(webkit_web_view_get_main_frame(c->view));
502 }
503
504 void
505 progresschange(WebKitWebView* view, gint p, Client *c) {
506         c->progress = p;
507         update(c, NULL);
508 }
509
510 void
511 request(SoupSession *s, SoupMessage *m, Client *c) {
512         soup_message_add_header_handler(m, "got-headers", "Set-Cookie",
513                         G_CALLBACK(proccookies), c);
514 }
515
516 void
517 reload(Client *c, const Arg *arg) {
518         gboolean nocache = *(gboolean *)arg;
519         if(nocache)
520                  webkit_web_view_reload_bypass_cache(c->view);
521         else
522                  webkit_web_view_reload(c->view);
523 }
524
525 void
526 rereadcookies() {
527         const gchar *filename, *home;
528
529         home = g_get_home_dir();
530         filename = g_build_filename(home, ".surf", "cookies", NULL);
531 }
532
533 void
534 setcookie(char *name, char *val, char *dom, char *path, long exp) {
535
536 }
537
538 void
539 setup() {
540         dpy = GDK_DISPLAY();
541         session = webkit_get_default_session();
542         urlprop = XInternAtom(dpy, "_SURF_URL", False);
543 }
544
545 void
546 showsearch(Client *c, const Arg *arg) {
547         hideurl(c, NULL);
548         gtk_widget_show(c->searchbar);
549         gtk_widget_grab_focus(c->searchbar);
550 }
551
552 void
553 searchtext(Client *c, const Arg *arg) {
554         gboolean forward = *(gboolean *)arg;
555         webkit_web_view_search_text(c->view,
556                         gtk_entry_get_text(GTK_ENTRY(c->searchbar)),
557                         FALSE,
558                         forward,
559                         TRUE);
560 }
561
562 void
563 showurl(Client *c, const Arg *arg) {
564         gchar *uri;
565
566         hidesearch(c, NULL);
567         uri = geturi(c);
568         gtk_entry_set_text(GTK_ENTRY(c->urlbar), uri);
569         gtk_widget_show(c->urlbar);
570         gtk_widget_grab_focus(c->urlbar);
571 }
572
573 void
574 stop(Client *c, const Arg *arg) {
575         if(c->download)
576                 webkit_download_cancel(c->download);
577         else
578                 webkit_web_view_stop_loading(c->view);
579         c->download = NULL;
580 }
581
582 void
583 titlechange(WebKitWebView *v, WebKitWebFrame *f, const gchar *t, Client *c) {
584         update(c, t);
585 }
586
587 void
588 usage() {
589         fputs("surf - simple browser\n", stderr);
590         die("usage: surf [-e] [-x] [uri]\n");
591 }
592
593 void
594 update(Client *c, const char *title) {
595         gchar *t;
596
597         if(title) {
598                 if(c->title)
599                         g_free(c->title);
600                 c->title = g_strdup(title);
601         }
602         if(c->progress == 100)
603                 t = g_strdup(c->title);
604         else
605                 t = g_strdup_printf("%s [%i%%]", c->title, c->progress);
606         drawindicator(c);
607         gtk_window_set_title(GTK_WINDOW(c->win), t);
608         g_free(t);
609
610 }
611
612 void
613 zoom(Client *c, const Arg *arg) {
614         if(arg->i < 0)          /* zoom out */
615                 webkit_web_view_zoom_out(c->view);
616         else if(arg->i > 0)     /* zoom in */
617                 webkit_web_view_zoom_in(c->view);
618         else                    /* reset */
619                 webkit_web_view_set_zoom_level(c->view, 1.0);
620 }
621
622 int main(int argc, char *argv[]) {
623         SoupSession *s;
624         Client *c;
625         int o;
626         const gchar *home, *filename;
627         Arg arg;
628
629         gtk_init(NULL, NULL);
630         if (!g_thread_supported())
631                 g_thread_init(NULL);
632         setup();
633         while((o = getopt(argc, argv, "vhxeu:f:")) != -1)
634                 switch(o) {
635                 case 'x':
636                         showxid = TRUE;
637                         break;
638                 case 'e':
639                         showxid = TRUE;
640                         embed = TRUE;
641                         break;
642                 case 'v':
643                         die("surf-"VERSION", © 2009 surf engineers, see LICENSE for details\n");
644                         break;
645                 default:
646                         usage();
647                 }
648         if(optind + 1 == argc) {
649                 c = newclient();
650                 arg.v = argv[optind];
651                 if(strchr("./", argv[optind][0]) || strcmp("-", argv[optind]) == 0)
652                         loadfile(c, argv[optind]);
653                 else
654                         loaduri(c, &arg);
655
656         }
657         else if(optind != argc)
658                 usage();
659         if(!clients)
660                 newclient();
661
662         /* make dirs */
663         home = g_get_home_dir();
664         filename = g_build_filename(home, ".surf", NULL);
665         g_mkdir_with_parents(filename, 0711);
666         filename = g_build_filename(home, ".surf", "dl", NULL);
667         g_mkdir_with_parents(filename, 0755);
668
669         /* cookie persistance */
670         s = webkit_get_default_session();
671         filename = g_build_filename(home, ".surf", "cookies.jar", NULL);
672         cookiejar = soup_cookie_jar_text_new(filename, FALSE);
673         soup_session_add_feature(s, SOUP_SESSION_FEATURE(cookiejar));
674
675         gtk_main();
676         cleanup();
677         return EXIT_SUCCESS;
678 }