Referência ao ficheiro src/vapiMacroXML.c

#include <stdio.h>
#include "vapiTypes.h"
#include "vapiAux.h"
#include "vapiString.h"
#include "vapiMacro.h"
#include "vapiMacroList.h"
#include "vapiOperationList.h"
#include "vapiOperationOptions.h"
#include "vapiGtkAux.h"
#include "vapiGtkAuxWindow.h"
#include "vapiOptions.h"
#include "vapiOptionsXML.h"
#include "vapiXML.h"
#include "vapiOperationXML.h"
#include <libxml/encoding.h>
#include <libxml/xmlreader.h>
#include <libxml/xmlwriter.h>
#include <string.h>

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

Ir para o código fonte deste ficheiro.

Funções

vMacroHeadervapiMacroFromXML (const char *filename, vOperationList *OperationList, vMacroList *MacroList)
 Imports a Macro from XML. It imports the Macro Name, Comments, Operations and Options.
char * vapiMacroFromXMLSetName (const char *filename)
 Get the Name of the Macro from the XML.
void vapiMacroToXML (vMacroHeader *MacroHeader, const char *filename)
 Exports a Macro to XML It will export the Operation Definitions and the options, if different from default.
static xmlTextWriter * vapiMacroXMLFileInit (vMacroHeader *MacroHeader, const char *filename)
vBoolean vapiMacroXMLLoadToList (vMacroList *MacroList, vOperationList *OperationList, const char *filename)
 Loads a Macro directly from file to the MacroList.


Documentação das funções

vMacroHeader* vapiMacroFromXML ( const char *  filename,
vOperationList OperationList,
vMacroList MacroList 
)

Imports a Macro from XML. It imports the Macro Name, Comments, Operations and Options.

Parâmetros:
filename The xml filename.

Definido na linha 122 do ficheiro vapiMacroXML.c.

Referências _vMacroHeader::Macro, MacroList, OperationList, _vEffect::OptionsSettings, v_debug, vapiCheckOperations(), vapiMacroAddItem(), vapiMacroNew(), vapiMacroUpdateComment(), vapiOperationListSelectOperation(), vapiOperationOptionsInit(), vapiOptionsCheck(), vapiOptionsXMLSetOptions(), vapiOptionsXMLSetOptionsOperation() e vapiXMLNextElement().

Referenciado por vapiMacroXMLLoadToList().

00124 {
00125         xmlTextReader *xmlInput;
00126         vMacroHeader *MacroHeader;
00127         vEffect *tempOperation;
00128         vOptions *tempOptions;
00129         int ret = 1;
00130         xmlInput = xmlReaderForFile (filename, "ISO-8859-1", XML_PARSE_DTDATTR |        /* default DTD attributes */
00131                                      XML_PARSE_NOENT |  /* substitute entities */
00132                                      XML_PARSE_DTDVALID);       /* validate with the DTD */
00133 
00134         if (xmlInput == NULL)
00135         {
00136                 return NULL;
00137         }
00138         xmlTextReaderRead (xmlInput);
00139         if (!strcmp
00140             ((char *) xmlTextReaderLocalName (xmlInput), "vapiMacro "))
00141         {
00142                 return MacroHeader = 0;
00143         }
00144 
00145         vapiXMLNextElement (xmlInput);
00146         MacroHeader =
00147                 vapiMacroNew ((char *) xmlTextReaderGetAttribute
00148                               (xmlInput, BAD_CAST "name"));
00149         /*
00150          * Entramos nas Operações.
00151          */
00152         if (vapiXMLNextElement (xmlInput) > 0)
00153         {
00154                 if (!strcmp
00155                     ((char *) xmlTextReaderLocalName (xmlInput), "Comment"))
00156                 {
00157                         v_debug ("comentário lido: .%s.", xmlTextReaderReadString
00158                                                 (xmlInput));
00159                         vapiMacroUpdateComment (MacroHeader,
00160                                                 (char *)
00161                                                 xmlTextReaderReadString
00162                                                 (xmlInput));
00163                         v_debug ("comentário lido: .%s.", xmlTextReaderReadString
00164                                                 (xmlInput));
00165                         vapiXMLNextElement (xmlInput);
00166                         
00167                 }
00168                 if (strcmp
00169                     ((char *) xmlTextReaderLocalName (xmlInput), "Operation"))
00170                 {
00171                         return MacroHeader = 0;
00172                 }
00173 
00174                 while (ret > 0)
00175                 {
00176 
00177                         tempOperation =
00178                                 vapiOperationListSelectOperation
00179                                 (OperationList, (char *)
00180                                  xmlTextReaderGetAttribute (xmlInput,
00181                                                             BAD_CAST "name"));
00182                         v_debug ("operation name: %s",
00183                                  xmlTextReaderGetAttribute (xmlInput,
00184                                                             BAD_CAST "name"));
00185 
00186                         tempOptions =
00187                                 vapiOperationOptionsInit (tempOperation);
00188 
00189                         vapiOptionsXMLSetOptions (xmlInput, tempOptions,
00190                                                   &vapiOptionsXMLSetOptionsOperation);
00191 
00192                         vapiMacroAddItem (MacroHeader->Macro,
00193                                           tempOperation, tempOptions);
00194                         ret = vapiXMLNextElement (xmlInput);
00195 
00196                         vapiOptionsCheck (tempOperation->OptionsSettings,
00197                                           tempOptions);
00198 
00199                         vapiCheckOperations (tempOperation, tempOptions,
00200                                              MacroList);
00201                 }
00202 
00203         }
00204 
00205 
00206         //v_info ("Carregada a Macro de xml");
00207         return MacroHeader;
00208 }

