• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright (c) 2021 Huawei Device Co., Ltd.
2  * Licensed under the Apache License, Version 2.0 (the "License");
3  * you may not use this file except in compliance with the License.
4  * You may obtain a copy of the License at
5  *
6  *     http://www.apache.org/licenses/LICENSE-2.0
7  *
8  * Unless required by applicable law or agreed to in writing, software
9  * distributed under the License is distributed on an "AS IS" BASIS,
10  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11  * See the License for the specific language governing permissions and
12  * limitations under the License.
13  */
14 #include <dlfcn.h>
15 #include <pthread.h>
16 #include <stdio.h>
17 #include <string.h>
18 #include "libwpa.h"
19 
20 pthread_t g_wpaThread;
21 
22 char* g_wpaArg[20] = {0};
23 int g_wpaArgc = 0;
24 
ThreadMain()25 static void* ThreadMain()
26 {
27     printf("[WpaSample]init enter.\r\n");
28     wpa_main(g_wpaArgc, g_wpaArg);
29     return NULL;
30 }
31 
main(int argc,char * argv[])32 int main(int argc, char *argv[])
33 {
34     g_wpaArgc = argc;
35     for (int i = 0; i < g_wpaArgc; i++) {
36         g_wpaArg[i] = argv[i];
37     }
38     int ret = pthread_create(&g_wpaThread, NULL, ThreadMain, NULL);
39     if (ret != 0) {
40         printf("[WpaSample]create thread failed, error:%s.\r\n", strerror(ret));
41         return 1;
42     }
43     pthread_join(g_wpaThread, NULL);
44     return 0;
45 }