static bool esp_get_mac_address_(serial_handle_t handle, std::string const &cmd, std::string const &key, mac_address_t *out) { *out = mac_address_t(); std::vector<std::string> lines; if (esp_run_command(handle, cmd, &lines)) { print_lines(&lines); std::string t; if (lookup(&lines, key, &t)) { t = trim_quot(t); int a, b, c, d, e, f; if (sscanf(t.c_str(), "%02x:%02x:%02x:%02x:%02x:%02x", &a, &b, &c, &d, &e, &f) == 6) { out->a = a; out->b = b; out->c = c; out->d = d; out->e = e; out->f = f; } return true; } } return false; }
static int check_w2k3_installer_root (guestfs_h *g, struct inspect_fs *fs, const char *txtsetup) { char *str; const char *v; int r; fs->type = OS_TYPE_WINDOWS; fs->distro = OS_DISTRO_WINDOWS; r = guestfs_int_first_egrep_of_file (g, txtsetup, "^productname[[:space:]]*=[[:space:]]*\"", 1, &str); if (r == -1) return -1; if (r > 0) { trim_cr (str); trim_quot (str); v = find_value (str); fs->product_name = safe_strdup (g, v+1); free (str); } r = guestfs_int_first_egrep_of_file (g, txtsetup, "^majorversion[[:space:]]*=[[:space:]]*[[:digit:]]+", 1, &str); if (r == -1) return -1; if (r > 0) { trim_cr (str); v = find_value (str); fs->major_version = guestfs_int_parse_unsigned_int_ignore_trailing (g, v); free (str); if (fs->major_version == -1) return -1; } r = guestfs_int_first_egrep_of_file (g, txtsetup, "^minorversion[[:space:]]*=[[:space:]]*[[:digit:]]+", 1, &str); if (r == -1) return -1; if (r > 0) { trim_cr (str); v = find_value (str); fs->minor_version = guestfs_int_parse_unsigned_int_ignore_trailing (g, v); free (str); if (fs->minor_version == -1) return -1; } /* This is the windows systemroot that would be chosen on * installation by default, although not necessarily the one that * the user will finally choose. */ r = guestfs_int_first_egrep_of_file (g, txtsetup, "^defaultpath[[:space:]]*=[[:space:]]*", 1, &str); if (r == -1) return -1; if (r > 0) { trim_cr (str); v = find_value (str); fs->windows_systemroot = safe_strdup (g, v); free (str); } return 0; }