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_apThread;
21
22 char* g_apArg[20] ={0};
23 int g_apArgc = 0;
24
ThreadMain()25 static void* ThreadMain()
26 {
27 printf("[HostapdSample]init hostapd.\n");
28 int ret = ap_main(g_apArgc, g_apArg);
29 printf("[HostapdSample]run ap_main result is %d.\n", ret);
30 return NULL;
31 }
32
main(int argc,char * argv[])33 int main(int argc, char *argv[])
34 {
35 g_apArgc = argc;
36 for (int i = 0; i < g_apArgc; i++) {
37 g_apArg[i] = argv[i];
38 }
39 int ret = pthread_create(&g_apThread, NULL, ThreadMain, NULL);
40 if (ret != 0) {
41 printf("[HostapdSample]create thread failed, errorNumberis %s.\n", strerror(ret));
42 return -1;
43 }
44 pthread_join(g_apThread, NULL);
45 return 0;
46 }