From 00a0b678dc063ca718fb80fa7426f64e1cccc1b8 Mon Sep 17 00:00:00 2001 From: Lakindu Akash Date: Wed, 13 Oct 2021 06:00:54 +0530 Subject: [PATCH] Run qrencode command --- src/ui/h_prop.c | 32 ++++++++++++++++++++++++++++++++ src/ui/h_prop.h | 2 ++ 2 files changed, 34 insertions(+) diff --git a/src/ui/h_prop.c b/src/ui/h_prop.c index 93c7379..53ac906 100644 --- a/src/ui/h_prop.c +++ b/src/ui/h_prop.c @@ -62,6 +62,8 @@ static char accepted_macs[BUFSIZE]; static const char* g_ssid=NULL; static const char* g_pass=NULL; +static char* qr_image_path; + //config_t cfg; static int parse_output(const char *cmd) { @@ -424,6 +426,36 @@ char** get_wifi_interface_list(int *length){ } +char* generate_qr_image(char* ssid,char* type,char *password){ + char cmd[BUFSIZE]; + + qr_image_path = "/tmp/wihotspot_qr.png"; + + snprintf(cmd, BUFSIZE, "%s -V -s 10 -d 256 -o %s 'WIFI:S:%s;T:%s;P:%s;;' ","qrencode",qr_image_path, ssid,type,password); + + FILE *fp; + + char temp_buff[1048]; + + if ((fp = popen(cmd, "r")) == NULL) { + printf("Error opening pipe!\n"); + + } + + + while (fgets(temp_buff, sizeof(temp_buff), fp) != NULL) { + + printf("%s", temp_buff); + } + + if (pclose(fp)) { + printf("Error executing qrencode\n"); + + } + + return qr_image_path; +} + Node get_connected_devices(char *PID) { char cmd[BUFSIZE]; diff --git a/src/ui/h_prop.h b/src/ui/h_prop.h index f407086..16a19e3 100644 --- a/src/ui/h_prop.h +++ b/src/ui/h_prop.h @@ -71,6 +71,8 @@ void write_accepted_macs(char* filename, char* accepted_macs); char * read_mac_filter_file(char * filename); +char* generate_qr_image(char* ssid,char* type,char *password); + Node get_connected_devices(char *PID); PtrToNode add_device_node(Node l, int number, char *line, int marker[3]);