PageRenderTime 48ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/drivers/net/wireless/tiwlan1251/pform/linux/src/osRgstry_parser.c

https://bitbucket.org/cyanogenmod/cm-kernel
C | 232 lines | 153 code | 34 blank | 45 comment | 42 complexity | 3b58d1230c00d1a7c5710935131fa6fd MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.0, AGPL-1.0
  1. /****************************************************************************
  2. **+-----------------------------------------------------------------------+**
  3. **| |**
  4. **| Copyright(c) 1998 - 2008 Texas Instruments. All rights reserved. |**
  5. **| All rights reserved. |**
  6. **| |**
  7. **| Redistribution and use in source and binary forms, with or without |**
  8. **| modification, are permitted provided that the following conditions |**
  9. **| are met: |**
  10. **| |**
  11. **| * Redistributions of source code must retain the above copyright |**
  12. **| notice, this list of conditions and the following disclaimer. |**
  13. **| * Redistributions in binary form must reproduce the above copyright |**
  14. **| notice, this list of conditions and the following disclaimer in |**
  15. **| the documentation and/or other materials provided with the |**
  16. **| distribution. |**
  17. **| * Neither the name Texas Instruments nor the names of its |**
  18. **| contributors may be used to endorse or promote products derived |**
  19. **| from this software without specific prior written permission. |**
  20. **| |**
  21. **| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |**
  22. **| "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |**
  23. **| LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |**
  24. **| A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |**
  25. **| OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |**
  26. **| SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |**
  27. **| LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |**
  28. **| DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |**
  29. **| THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |**
  30. **| (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |**
  31. **| OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |**
  32. **| |**
  33. **+-----------------------------------------------------------------------+**
  34. ****************************************************************************/
  35. #include "osrgstry_parser.h"
  36. extern VOID regReadLastDbgState(PTIWLN_ADAPTER_T pAdapter);
  37. static char *init_file = NULL;
  38. static int init_file_length= 0;
  39. static PNDIS_CONFIGURATION_PARAMETER pNdisParm;
  40. extern int osInitTable_IniFile(tiwlan_net_dev_t *drv, initTable_t *InitTable, char *file_buf, int file_length)
  41. {
  42. NDIS_CONFIGURATION_PARAMETER parm;
  43. init_file = file_buf;
  44. init_file_length = file_length;
  45. pNdisParm = &parm;
  46. regFillInitTable( &drv->adapter, InitTable );
  47. #ifdef TI_DBG
  48. regReadLastDbgState(&drv->adapter);
  49. #endif
  50. return 0;
  51. }
  52. unsigned long TiDebugFlag;
  53. /* void PRINT( char * type, char *format, ... )*/
  54. /* {*/
  55. /* return ;*/
  56. /* }*/
  57. NDIS_STATUS NdisUnicodeStringToAnsiString( IN OUT PANSI_STRING DestinationString,
  58. IN PUNICODE_STRING SourceString )
  59. {
  60. if( DestinationString->MaximumLength < SourceString->Length )
  61. return NDIS_STATUS_BUFFER_TOO_SHORT;
  62. DestinationString->Length = SourceString->Length;
  63. os_memoryCopy( NULL, DestinationString->Buffer, SourceString->Buffer, SourceString->Length );
  64. return NDIS_STATUS_SUCCESS;
  65. }
  66. #ifndef tolower
  67. #define tolower(c) ( (c) | 0x20)
  68. #endif
  69. /* Search sub-string in memory buffer */
  70. /* From '#' to EOL ---- remarks */
  71. char *mem_str(char *buf, char *str, char *end_buf)
  72. {
  73. int i;
  74. for( ; buf <= end_buf; buf++ )
  75. {
  76. if( *buf == '#' )
  77. {
  78. buf = strchr(buf+1, '\n' );
  79. if( !buf )
  80. return NULL;
  81. }
  82. for( i=0; &buf[i] <= end_buf && buf[i] && str[i] && (tolower(buf[i]) == tolower(str[i])); i++ ) ;
  83. if ((!str[i]) && (!((tolower(*(buf-1))>='a') && (tolower(*(buf-1))<='z'))))
  84. return buf;
  85. }
  86. return NULL;
  87. }
  88. char * ltrim(char *s )
  89. {
  90. while( *s == ' ' || *s == '\t' ) s++;
  91. return s;
  92. }
  93. VOID NdisReadConfiguration( OUT PNDIS_STATUS status, OUT PNDIS_CONFIGURATION_PARAMETER *param_value,
  94. IN NDIS_HANDLE config_handle, IN PNDIS_STRING keyword, IN NDIS_PARAMETER_TYPE param_type )
  95. {
  96. #ifdef USE_INIT_FILE
  97. char *name = keyword->Buffer;
  98. char *s, *buf = init_file, *end_buf = init_file + init_file_length;
  99. static int count = 0;
  100. *status = NDIS_STATUS_FAILURE;
  101. *param_value = pNdisParm;
  102. if( !count )
  103. {
  104. print_deb("\n++++++++++++\n%s+++++++++++\n", init_file);
  105. count++;
  106. }
  107. if( !name || !*name || !init_file || !init_file_length )
  108. return ;
  109. memset(pNdisParm, 0, sizeof(NDIS_CONFIGURATION_PARAMETER));
  110. while(buf < end_buf)
  111. {
  112. buf = ltrim(buf);
  113. if( !(s = mem_str(buf, name, end_buf)) )
  114. break;
  115. buf = ltrim(s + strlen(name));
  116. if( *buf == '=' )
  117. buf++;
  118. else {
  119. /*print_err("\n...init_config err: delim not found (=): ** %s **\n", buf );*/
  120. buf = s + 1; /*strlen(name);*/
  121. continue;
  122. }
  123. buf = ltrim(buf);
  124. if( param_type == NdisParameterString )
  125. {
  126. char *remark = NULL;
  127. s = strchr(buf, '\n');
  128. if( !s )
  129. s = buf+strlen(buf);
  130. remark = memchr(buf, '#', s - buf); /* skip remarks */
  131. if( remark )
  132. {
  133. do { /* remove whitespace */
  134. remark--;
  135. } while( *remark == ' ' || *remark == '\t' );
  136. pNdisParm->ParameterData.StringData.Length = remark - buf + 1;
  137. }
  138. else
  139. pNdisParm->ParameterData.StringData.Length = s - buf;
  140. pNdisParm->ParameterData.StringData.Buffer = (PUCHAR)&pNdisParm->StringBuffer[0];
  141. pNdisParm->ParameterData.StringData.MaximumLength = NDIS_MAX_STRING_LEN;
  142. if( !pNdisParm->ParameterData.StringData.Length > NDIS_MAX_STRING_LEN )
  143. {
  144. *status = NDIS_STATUS_BUFFER_TOO_SHORT;
  145. return;
  146. }
  147. memcpy(pNdisParm->ParameterData.StringData.Buffer, buf, pNdisParm->ParameterData.StringData.Length);
  148. print_info("NdisReadConfiguration(): %s = (%d)'%s'\n", name, pNdisParm->ParameterData.StringData.Length, pNdisParm->ParameterData.StringData.Buffer);
  149. }
  150. else if( param_type == NdisParameterInteger )
  151. {
  152. char *end_p;
  153. pNdisParm->ParameterData.IntegerData = simple_strtol(buf, &end_p, 0);
  154. if (end_p && *end_p && *end_p!=' ' && *end_p!='\n'
  155. && *end_p!='\r' && *end_p!='\t')
  156. {
  157. print_err("\n...init_config: invalid int value for <%s> : %s\n", name, buf );
  158. return;
  159. }
  160. /*print_deb(" NdisReadConfiguration(): buf = %p (%.20s)\n", buf, buf );*/
  161. print_info("NdisReadConfiguration(): %s = %d\n", name, (INT32) pNdisParm->ParameterData.IntegerData);
  162. }
  163. else
  164. {
  165. print_err("NdisReadConfiguration(): unknow parameter type %d for %s\n", param_type, name );
  166. return;
  167. }
  168. *status = NDIS_STATUS_SUCCESS;
  169. return;
  170. }
  171. /* print_deb("NdisReadConfiguration(%d): (%c)%s - not found\n", init_file_length,*/
  172. /* (param_type == NdisParameterString) ? 'S' : 'D', name );*/
  173. #else
  174. /* No init file support */
  175. *status = NDIS_STATUS_FAILURE;
  176. #endif
  177. return ;
  178. }
  179. VOID NdisWriteConfiguration( OUT PNDIS_STATUS Status,
  180. IN NDIS_HANDLE ConfigurationHandle,
  181. IN PNDIS_STRING Keyword,
  182. IN PNDIS_CONFIGURATION_PARAMETER ParameterValue )
  183. {
  184. print_err(" NdisWriteConfiguration(): ** not implemented yet ...\n");
  185. }
  186. VOID NdisReadNetworkAddress( OUT PNDIS_STATUS Status, OUT PVOID *NetworkAddress, OUT PUINT NetworkAddressLength,
  187. IN NDIS_HANDLE ConfigurationHandle )
  188. {
  189. print_err(" NdisReadNetworkAddress(): ** not implemented yet ...\n");
  190. }
  191. VOID NdisMIndicateStatus(
  192. NDIS_HANDLE MiniportAdapterHandle,
  193. NDIS_STATUS GeneralStatus,
  194. PVOID StatusBuffer,
  195. UINT StatusBufferSize
  196. )
  197. {
  198. }