tzsetup.c (94cb21cda66b33851a0eb82a7df8b64047a31c3f) tzsetup.c (336c4682b6f3d181daf9fc7a8c9386c8c06ce996)
1/*
2 * Copyright 1996 Massachusetts Institute of Technology
3 *
4 * Permission to use, copy, modify, and distribute this software and
5 * its documentation for any purpose and without fee is hereby
6 * granted, provided that both the above copyright notice and this
7 * permission notice appear in all copies, that both the above
8 * copyright notice and this permission notice appear in all

--- 18 unchanged lines hidden (view full) ---

27 * SUCH DAMAGE.
28 */
29
30/*
31 * Second attempt at a `tzmenu' program, using the separate description
32 * files provided in newer tzdata releases.
33 */
34
1/*
2 * Copyright 1996 Massachusetts Institute of Technology
3 *
4 * Permission to use, copy, modify, and distribute this software and
5 * its documentation for any purpose and without fee is hereby
6 * granted, provided that both the above copyright notice and this
7 * permission notice appear in all copies, that both the above
8 * copyright notice and this permission notice appear in all

--- 18 unchanged lines hidden (view full) ---

27 * SUCH DAMAGE.
28 */
29
30/*
31 * Second attempt at a `tzmenu' program, using the separate description
32 * files provided in newer tzdata releases.
33 */
34
35/*
36 * When making changes to parser code, run baseline target, check that there are
37 * no unintended changes and commit updated file.
38 */
39
35#include <sys/cdefs.h>
36__FBSDID("$FreeBSD$");
37
38#include <err.h>
39#include <errno.h>
40#include <stdio.h>
41#include <stdlib.h>
42#include <string.h>

--- 196 unchanged lines hidden (view full) ---

239 int i;
240
241 for (i = 0; i < NCONTINENTS; i++)
242 if (strcmp(name, continent_names[i].name) == 0)
243 return (continent_names[i].continent);
244 return (0);
245}
246
40#include <sys/cdefs.h>
41__FBSDID("$FreeBSD$");
42
43#include <err.h>
44#include <errno.h>
45#include <stdio.h>
46#include <stdlib.h>
47#include <string.h>

--- 196 unchanged lines hidden (view full) ---

