src/vapiOptionsSet.c

Ir para a documentação deste ficheiro.
00001 #include <stdarg.h>
00002 #include <stdio.h>
00003 #include "vapiTypes.h"
00004 #include "vapiOptions.h"
00005 #include "vapiAux.h"
00006 
00007 void
00008 vapiOptionsSetInt (vOptionsSettings * OptionsSettings, const char *name,
00009                    const char *description, int min, int max,
00010                    int defaultValue, int scale, vInterfaceType interfaceType)
00011 {
00012         int pos = OptionsSettings->intsNumber;
00013         if (OptionsSettings->intsNumber == 0)
00014         {
00015                 OptionsSettings->ints =
00016                         malloc (++OptionsSettings->intsNumber *
00017                                 sizeof (vOptint));
00018         }
00019         else
00020         {
00021                 OptionsSettings->ints =
00022                         realloc (OptionsSettings->ints,
00023                                  ++OptionsSettings->intsNumber *
00024                                  sizeof (vOptint));
00025         }
00026 
00027         OptionsSettings->ints[pos].min = min;
00028         OptionsSettings->ints[pos].max = max;
00029         OptionsSettings->ints[pos].scale = scale;
00030         OptionsSettings->ints[pos].defaultValue = defaultValue;
00031         OptionsSettings->ints[pos].name = vapiReturnStringPointer (name);
00032         OptionsSettings->ints[pos].description =
00033                 vapiReturnStringPointer (description);
00034         OptionsSettings->ints[pos].interfaceType = interfaceType;
00035 }
00036 
00037 void
00038 vapiOptionsSetFloat (vOptionsSettings * OptionsSettings, const char *name,
00039                      const char *description, double min,
00040                      double max, double defaultValue, double scale,
00041                      vInterfaceType interfaceType)
00042 {
00043         int pos = OptionsSettings->floatsNumber;
00044         if (OptionsSettings->floatsNumber == 0)
00045         {
00046                 OptionsSettings->floats =
00047                         malloc (++OptionsSettings->floatsNumber *
00048                                 sizeof (vOptfloat));
00049         }
00050         else
00051         {
00052                 OptionsSettings->floats =
00053                         realloc (OptionsSettings->floats,
00054                                  ++OptionsSettings->floatsNumber *
00055                                  sizeof (vOptfloat));
00056         }
00057         OptionsSettings->floats[pos].min = min;
00058         OptionsSettings->floats[pos].max = max;
00059         OptionsSettings->floats[pos].scale = scale;
00060         OptionsSettings->floats[pos].defaultValue = defaultValue;
00061         OptionsSettings->floats[pos].name = vapiReturnStringPointer (name);
00062         OptionsSettings->floats[pos].description =
00063                 vapiReturnStringPointer (description);
00064         OptionsSettings->floats[pos].interfaceType = interfaceType;
00065 }
00066 
00067 void
00068 vapiOptionsSetBoolean (vOptionsSettings * OptionsSettings, const char *name,
00069                        const char *description, vBoolean defaultValue)
00070 {
00071         int pos = OptionsSettings->booleansNumber;
00072         if (OptionsSettings->booleansNumber == 0)
00073         {
00074                 OptionsSettings->booleans =
00075                         malloc (++OptionsSettings->booleansNumber *
00076                                 sizeof (vOptBoolean));
00077         }
00078         else
00079         {
00080                 OptionsSettings->booleans =
00081                         realloc (OptionsSettings->booleans,
00082                                  ++OptionsSettings->
00083                                  booleansNumber * sizeof (vOptBoolean));
00084         }
00085         OptionsSettings->booleans[pos].defaultValue = defaultValue;
00086         OptionsSettings->booleans[pos].name = vapiReturnStringPointer (name);
00087         OptionsSettings->booleans[pos].description =
00088                 vapiReturnStringPointer (description);
00089 }
00090 
00091 void
00092 vapiOptionsSetChoose (vOptionsSettings * OptionsSettings,
00093                       const char *name, const char *description,
00094                       int numberOfChoices, int defaultOption, va_list choices)
00095 {
00096         
00097         char *choice;
00098         int pos = OptionsSettings->chooseNumber, i;
00099         if (OptionsSettings->chooseNumber == 0)
00100         {
00101                 OptionsSettings->choose =
00102                         malloc (++OptionsSettings->chooseNumber *
00103                                 sizeof (vOptChoose));
00104         }
00105         else
00106         {
00107                 OptionsSettings->choose =
00108                         realloc (OptionsSettings->choose,
00109                                  ++OptionsSettings->chooseNumber *
00110                                  sizeof (vOptChoose));
00111         }
00112         OptionsSettings->choose[pos].name = vapiReturnStringPointer (name);
00113         OptionsSettings->choose[pos].description =
00114                 vapiReturnStringPointer (description);
00115         OptionsSettings->choose[pos].defaultOption = defaultOption;
00116         OptionsSettings->choose[pos].numberOfChoices = 0;
00117 
00118         for (i = 0; i < numberOfChoices; i++)
00119         {
00120                 choice = va_arg (choices, char *);
00121                 if (OptionsSettings->choose[pos].numberOfChoices == 0)
00122                 {
00123                         OptionsSettings->choose[pos].
00124                                 listOfChoices =
00125                                 malloc (++OptionsSettings->
00126                                         choose[pos].numberOfChoices *
00127                                         sizeof (vChar));
00128                 }
00129                 else
00130                 {
00131                         OptionsSettings->choose[pos].
00132                                 listOfChoices =
00133                                 realloc (OptionsSettings->
00134                                          choose[pos].listOfChoices,
00135                                          ++OptionsSettings->
00136                                          choose[pos].numberOfChoices *
00137                                          sizeof (vChar));
00138                 }
00139                 OptionsSettings->choose[pos].
00140                         listOfChoices[OptionsSettings->choose[pos].
00141                                       numberOfChoices - 1].ch =
00142                         vapiReturnStringPointer (choice);
00143         }
00144 }
00145 
00146 void
00147 vapiOptionsSetChar (vOptionsSettings * OptionsSettings, const char *name,
00148                     const char *description)
00149 {
00150         int pos = OptionsSettings->charsNumber;
00151         if (OptionsSettings->charsNumber == 0)
00152         {
00153                 OptionsSettings->chars =
00154                         malloc (++OptionsSettings->charsNumber *
00155                                 sizeof (vOptchar));
00156         }
00157         else
00158         {
00159                 OptionsSettings->chars =
00160                         realloc (OptionsSettings->chars,
00161                                  ++OptionsSettings->charsNumber *
00162                                  sizeof (vOptchar));
00163         }
00164         OptionsSettings->chars[pos].name = vapiReturnStringPointer (name);
00165         OptionsSettings->chars[pos].description =
00166                 vapiReturnStringPointer (description);
00167 }

Gerado em Tue Jul 24 10:34:59 2007 para Vapi por  doxygen 1.5.1