PageRenderTime 44ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/drivers/net/wireless/tiwlan1251/CUDK/IPC/Linux/proc_main.c

http://github.com/CyanogenMod/cm-kernel
C | 132 lines | 82 code | 24 blank | 26 comment | 21 complexity | 2a3d1adf5e78e56c6090ad5783bb0185 MD5 | raw file
Possible License(s): AGPL-1.0, GPL-2.0, LGPL-2.0
  1. /*******************************************************************************
  2. **+--------------------------------------------------------------------------+**
  3. **| |**
  4. **| Copyright 1998-2008 Texas Instruments, Inc. - http://www.ti.com/ |**
  5. **| |**
  6. **| Licensed under the Apache License, Version 2.0 (the "License"); |**
  7. **| you may not use this file except in compliance with the License. |**
  8. **| You may obtain a copy of the License at |**
  9. **| |**
  10. **| http://www.apache.org/licenses/LICENSE-2.0 |**
  11. **| |**
  12. **| Unless required by applicable law or agreed to in writing, software |**
  13. **| distributed under the License is distributed on an "AS IS" BASIS, |**
  14. **| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |**
  15. **| See the License for the specific language governing permissions and |**
  16. **| limitations under the License. |**
  17. **| |**
  18. **+--------------------------------------------------------------------------+**
  19. *******************************************************************************/
  20. /**************************************************************************/
  21. /* */
  22. /* MODULE: proc_main.c */
  23. /* PURPOSE: Supplicant Initialization */
  24. /* */
  25. /**************************************************************************/
  26. #include <string.h>
  27. #include <stdlib.h>
  28. #include <stdio.h>
  29. #include <errno.h>
  30. #include <fcntl.h> /* for O_WRONLY*/
  31. #include <sys/time.h>
  32. #include <sys/resource.h>
  33. #include <unistd.h>
  34. typedef unsigned int UINT32; /*nick*/
  35. #include "osTIType.h"
  36. #include "TI_SupplicantStub.h"
  37. #include "TI_IPC_Api.h"
  38. #include "ipc_event.h"
  39. extern tiBOOL g_bTerminate ;
  40. int main(int argc, char ** argv)
  41. {
  42. #ifdef TI_DBG
  43. struct rlimit rLimit;
  44. rLimit.rlim_cur = 1024*1024;
  45. rLimit.rlim_max = 1024*1024;
  46. setrlimit(RLIMIT_CORE,&rLimit);
  47. #endif
  48. FILE *f = fopen("/dev/console", "w" );
  49. int hfile_output = -1;
  50. if( !f )
  51. fprintf(stderr, "/dev/console open failed: %d(%s)\n", errno, strerror(errno) );
  52. else
  53. {
  54. if( dup2( f->_fileno, 1 ) == -1 )
  55. {
  56. fprintf(f, "dup2(hfile, 1) failed: %d(%s)\n", errno, strerror(errno) );
  57. }
  58. if( dup2( f->_fileno, 2 ) == -1 )
  59. {
  60. fprintf(f, "dup2(hfile, 2) failed: %d(%s)\n", errno, strerror(errno) );
  61. }
  62. }
  63. if( argc == 2 )
  64. {
  65. hfile_output = open((char *) argv[1], O_WRONLY );
  66. if( hfile_output == -1 )
  67. {
  68. perror((char *) argv[1]);
  69. goto exit;
  70. }
  71. if( dup2( 1, hfile_output ) == -1 )
  72. {
  73. fprintf(stderr, "dup2(1, hfile_output) failed: %d(%s)\n", errno, strerror(errno) );
  74. }
  75. if( dup2( 2, hfile_output ) == -1 )
  76. {
  77. fprintf(stderr, "dup2(2, hfile_output) failed: %d(%s)\n", errno, strerror(errno) );
  78. }
  79. }
  80. /* Open socket channel for CLI configuration */
  81. if(cnfg_open() != 0)
  82. {
  83. printf("\nCan't initialize configure socket\n");
  84. return -1;
  85. }
  86. if(IPC_Init())
  87. {
  88. printf("---main(): ERROR IPC init\n");
  89. }
  90. IPC_CONFIG_PARAMS *pRegistry_config = (IPC_CONFIG_PARAMS*)malloc(sizeof(IPC_CONFIG_PARAMS));
  91. pRegistry_config->F_ConfigNotification = SendDataStub;
  92. if(IPC_RegisterConfig((void*)pRegistry_config,
  93. sizeof(IPC_CONFIG_PARAMS)))
  94. {
  95. printf("---main(): ERROR registration CONFIG Messages\n");
  96. }
  97. free(pRegistry_config);
  98. for(;g_bTerminate != TRUE;)
  99. {
  100. usleep(1000000); /* sleep 1 sec*/
  101. }
  102. exit:
  103. if( f > 0 )
  104. fclose( f );
  105. if( hfile_output > 0 )
  106. close( hfile_output );
  107. return 0;
  108. }