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_wpaThread; 13e5b75505Sopenharmony_ci 14e5b75505Sopenharmony_cichar* g_wpaArg[20] = {0}; 15e5b75505Sopenharmony_ciint g_wpaArgc = 0; 16e5b75505Sopenharmony_ci 17e5b75505Sopenharmony_cistatic void* ThreadMain() 18e5b75505Sopenharmony_ci{ 19e5b75505Sopenharmony_ci printf("[WpaSample]init enter.\r\n"); 20e5b75505Sopenharmony_ci wpa_main(g_wpaArgc, g_wpaArg); 21e5b75505Sopenharmony_ci return NULL; 22e5b75505Sopenharmony_ci} 23e5b75505Sopenharmony_ci 24e5b75505Sopenharmony_ciint main(int argc, char *argv[]) 25e5b75505Sopenharmony_ci{ 26e5b75505Sopenharmony_ci g_wpaArgc = argc; 27e5b75505Sopenharmony_ci for (int i = 0; i < g_wpaArgc; i++) { 28e5b75505Sopenharmony_ci g_wpaArg[i] = argv[i]; 29e5b75505Sopenharmony_ci } 30e5b75505Sopenharmony_ci int ret = pthread_create(&g_wpaThread, NULL, ThreadMain, NULL); 31e5b75505Sopenharmony_ci if (ret != 0) { 32e5b75505Sopenharmony_ci printf("[WpaSample]create thread failed, error:%s.\r\n", strerror(ret)); 33e5b75505Sopenharmony_ci return 1; 34e5b75505Sopenharmony_ci } 35e5b75505Sopenharmony_ci pthread_join(g_wpaThread, NULL); 36e5b75505Sopenharmony_ci return 0; 37e5b75505Sopenharmony_ci}