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