1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
/*
* File: util.h
* Author: savop
*
* Created on 21. Mai 2009, 21:25
*/
#ifndef _UTIL_H
#define _UTIL_H
#include <vdr/tools.h>
#include <vdr/plugin.h>
#include <upnp/ixml.h>
#ifdef __cplusplus
extern "C" {
#if 0
}
#endif
#include <libavformat/avformat.h>
#include <libavcodec/avcodec.h>
/**
* Compares two strings
*
* This struct compares two strings and returns true on equality or false otherwise
* It is used in conjuction with hashmaps
*/
struct strCmp {
/**
* Compares two strings
* @return returns
* - \bc true, in case of equality
* - \bc false, otherwise
* @param s1 the first string
* @param s2 the second string
*/
bool operator()(const char* s1, const char* s2) const { return (strcmp(s1,s2) < 0); }
};
/**
* Gets the IP address
*
* Returns the IP address of a given interface. The interface must be a valid interface
* identifier like eth0 or wlan1.
*
* @return a structure containing the IP address
* @param Interface to obtain the IP from
*/
const sockaddr_in* getIPFromInterface(const char* Interface);
/**
* Gets the MAC address
*
* Returns a string representation of the MAC address of a given interface. The interface
* must be a valid interface identifier like eth0 or wlan1.
*
* The pattern of the address is sixth byte hex number separated with ":"
*
* @return a string containing the MAC
* @param Interface to obtain the MAC from
*/
const char* getMACFromInterface(const char* Interface);
/**
* List with interfaces
*
* Returns an array with interfaces found on the system. The number of items
* in the array is stored in the parameter \c count.
*
* @return array list of interfaces
* @param count number of interfaces in the array
*/
char** getNetworkInterfaces(int *count);
/**
* First occurance of item
*
* Finds the first occurance of a specified item in a given \bc IXML document and returns its value.
* If an error occures, its code is stored in the last parameter \c 'error'.
*
* @return the value of the item
* @param doc the \c IXML document to be parsed
* @param item the item which shall be found
* @param error the error code in case of an error
*/
char* ixmlGetFirstDocumentItem( IN IXML_Document * doc, IN const char *item, int* error );
/**
* Adds a property
*
* This adds a UPnP property to an \bc IXML document.
* The property must have the pattern "namespace:property@attribute".
*
* @return returns
* - \bc NULL, in case of an error
* - \bc the newly created property node or the node at which the attribute was
* appended to
* @param document the \c IXML document to put the parameter in
* @param node the specific node where to put the parameter
* @param upnpproperty the upnp property
* @param value the value of the upnp property
*/
IXML_Element* ixmlAddProperty(IN IXML_Document* document, IN IXML_Element* node, IN const char* upnpproperty, IN const char* value );
IXML_Element* ixmlAddFilteredProperty(IN cStringList* Filter, IN IXML_Document* document, IN IXML_Element* node, IN const char* upnpproperty, IN const char* value );
/**
* creates a part of a string
*
* This creates a substring of a string which begins at the given offset and has the
* specified lenght.
*
* @return the new string
* @param str the full string
* @param offset the starting index
* @param length the length of the new string
*/
char* substr(const char* str, unsigned int offset, unsigned int length);
char* duration(off64_t duration, unsigned int timeBase = 1);
#if 0
{
#endif
}
#endif
/**
* Escapes XML special characters
*
* This function escapes XML special characters, which must be transformed before
* inserting it into another XML document.
*
* @return the escaped document
* @param Data the data to escape
* @param Buf the pointer where the escaped document shall be stored
*/
const char* escapeXMLCharacters(const char* Data, char** Buf);
/** @private */
class cMenuEditIpItem: public cMenuEditItem {
private:
char *value;
int curNum;
int pos;
bool step;
protected:
virtual void Set(void);
public:
cMenuEditIpItem(const char *Name, char *Value); // Value must be 16 bytes
~cMenuEditIpItem();
virtual eOSState ProcessKey(eKeys Key);
};
#endif /* _UTIL_H */
|