1 /* Copyright (c) 2021 Huawei Device Co., Ltd.
2 *
3 * This software may be distributed under the terms of the BSD license.
4 * See README for more details.
5 */
6 #include <dlfcn.h>
7 #include <pthread.h>
8 #include <stdio.h>
9 #include <string.h>
10 #include "libwpa.h"
11
12 pthread_t g_apThread;
13
14 char* g_apArg[20] ={0};
15 int g_apArgc = 0;
16
ThreadMain()17 static void* ThreadMain()
18 {
19 printf("[HostapdSample]init hostapd.\n");
20 int ret = ap_main(g_apArgc, g_apArg);
21 printf("[HostapdSample]run ap_main result is %d.\n", ret);
22 return NULL;
23 }
24
main(int argc,char * argv[])25 int main(int argc, char *argv[])
26 {
27 g_apArgc = argc;
28 for (int i = 0; i < g_apArgc; i++) {
29 g_apArg[i] = argv[i];
30 }
31 int ret = pthread_create(&g_apThread, NULL, ThreadMain, NULL);
32 if (ret != 0) {
33 printf("[HostapdSample]create thread failed, errorNumberis %s.\n", strerror(ret));
34 return -1;
35 }
36 pthread_join(g_apThread, NULL);
37 return 0;
38 }