Grafo de chamadas desta função:

Here is the caller graph for this function:

char* vapiMacroFromXMLSetName ( const char *  filename  ) 

Get the Name of the Macro from the XML.

Parâmetros:
filename The xml filename.
Retorna:
the name of the macro that the xml holds, or returns NULL if it is not a valid vpiMaccroXML file.

Definido na linha 211 do ficheiro vapiMacroXML.c.

Referências vapiXMLNextElement().

Referenciado por vapiGtkMacroOpenFromXML(), vapiGtkMacroTestXMLFileOpen(), vapiGtkMacroUpdateMacroName() e vapiMacroXMLLoadToList().

00212 {
00213 
00214         xmlTextReader *xmlInput;
00215 
00216         xmlInput = xmlReaderForFile (filename, "ISO-8859-1", XML_PARSE_DTDATTR |        /* default DTD attributes */
00217                                      XML_PARSE_NOENT |  /* substitute entities */
00218                                      XML_PARSE_DTDVALID);       /* validate with the DTD */
00219 
00220         if (xmlInput == NULL)
00221         {
00222                 return NULL;
00223         }
00224         if (xmlTextReaderRead (xmlInput) < 0)
00225         {
00226                 return NULL;
00227         }
00228 
00229         if (!strcmp
00230             ((char *) xmlTextReaderLocalName (xmlInput), "vapiMacro "))
00231         {
00232                 return NULL;
00233         }
00234 
00235         vapiXMLNextElement (xmlInput);
00236         return ((char *)
00237                 xmlTextReaderGetAttribute (xmlInput, BAD_CAST "name"));
00238 }

Grafo de chamadas desta função:

Here is the caller graph for this function:

void vapiMacroToXML ( vMacroHeader MacroHeader,
const char *  filename 
)

Exports a Macro to XML It will export the Operation Definitions and the options, if different from default.

Parâmetros:
filename the name of the xml file to save to.

Definido na linha 68 do ficheiro vapiMacroXML.c.

Referências _vMacroHeader::Macro, _vEffect::name, _vMacroItem::Operation, _vMacroItem::Options, _vEffect::OptionsSettings, v_info(), vapiMacroCountElements(), vapiMacroSelectItem(), vapiMacroXMLFileInit(), vapiOptionsXMLGetOptions() e vapiOptionsXMLGetOptionsOperation().

Referenciado por vapiGtkMacroSaveToXML().

00069 {
00070         xmlTextWriter *xmlOutput;
00071         int i, OperationNumber;
00072         vMacroItem *Item;
00073 
00074         /*
00075          * Criar cabeçalho do Ficheiro XML.
00076          */
00077 
00078         xmlOutput = vapiMacroXMLFileInit (MacroHeader, filename);
00079 
00080         /*
00081          * Ir a cada Operação da Macro.
00082          */
00083 
00084         OperationNumber = vapiMacroCountElements (MacroHeader->Macro);
00085 
00086         if (!OperationNumber)
00087         {
00088                 return;
00089         }
00090 
00091         for (i = 0; i < OperationNumber; i++)
00092         {
00093                 Item = vapiMacroSelectItem (MacroHeader->Macro, i);
00094 
00095                 xmlTextWriterStartElement (xmlOutput, BAD_CAST "Operation");
00096 
00097                 xmlTextWriterWriteAttribute (xmlOutput, BAD_CAST "name",
00098                                              BAD_CAST Item->Operation->name);
00099 
00100                 /*
00101                  * Get Options.
00102                  */
00103                 vapiOptionsXMLGetOptions (xmlOutput,
00104                                           Item->Operation->OptionsSettings,
00105                                           Item->Options,
00106                                           &vapiOptionsXMLGetOptionsOperation);
00107 
00108 
00109                 xmlTextWriterEndElement (xmlOutput);
00110 
00111         }
00112 
00113 
00114         xmlTextWriterEndDocument (xmlOutput);
00115 
00116         xmlFreeTextWriter (xmlOutput);
00117         v_info ("Guardada Macro para xml");
00118 
00119 }

