Referência ao ficheiro src/vapiOptionsXML.c

#include <libxml/encoding.h>
#include <libxml/xmlreader.h>
#include <libxml/xmlwriter.h>
#include <string.h>
#include <stdarg.h>
#include "vapiOptions.h"
#include "vapiOptionsXML.h"
#include "vapiString.h"
#include "vapiXML.h"
#include "vapiAux.h"
#include "vapiOperation.h"

Diagrama de dependências de inclusão para vapiOptionsXML.c:

Ir para o código fonte deste ficheiro.

Funções

int vapiOptionsXMLCheckOption (xmlTextReader *xmlInput, int ret)
 checks the options grabbed from the xml file.
static void vapiOptionsXMLGetBooleans (vOptionsSettings *OptionsSettings, vOptions *Options, xmlTextWriter *xmlOutput)
static void vapiOptionsXMLGetChars (vOptionsSettings *OptionsSettings, vOptions *Options, xmlTextWriter *xmlOutput)
static void vapiOptionsXMLGetChoices (vOptionsSettings *OptionsSettings, vOptions *Options, xmlTextWriter *xmlOutput)
static void vapiOptionsXMLGetFloats (vOptionsSettings *OptionsSettings, vOptions *Options, xmlTextWriter *xmlOutput)
static void vapiOptionsXMLGetInts (vOptionsSettings *OptionsSettings, vOptions *Options, xmlTextWriter *xmlOutput)
void vapiOptionsXMLGetOptions (xmlTextWriter *xmlOutput, vOptionsSettings *OptionsSettings, vOptions *Options, vOptionsXMLGetOptionsCustom OptionsXMLGetOptions)
 This function grabs the options data from the xml file and stores it into the options data structure.
void vapiOptionsXMLOptionsElement (xmlTextWriter *xmlOutput, int NumberOfCustomOptions,...)
 defines the options dtd group. It accepts a list of custom option attributes.
static int vapiOptionsXMLSetBooleans (xmlTextReader *xmlInput, vOptions *Options)
static int vapiOptionsXMLSetChars (xmlTextReader *xmlInput, vOptions *Options)
static int vapiOptionsXMLSetChoices (xmlTextReader *xmlInput, vOptions *Options)
static int vapiOptionsXMLSetFloats (xmlTextReader *xmlInput, vOptions *Options)
static int vapiOptionsXMLSetInts (xmlTextReader *xmlInput, vOptions *Options)
void vapiOptionsXMLSetOptions (xmlTextReader *xmlInput, vOptions *Options, vOptionsXMLSetOptionsCustom OptionsXMLSetOptionsCustom)
 This function grabs the options data and saves it to the xml file.


Documentação das funções

int vapiOptionsXMLCheckOption ( xmlTextReader *  xmlInput,
int  ret 
)

checks the options grabbed from the xml file.

Parâmetros:
ret previous xml handler state
Retorna:
the operation's state

Definido na linha 188 do ficheiro vapiOptionsXML.c.

Referenciado por vapiOptionsXMLSetOptions() e vapiOptionsXMLSetOptionsOperation().

00189 {
00190         char *nodeType;
00191         if ((nodeType =
00192              (char *) xmlTextReaderGetAttribute (xmlInput,
00193                                                  BAD_CAST "type")) == NULL)
00194         {
00195                 if (ret == 0)
00196                 {
00197                         return -1;
00198                 }
00199                 return 0;
00200         }
00201         return 1;
00202 
00203 }

Here is the caller graph for this function:

static void vapiOptionsXMLGetBooleans ( vOptionsSettings OptionsSettings,
vOptions Options,
xmlTextWriter *  xmlOutput 
) [static]

Definido na linha 437 do ficheiro vapiOptionsXML.c.

Referências _vOptions::booleans e _vOptionsSettings::booleansNumber.

Referenciado por vapiOptionsXMLGetOptions().

