diff options
Diffstat (limited to 'misc')
-rw-r--r-- | misc/avdetector.cpp | 2 | ||||
-rw-r--r-- | misc/avdetector.h | 19 | ||||
-rw-r--r-- | misc/config.cpp | 18 | ||||
-rw-r--r-- | misc/config.h | 49 | ||||
-rw-r--r-- | misc/menusetup.cpp | 4 | ||||
-rw-r--r-- | misc/menusetup.h | 31 | ||||
-rw-r--r-- | misc/search.cpp | 66 | ||||
-rw-r--r-- | misc/search.h | 76 | ||||
-rw-r--r-- | misc/util.cpp | 19 | ||||
-rw-r--r-- | misc/util.h | 101 |
10 files changed, 318 insertions, 67 deletions
diff --git a/misc/avdetector.cpp b/misc/avdetector.cpp index d66988e..8f3bc8f 100644 --- a/misc/avdetector.cpp +++ b/misc/avdetector.cpp @@ -55,7 +55,7 @@ int cAudioVideoDetector::detectVideoProperties(cUPnPResource* Resource, const ch unsigned int bitrate = CodecCtx->bit_rate; const char* codecName = (Codec)?Codec->name:"unknown"; - MESSAGE("AVDetector: %s-stream %dx%d at %d bit/s", codecName, width, height, bitrate); + MESSAGE(VERBOSE_METADATA, "AVDetector: %s-stream %dx%d at %d bit/s", codecName, width, height, bitrate); Resource->mBitrate = bitrate; Resource->mSampleFrequency = CodecCtx->sample_rate; diff --git a/misc/avdetector.h b/misc/avdetector.h index 0b8bb81..b043c59 100644 --- a/misc/avdetector.h +++ b/misc/avdetector.h @@ -10,10 +10,29 @@ #include "../database/object.h" +/** + * The audio/video detector + * + * This is the audio video detector, which analizes the audio and video stream + * of a file to gather more information about the resource. This is also + * required for determination of a suitable DLNA profile. + */ class cAudioVideoDetector { public: cAudioVideoDetector(){}; virtual ~cAudioVideoDetector(){}; + /** + * Detect video properties + * + * This detects video properties of a video stream and stores them in the + * Resource object. + * + * @param Resource the resource, where to save the data + * @param Filename the file, which shall be read + * @return returns + * - \bc 0, if the detection was successful + * - \bc <0, otherwise + */ int detectVideoProperties(cUPnPResource* Resource, const char* Filename); private: }; diff --git a/misc/config.cpp b/misc/config.cpp index 59bf4a6..1fa0ccb 100644 --- a/misc/config.cpp +++ b/misc/config.cpp @@ -32,6 +32,7 @@ cUPnPConfig* cUPnPConfig::get(){ } cUPnPConfig* cUPnPConfig::mInstance = NULL; +int cUPnPConfig::verbosity = 0; bool cUPnPConfig::processArgs(int argc, char* argv[]){ // Implement command line argument processing here if applicable. @@ -39,7 +40,9 @@ bool cUPnPConfig::processArgs(int argc, char* argv[]){ {"int", required_argument, NULL, 'i'}, {"address", required_argument, NULL, 'a'}, {"port", required_argument, NULL, 'p'}, - {"autodetect", no_argument, NULL, 'd'} + {"autodetect", no_argument, NULL, 'd'}, + {"verbose", no_argument, NULL, 'v'}, + {0, 0, 0, 0} }; int c = 0; @@ -55,8 +58,9 @@ bool cUPnPConfig::processArgs(int argc, char* argv[]){ bool success = true; bool ifaceExcistent = false; bool addExcistent = false; + static int verbose = 0; - while((c = getopt_long(argc, argv, "i:a:p:v",long_options, NULL)) != -1){ + while((c = getopt_long(argc, argv, "i:a:p:dv",long_options, NULL)) != -1){ switch(c){ case 'i': if(addExcistent) { ERROR("Address given but must be absent!"); return false; } @@ -78,6 +82,12 @@ bool cUPnPConfig::processArgs(int argc, char* argv[]){ break; case 'd': success = this->parseSetup(SETUP_SERVER_AUTO, optarg) && success; + break; + case 'v': + cUPnPConfig::verbosity++; + verbose++; + WARNING("Verbosity level: %i ", verbose); + break; default: return false; } @@ -90,11 +100,11 @@ bool cUPnPConfig::parseSetup(const char *Name, const char *Value) { const char* ptr; if(*this->mParsedArgs && (ptr = strstr(this->mParsedArgs,Name))!=NULL){ - MESSAGE("Skipping %s=%s, was overridden in command line.",Name, Value); + MESSAGE(VERBOSE_SDK, "Skipping %s=%s, was overridden in command line.",Name, Value); return true; } - MESSAGE("VARIABLE %s has value %s", Name, Value); + MESSAGE(VERBOSE_SDK, "VARIABLE %s has value %s", Name, Value); // Parse your own setup parameters and store their values. if (!strcasecmp(Name, SETUP_SERVER_ENABLED)) this->mEnable = atoi(Value); else if (!strcasecmp(Name, SETUP_SERVER_AUTO)) this->mAutoSetup = atoi(Value); diff --git a/misc/config.h b/misc/config.h index 018213e..40ae6f7 100644 --- a/misc/config.h +++ b/misc/config.h @@ -11,21 +11,60 @@ #include <vdr/tools.h> #include "../common.h" +/** + * The configuration settings + * + * This holds the configurations for the server. It holds information about the + * network settings as well as some status flags. + */ class cUPnPConfig { private: static cUPnPConfig* mInstance; cString mParsedArgs; cUPnPConfig(); public: - char* mInterface; - char* mAddress; - int mPort; - int mEnable; - int mAutoSetup; + static int verbosity; ///< the verbosity of the plugin, the higher the more messages + ///< are printed. + char* mInterface; ///< the network interface, which the server is bound to + char* mAddress; ///< the IP address which is used by the server + int mPort; ///< the port which the server is listening on + int mEnable; ///< indicates, if the server is enabled or not + int mAutoSetup; ///< indicates, if the settings are automatically detected public: virtual ~cUPnPConfig(); + /** + * Get the configuration + * + * This returns the instance of the current configuration settings. + * + * @return the configuration object + */ static cUPnPConfig* get(); + /** + * Parse setup variable + * + * This parses the setup variable with the according value. The value is a + * string representation and must be converted into the according data type. + * + * @return returns + * - \bc true, if parsing was successful + * - \bc false, otherwise + * @param Name the name of the variable + * @param Value the according value of the variable + */ bool parseSetup(const char* Name, const char* Value); + /** + * Processes the commandline arguments + * + * This processes the commandline arguments which the user specified at the + * start of the plugin. + * + * @return returns + * - \bc true, if processing was successful + * - \bc false, otherwise + * @param argc the number of arguments in the list + * @param argv the arguments as a char array + */ bool processArgs(int argc, char* argv[]); }; diff --git a/misc/menusetup.cpp b/misc/menusetup.cpp index 9e8386f..c385b2d 100644 --- a/misc/menusetup.cpp +++ b/misc/menusetup.cpp @@ -18,7 +18,7 @@ cMenuSetupUPnP::cMenuSetupUPnP(){ // Get server acitve state - MESSAGE("Creating menu"); + MESSAGE(VERBOSE_CUSTOM_OUTPUT, "Creating menu"); this->mCtrlBind = NULL; this->mCtrlAutoMode = NULL; this->mCtrlEnabled = NULL; @@ -63,7 +63,7 @@ const char* const* cMenuSetupUPnP::getInterfaceList(int* count){ } int cMenuSetupUPnP::getInterfaceIndex(const char* Interface){ - MESSAGE("Getting Index of %s", Interface); + MESSAGE(VERBOSE_CUSTOM_OUTPUT, "Getting Index of %s", Interface); if(!Interface) return 0; int count; int Index = 0; diff --git a/misc/menusetup.h b/misc/menusetup.h index ae40e97..4e32efc 100644 --- a/misc/menusetup.h +++ b/misc/menusetup.h @@ -17,17 +17,42 @@ * * This class shows and manages the settings within the VDR setup OSD * - * @author Denis Loh - * @version 0.0.1 */ class cMenuSetupUPnP : public cMenuSetupPage { public: cMenuSetupUPnP(); // virtual ~cMenuSetupUPnP(); - virtual eOSState ProcessKey(eKeys Key); + /** + * Processes a keystroke + * + * This processes a keystroke which is done by the user and updates the + * menu accordingly + * + * It returns the current state of the VDR after pressing a key + * + * @return The current state of the VDR + */ + virtual eOSState ProcessKey( + eKeys Key ///< Key, pressed by the user + ); protected: + /** + * Stores the setup information + * + * This stores the setup information in the configuration file + */ virtual void Store(void); + /** + * Update the menu + * + * This updates the menu osd and refreshes the screen. + */ void Update(void); + /** + * Loads the setup information + * + * This loads the setup information from the configuration file + */ void Load(void); private: const char* const* getInterfaceList(int *count); diff --git a/misc/search.cpp b/misc/search.cpp index deee8b0..b3534f1 100644 --- a/misc/search.cpp +++ b/misc/search.cpp @@ -28,6 +28,7 @@ typedef function1<void, const char> charCallback; typedef function1<void, int> intCallback; // The defined ColumnNames +/** @private */ struct cProperties : symbols<const char*> { //struct cProperties : symbols<> { cProperties(){ @@ -107,6 +108,7 @@ struct cProperties : symbols<const char*> { } } Properties; +/** @private */ struct cOperators : symbols<const char*> { cOperators(){ add @@ -123,6 +125,7 @@ struct cOperators : symbols<const char*> { } } Operators; +/** @private */ struct cConcatOperators : symbols<const char*> { cConcatOperators(){ add @@ -132,6 +135,7 @@ struct cConcatOperators : symbols<const char*> { } } ConcatOperators; +/** @private */ struct cExistanceOperator : symbols<const char*> { cExistanceOperator(){ add @@ -145,6 +149,7 @@ struct cExistanceOperator : symbols<const char*> { // This is the grammar including the functors which calls the member functions // of search. The callback definitions at the end of the constructor are // essential. DO NOT MODIFY if you don't know how! +/** @private */ struct cSearchGrammar : public boost::spirit::grammar<cSearchGrammar> { // The callbacks members charCallback &endBrackedExp; @@ -176,6 +181,7 @@ struct cSearchGrammar : public boost::spirit::grammar<cSearchGrammar> { startBrackedExp(startBrackedExp){} template <typename scanner> + /** @private */ struct definition { boost::spirit::rule<scanner> searchCrit, searchExp, logOp, \ relExp, binOp, relOp, stringOp, \ @@ -278,6 +284,7 @@ struct cSearchGrammar : public boost::spirit::grammar<cSearchGrammar> { }; }; +/** @private */ struct cSortGrammar : public boost::spirit::grammar<cSortGrammar> { // The callback members propCallback &pushProperty; @@ -290,6 +297,7 @@ struct cSortGrammar : public boost::spirit::grammar<cSortGrammar> { pushDirection(pushDirection){} template <typename scanner> + /** @private */ struct definition { boost::spirit::rule<scanner> sortCrit, sortExp, property, direction; @@ -312,6 +320,7 @@ struct cSortGrammar : public boost::spirit::grammar<cSortGrammar> { }; }; +/** @private */ struct cFilterGrammar : public boost::spirit::grammar<cFilterGrammar> { // The callback members propCallback &pushProperty; @@ -324,6 +333,7 @@ struct cFilterGrammar : public boost::spirit::grammar<cFilterGrammar> { pushAsterisk(pushAsterisk){} template <typename scanner> + /** @private */ struct definition { boost::spirit::rule<scanner> filterCrit, filterExp, property; @@ -351,7 +361,7 @@ struct cFilterGrammar : public boost::spirit::grammar<cFilterGrammar> { \**********************************************/ void cSearch::pushEndBrackedExp(const char){ - MESSAGE("Pushing closing bracket"); + MESSAGE(VERBOSE_PARSERS, "Pushing closing bracket"); if(asprintf(&this->SQLWhereStmt, "%s)", this->SQLWhereStmt)==-1){ ERROR("Unable to allocate SQL Statement"); return; @@ -369,21 +379,21 @@ void cSearch::pushExpression(const char*, const char*){ long int IntegerValue; if(sscanf(Value, "%ld", &IntegerValue)!=EOF && sscanf(Value, "%*4d-%*2d-%*2d")==EOF){ - MESSAGE("Popping '%s %s %ld'",Property, Operator, IntegerValue); + MESSAGE(VERBOSE_PARSERS, "Popping '%s %s %ld'",Property, Operator, IntegerValue); if(asprintf(&Statement, "%s %s %ld", Property, Operator, IntegerValue)==-1){ ERROR("Failed to allocated memory for statement."); return; } } else if(!strcasecmp(Operator, "IS")){ - MESSAGE("Popping '%s %s %s'", Property, Operator, Value); + MESSAGE(VERBOSE_PARSERS, "Popping '%s %s %s'", Property, Operator, Value); if(asprintf(&Statement, "%s %s %s", Property, Operator, Value)==-1){ ERROR("Failed to allocated memory for statement."); return; } } else { - MESSAGE("Popping '%s %s \"%s\"'",Property, Operator, Value); + MESSAGE(VERBOSE_PARSERS, "Popping '%s %s \"%s\"'",Property, Operator, Value); if(asprintf(&Statement, "%s %s '%s'", Property, Operator, Value)==-1){ ERROR("Failed to allocated memory for statement."); return; @@ -401,12 +411,12 @@ void cSearch::pushExpression(const char*, const char*){ void cSearch::pushProperty(const char* Property){ this->CurrentProperty = strdup(Property); - MESSAGE("Property %s added",Property); + MESSAGE(VERBOSE_PARSERS, "Property %s added",Property); } void cSearch::pushOperator(const char* Operator){ this->CurrentOperator = strdup(Operator); - MESSAGE("Operator %s added",Operator); + MESSAGE(VERBOSE_PARSERS, "Operator %s added",Operator); } void cSearch::pushValue(const char* Start, const char* End){ @@ -414,13 +424,13 @@ void cSearch::pushValue(const char* Start, const char* End){ if(!Value || !strcmp(Value,"")) return; this->CurrentValue = strdup(Value); - MESSAGE("Value %s added", Value); + MESSAGE(VERBOSE_PARSERS, "Value %s added", Value); } void cSearch::pushExistance(const char* Exists){ this->CurrentValue = strdup(Exists); this->CurrentOperator = strdup("IS"); - MESSAGE("Existance expression called. '%s'", Exists); + MESSAGE(VERBOSE_PARSERS, "Existance expression called. '%s'", Exists); } void cSearch::pushConcatOp(const char* Operator){ @@ -429,11 +439,11 @@ void cSearch::pushConcatOp(const char* Operator){ return; } - MESSAGE("Concatenation expression called. '%s'", Operator); + MESSAGE(VERBOSE_PARSERS, "Concatenation expression called. '%s'", Operator); } void cSearch::pushStartBrackedExp(const char){ - MESSAGE("Pushing opening bracket"); + MESSAGE(VERBOSE_PARSERS, "Pushing opening bracket"); if(asprintf(&this->SQLWhereStmt, "%s(", this->SQLWhereStmt)==-1){ ERROR("Unable to allocate SQL Statement"); return; @@ -478,13 +488,13 @@ bool cSearch::parseCriteria(const char* Search){ pushConcatOpCB, startBrackedExpCB); - MESSAGE("Starting search parsing"); + MESSAGE(VERBOSE_PARSERS, "Starting search parsing"); if(boost::spirit::parse(Search, Grammar).full){ - MESSAGE("Parsing successful"); + MESSAGE(VERBOSE_DIDL, "Parsed search expression successfuly"); } else { - ERROR("Parsing failed"); + ERROR("Parsing search expression failed"); return false; } return true; @@ -532,7 +542,7 @@ bool cFilterCriteria::parseFilter(const char* Filter){ this->mFilterList = new cStringList; if(Filter && !strcasecmp(Filter, "")){ - MESSAGE("Empty filter"); + MESSAGE(VERBOSE_PARSERS, "Empty filter"); return true; } @@ -542,7 +552,7 @@ bool cFilterCriteria::parseFilter(const char* Filter){ cFilterGrammar Grammar(pushPropertyCB, pushAsteriskCB); if(boost::spirit::parse(Filter, Grammar).full){ - MESSAGE("Parse filter successful"); + MESSAGE(VERBOSE_PARSERS, "Parse filter successful"); } else { ERROR("Parsing filter failed"); @@ -558,12 +568,12 @@ bool cFilterCriteria::parseFilter(const char* Filter){ \**********************************************/ void cFilterCriteria::pushProperty(const char* Property){ - MESSAGE("Pushing property"); + MESSAGE(VERBOSE_PARSERS, "Pushing property"); this->mFilterList->Append(strdup(Property)); } void cFilterCriteria::pushAsterisk(const char){ - MESSAGE("Pushing asterisk (*)"); + MESSAGE(VERBOSE_PARSERS, "Pushing asterisk (*)"); if(this->mFilterList) delete this->mFilterList; this->mFilterList = NULL; return; @@ -596,7 +606,7 @@ cList<cSortCrit>* cSortCriteria::parse(const char* Sort){ bool cSortCriteria::parseSort(const char* Sort){ if(!Sort || !strcasecmp(Sort, "")){ - MESSAGE("Empty Sort"); + MESSAGE(VERBOSE_PARSERS, "Empty Sort"); return true; } @@ -606,7 +616,7 @@ bool cSortCriteria::parseSort(const char* Sort){ cSortGrammar Grammar(pushPropertyCB, pushDirectionCB); if(boost::spirit::parse(Sort, Grammar).full){ - MESSAGE("Parse Sort successful"); + MESSAGE(VERBOSE_PARSERS, "Parse Sort successful"); } else { ERROR("Parsing Sort failed"); @@ -622,14 +632,14 @@ bool cSortCriteria::parseSort(const char* Sort){ \**********************************************/ void cSortCriteria::pushProperty(const char* Property){ - MESSAGE("Pushing property '%s'", Property); + MESSAGE(VERBOSE_PARSERS, "Pushing property '%s'", Property); this->mCurrentCrit->Property = strdup(Property); this->mCriteriaList->Add(this->mCurrentCrit); return; } void cSortCriteria::pushDirection(const char Direction){ - MESSAGE("Pushing direction '%c'", Direction); + MESSAGE(VERBOSE_PARSERS, "Pushing direction '%c'", Direction); this->mCurrentCrit = new cSortCrit; this->mCurrentCrit->SortDescending = (Direction=='-')?true:false; return; @@ -641,6 +651,7 @@ void cSortCriteria::pushDirection(const char Direction){ * * \**********************************************/ +/** @private */ struct cWebserverSections : symbols<> { cWebserverSections(){ add @@ -649,6 +660,7 @@ struct cWebserverSections : symbols<> { } } WebserverSections; +/** @private */ struct cWebserverMethods : symbols<int> { cWebserverMethods(){ add @@ -661,6 +673,7 @@ struct cWebserverMethods : symbols<int> { } } WebserverMethods; +/** @private */ struct cPathParserGrammar : public boost::spirit::grammar<cPathParserGrammar> { intCallback &pushSection; @@ -678,6 +691,7 @@ struct cPathParserGrammar : public boost::spirit::grammar<cPathParserGrammar> { pushPropertyValue(pushPropertyValue){} template <typename scanner> + /** @private */ struct definition { boost::spirit::rule<scanner> pathExp, section, method, methodProperties, property, key, value, uncriticalChar; @@ -742,7 +756,7 @@ bool cPathParser::parsePath(const char* Path, int* Section, int* Method, propert cPathParserGrammar Grammar(pushSectionCB, pushMethodCB, pushPropertyKeyCB, pushPropertyValueCB); if(boost::spirit::parse(Path, Grammar).full){ - MESSAGE("Parse path successful"); + MESSAGE(VERBOSE_PARSERS, "Parse path successful"); *Section = this->mSection; *Method = this->mMethod; *Properties = this->mProperties; @@ -765,7 +779,7 @@ bool cPathParser::parsePath(const char* Path, int* Section, int* Method, propert void cPathParser::pushPropertyKey(const char* Start, const char* End){ char* Key = strndup(Start, End-Start); - MESSAGE("Pushing key '%s'", Key); + MESSAGE(VERBOSE_PARSERS, "Pushing key '%s'", Key); this->mKey = Key; @@ -775,7 +789,7 @@ void cPathParser::pushPropertyKey(const char* Start, const char* End){ void cPathParser::pushPropertyValue(const char* Start, const char* End){ char* Value = strndup(Start, End-Start); - MESSAGE("Pushing value '%s'", Value); + MESSAGE(VERBOSE_PARSERS, "Pushing value '%s'", Value); // TODO: urlDecode Value if(*this->mKey){ @@ -785,11 +799,11 @@ void cPathParser::pushPropertyValue(const char* Start, const char* End){ } void cPathParser::pushMethod(int Method){ - MESSAGE("Pushing method '%d'", Method); + MESSAGE(VERBOSE_PARSERS, "Pushing method '%d'", Method); this->mMethod = Method; } void cPathParser::pushSection(int Section){ - MESSAGE("Pushing section '%d'", Section); + MESSAGE(VERBOSE_PARSERS, "Pushing section '%d'", Section); this->mSection = Section; }
\ No newline at end of file diff --git a/misc/search.h b/misc/search.h index df2442e..ef162b1 100644 --- a/misc/search.h +++ b/misc/search.h @@ -12,13 +12,27 @@ #include <vdr/tools.h> #include "util.h" +/** + * Sort criteria + * + * This is a structure for sorting objects. It has a certain property and + * a direction flag. + */ struct cSortCrit : public cListObject { - const char* Property; - bool SortDescending; + const char* Property; ///< the Property, which shall be sorted + bool SortDescending; ///< sort the objects in descending order }; typedef std::map<const char*, const char*, strCmp> propertyMap; +/** + * Web path parser + * + * Parses paths which came from the webserver. It splits the path into + * a section, a certain method and its properties. + * + * This can be used to easily determine which file was requested by a client + */ class cPathParser { private: cString mKey; @@ -33,9 +47,30 @@ private: cPathParser(); public: virtual ~cPathParser(); - static bool parse(const char* Path, int* Section, int* Method, propertyMap* Properties); + /** + * Parses the path + * + * This will parse the path and stores the result in the pointers given. + * + * @return returns + * - \bc true, if the parsing was successful + * - \bc false, otherwise + */ + static bool parse( + const char* Path, ///< the path which is parsed + int* Section, ///< the number of the registered section + int* Method, ///< the number of the registered method + propertyMap* Properties ///< the properties found in the path + ); }; +/** + * Creates a list with sort criteria + * + * This parser creates a list of sort criteria. It parses the sort criteria string + * from a \em Browse or \em Search request and stores the information in a \c cSortCrit + * structure. + */ class cSortCriteria { private: cSortCrit* mCurrentCrit; @@ -47,9 +82,26 @@ private: cSortCriteria(); public: virtual ~cSortCriteria(); - static cList<cSortCrit>* parse(const char* Sort); + /** + * Parses the sort criteria + * + * This parses the sort criteria and returns a list with valid criterias + * + * @return returns + * - a list with valid sort criterias + * - \bc null, otherwise + */ + static cList<cSortCrit>* parse( + const char* Sort ///< the string container the sort criteria + ); }; +/** + * Parses the filter criteria + * + * This parses the filter criteria which comes from a \em Browse or \em Search + * request. + */ class cFilterCriteria { private: cStringList* mFilterList; @@ -60,9 +112,23 @@ private: cStringList* getFilterList() const { return this->mFilterList; } public: virtual ~cFilterCriteria(); - static cStringList* parse(const char* Filter); + /** + * Parses the filter criteria + * + * This parses the filter criteria. It may be a empty string list, a \bc NULL + * pointer or a list with properties which shall be shown in the \em DIDL-Lite fragment. + * + * @return the stringlist containing the filter + */ + static cStringList* parse( + const char* Filter ///< the filter string + ); }; +/** + * @private + * @todo This is implemented very soon + */ class cSearch { private: char* SQLWhereStmt; diff --git a/misc/util.cpp b/misc/util.cpp index dc75706..8cfc524 100644 --- a/misc/util.cpp +++ b/misc/util.cpp @@ -240,25 +240,6 @@ eOSState cMenuEditIpItem::ProcessKey(eKeys Key) { return osContinue; } -const char* escapeSQLite(const char* Data, char** Buf){ - if(!Data){ - *Buf = NULL; - } - else { - std::string NewData = ""; - int Char = 0; - for(unsigned int i = 0; i < strlen(Data); i++){ - Char = Data[i]; - switch(Char){ - case L'\'': NewData += "''"; break; - default: NewData += Data[i]; break; - } - } - *Buf = strdup(NewData.c_str()); - } - return (*Buf); -} - const char* escapeXMLCharacters(const char* Data, char** Buf){ if(Data==NULL){ ERROR("Escape XML: No data to escape"); diff --git a/misc/util.h b/misc/util.h index ffedd67..6ff2a54 100644 --- a/misc/util.h +++ b/misc/util.h @@ -14,19 +14,116 @@ #ifdef __cplusplus extern "C" { -struct strCmp { bool operator()(const char* s1, const char* s2) const { return (strcmp(s1,s2) < 0); }}; +#if 0 +} +#endif +/** + * 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 <0, in case of an error + * - \bc 0, otherwise + * @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 + */ int ixmlAddProperty(IN IXML_Document* document, IN IXML_Element* node, const char* upnpproperty, 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); +#if 0 +{ +#endif } #endif -const char* escapeSQLite(const char* Data, char** Buf); +/** + * 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; |