Eneboo - Documentación para desarrolladores
src/libdigidoc/DigiDocGen.h
Ir a la documentación de este archivo.
00001 #ifndef __DIGIDOC_GEN_H__
00002 #define __DIGIDOC_GEN_H__
00003 //==================================================
00004 // FILE:        DigiDocGen.h
00005 // PROJECT:     Digi Doc
00006 // DESCRIPTION: DigiDoc helper routines for XML generation
00007 // AUTHOR:  Veiko Sinivee, S|E|B IT Partner Estonia
00008 //==================================================
00009 // Copyright (C) AS Sertifitseerimiskeskus
00010 // This library is free software; you can redistribute it and/or
00011 // modify it under the terms of the GNU Lesser General Public
00012 // License as published by the Free Software Foundation; either
00013 // version 2.1 of the License, or (at your option) any later version.
00014 // This library is distributed in the hope that it will be useful,
00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017 // Lesser General Public License for more details.
00018 // GNU Lesser General Public Licence is available at
00019 // http://www.gnu.org/copyleft/lesser.html
00020 //==========< HISTORY >=============================
00021 //      11.04.2006      Veiko Sinivee
00022 //                      Creation
00023 //==================================================
00024 
00025 #include <libdigidoc/DigiDocDefs.h>
00026 #include <libdigidoc/DigiDocObj.h>
00027 #include <libdigidoc/DigiDocMem.h>
00028 
00029 
00030 //==========< XML generation routines >========================
00031 
00032 #ifdef  __cplusplus
00033 extern "C" {
00034 #endif
00035 
00036 #ifdef WITH_TIMETSTAMP_STRUCT
00037 // contains timestamp data
00038 typedef struct Timestamp_st {
00039   int year;
00040   int mon;
00041   int day;
00042   int hour;
00043   int min;
00044   int sec;
00045   int tz;
00046 } Timestamp;
00047 
00048 // converts timestamp string to it's components
00049 EXP_OPTION int convertStringToTimestamp(const SignedDoc* pSigDoc, const char* szTimestamp, Timestamp* pTimestamp);
00050 // converts timestamp to string 
00051 EXP_OPTION int convertTimestampToString(const SignedDoc* pSigDoc, const Timestamp* pTimestamp, char* szTimestamp, int len);
00052 // creates new timestamp object
00053 EXP_OPTION int Timestamp_new(Timestamp **, int year,int month,int day,int hour,int minute,int second,int timezone);
00054 // frees this timestamp object
00055 EXP_OPTION void Timestamp_free(Timestamp* pTimestamp);
00056 
00057 #endif
00058 
00059 //============================================================
00060 // Creates a timestamp string
00061 // buf - output buffer
00062 // len - length of output buffer
00063 // returns number of output bytes written
00064 //============================================================
00065 int createTimestamp(const SignedDoc* pSigDoc, char* buf, int len);
00066 
00067 // converts timestamp string to time_t value
00068 EXP_OPTION time_t convertStringToTimeT(const SignedDoc* pSigDoc, const char* szTimestamp);
00069 
00070 
00071 //--------------------------------------------------
00072 // Appends an xml element start to buffer, but no ">"
00073 // pBuf - memory buffer to store xml [REQUIRED]
00074 // elemName - xml element name [REQUIRED]
00075 // returns error code or ERR_OK
00076 //--------------------------------------------------
00077 int ddocGen_startElemBegin(DigiDocMemBuf* pBuf, const char* elemName);
00078 
00079 //--------------------------------------------------
00080 // Appends an xml element start tag end to buffer - ">"
00081 // pBuf - memory buffer to store xml [REQUIRED]
00082 // returns error code or ERR_OK
00083 //--------------------------------------------------
00084 int ddocGen_startElemEnd(DigiDocMemBuf* pBuf);
00085 
00086 //--------------------------------------------------
00087 // Appends an xml element start to buffer - <tag>
00088 // pBuf - memory buffer to store xml [REQUIRED]
00089 // elemName - xml element name [REQUIRED]
00090 // returns error code or ERR_OK
00091 //--------------------------------------------------
00092 int ddocGen_startElem(DigiDocMemBuf* pBuf, const char* elemName);
00093 
00094 //--------------------------------------------------
00095 // Appends an xml element end to buffer
00096 // pBuf - memory buffer to store xml [REQUIRED]
00097 // elemName - xml element name [REQUIRED]
00098 // returns error code or ERR_OK
00099 //--------------------------------------------------
00100 int ddocGen_endElem(DigiDocMemBuf* pBuf, const char* elemName);
00101 
00102 //--------------------------------------------------
00103 // Appends an xml element's atribute to buffer
00104 // pBuf - memory buffer to store xml [REQUIRED]
00105 // name - xml atribute name [REQUIRED]
00106 // value - xml atribute value [REQUIRED]
00107 // returns error code or ERR_OK
00108 //--------------------------------------------------
00109 int ddocGen_addAtribute(DigiDocMemBuf* pBuf, const char* name, const char* value);
00110 
00111 //================< functions generating DigiDoc formats 1.0 - 1.3 > =================================
00112 
00113 // writes the signed doc to a file
00114 EXP_OPTION int createSignedDoc(SignedDoc* pSigDoc, const char* szOldFile, const char* szSigDocFile);
00115 
00116 //============================================================
00117 // Canonicalizes XML
00118 // source - input data
00119 // len - input length
00120 // returns a newly allocated buffer with canonicalized XML
00121 // Caller must free() the result.
00122 //============================================================
00123 char* canonicalizeXML(char* source, int len);
00124 
00125 //============================================================
00126 // Creates a <SignedProperties> XML block
00127 // pSigDoc - signed document pointer
00128 // pSigInfo - signature info data
00129 // bWithEscapes - 1=escape xml sümbols, 0=don't escape
00130 // returns new <SignedProperties> node
00131 //============================================================
00132 char* createXMLSignedProperties(const SignedDoc* pSigDoc, const SignatureInfo* pSigInfo, int bWithEscapes);
00133 
00134 //============================================================
00135 // Generates DataFile elements XML form and stores it in a file
00136 // pSigDoc - signed document
00137 // pDataFile - data file object to be converted
00138 // szDataFile - input file name
00139 // hFile - output file handle
00140 // pMBufXML - output buffer if we want data to be returned in mem buf
00141 //============================================================
00142 int generateDataFileXML(SignedDoc* pSigDoc, DataFile* pDataFile, 
00143                         const char* szDataFile, FILE* hFile, DigiDocMemBuf* pMBufXML);
00144 
00145 //--------------------------------------------------
00146 // Creates a new signed document in memory buffer
00147 // pSigDoc - signed doc info
00148 // szOldFile - name of old file on disk to copy DataFile contents
00149 // pMBuf - buffer for new digidoc document
00150 // returns error code or ERR_OK for success
00151 //--------------------------------------------------
00152 EXP_OPTION int createSignedDocInMemory(SignedDoc* pSigDoc, const char* szOldFile, DigiDocMemBuf* pMBuf);
00153 
00154 //--------------------------------------------------
00155 // Removes incomplete or orphoned signatures.
00156 // Signature is incomplete if it hasn't got the signature
00157 // value
00158 // pSigDoc - signed doc info
00159 // returns error code or ERR_OK for success
00160 //--------------------------------------------------
00161 EXP_OPTION int removeIncompleteSignatures(SignedDoc* pSigDoc);
00162 
00163 //--------------------------------------------------
00164 // Checks for incomplete or orphoned signatures.
00165 // Signature is incomplete if it hasn't got the signature
00166 // value
00167 // pSigDoc - signed doc info
00168 // returns error code if DigiDoc has orphoned signature or ERR_OK for success
00169 //--------------------------------------------------
00170 EXP_OPTION int hasIncompleteSignatures(SignedDoc* pSigDoc);
00171 
00172 #ifdef  __cplusplus
00173 }
00174 #endif
00175 
00176 
00177 #endif // __DIGIDOC_GEN_H__
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'