00439 {
00440 
00441         int i;
00442 
00443         if (OptionsSettings->booleansNumber)
00444         {
00445                 for (i = 0; i < OptionsSettings->booleansNumber; i++)
00446                 {
00447                         xmlTextWriterStartElement (xmlOutput,
00448                                                    BAD_CAST "option");
00449                         xmlTextWriterWriteAttribute (xmlOutput,
00450                                                      BAD_CAST "type",
00451                                                      BAD_CAST "booleans");
00452                         if (Options->booleans[i])
00453                         {
00454                                 xmlTextWriterWriteFormatString (xmlOutput,
00455                                                                 "%s",
00456                                                                 "vTRUE");
00457                         }
00458                         else
00459                         {
00460                                 xmlTextWriterWriteFormatString (xmlOutput,
00461                                                                 "%s",
00462                                                                 "vFALSE");
00463                         }
00464                         xmlTextWriterEndElement (xmlOutput);
00465                 }
00466 
00467         }
00468 
00469 }

Here is the caller graph for this function:

static void vapiOptionsXMLGetChars ( vOptionsSettings OptionsSettings,
vOptions Options,
xmlTextWriter *  xmlOutput 
) [static]

Definido na linha 403 do ficheiro vapiOptionsXML.c.

Referências _vChar::ch, _vOptions::chars, _vOptionsSettings::charsNumber e v_debug.

Referenciado por vapiOptionsXMLGetOptions().

00405 {
00406 
00407         int i;
00408 
00409         if (OptionsSettings->charsNumber)
00410         {
00411                 for (i = 0; i < OptionsSettings->charsNumber; i++)
00412                 {
00413                         xmlTextWriterStartElement (xmlOutput,
00414                                                    BAD_CAST "option");
00415                         xmlTextWriterWriteAttribute (xmlOutput,
00416                                                      BAD_CAST "type",
00417                                                      BAD_CAST "text");
00418                         v_debug ("XML CHAR: %s", Options->chars[i].ch);
00419 
00420                         if (strlen (Options->chars[i].ch) > 0)
00421                         {
00422 
00423                                 xmlTextWriterWriteFormatString (xmlOutput,
00424                                                                 "%s",
00425                                                                 Options->
00426                                                                 chars[i].ch);
00427                         }
00428 
00429                         xmlTextWriterEndElement (xmlOutput);
00430                 }
00431 
00432         }
00433 
00434 }

Here is the caller graph for this function:

static void vapiOptionsXMLGetChoices ( vOptionsSettings OptionsSettings,
vOptions Options,
xmlTextWriter *  xmlOutput 
) [static]

Definido na linha 377 do ficheiro vapiOptionsXML.c.

Referências _vOptions::choices e _vOptionsSettings::chooseNumber.

Referenciado por vapiOptionsXMLGetOptions().

00379 {
00380 
00381         int i;
00382 
00383         if (OptionsSettings->chooseNumber)
00384         {
00385                 for (i = 0; i < OptionsSettings->chooseNumber; i++)
00386                 {
00387                         xmlTextWriterStartElement (xmlOutput,
00388                                                    BAD_CAST "option");
00389                         xmlTextWriterWriteAttribute (xmlOutput,
00390                                                      BAD_CAST "type",
00391                                                      BAD_CAST "choices");
00392                         xmlTextWriterWriteFormatString (xmlOutput,
00393                                                         "%d",
00394                                                         Options->choices[i]);
00395                         xmlTextWriterEndElement (xmlOutput);
00396                 }
00397 
00398         }
00399 
00400 }

Here is the caller graph for this function:

static void vapiOptionsXMLGetFloats ( vOptionsSettings OptionsSettings,
vOptions Options,
xmlTextWriter *  xmlOutput 
) [static]

Definido na linha 325 do ficheiro vapiOptionsXML.c.

Referências _vOptions::floats e _vOptionsSettings::floatsNumber.

Referenciado por vapiOptionsXMLGetOptions().

00327 {
00328 
00329         int i;
00330 
00331         if (OptionsSettings->floatsNumber)
00332         {
00333                 for (i = 0; i < OptionsSettings->floatsNumber; i++)
00334                 {
00335                         xmlTextWriterStartElement (xmlOutput,
00336                                                    BAD_CAST "option");
00337                         xmlTextWriterWriteAttribute (xmlOutput,
00338                                                      BAD_CAST "type",
00339                                                      BAD_CAST "floats");
00340                         xmlTextWriterWriteFormatString (xmlOutput,
00341                                                         "%1.2f",
00342                                                         Options->floats[i]);
00343                         xmlTextWriterEndElement (xmlOutput);
00344                 }
00345 
00346         }
00347 
00348 }