Grafo de chamadas desta função:

Here is the caller graph for this function:

static xmlTextWriter* vapiMacroXMLFileInit ( vMacroHeader MacroHeader,
const char *  filename 
) [static]

Definido na linha 21 do ficheiro vapiMacroXML.c.

Referências _vMacroHeader::MacroComment, _vMacroHeader::MacroName e vapiOptionsXMLOptionsElement().

Referenciado por vapiMacroToXML().

00022 {
00023         xmlTextWriter *xmlOutput;
00024 
00025         /*
00026          * Como colocar a string do ficheiro Automatica.
00027          */
00028 
00029         xmlOutput = xmlNewTextWriterFilename (filename, 0);
00030 
00031         xmlTextWriterSetIndent (xmlOutput, 1);
00032 
00033         xmlTextWriterStartDocument (xmlOutput, NULL, "ISO-8859-1", NULL);
00034 
00035         xmlTextWriterStartDTD (xmlOutput, BAD_CAST "vapiMacro", NULL, NULL);
00036 
00037         xmlTextWriterWriteDTDElement (xmlOutput,
00038                                       BAD_CAST "vapiMacro",
00039                                       BAD_CAST "(Operation*,Comment?)");
00040         xmlTextWriterWriteDTDAttlist (xmlOutput,
00041                                       BAD_CAST "vapiMacro",
00042                                       BAD_CAST "name NMTOKENS #REQUIRED");
00043         xmlTextWriterWriteDTDElement (xmlOutput, BAD_CAST "Comment",
00044                                       BAD_CAST "(#PCDATA)");
00045         xmlTextWriterWriteDTDElement (xmlOutput,
00046                                       BAD_CAST "Operation",
00047                                       BAD_CAST "(option)*");
00048         xmlTextWriterWriteDTDAttlist (xmlOutput,
00049                                       BAD_CAST "Operation",
00050                                       BAD_CAST "name NMTOKENS #REQUIRED");
00051 
00052         vapiOptionsXMLOptionsElement (xmlOutput, 2, "times", "original");
00053 
00054         xmlTextWriterEndDTD (xmlOutput);
00055 
00056         xmlTextWriterStartElement (xmlOutput, BAD_CAST "vapiMacro");
00057         xmlTextWriterWriteAttribute (xmlOutput, BAD_CAST "name",
00058                                      BAD_CAST MacroHeader->MacroName);
00059         
00060         xmlTextWriterStartElement (xmlOutput, BAD_CAST "Comment");
00061         xmlTextWriterWriteString (xmlOutput, BAD_CAST MacroHeader->MacroComment);
00062         xmlTextWriterEndElement (xmlOutput);
00063 
00064         return xmlOutput;
00065 }

Grafo de chamadas desta função:

Here is the caller graph for this function:

vBoolean vapiMacroXMLLoadToList ( vMacroList MacroList,
vOperationList OperationList,
const char *  filename 
)

Loads a Macro directly from file to the MacroList.

Retorna:
vTRUE if it has errors.

Definido na linha 241 do ficheiro vapiMacroXML.c.

Referências MacroList, MacroName, OperationList, vapiMacroFromXML(), vapiMacroFromXMLSetName(), vapiMacroListAddItem(), vapiMacroListMacroExist(), vFALSE e vTRUE.

Referenciado por vapiGtkMacroOpenFromXML() e vapiLoadExampleMacros().

00243 {
00244         char *MacroName;
00245         vMacroHeader *MacroHeader;
00246 
00247         MacroName = vapiMacroFromXMLSetName (filename);
00248 
00249         if (MacroName == NULL)
00250         {
00251                 return vFALSE;
00252         }
00253 
00254         if (vapiMacroListMacroExist (MacroList, MacroName, 1) == -1)
00255         {
00256                 return vFALSE;
00257         }
00258 
00259         MacroHeader = vapiMacroFromXML (filename, OperationList, MacroList);
00260 
00261         vapiMacroListAddItem (MacroList, MacroHeader);
00262 
00263         return vTRUE;
00264 
00265 }

Grafo de chamadas desta função:

Here is the caller graph for this function:


Gerado em Tue Jul 24 10:38:46 2007 para Vapi por  doxygen 1.5.1