Mercurial > gftp.yaz
comparison lib/config_file.c @ 87:6df043359b41
2003-1-11 Brian Masney <masneyb@gftp.org>
* autogen.sh - removed --intl and --no-changelog flags to gettextize
* aclocal.m4 - updated
* configure.in - and intl and po directories to AC_OUTPUT
* cvsclean - remove more stuff
* lib/bookmark.c (bookmark_parse_url) - use gftp_parse_bookmark
function
* lib/cache.c - remove gftp_cache_get_url_prefix(). Use
request->url_prefix instead
* lib/config_file.c - use proper exit codes. Also complain if the
default protocol specified in the config file is invalid
* lib/gftp.h lib/local.c lib/protocols.c - removed isblock, ischar,
issocket and isfifo in struct gftp_file (not used anymore)
* lib/gftp.h lib/misc.c - removed file_countlf (not used anymore)
* lib/local.c lib/misc.c lib/protocols.c - various small cleanups
* lib/misc.c (string_hash_function) - check key[i] instead of key[0]
* lib/protocols.c lib/gftp.h - added gftp_parse_bookmark()
* lib/rfc2068.c - if we are connected to a FTP url via a proxy, set
request->url_prefix to be ftp. Added rfc2068_destroy() to free
url_prefix whenever the structure is to be freed
author | masneyb |
---|---|
date | Sat, 11 Jan 2003 15:47:09 +0000 |
parents | 7ef60ce2bdb2 |
children | 5f9ad9facf0e |
comparison
equal
deleted
inserted
replaced
86:759c7d019a89 | 87:6df043359b41 |
---|---|
234 config_htable = g_hash_table_new (string_hash_function, string_hash_compare); | 234 config_htable = g_hash_table_new (string_hash_function, string_hash_compare); |
235 | 235 |
236 if ((tempstr = expand_path (CONFIG_FILE)) == NULL) | 236 if ((tempstr = expand_path (CONFIG_FILE)) == NULL) |
237 { | 237 { |
238 printf (_("gFTP Error: Bad config file name %s\n"), CONFIG_FILE); | 238 printf (_("gFTP Error: Bad config file name %s\n"), CONFIG_FILE); |
239 exit (0); | 239 exit (1); |
240 } | 240 } |
241 | 241 |
242 if (access (tempstr, F_OK) == -1) | 242 if (access (tempstr, F_OK) == -1) |
243 { | 243 { |
244 temp1str = expand_path (BASE_CONF_DIR); | 244 temp1str = expand_path (BASE_CONF_DIR); |
246 { | 246 { |
247 if (mkdir (temp1str, S_IRUSR | S_IWUSR | S_IXUSR) != 0) | 247 if (mkdir (temp1str, S_IRUSR | S_IWUSR | S_IXUSR) != 0) |
248 { | 248 { |
249 printf (_("gFTP Error: Could not make directory %s: %s\n"), | 249 printf (_("gFTP Error: Could not make directory %s: %s\n"), |
250 temp1str, g_strerror (errno)); | 250 temp1str, g_strerror (errno)); |
251 exit (-1); | 251 exit (1); |
252 } | 252 } |
253 } | 253 } |
254 g_free (temp1str); | 254 g_free (temp1str); |
255 | 255 |
256 temp1str = g_strdup_printf ("%s/gftprc", SHARE_DIR); | 256 temp1str = g_strdup_printf ("%s/gftprc", SHARE_DIR); |
257 if (access (temp1str, F_OK) == -1) | 257 if (access (temp1str, F_OK) == -1) |
258 { | 258 { |
259 printf (_("gFTP Error: Cannot find master config file %s\n"), | 259 printf (_("gFTP Error: Cannot find master config file %s\n"), |
260 temp1str); | 260 temp1str); |
261 printf (_("Did you do a make install?\n")); | 261 printf (_("Did you do a make install?\n")); |
262 exit (-1); | 262 exit (1); |
263 } | 263 } |
264 copyfile (temp1str, tempstr); | 264 copyfile (temp1str, tempstr); |
265 g_free (temp1str); | 265 g_free (temp1str); |
266 } | 266 } |
267 | 267 |
268 if ((conffile = fopen (tempstr, "r")) == NULL) | 268 if ((conffile = fopen (tempstr, "r")) == NULL) |
269 { | 269 { |
270 printf (_("gFTP Error: Cannot open config file %s: %s\n"), CONFIG_FILE, | 270 printf (_("gFTP Error: Cannot open config file %s: %s\n"), CONFIG_FILE, |
271 g_strerror (errno)); | 271 g_strerror (errno)); |
272 exit (0); | 272 exit (1); |
273 } | 273 } |
274 g_free (tempstr); | 274 g_free (tempstr); |
275 | 275 |
276 for (i = 0; config_file_vars[i].var != NULL; i++) | 276 for (i = 0; config_file_vars[i].var != NULL; i++) |
277 { | 277 { |
434 { | 434 { |
435 default_protocol = g_malloc (4); | 435 default_protocol = g_malloc (4); |
436 strcpy (default_protocol, "FTP"); | 436 strcpy (default_protocol, "FTP"); |
437 } | 437 } |
438 | 438 |
439 for (i = 0; gftp_protocols[i].name; i++) | |
440 { | |
441 if (strcmp (gftp_protocols[i].name, default_protocol) == 0) | |
442 break; | |
443 } | |
444 | |
445 if (gftp_protocols[i].name == NULL) | |
446 { | |
447 printf (_("gFTP Error: Default protocol %s is not a valid protocol\n"), default_protocol); | |
448 exit (1); | |
449 } | |
450 | |
439 if ((tempstr = expand_path (LOG_FILE)) == NULL) | 451 if ((tempstr = expand_path (LOG_FILE)) == NULL) |
440 { | 452 { |
441 printf (_("gFTP Error: Bad log file name %s\n"), LOG_FILE); | 453 printf (_("gFTP Error: Bad log file name %s\n"), LOG_FILE); |
442 exit (0); | 454 exit (1); |
443 } | 455 } |
444 | 456 |
445 if ((logfd = fopen (tempstr, "w")) == NULL) | 457 if ((logfd = fopen (tempstr, "w")) == NULL) |
446 { | 458 { |
447 printf (_("gFTP Warning: Cannot open %s for writing: %s\n"), | 459 printf (_("gFTP Warning: Cannot open %s for writing: %s\n"), |
520 int line; | 532 int line; |
521 | 533 |
522 if ((tempstr = expand_path (BOOKMARKS_FILE)) == NULL) | 534 if ((tempstr = expand_path (BOOKMARKS_FILE)) == NULL) |
523 { | 535 { |
524 printf (_("gFTP Error: Bad bookmarks file name %s\n"), BOOKMARKS_FILE); | 536 printf (_("gFTP Error: Bad bookmarks file name %s\n"), BOOKMARKS_FILE); |
525 exit (0); | 537 exit (1); |
526 } | 538 } |
527 | 539 |
528 if (access (tempstr, F_OK) == -1) | 540 if (access (tempstr, F_OK) == -1) |
529 { | 541 { |
530 temp1str = g_strdup_printf ("%s/bookmarks", SHARE_DIR); | 542 temp1str = g_strdup_printf ("%s/bookmarks", SHARE_DIR); |
541 | 553 |
542 if ((bmfile = fopen (tempstr, "r")) == NULL) | 554 if ((bmfile = fopen (tempstr, "r")) == NULL) |
543 { | 555 { |
544 printf (_("gFTP Error: Cannot open bookmarks file %s: %s\n"), tempstr, | 556 printf (_("gFTP Error: Cannot open bookmarks file %s: %s\n"), tempstr, |
545 g_strerror (errno)); | 557 g_strerror (errno)); |
546 exit (0); | 558 exit (1); |
547 } | 559 } |
548 g_free (tempstr); | 560 g_free (tempstr); |
549 | 561 |
550 line = 0; | 562 line = 0; |
551 newentry = NULL; | 563 newentry = NULL; |
748 histhdr = N_("This section contains the data that is in the history"); | 760 histhdr = N_("This section contains the data that is in the history"); |
749 | 761 |
750 if ((tempstr = expand_path (CONFIG_FILE)) == NULL) | 762 if ((tempstr = expand_path (CONFIG_FILE)) == NULL) |
751 { | 763 { |
752 printf (_("gFTP Error: Bad config file name %s\n"), CONFIG_FILE); | 764 printf (_("gFTP Error: Bad config file name %s\n"), CONFIG_FILE); |
753 exit (0); | 765 exit (1); |
754 } | 766 } |
755 | 767 |
756 if ((conffile = fopen (tempstr, "w+")) == NULL) | 768 if ((conffile = fopen (tempstr, "w+")) == NULL) |
757 { | 769 { |
758 printf (_("gFTP Error: Cannot open config file %s: %s\n"), CONFIG_FILE, | 770 printf (_("gFTP Error: Cannot open config file %s: %s\n"), CONFIG_FILE, |
759 g_strerror (errno)); | 771 g_strerror (errno)); |
760 exit (0); | 772 exit (1); |
761 } | 773 } |
762 | 774 |
763 g_free (tempstr); | 775 g_free (tempstr); |
764 | 776 |
765 write_comment (conffile, _(hdr)); | 777 write_comment (conffile, _(hdr)); |
870 bmhdr = N_("Bookmarks file for gFTP. Copyright (C) 1998-2002 Brian Masney <masneyb@gftp.org>. Warning: Any comments that you add to this file WILL be overwritten"); | 882 bmhdr = N_("Bookmarks file for gFTP. Copyright (C) 1998-2002 Brian Masney <masneyb@gftp.org>. Warning: Any comments that you add to this file WILL be overwritten"); |
871 | 883 |
872 if ((tempstr = expand_path (BOOKMARKS_FILE)) == NULL) | 884 if ((tempstr = expand_path (BOOKMARKS_FILE)) == NULL) |
873 { | 885 { |
874 printf (_("gFTP Error: Bad bookmarks file name %s\n"), CONFIG_FILE); | 886 printf (_("gFTP Error: Bad bookmarks file name %s\n"), CONFIG_FILE); |
875 exit (0); | 887 exit (1); |
876 } | 888 } |
877 | 889 |
878 if ((bmfile = fopen (tempstr, "w+")) == NULL) | 890 if ((bmfile = fopen (tempstr, "w+")) == NULL) |
879 { | 891 { |
880 printf (_("gFTP Error: Cannot open bookmarks file %s: %s\n"), | 892 printf (_("gFTP Error: Cannot open bookmarks file %s: %s\n"), |
881 CONFIG_FILE, g_strerror (errno)); | 893 CONFIG_FILE, g_strerror (errno)); |
882 exit (0); | 894 exit (1); |
883 } | 895 } |
884 | 896 |
885 g_free (tempstr); | 897 g_free (tempstr); |
886 | 898 |
887 write_comment (bmfile, _(bmhdr)); | 899 write_comment (bmfile, _(bmhdr)); |