Here is the caller graph for this function:

static void vapiOptionsXMLGetInts ( vOptionsSettings OptionsSettings,
vOptions Options,
xmlTextWriter *  xmlOutput 
) [static]

Definido na linha 351 do ficheiro vapiOptionsXML.c.

Referências _vOptions::ints e _vOptionsSettings::intsNumber.

Referenciado por vapiOptionsXMLGetOptions().

00353 {
00354 
00355         int i;
00356 
00357         if (OptionsSettings->intsNumber)
00358         {
00359                 for (i = 0; i < OptionsSettings->intsNumber; i++)
00360                 {
00361                         xmlTextWriterStartElement (xmlOutput,
00362                                                    BAD_CAST "option");
00363                         xmlTextWriterWriteAttribute (xmlOutput,
00364                                                      BAD_CAST "type",
00365                                                      BAD_CAST "ints");
00366                         xmlTextWriterWriteFormatString (xmlOutput,
00367                                                         "%d",
00368                                                         Options->ints[i]);
00369                         xmlTextWriterEndElement (xmlOutput);
00370                 }
00371 
00372         }
00373 
00374 }

Here is the caller graph for this function:

void vapiOptionsXMLGetOptions ( xmlTextWriter *  xmlOutput,
vOptionsSettings OptionsSettings,
vOptions Options,
vOptionsXMLGetOptionsCustom  OptionsXMLGetOptions 
)

This function grabs the options data from the xml file and stores it into the options data structure.

Definido na linha 472 do ficheiro vapiOptionsXML.c.

Referências vapiOptionsXMLGetBooleans(), vapiOptionsXMLGetChars(), vapiOptionsXMLGetChoices(), vapiOptionsXMLGetFloats() e vapiOptionsXMLGetInts().

Referenciado por vapiIOConfiguredToXML() e vapiMacroToXML().

00476 {
00477 
00478 
00479         if (OptionsXMLGetOptions != NULL)
00480         {
00481                 OptionsXMLGetOptions (xmlOutput, OptionsSettings, Options);
00482         }
00483 
00484         vapiOptionsXMLGetFloats (OptionsSettings, Options, xmlOutput);
00485 
00486         vapiOptionsXMLGetInts (OptionsSettings, Options, xmlOutput);
00487 
00488         vapiOptionsXMLGetChars (OptionsSettings, Options, xmlOutput);
00489 
00490         vapiOptionsXMLGetChoices (OptionsSettings, Options, xmlOutput);
00491 
00492         vapiOptionsXMLGetBooleans (OptionsSettings, Options, xmlOutput);
00493 
00494 }

Grafo de chamadas desta função:

Here is the caller graph for this function:

void vapiOptionsXMLOptionsElement ( xmlTextWriter *  xmlOutput,
int  NumberOfCustomOptions,
  ... 
)

defines the options dtd group. It accepts a list of custom option attributes.

Definido na linha 497 do ficheiro vapiOptionsXML.c.

Referências v_printf() e vapiReturnStringPointer().

Referenciado por vapiIOXMLFileInit() e vapiMacroXMLFileInit().

