1 /* Find BunsenLabs Linux tint2 session file */ 2 3 #include <stdio.h> 4 #include <stdlib.h> 5 #include <string.h> 6 7 #include "bl.h" 8 #include "util.h" 9 #include "banned.h" 10 11 #define TINT2SESSIONFILE "~/.config/tint2/tint2-sessionfile" 12 bl_tint2file(struct sbuf * tint2_file)13void bl_tint2file(struct sbuf *tint2_file) 14 { 15 struct sbuf blfile; 16 FILE *fp; 17 char line[2048], *p; 18 19 sbuf_init(&blfile); 20 sbuf_addstr(&blfile, TINT2SESSIONFILE); 21 sbuf_expand_tilde(&blfile); 22 fp = fopen(blfile.buf, "r"); 23 if (!fp) 24 goto out; 25 if (!fgets(line, sizeof(line), fp)) 26 goto out; 27 p = strchr(line, '\n'); 28 if (p) 29 *p = '\0'; 30 sbuf_cpy(tint2_file, line); 31 out: 32 if (fp) 33 fclose(fp); 34 free(blfile.buf); 35 } 36