aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2009-02-24 14:45:19 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2009-02-24 14:45:19 +0200
commitb1472caae9a1b6905b6bbe42e69539b29febcf5c (patch)
tree3aaf7a2b4b95ecbdeceefcb8d649c4cb726e84fa
parentf7834b6f1aa00b7173a2fe338756c2bad4e3927b (diff)
downloadwydawca-b1472caae9a1b6905b6bbe42e69539b29febcf5c.tar.gz
wydawca-b1472caae9a1b6905b6bbe42e69539b29febcf5c.tar.bz2
Improve daemon mode.
* gconf/gconf-gram.y: Provide created lists with appropriate equal tests. Special handling for lists of strings. * src/cmdline.opt: Minor fix. * src/config.c: New keyword all-spools. * src/job.c: Hanlde "all spools" requests. * src/net.c: Likewise. * src/process.c (spool_check_alias): Rewrite using gl_list_search (scan_directories): Rename to scan_all_spools. (spool_create_timers): New function. * src/wydawca.c (all_spool_aliases): New global. (initstats): New function. * src/wydawca.h: Add new declarations.
-rw-r--r--gconf/gconf-gram.y139
-rw-r--r--src/cmdline.opt6
-rw-r--r--src/config.c3
-rw-r--r--src/job.c18
-rw-r--r--src/net.c12
-rw-r--r--src/process.c30
-rw-r--r--src/wydawca.c10
-rw-r--r--src/wydawca.h6
8 files changed, 154 insertions, 70 deletions
diff --git a/gconf/gconf-gram.y b/gconf/gconf-gram.y
index f7ee710..66b5416 100644
--- a/gconf/gconf-gram.y
+++ b/gconf/gconf-gram.y
@@ -708,29 +708,62 @@ string_convert (void *target, enum gconf_data_type type, const char *string)
708 return 0; 708 return 0;
709} 709}
710 710
711size_t gconf_type_size_tab[] = { 711struct gconf_prop
712 0 /* gconf_type_void */, 712{
713 sizeof (char*) /* gconf_type_string */, 713 size_t size;
714 sizeof (short) /* gconf_type_short */, 714 gl_listelement_equals_fn eqfn;
715 sizeof (unsigned short) /* gconf_type_ushort */, 715};
716 sizeof (int) /* gconf_type_int */, 716
717 sizeof (unsigned int) /* gconf_type_uint */, 717static bool
718 sizeof (long) /* gconf_type_long */, 718string_eq (const void *elt1, const void *elt2)
719 sizeof (unsigned long) /* gconf_type_ulong */, 719{
720 sizeof (size_t) /* gconf_type_size */, 720 return strcmp ((const char *)elt1, (const char *)elt2) == 0;
721}
722
723#define __gconf_name_cat__(a,b) a ## b
724#define NUMEQ(type) __gconf_name_cat__(type,_eq)
725#define __DECL_NUMEQ(type,ctype) \
726 static bool \
727 NUMEQ(type) (const void *elt1, const void *elt2) \
728 { \
729 return memcmp (elt1, elt2, sizeof (ctype)) == 0; \
730 }
731#define DECL_NUMEQ(type) __DECL_NUMEQ(type,type)
732
733DECL_NUMEQ(short)
734DECL_NUMEQ(int)
735DECL_NUMEQ(long)
736DECL_NUMEQ(size_t)
737DECL_NUMEQ(uintmax_t)
738DECL_NUMEQ(intmax_t)
739DECL_NUMEQ(time_t)
740__DECL_NUMEQ(in_addr, struct in_addr)
741__DECL_NUMEQ(gconf_sockaddr, struct gconf_sockaddr)
742
743struct gconf_prop gconf_prop_tab[] = {
744 { 0, NULL }, /* gconf_type_void */
745 { sizeof (char*), string_eq }, /* gconf_type_string */
746 { sizeof (short), NUMEQ (short) }, /* gconf_type_short */
747 { sizeof (unsigned short), NUMEQ (short) }, /* gconf_type_ushort */
748 { sizeof (int), NUMEQ (int) }, /* gconf_type_int */
749 { sizeof (unsigned int), NUMEQ (int) }, /* gconf_type_uint */
750 { sizeof (long), NUMEQ (long) }, /* gconf_type_long */
751 { sizeof (unsigned long), NUMEQ (long) }, /* gconf_type_ulong */
752 { sizeof (size_t), NUMEQ (size_t) }, /* gconf_type_size */
721 /* gconf_type_off,*/ 753 /* gconf_type_off,*/
722 sizeof (uintmax_t) /* gconf_type_uintmax */, 754 { sizeof (uintmax_t), NUMEQ (uintmax_t) }, /* gconf_type_uintmax */
723 sizeof (intmax_t) /* gconf_type_intmax */, 755 { sizeof (intmax_t), NUMEQ (intmax_t) }, /* gconf_type_intmax */
724 sizeof (time_t) /* gconf_type_time */, 756 { sizeof (time_t), NUMEQ (time_t) }, /* gconf_type_time */
725 sizeof (int) /* gconf_type_bool */, 757 { sizeof (int), NUMEQ (int) }, /* gconf_type_bool */
726 sizeof (struct in_addr) /* gconf_type_ipv4 */, 758 { sizeof (struct in_addr), NUMEQ (in_addr) }, /* gconf_type_ipv4 */
727 0 /* FIXME: gconf_type_cidr */, 759 { 0, NULL }, /* FIXME: gconf_type_cidr */
728 sizeof (struct in_addr) /* gconf_type_host */, 760 { sizeof (struct in_addr), NUMEQ (in_addr) }, /* gconf_type_host */
729 sizeof (struct gconf_sockaddr) /* gconf_type_sockaddr */, 761 { sizeof (struct gconf_sockaddr), NUMEQ (gconf_sockaddr) },
730 0 /* gconf_type_section */ 762 /* gconf_type_sockaddr */
763 { 0, NULL } /* gconf_type_section */
731}; 764};
732#define gconf_type_size_count \ 765#define gconf_prop_count \
733 (sizeof (gconf_type_size_tab) / sizeof (gconf_type_size_tab[0])) 766 (sizeof (gconf_prop_tab) / sizeof (gconf_prop_tab[0]))
734 767
735static void 768static void
736process_ident (struct gconf_keyword *kwp, gconf_value_t *value) 769process_ident (struct gconf_keyword *kwp, gconf_value_t *value)
@@ -763,27 +796,35 @@ process_ident (struct gconf_keyword *kwp, gconf_value_t *value)
763 enum gconf_data_type type = GCONF_TYPE (kwp->type); 796 enum gconf_data_type type = GCONF_TYPE (kwp->type);
764 int num = 1; 797 int num = 1;
765 const void *p; 798 const void *p;
766 gl_list_t list = simple_list_create (true); 799 gl_list_t list;
800 size_t size;
767 801
802 if (type >= gconf_prop_count
803 || (size = gconf_prop_tab[type].size) == 0)
804 {
805 gconf_error (&gconf_current_locus, 0,
806 _("INTERNAL ERROR at %s:%d: "
807 "unhandled data type %d"),
808 __FILE__, __LINE__, type);
809 abort ();
810 }
811
812 list = gl_list_create_empty (&gl_linked_list_implementation,
813 gconf_prop_tab[type].eqfn,
814 NULL,
815 listel_dispose,
816 false);
817
768 while (gl_list_iterator_next (&itr, &p, NULL)) 818 while (gl_list_iterator_next (&itr, &p, NULL))
769 { 819 {
770 const gconf_value_t *vp = p; 820 const gconf_value_t *vp = p;
771 size_t size;
772 821
773 if (type >= gconf_type_size_count
774 || (size = gconf_type_size_tab[type]) == 0)
775 {
776 gconf_error (&gconf_current_locus, 0,
777 _("INTERNAL ERROR at %s:%d: "
778 "unhandled data type %d"),
779 __FILE__, __LINE__, type);
780 abort ();
781 }
782
783 if (vp->type != GCONF_TYPE_STRING) 822 if (vp->type != GCONF_TYPE_STRING)
784 gconf_error (&gconf_current_locus, 0, 823 gconf_error (&gconf_current_locus, 0,
785 _("%s: incompatible data type in list item #%d"), 824 _("%s: incompatible data type in list item #%d"),
786 kwp->ident, num); 825 kwp->ident, num);
826 else if (type == gconf_type_string)
827 gl_list_add_last (list, vp->v.string);
787 else 828 else
788 { 829 {
789 void *ptr = xmalloc (size); 830 void *ptr = xmalloc (size);
@@ -798,34 +839,46 @@ process_ident (struct gconf_keyword *kwp, gconf_value_t *value)
798 } 839 }
799 else 840 else
800 { 841 {
801 gconf_error (&gconf_current_locus, 0, _("incompatible data type for `%s'"), 842 gconf_error (&gconf_current_locus, 0,
843 _("incompatible data type for `%s'"),
802 kwp->ident); 844 kwp->ident);
803 return; 845 return;
804 } 846 }
805 } 847 }
806 else if (GCONF_IS_LIST (kwp->type)) 848 else if (GCONF_IS_LIST (kwp->type))
807 { 849 {
808 gl_list_t list = simple_list_create (true); 850 gl_list_t list;
809 enum gconf_data_type type = GCONF_TYPE (kwp->type); 851 enum gconf_data_type type = GCONF_TYPE (kwp->type);
810 size_t size; 852 size_t size;
811 void *ptr; 853 void *ptr;
812 854
813 if (type >= gconf_type_size_count 855 if (type >= gconf_prop_count
814 || (size = gconf_type_size_tab[type]) == 0) 856 || (size = gconf_prop_tab[type].size) == 0)
815 { 857 {
816 gconf_error (&gconf_current_locus, 0, 858 gconf_error (&gconf_current_locus, 0,
817 _("INTERNAL ERROR at %s:%d: unhandled data type %d"), 859 _("INTERNAL ERROR at %s:%d: unhandled data type %d"),
818 __FILE__, __LINE__, type); 860 __FILE__, __LINE__, type);
819 abort(); 861 abort();
820 } 862 }
821 ptr = xmalloc (size); 863
822 if (string_convert (ptr, type, value->v.string)) 864 list = gl_list_create_empty (&gl_linked_list_implementation,
865 gconf_prop_tab[type].eqfn,
866 NULL,
867 listel_dispose,
868 false);
869 if (type == gconf_type_string)
870 gl_list_add_last (list, value->v.string);
871 else
823 { 872 {
824 free (ptr); 873 ptr = xmalloc (size);
825 gl_list_free (list); 874 if (string_convert (ptr, type, value->v.string))
826 return; 875 {
876 free (ptr);
877 gl_list_free (list);
878 return;
879 }
880 gl_list_add_last (list, ptr);
827 } 881 }
828 gl_list_add_last (list, ptr);
829 *(gl_list_t*)target = list; 882 *(gl_list_t*)target = list;
830 } 883 }
831 else 884 else
diff --git a/src/cmdline.opt b/src/cmdline.opt
index b61517b..8b45791 100644
--- a/src/cmdline.opt
+++ b/src/cmdline.opt
@@ -21,7 +21,7 @@ static gl_list_t source_list;
21static gl_list_t tag_list; 21static gl_list_t tag_list;
22 22
23static bool 23static bool
24source_eq (const void *elt1, const void *elt2) 24string_eq (const void *elt1, const void *elt2)
25{ 25{
26 return strcmp ((const char *)elt1, (const char *)elt2) == 0; 26 return strcmp ((const char *)elt1, (const char *)elt2) == 0;
27} 27}
@@ -99,7 +99,7 @@ OPTION(spool,S,TAG,
99BEGIN