00499 {
00500         va_list CustomOptions;
00501         char *DTDAttlistStart, *DTDAttlistEnd, *TempString, *TempString2,
00502                 *FinalString;
00503         int i;
00504         DTDAttlistStart = "type (ints | text | floats | choices | booleans";
00505         DTDAttlistEnd = ") #REQUIRED";
00506         TempString = vapiReturnStringPointer ("");
00507         va_start (CustomOptions, NumberOfCustomOptions);
00508         if (NumberOfCustomOptions > 0)
00509         {
00510                 TempString =
00511                         v_printf (" | %s", va_arg (CustomOptions, char *));
00512 
00513                 for (i = 1; i < NumberOfCustomOptions; i++)
00514                 {
00515                         TempString2 =
00516                                 v_printf ("%s | %s", TempString,
00517                                           va_arg (CustomOptions, char *));
00518                         free (TempString);
00519                         TempString = TempString2;
00520                 }
00521                 FinalString =
00522                         v_printf ("%s %s %s",
00523                                   DTDAttlistStart, TempString, DTDAttlistEnd);
00524                 free (TempString);
00525         }
00526         else
00527         {
00528                 FinalString =
00529                         v_printf ("%s %s", DTDAttlistStart, DTDAttlistEnd);
00530         }
00531         va_end (CustomOptions);
00532 
00533         xmlTextWriterWriteDTDElement (xmlOutput, BAD_CAST "option",
00534                                       BAD_CAST "(#PCDATA)");
00535         xmlTextWriterWriteDTDAttlist (xmlOutput, BAD_CAST "option",
00536                                       BAD_CAST FinalString);
00537         free (FinalString);
00538 }

Grafo de chamadas desta função:

Here is the caller graph for this function:

static int vapiOptionsXMLSetBooleans ( xmlTextReader *  xmlInput,
vOptions Options 
) [static]

Definido na linha 149 do ficheiro vapiOptionsXML.c.

Referências _vOptions::booleans, v_debug, vapiXMLNextElementNamed(), vFALSE e vTRUE.

Referenciado por vapiOptionsXMLSetOptions().

00150 {
00151         int countLine = 0, ret;
00152 
00153         for (;;)
00154         {
00155 
00156                 if (strcmp ((char *) xmlTextReaderGetAttribute
00157                             (xmlInput, BAD_CAST "type"), "booleans") != 0)
00158                 {
00159                         return -1;
00160                 }
00161 
00162                 xmlTextReaderRead (xmlInput);
00163                 if (!strcmp ((char *) xmlTextReaderValue (xmlInput), "vTRUE"))
00164                 {
00165                         Options->booleans[countLine] = vTRUE;
00166                 }
00167                 if (!strcmp
00168                     ((char *) xmlTextReaderValue (xmlInput), "vFALSE"))
00169                 {
00170                         Options->booleans[countLine] = vFALSE;
00171                 }
00172 
00173                 v_debug ("countline-1: %d, int: %d, %s", countLine,
00174                          Options->booleans[countLine],
00175                          xmlTextReaderValue (xmlInput));
00176 
00177                 if (!(ret = vapiXMLNextElementNamed (xmlInput, "option")) > 0)
00178                 {
00179                         break;
00180                 }
00181                 ++countLine;
00182         }
00183         return ret;
00184 
00185 }

Grafo de chamadas desta função:

Here is the caller graph for this function:

static int vapiOptionsXMLSetChars ( xmlTextReader *  xmlInput,
vOptions Options 
) [static]

Definido na linha 89 do ficheiro vapiOptionsXML.c.

Referências _vChar::ch, _vOptions::chars, v_debug, vapiReturnStringPointer() e vapiXMLNextElementNamed().

Referenciado por vapiOptionsXMLSetOptions().

00090 {
00091         int countLine = 0, ret;
00092 
00093         for (;;)
00094         {
00095 
00096                 if (strcmp ((char *) xmlTextReaderGetAttribute
00097                             (xmlInput, BAD_CAST "type"), "text") != 0)
00098                 {
00099                         return -1;
00100                 }
00101 
00102                 xmlTextReaderRead (xmlInput);
00103                 Options->chars[countLine].ch =
00104                         vapiReturnStringPointer ((char *) xmlTextReaderValue
00105                                                  (xmlInput));
00106                 v_debug ("countline: %d, chars: %s, %s", countLine,
00107                          Options->chars[countLine].ch,
00108                          xmlTextReaderValue (xmlInput));
00109 
00110                 if (!(ret = vapiXMLNextElementNamed (xmlInput, "option")) > 0)
00111                 {
00112                         break;
00113                 }
00114                 ++countLine;
00115         }
00116         return ret;
00117 }

Grafo de chamadas desta função:

Here is the caller graph for this function:

static int vapiOptionsXMLSetChoices ( xmlTextReader *  xmlInput,
vOptions Options 
) [static]

Definido na linha 120 do ficheiro vapiOptionsXML.c.

