aboutsummaryrefslogtreecommitdiff
path: root/src/sg_vpd.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/sg_vpd.h')
-rw-r--r--src/sg_vpd.h79
1 files changed, 79 insertions, 0 deletions
diff --git a/src/sg_vpd.h b/src/sg_vpd.h
new file mode 100644
index 00000000..67205717
--- /dev/null
+++ b/src/sg_vpd.h
@@ -0,0 +1,79 @@
+#ifndef SG_VPD_H
+#define SG_VPD_H
+
+/*
+ * Copyright (c) 2022 Douglas Gilbert.
+ * All rights reserved.
+ * Use of this source code is governed by a BSD-style
+ * license that can be found in the BSD_LICENSE file.
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "sg_lib.h"
+#include "sg_pr2serr.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* These two structures are duplicates of those of the same name in
+ * sg_vpd_vendor.c . <<< Take care that both are the same. >>> */
+struct opts_t {
+ bool do_all;
+ bool do_enum;
+ bool do_force;
+ bool do_long;
+ bool do_quiet;
+ bool verbose_given;
+ bool version_given;
+ int do_hex;
+ int do_ident;
+ int do_raw;
+ int examine;
+ int maxlen;
+ int vend_prod_num;
+ int verbose;
+ int vpd_pn;
+ const char * device_name;
+ const char * page_str;
+ const char * inhex_fn;
+ const char * vend_prod;
+ sgj_state json_st;
+};
+
+struct svpd_values_name_t {
+ int value; /* VPD page number */
+ int subvalue; /* to differentiate if value+pdt are not unique */
+ int pdt; /* peripheral device type id, -1 is the default */
+ /* (all or not applicable) value */
+ const char * acron;
+ const char * name;
+};
+
+void svpd_enumerate_vendor(int vend_prod_num);
+int svpd_count_vendor_vpds(int vpd_pn, int vend_prod_num);
+int svpd_decode_vendor(int sg_fd, struct opts_t * op, int off);
+const struct svpd_values_name_t * svpd_find_vendor_by_acron(const char * ap);
+int svpd_find_vp_num_by_acron(const char * vp_ap);
+const struct svpd_values_name_t * svpd_find_vendor_by_num(int page_num,
+ int vend_prod_num);
+int vpd_fetch_page(int sg_fd, uint8_t * rp, int page, int mxlen,
+ bool qt, int vb, int * rlenp);
+void dup_sanity_chk(int sz_opts_t, int sz_values_name_t);
+
+extern uint8_t * rsp_buff;
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* end of SG_VPD_H */