Run qrencode command

This commit is contained in:
Lakindu Akash 2021-10-13 06:00:54 +05:30
parent 211610d3e7
commit 00a0b678dc
No known key found for this signature in database
GPG Key ID: 6FB0085A614E0AC2
2 changed files with 34 additions and 0 deletions

View File

@ -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];

View File

@ -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]);