| 54 | } |
| 55 | |
| 56 | static int |
| 57 | graph_pcap_default_path_get(char **dir_path) |
| 58 | { |
| 59 | struct passwd *pwd; |
| 60 | char *home_dir; |
| 61 | |
| 62 | /* First check for shell environment variable */ |
| 63 | home_dir = getenv("HOME"); |
| 64 | if (home_dir == NULL) { |
| 65 | graph_warn("Home env not preset."); |
| 66 | /* Fallback to password file entry */ |
| 67 | pwd = getpwuid(getuid()); |
| 68 | if (pwd == NULL) |
| 69 | return -EINVAL; |
| 70 | |
| 71 | home_dir = pwd->pw_dir; |
| 72 | } |
| 73 | |
| 74 | /* Append default pcap file to directory */ |
| 75 | if (asprintf(dir_path, "%s/%s", home_dir, GRAPH_PCAP_FILE_NAME) == -1) |
| 76 | return -ENOMEM; |
| 77 | |
| 78 | return 0; |
| 79 | } |
| 80 | |
| 81 | int |
| 82 | graph_pcap_file_open(const char *filename) |
no test coverage detected