hc
2024-05-10 10ebd8556b7990499c896a550e3d416b444211e6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <stdbool.h>
#include <sys/types.h>
#include <unistd.h>
#include <ctype.h>
#include <inttypes.h>
 
#include <glib.h>
 
#include <pthread.h>
 
#include "json-c/json.h"
#include "netserver.h"
 
#define TYPE_ALL    ""
#define TYPE_WIFI    "wifi"
#define TYPE_ETH    "ethernet"
 
void netserver_test(void)
{
    char *json_str;
    netserver_scan_wifi();
 
    json_str = netserver_get_service(TYPE_ETH);
    printf("%s, netserver_get_service, %s\n", __func__, json_str);
    if (json_str)
        g_free(json_str);
 
    json_str = netserver_get_config("ethernet_84c2e41b56b1_cable");
    printf("%s, netserver_get_config, %s\n", __func__, json_str);
    if (json_str)
        g_free(json_str);
 
    json_str = netserver_get_networkip("eth0");
    printf("%s, netserver_get_networkip, %s\n", __func__, json_str);
    if (json_str)
        g_free(json_str);
 
    json_str = netserver_get_networkip("wlan0");
    printf("%s, netserver_get_networkip, %s\n", __func__, json_str);
    if (json_str)
        g_free(json_str);
}
 
int main( int argc , char ** argv)
{
    GMainLoop *main_loop;
 
    netserver_test();
 
    main_loop = g_main_loop_new(NULL, FALSE);
 
    g_main_loop_run(main_loop);
    if (main_loop)
        g_main_loop_unref(main_loop);
 
    return 0;
}