244 int i;
245
246 for (i = 0; i < NCONTINENTS; i++)
247 if (strcmp(name, continent_names[i].name) == 0)
248 return (continent_names[i].continent);
249 return (0);
250}
251
252static const char *
253find_continent_name(struct continent *cont)
254{
255 int i;
256
257 for (i = 0; i < NCONTINENTS; i++)
258 if (cont == continent_names[i].continent)
259 return (continent_names[i].name);
260 return ("Unknown");
261}
262
247struct country {
248 char *name;
249 char *tlc;
250 int nzones;
251 char *filename; /* use iff nzones < 0 */
252 struct continent *continent; /* use iff nzones < 0 */
253 TAILQ_HEAD(, zone) zones; /* use iff nzones > 0 */
254 dialogMenuItem *submenu; /* use iff nzones > 0 */

--- 524 unchanged lines hidden (view full) ---

779 fclose(f);
780 }
781 }
782
783 return (rv);
784}
785
786static void
263struct country {
264 char *name;
265 char *tlc;
266 int nzones;
267 char *filename; /* use iff nzones < 0 */
268 struct continent *continent; /* use iff nzones < 0 */
269 TAILQ_HEAD(, zone) zones; /* use iff nzones > 0 */
270 dialogMenuItem *submenu; /* use iff nzones > 0 */

--- 524 unchanged lines hidden (view full) ---

795 fclose(f);
796 }
797 }
798
799 return (rv);
800}
801
802static void
803dump_zonetab(void)
804{
805 struct country *cp;
806 struct zone *zp;
807 const char *cont;
808
809 for (cp = countries; cp->name != NULL; cp++) {
810 printf("%s:%s\n", cp->tlc, cp->name);
811 if (cp->nzones < 0) {
812 cont = find_continent_name(cp->continent);
813 printf(" %s:%s\n", cont, cp->filename);
814 } else {
815 TAILQ_FOREACH(zp, &cp->zones, link) {
816 cont = find_continent_name(zp->continent);
817 printf(" %s:%s\n", cont, zp->filename);
818 }
819 }
820 }
821}
822
823static void
787usage(void)
788{
789
790 fprintf(stderr, "usage: tzsetup [-nrs] [-C chroot_directory]"
791 " [zoneinfo_file | zoneinfo_name]\n");
792 exit(1);
793}
794
795int
796main(int argc, char **argv)
797{
798#ifdef HAVE_BSDDIALOG
799 char prompt[128];
800 int fd;
801#endif
802 int c, rv, skiputc;
803 char vm_guest[16] = "";
804 size_t len = sizeof(vm_guest);
824usage(void)
825{
826
827 fprintf(stderr, "usage: tzsetup [-nrs] [-C chroot_directory]"
828 " [zoneinfo_file | zoneinfo_name]\n");
829 exit(1);
830}
831
832int
833main(int argc, char **argv)
834{
835#ifdef HAVE_BSDDIALOG
836 char prompt[128];
837 int fd;
838#endif
839 int c, rv, skiputc;
840 char vm_guest[16] = "";
841 size_t len = sizeof(vm_guest);
842 char *dztpath;
805
843
844 dztpath = NULL;
806 skiputc = 0;
807
808#ifdef HAVE_BSDDIALOG
809 setlocale(LC_ALL, "");
810#endif
811
812 /* Default skiputc to 1 for VM guests */
813 if (sysctlbyname("kern.vm_guest", vm_guest, &len, NULL, 0) == 0 &&
814 strcmp(vm_guest, "none") != 0)
815 skiputc = 1;
816
845 skiputc = 0;
846
847#ifdef HAVE_BSDDIALOG
848 setlocale(LC_ALL, "");
849#endif
850
851 /* Default skiputc to 1 for VM guests */
852 if (sysctlbyname("kern.vm_guest", vm_guest, &len, NULL, 0) == 0 &&
853 strcmp(vm_guest, "none") != 0)
854 skiputc = 1;
855
817 while ((c = getopt(argc, argv, "C:nrs")) != -1) {
856 while ((c = getopt(argc, argv, "C:d:nrs")) != -1) {
818 switch(c) {
819 case 'C':
820 chrootenv = optarg;
821 break;
857 switch(c) {
858 case 'C':
859 chrootenv = optarg;
860 break;
861 case 'd':
862 dztpath = optarg;
863 break;
822 case 'n':
823 reallydoit = 0;
824 break;
825 case 'r':
826 reinstall = 1;
827#ifdef HAVE_BSDDIALOG
828 usedialog = 0;
829#endif

--- 5 unchanged lines hidden (view full) ---

835 usage();
836 }
837 }
838
839 if (argc - optind > 1)
840 usage();
841
842 if (chrootenv == NULL) {
864 case 'n':
865 reallydoit = 0;
866 break;
867 case 'r':
868 reinstall = 1;
869#ifdef HAVE_BSDDIALOG
870 usedialog = 0;
871#endif

--- 5 unchanged lines hidden (view full) ---

877 usage();
878 }
879 }
880
881 if (argc - optind > 1)
882 usage();
883
884 if (chrootenv == NULL) {
843 strcpy(path_zonetab, _PATH_ZONETAB);
885 if (dztpath == NULL)
886 strcpy(path_zonetab, _PATH_ZONETAB);
887 else
888 strlcpy(path_zonetab, dztpath, sizeof(path_zonetab));
844 strcpy(path_iso3166, _PATH_ISO3166);
845 strcpy(path_zoneinfo, _PATH_ZONEINFO);
846 strcpy(path_localtime, _PATH_LOCALTIME);
847 strcpy(path_db, _PATH_DB);
848 strcpy(path_wall_cmos_clock, _PATH_WALL_CMOS_CLOCK);
849 } else {
850 sprintf(path_zonetab, "%s/%s", chrootenv, _PATH_ZONETAB);
851 sprintf(path_iso3166, "%s/%s", chrootenv, _PATH_ISO3166);

--- 45 unchanged lines hidden (view full) ---

897 }
898 /* FALLTHROUGH */
899 }
900#ifdef HAVE_BSDDIALOG
901
902 read_iso3166_table();
903 read_zones();
904 sort_countries();
889 strcpy(path_iso3166, _PATH_ISO3166);
890 strcpy(path_zoneinfo, _PATH_ZONEINFO);
891 strcpy(path_localtime, _PATH_LOCALTIME);
892 strcpy(path_db, _PATH_DB);
893 strcpy(path_wall_cmos_clock, _PATH_WALL_CMOS_CLOCK);
894 } else {
895 sprintf(path_zonetab, "%s/%s", chrootenv, _PATH_ZONETAB);
896 sprintf(path_iso3166, "%s/%s", chrootenv, _PATH_ISO3166);

--- 45 unchanged lines hidden (view full) ---

942 }
943 /* FALLTHROUGH */
944 }
945#ifdef HAVE_BSDDIALOG
946
947 read_iso3166_table();
948 read_zones();
949 sort_countries();
950 if (dztpath != NULL) {
951 dump_zonetab();
952 return (0);
953 }
905 make_menus();
906
907 bsddialog_initconf(&conf);
908 conf.clear = true;
909 conf.auto_minwidth = 24;
910 conf.key.enable_esc = true;
911
912 if (bsddialog_init() == BSDDIALOG_ERROR)

--- 45 unchanged lines hidden ---
954 make_menus();
955
956 bsddialog_initconf(&conf);
957 conf.clear = true;
958 conf.auto_minwidth = 24;
959 conf.key.enable_esc = true;
960
961 if (bsddialog_init() == BSDDIALOG_ERROR)

--- 45 unchanged lines hidden ---