Referências _vOptions::choices, v_debug e vapiXMLNextElementNamed().

Referenciado por vapiOptionsXMLSetOptions().

00121 {
00122         int countLine = 0, ret;
00123 
00124         for (;;)
00125         {
00126                 if (strcmp ((char *) xmlTextReaderGetAttribute
00127                             (xmlInput, BAD_CAST "type"), "choices") != 0)
00128                 {
00129                         return -1;
00130                 }
00131 
00132                 xmlTextReaderRead (xmlInput);
00133                 Options->choices[countLine] =
00134                         atoi ((char *) xmlTextReaderValue (xmlInput));
00135                 v_debug ("countline: %d, choice: %d, %s", countLine,
00136                          Options->choices[countLine],
00137                          xmlTextReaderValue (xmlInput));
00138 
00139                 if (!(ret = vapiXMLNextElementNamed (xmlInput, "option")) > 0)
00140                 {
00141                         break;
00142                 }
00143                 ++countLine;
00144         }
00145         return ret;
00146 }

Grafo de chamadas desta função:

Here is the caller graph for this function:

static int vapiOptionsXMLSetFloats ( xmlTextReader *  xmlInput,
vOptions Options 
) [static]

Definido na linha 49 do ficheiro vapiOptionsXML.c.

Referências _vOptions::floats, v_debug, vapiComaToPoint() e vapiXMLNextElementNamed().

Referenciado por vapiOptionsXMLSetOptions().

00050 {
00051 
00052         int countLine = 0, ret;
00053 
00054         for (;;)
00055         {
00056 
00057                 if (strcmp ((char *) xmlTextReaderGetAttribute
00058                             (xmlInput, BAD_CAST "type"), "floats") != 0)
00059                 {
00060                         return -1;
00061                 }
00062 
00063                 xmlTextReaderRead (xmlInput);
00064 #ifndef VAPI_OS_LINUX
00065                 Options->floats[countLine] =
00066                         atof (vapiComaToPoint
00067                               ((char *) xmlTextReaderValue (xmlInput)));
00068 #else
00069                 Options->floats[countLine] =
00070                         atof ((char *) xmlTextReaderValue (xmlInput));
00071 #endif
00072 
00073                 v_debug ("countline: %d, float: %1.2f, %s", countLine,
00074                          Options->floats[countLine], (char *)
00075                          xmlTextReaderValue (xmlInput));
00076 
00077                 if (!(ret = vapiXMLNextElementNamed (xmlInput, "option")) > 0)
00078                 {
00079                         break;
00080                 }
00081                 ++countLine;
00082         }
00083         return ret;
00084 
00085 
00086 }

Grafo de chamadas desta função:

Here is the caller graph for this function:

static int vapiOptionsXMLSetInts ( xmlTextReader *  xmlInput,
vOptions Options 
) [static]

Definido na linha 18 do ficheiro vapiOptionsXML.c.

Referências _vOptions::ints, v_debug e vapiXMLNextElementNamed().

Referenciado por vapiOptionsXMLSetOptions().

00019 {
00020         int countLine = 0, ret;
00021 
00022         for (;;)
00023         {
00024 
00025                 if (strcmp ((char *) xmlTextReaderGetAttribute
00026                             (xmlInput, BAD_CAST "type"), "ints") != 0)
00027                 {
00028                         return -1;
00029                 }
00030 
00031                 xmlTextReaderRead (xmlInput);
00032                 Options->ints[countLine] =
00033                         atoi ((char *) xmlTextReaderValue (xmlInput));
00034                 v_debug ("countline: %d, int: %d, %s", countLine,
00035                          Options->ints[countLine],
00036                          xmlTextReaderValue (xmlInput));
00037 
00038                 if (!(ret = vapiXMLNextElementNamed (xmlInput, "option")) > 0)
00039                 {
00040                         break;
00041                 }
00042                 ++countLine;
00043         }
00044         return ret;
00045 
00046 }

Grafo de chamadas desta função:

Here is the caller graph for this function:

void vapiOptionsXMLSetOptions ( xmlTextReader *  xmlInput,
vOptions Options,
vOptionsXMLSetOptionsCustom  OptionsXMLSetOptionsCustom 
)

