mail-notification

Fork of Jean-Yves Lefort's mail-notification, a tray icon to notify of new mail
git clone https://code.djc.id.au/git/mail-notification/

jbsrc/lib/src/core/jb-variable.h (4153B) - raw

      1 /*
      2  * JB, the Jean-Yves Lefort's Build System
      3  * Copyright (C) 2008 Jean-Yves Lefort <jylefort@brutele.be>
      4  *
      5  * This program is free software; you can redistribute it and/or modify
      6  * it under the terms of the GNU General Public License as published by
      7  * the Free Software Foundation; either version 3 of the License, or
      8  * (at your option) any later version.
      9  *
     10  * This program is distributed in the hope that it will be useful,
     11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     13  * GNU General Public License for more details.
     14  *
     15  * You should have received a copy of the GNU General Public License along
     16  * with this program; if not, write to the Free Software Foundation, Inc.,
     17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
     18  */
     19 
     20 #ifndef _JB_VARIABLE_H
     21 #define _JB_VARIABLE_H
     22 
     23 #include <stdarg.h>
     24 #include <sys/types.h>
     25 #include <sys/stat.h>
     26 #include <glib-object.h>
     27 
     28 typedef enum
     29 {
     30   /* allow the user to set it on the command line */
     31   JB_VARIABLE_USER_SETTABLE	= 1 << 0,
     32 
     33   /* add -DWITH_name=0|1 (bool variables only) */
     34   JB_VARIABLE_C_DEFINE		= 1 << 1,
     35 
     36   /* omit it from the configure report */
     37   JB_VARIABLE_NO_REPORT		= 1 << 2
     38 } JBVariableFlags;
     39 
     40 typedef struct
     41 {
     42   char		*name;
     43 } JBVariableGroup;
     44 
     45 typedef struct
     46 {
     47   char		*name;
     48 
     49   GType		gtype;
     50 
     51   gboolean	(*from_string)	(const char *str, GValue *value, GError **err);
     52   char *	(*to_string)	(const GValue *value);
     53 } JBVariableType;
     54 
     55 typedef struct
     56 {
     57   JBVariableType	*type;
     58   char			*name;
     59 
     60   /* can be NULL if the group is NULL */
     61   char			*description;
     62 
     63   /* if NULL, the variable is omitted from the help and report */
     64   JBVariableGroup	*group;
     65 
     66   JBVariableFlags	flags;
     67 
     68   GValue		value;
     69 
     70   int			user_set : 1;
     71 } JBVariable;
     72 
     73 extern GSList *jb_variables;
     74 
     75 extern GSList *jb_variable_groups;
     76 
     77 extern JBVariableGroup *jb_variable_group_compiler_options;
     78 extern JBVariableGroup *jb_variable_group_installation_options;
     79 extern JBVariableGroup *jb_variable_group_external_programs;
     80 
     81 extern JBVariableType *jb_variable_type_bool;
     82 extern JBVariableType *jb_variable_type_string;
     83 extern JBVariableType *jb_variable_type_mode;
     84 
     85 void jb_variable_init (void);
     86 
     87 JBVariableGroup *jb_variable_add_group (const char *name);
     88 
     89 JBVariableType *jb_variable_get_type (const char *name);
     90 
     91 JBVariable *jb_variable_get_variable (const char *name);
     92 JBVariable *jb_variable_get_variable_or_error (const char *name);
     93 
     94 JBVariable *jb_variable_add (JBVariableType *type,
     95 			     const char *name,
     96 			     const char *description,
     97 			     JBVariableGroup *group,
     98 			     JBVariableFlags flags);
     99 
    100 void jb_variable_add_bool (const char *name,
    101 			   const char *description,
    102 			   JBVariableGroup *group,
    103 			   JBVariableFlags flags,
    104 			   gboolean default_value);
    105 void jb_variable_add_string (const char *name,
    106 			     const char *description,
    107 			     JBVariableGroup *group,
    108 			     JBVariableFlags flags,
    109 			     const char *default_value);
    110 void jb_variable_add_mode (const char *name,
    111 			   const char *description,
    112 			   JBVariableGroup *group,
    113 			   JBVariableFlags flags,
    114 			   mode_t default_value);
    115 
    116 gboolean jb_variable_get_bool (const char *name);
    117 void jb_variable_set_bool (const char *name, gboolean value);
    118 
    119 const char *jb_variable_get_string (const char *name);
    120 const char *jb_variable_get_string_or_null (const char *name);
    121 void jb_variable_set_string (const char *name, const char *value);
    122 
    123 mode_t jb_variable_get_mode (const char *name);
    124 void jb_variable_set_mode (const char *name, mode_t value);
    125 
    126 void jb_variable_set_package_flags (const char *name,
    127 				    const char *cflags,
    128 				    const char *cppflags,
    129 				    const char *ldflags,
    130 				    const char *libs);
    131 
    132 gboolean jb_variable_set_from_string (JBVariable *self,
    133 				      const char *value,
    134 				      GError **err);
    135 
    136 char *jb_variable_to_string (JBVariable *self);
    137 
    138 char *jb_variable_evaluate (JBVariable *variable);
    139 char *jb_variable_expand (const char *str, ...) G_GNUC_NULL_TERMINATED;
    140 char *jb_variable_expandv (const char *str, va_list args);
    141 
    142 const char *jb_variable_get_type_name (JBVariable *self);
    143 
    144 #endif /* _JB_VARIABLE_H */