Estonian ID Card C-library
Loading...
Searching...
No Matches
libdigidoc
DigiDocMem.h
1
#ifndef __DIGIDOC_MEM_H__
2
#define __DIGIDOC_MEM_H__
3
//==================================================
4
// FILE: DigiDocMem.h
5
// PROJECT: Digi Doc
6
// DESCRIPTION: Digi Doc functions for memory buffer management
7
// AUTHOR: Veiko Sinivee, S|E|B IT Partner Estonia
8
//==================================================
9
// Copyright (C) AS Sertifitseerimiskeskus
10
// This library is free software; you can redistribute it and/or
11
// modify it under the terms of the GNU Lesser General Public
12
// License as published by the Free Software Foundation; either
13
// version 2.1 of the License, or (at your option) any later version.
14
// This library is distributed in the hope that it will be useful,
15
// but WITHOUT ANY WARRANTY; without even the implied warranty of
16
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
// Lesser General Public License for more details.
18
// GNU Lesser General Public Licence is available at
19
// http://www.gnu.org/copyleft/lesser.html
20
//==========< HISTORY >=============================
21
// 09.09.2004 Veiko Sinivee
22
// Creation
23
//==================================================
24
25
#include "DigiDocDefs.h"
26
27
#ifdef __cplusplus
28
extern
"C"
{
29
#endif
30
31
32
typedef
struct
DigiDocMemBuf_st
{
33
void
* pMem;
// functions will assign allocated memory address here
34
long
nLen;
// length of data in number of bytes
35
}
DigiDocMemBuf
;
36
37
//--------------------------------------------------
38
// Helper function to append data to a memory buffer
39
// and grow it as required.
40
// pBuf - address of memory buffer pointer
41
// data - new data to be appended
42
// len - length of data or -1 for zero terminated strings
43
//--------------------------------------------------
44
EXP_OPTION
int
ddocMemAppendData(
DigiDocMemBuf
* pBuf,
const
char
* data,
long
len);
45
46
//--------------------------------------------------
47
// Helper function to assign data to a memory buffer
48
// and release old content if necessary
49
// pBuf - address of memory buffer pointer
50
// data - new data to be appended
51
// len - length of data or -1 for zero terminated strings
52
//--------------------------------------------------
53
EXP_OPTION
int
ddocMemAssignData(
DigiDocMemBuf
* pBuf,
const
char
* data,
long
len);
54
EXP_OPTION
int
ddocMemAssignData2(
DigiDocMemBuf
* pBuf,
const
char
* data,
long
len);
55
56
//--------------------------------------------------
57
// Helper function to set buffer length as required
58
// It will fill acquired mem with zeros.
59
// pBuf - address of memory buffer pointer
60
// len - new length of buffer
61
//--------------------------------------------------
62
EXP_OPTION
int
ddocMemSetLength(
DigiDocMemBuf
* pBuf,
long
len);
63
64
//--------------------------------------------------
65
// Helper function to free/cleanup memory buffer
66
// This does not attempt to release the buffer object
67
// itself but only it's contents.
68
// pBuf - memory buffer pointer
69
//--------------------------------------------------
70
EXP_OPTION
int
ddocMemBuf_free(
DigiDocMemBuf
* pBuf);
71
72
//--------------------------------------------------
73
// Helper function to assign zero terminated strings
74
// and release old content if necessary
75
// dest - destination address
76
// src - new data to be assigned
77
//--------------------------------------------------
78
EXP_OPTION
int
ddocMemAssignString(
char
** dest,
const
char
* src);
79
80
//--------------------------------------------------
81
// Replaces a substring with another substring
82
// pBuf1 - memory buffer to search in
83
// pBuf2 - memory buffer to write converted value to
84
// search - search value
85
// replacement - replacement value
86
//--------------------------------------------------
87
EXP_OPTION
int
ddocMemReplaceSubstr(
DigiDocMemBuf
* pBuf1,
DigiDocMemBuf
* pBuf2,
88
const
char
* search,
const
char
* replacment);
89
EXP_OPTION
int
ddocMemGetSubstr(
DigiDocMemBuf
* pBuf1,
DigiDocMemBuf
* pBuf2,
90
const
char
* search,
const
char
* replacment);
91
EXP_OPTION
char
*replaceStr(
char
*str,
char
*orig,
char
*rep);
92
//--------------------------------------------------
93
// Compares memory buffers
94
// pBuf1 - memory buffer to value 1
95
// pBuf2 - memory buffer to value 2
96
// return 0 if both buffers are equal, 1 if not equal
97
//--------------------------------------------------
98
EXP_OPTION
int
ddocMemCompareMemBufs(
DigiDocMemBuf
* pBuf1,
DigiDocMemBuf
* pBuf2);
99
100
int
ddocMemPush(
DigiDocMemBuf
* pBuf1,
const
char
* tag);
101
const
char
* ddocMemPop(
DigiDocMemBuf
* pBuf1);
102
103
104
#ifdef __cplusplus
105
}
106
#endif
107
108
#endif
// __DIGIDOC_MEM_H__
DigiDocMemBuf_st
Definition
DigiDocMem.h:32
Generated on Tue Mar 26 2024 18:08:04 for Estonian ID Card C-library by
1.9.8