This function grabs the options data and saves it to the xml file.

Definido na linha 206 do ficheiro vapiOptionsXML.c.

Referências vapiOptionsXMLCheckOption(), vapiOptionsXMLSetBooleans(), vapiOptionsXMLSetChars(), vapiOptionsXMLSetChoices(), vapiOptionsXMLSetFloats(), vapiOptionsXMLSetInts() e vapiXMLNextElementNamed().

Referenciado por vapiIOConfiguredListFromXML() e vapiMacroFromXML().

00209 {
00210         int ret = 1, bk = 1;
00211 
00212 
00213         if (xmlTextReaderIsEmptyElement (xmlInput))
00214         {
00215                 return;
00216 
00217         }
00218         ret = vapiXMLNextElementNamed (xmlInput, "option");
00219 
00220         while (bk != -1 && ret != 0)
00221         {
00222 
00223                 if ((bk = vapiOptionsXMLCheckOption (xmlInput, ret)) == 0)
00224                 {
00225                         continue;
00226                 }
00227                 if (bk == -1)
00228                 {
00229                         break;
00230                 }
00231                 if (OptionsXMLSetOptionsCustom != NULL)
00232                 {
00233                         bk = OptionsXMLSetOptionsCustom (xmlInput, Options);
00234 
00235                         if (bk == 0)
00236                         {
00237 
00238                                 continue;
00239                         }
00240                         if (bk == -1)
00241                         {
00242                                 break;
00243                         }
00244                 }
00245 
00246                 if (strcmp
00247                     ((char *)
00248                      xmlTextReaderGetAttribute (xmlInput, BAD_CAST "type"),
00249                      "ints") == 0)
00250                 {
00251                         ret = vapiOptionsXMLSetInts (xmlInput, Options);
00252                 }
00253 
00254                 if ((bk = vapiOptionsXMLCheckOption (xmlInput, ret)) == 0)
00255                 {
00256 
00257                         continue;
00258                 }
00259                 if (bk == -1)
00260                 {
00261                         break;
00262                 }
00263 
00264                 if (strcmp
00265                     ((char *)
00266                      xmlTextReaderGetAttribute (xmlInput, BAD_CAST "type"),
00267                      "text") == 0)
00268                 {
00269                         ret = vapiOptionsXMLSetChars (xmlInput, Options);
00270                 }
00271                 if ((bk = vapiOptionsXMLCheckOption (xmlInput, ret)) == 0)
00272                 {
00273 
00274                         continue;
00275                 }
00276                 if (bk == -1)
00277                 {
00278                         break;
00279                 }
00280                 if (strcmp
00281                     ((char *)
00282                      xmlTextReaderGetAttribute (xmlInput, BAD_CAST "type"),
00283                      "floats") == 0)
00284                 {
00285                         ret = vapiOptionsXMLSetFloats (xmlInput, Options);
00286                 }
00287                 if ((bk = vapiOptionsXMLCheckOption (xmlInput, ret)) == 0)
00288                 {
00289 
00290                         continue;
00291                 }
00292                 if (bk == -1)
00293                 {
00294                         break;
00295                 }
00296                 if (strcmp
00297                     ((char *)
00298                      xmlTextReaderGetAttribute (xmlInput, BAD_CAST "type"),
00299                      "choices") == 0)
00300                 {
00301                         ret = vapiOptionsXMLSetChoices (xmlInput, Options);
00302                 }
00303                 if ((bk = vapiOptionsXMLCheckOption (xmlInput, ret)) == 0)
00304                 {
00305 
00306                         continue;
00307                 }
00308                 if (bk == -1)
00309                 {
00310                         break;
00311                 }
00312                 if (strcmp
00313                     ((char *)
00314                      xmlTextReaderGetAttribute (xmlInput, BAD_CAST "type"),
00315                      "booleans") == 0)
00316                 {
00317                         ret = vapiOptionsXMLSetBooleans (xmlInput, Options);
00318                 }
00319 
00320         }
00321 }

Grafo de chamadas desta função:

Here is the caller graph for this function:


Gerado em Tue Jul 24 10:39:32 2007 para Vapi por  doxygen 1.5.1