Main Page | Modules | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

plural-exp.h

00001 /* Expression parsing and evaluation for plural form selection.
00002    Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
00003    Written by Ulrich Drepper <[email protected]>, 2000.
00004 
00005    This program is free software; you can redistribute it and/or modify it
00006    under the terms of the GNU Library General Public License as published
00007    by the Free Software Foundation; either version 2, or (at your option)
00008    any later version.
00009 
00010    This program is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public
00016    License along with this program; if not, write to the Free Software
00017    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
00018    USA.  */
00019 
00020 #ifndef _PLURAL_EXP_H
00021 #define _PLURAL_EXP_H
00022 
00023 #ifndef PARAMS
00024 # if __STDC__ || defined __GNUC__ || defined __SUNPRO_C || defined __cplusplus || __PROTOTYPES
00025 #  define PARAMS(args) args
00026 # else
00027 #  define PARAMS(args) ()
00028 # endif
00029 #endif
00030 
00031 #ifndef internal_function
00032 # define internal_function
00033 #endif
00034 
00035 #ifndef attribute_hidden
00036 # define attribute_hidden
00037 #endif
00038 
00039 
00040 /* This is the representation of the expressions to determine the
00041    plural form.  */
00042 struct expression
00043 {
00044   int nargs;                    /* Number of arguments.  */
00045   enum operator
00046   {
00047     /* Without arguments:  */
00048     var,                        /* The variable "n".  */
00049     num,                        /* Decimal number.  */
00050     /* Unary operators:  */
00051     lnot,                       /* Logical NOT.  */
00052     /* Binary operators:  */
00053     mult,                       /* Multiplication.  */
00054     divide,                     /* Division.  */
00055     module,                     /* Modulo operation.  */
00056     plus,                       /* Addition.  */
00057     minus,                      /* Subtraction.  */
00058     less_than,                  /* Comparison.  */
00059     greater_than,               /* Comparison.  */
00060     less_or_equal,              /* Comparison.  */
00061     greater_or_equal,           /* Comparison.  */
00062     equal,                      /* Comparison for equality.  */
00063     not_equal,                  /* Comparison for inequality.  */
00064     land,                       /* Logical AND.  */
00065     lor,                        /* Logical OR.  */
00066     /* Ternary operators:  */
00067     qmop                        /* Question mark operator.  */
00068   } operation;
00069   union
00070   {
00071     unsigned long int num;      /* Number value for `num'.  */
00072     struct expression *args[3]; /* Up to three arguments.  */
00073   } val;
00074 };
00075 
00076 /* This is the data structure to pass information to the parser and get
00077    the result in a thread-safe way.  */
00078 struct parse_args
00079 {
00080   const char *cp;
00081   struct expression *res;
00082 };
00083 
00084 
00085 /* Names for the libintl functions are a problem.  This source code is used
00086    1. in the GNU C Library library,
00087    2. in the GNU libintl library,
00088    3. in the GNU gettext tools.
00089    The function names in each situation must be different, to allow for
00090    binary incompatible changes in 'struct expression'.  Furthermore,
00091    1. in the GNU C Library library, the names have a __ prefix,
00092    2.+3. in the GNU libintl library and in the GNU gettext tools, the names
00093          must follow ANSI C and not start with __.
00094    So we have to distinguish the three cases.  */
00095 #ifdef _LIBC
00096 # define FREE_EXPRESSION __gettext_free_exp
00097 # define PLURAL_PARSE __gettextparse
00098 # define GERMANIC_PLURAL __gettext_germanic_plural
00099 # define EXTRACT_PLURAL_EXPRESSION __gettext_extract_plural
00100 #elif defined (IN_LIBINTL)
00101 # define FREE_EXPRESSION libintl_gettext_free_exp
00102 # define PLURAL_PARSE libintl_gettextparse
00103 # define GERMANIC_PLURAL libintl_gettext_germanic_plural
00104 # define EXTRACT_PLURAL_EXPRESSION libintl_gettext_extract_plural
00105 #else
00106 # define FREE_EXPRESSION free_plural_expression
00107 # define PLURAL_PARSE parse_plural_expression
00108 # define GERMANIC_PLURAL germanic_plural
00109 # define EXTRACT_PLURAL_EXPRESSION extract_plural_expression
00110 #endif
00111 
00112 extern void FREE_EXPRESSION PARAMS ((struct expression *exp))
00113      internal_function;
00114 extern int PLURAL_PARSE PARAMS ((void *arg));
00115 extern struct expression GERMANIC_PLURAL attribute_hidden;
00116 extern void EXTRACT_PLURAL_EXPRESSION PARAMS ((const char *nullentry,
00117                                                struct expression **pluralp,
00118                                                unsigned long int *npluralsp))
00119      internal_function;
00120 
00121 #if !defined (_LIBC) && !defined (IN_LIBINTL)
00122 extern unsigned long int plural_eval PARAMS ((struct expression *pexp,
00123                                               unsigned long int n));
00124 #endif
00125 
00126 #endif /* _PLURAL_EXP_H */

Generated on Tue Dec 20 10:14:20 2005 for vlc-0.8.4a by  doxygen 1.4.2