mptsd reads mpegts streams from udp/multicast or http and combines them into one multiple program stream that is suitable for outputting to DVB-C modulator. Tested with Dektec DTE-3114 Quad QAM Modulator and used in production in small DVB-C networks. https://georgi.unixsol.org/programs/mptsd/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

inidict.h 6.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. /*-------------------------------------------------------------------------*/
  2. /**
  3. @file dictionary.h
  4. @author N. Devillard
  5. @date Sep 2007
  6. @version Revision: 1.12
  7. @brief Implements a dictionary for string variables.
  8. This module implements a simple dictionary object, i.e. a list
  9. of string/string associations. This object is useful to store e.g.
  10. informations retrieved from a configuration file (ini files).
  11. */
  12. /*--------------------------------------------------------------------------*/
  13. /*
  14. Id: dictionary.h,v 1.12 2007-11-23 21:37:00 ndevilla Exp
  15. Author: ndevilla
  16. Date: 2007-11-23 21:37:00
  17. Revision: 1.12
  18. */
  19. #ifndef _DICTIONARY_H_
  20. #define _DICTIONARY_H_
  21. /*---------------------------------------------------------------------------
  22. Includes
  23. ---------------------------------------------------------------------------*/
  24. #include <stdio.h>
  25. #include <stdlib.h>
  26. #include <string.h>
  27. #include <unistd.h>
  28. /*---------------------------------------------------------------------------
  29. New types
  30. ---------------------------------------------------------------------------*/
  31. /*-------------------------------------------------------------------------*/
  32. /**
  33. @brief Dictionary object
  34. This object contains a list of string/string associations. Each
  35. association is identified by a unique string key. Looking up values
  36. in the dictionary is speeded up by the use of a (hopefully collision-free)
  37. hash function.
  38. */
  39. /*-------------------------------------------------------------------------*/
  40. typedef struct _dictionary_ {
  41. int n ; /** Number of entries in dictionary */
  42. int size ; /** Storage size */
  43. char ** val ; /** List of string values */
  44. char ** key ; /** List of string keys */
  45. unsigned * hash ; /** List of hash values for keys */
  46. } dictionary ;
  47. /*---------------------------------------------------------------------------
  48. Function prototypes
  49. ---------------------------------------------------------------------------*/
  50. /*-------------------------------------------------------------------------*/
  51. /**
  52. @brief Compute the hash key for a string.
  53. @param key Character string to use for key.
  54. @return 1 unsigned int on at least 32 bits.
  55. This hash function has been taken from an Article in Dr Dobbs Journal.
  56. This is normally a collision-free function, distributing keys evenly.
  57. The key is stored anyway in the struct so that collision can be avoided
  58. by comparing the key itself in last resort.
  59. */
  60. /*--------------------------------------------------------------------------*/
  61. unsigned dictionary_hash(char * key);
  62. /*-------------------------------------------------------------------------*/
  63. /**
  64. @brief Create a new dictionary object.
  65. @param size Optional initial size of the dictionary.
  66. @return 1 newly allocated dictionary objet.
  67. This function allocates a new dictionary object of given size and returns
  68. it. If you do not know in advance (roughly) the number of entries in the
  69. dictionary, give size=0.
  70. */
  71. /*--------------------------------------------------------------------------*/
  72. dictionary * dictionary_new(int size);
  73. /*-------------------------------------------------------------------------*/
  74. /**
  75. @brief Delete a dictionary object
  76. @param d dictionary object to deallocate.
  77. @return void
  78. Deallocate a dictionary object and all memory associated to it.
  79. */
  80. /*--------------------------------------------------------------------------*/
  81. void dictionary_del(dictionary * vd);
  82. /*-------------------------------------------------------------------------*/
  83. /**
  84. @brief Get a value from a dictionary.
  85. @param d dictionary object to search.
  86. @param key Key to look for in the dictionary.
  87. @param def Default value to return if key not found.
  88. @return 1 pointer to internally allocated character string.
  89. This function locates a key in a dictionary and returns a pointer to its
  90. value, or the passed 'def' pointer if no such key can be found in
  91. dictionary. The returned character pointer points to data internal to the
  92. dictionary object, you should not try to free it or modify it.
  93. */
  94. /*--------------------------------------------------------------------------*/
  95. char * dictionary_get(dictionary * d, char * key, char * def);
  96. /*-------------------------------------------------------------------------*/
  97. /**
  98. @brief Set a value in a dictionary.
  99. @param d dictionary object to modify.
  100. @param key Key to modify or add.
  101. @param val Value to add.
  102. @return int 0 if Ok, anything else otherwise
  103. If the given key is found in the dictionary, the associated value is
  104. replaced by the provided one. If the key cannot be found in the
  105. dictionary, it is added to it.
  106. It is Ok to provide a NULL value for val, but NULL values for the dictionary
  107. or the key are considered as errors: the function will return immediately
  108. in such a case.
  109. Notice that if you dictionary_set a variable to NULL, a call to
  110. dictionary_get will return a NULL value: the variable will be found, and
  111. its value (NULL) is returned. In other words, setting the variable
  112. content to NULL is equivalent to deleting the variable from the
  113. dictionary. It is not possible (in this implementation) to have a key in
  114. the dictionary without value.
  115. This function returns non-zero in case of failure.
  116. */
  117. /*--------------------------------------------------------------------------*/
  118. int dictionary_set(dictionary * vd, char * key, char * val);
  119. /*-------------------------------------------------------------------------*/
  120. /**
  121. @brief Delete a key in a dictionary
  122. @param d dictionary object to modify.
  123. @param key Key to remove.
  124. @return void
  125. This function deletes a key in a dictionary. Nothing is done if the
  126. key cannot be found.
  127. */
  128. /*--------------------------------------------------------------------------*/
  129. void dictionary_unset(dictionary * d, char * key);
  130. /*-------------------------------------------------------------------------*/
  131. /**
  132. @brief Dump a dictionary to an opened file pointer.
  133. @param d Dictionary to dump
  134. @param f Opened file pointer.
  135. @return void
  136. Dumps a dictionary onto an opened file pointer. Key pairs are printed out
  137. as @c [Key]=[Value], one per line. It is Ok to provide stdout or stderr as
  138. output file pointers.
  139. */
  140. /*--------------------------------------------------------------------------*/
  141. void dictionary_dump(dictionary * d, FILE * out);
  142. #endif