#include <stdio.h>
#include "libnethogs.h"
#include "memory.h"
#include <stdlib.h>
#include <unistd.h>
void callback(int action,
NethogsMonitorRecord const *data) {
if (action == NETHOGS_APP_ACTION_REMOVE || data->sent_bytes || data->recv_bytes) {
printf("name: %s\n, ", data->name);
printf("devname: %s\n", data->device_name),
printf("send: %f, %ld\n", data->sent_kbs, data->sent_bytes);
printf("recv: %f, %ld\n", data->recv_kbs, data->recv_bytes);
printf("recoid: %d\n", data->record_id);
printf("----------------------------------\n");
}
}
int main() {
struct NethogsMonitorRecord record;
NethogsMonitorCallback cb = callback;
// int a = nethogsmonitor_loop(cb, NULL);
nethogsmonitor_loop_devices(cb, NULL, 0, NULL, false);
// printf("%d\n", a);
return 0;
}
cmake_minimum_required(VERSION 3.14)
project(test_call_so C)
set(CMAKE_C_STANDARD 99)
link_directories(/home/baloneo/CLionProjects/test_call_so)
link_libraries(nethogs)
add_executable(test_call_so main.c libnethogs.h)
网友评论