summaryrefslogtreecommitdiff
path: root/source3/utils/regedit_dialog.c
diff options
context:
space:
mode:
authorChris Davis <cd.rattan@gmail.com>2014-08-08 23:55:25 -0700
committerMichael Adam <obnox@samba.org>2014-10-01 14:32:09 +0200
commit4badab3a6062a473b9651564ce43bb51c63457c1 (patch)
tree0f4e736c85d5ed5a1fc75bb0e1389f1c6eabc292 /source3/utils/regedit_dialog.c
parent8acb87e42e8004c6a2f04085825fadad3cfbc5b2 (diff)
downloadsamba-4badab3a6062a473b9651564ce43bb51c63457c1.tar.gz
regedit: add a button to resize hexedit buffer
Signed-off-by: Chris Davis <cd.rattan@gmail.com> Reviewed-by: Andreas Schneider <asn@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
Diffstat (limited to 'source3/utils/regedit_dialog.c')
-rw-r--r--source3/utils/regedit_dialog.c48
1 files changed, 46 insertions, 2 deletions
diff --git a/source3/utils/regedit_dialog.c b/source3/utils/regedit_dialog.c
index dff44ea5ff9..6f0aedad5b1 100644
--- a/source3/utils/regedit_dialog.c
+++ b/source3/utils/regedit_dialog.c
@@ -1224,6 +1224,23 @@ void dialog_section_hexedit_get_buf(struct dialog_section *section,
*size = hexedit_get_buf_len(hexedit->buf);
}
+WERROR dialog_section_hexedit_resize(struct dialog_section *section,
+ size_t size)
+{
+ WERROR rv;
+ struct dialog_section_hexedit *hexedit =
+ talloc_get_type_abort(section, struct dialog_section_hexedit);
+
+ SMB_ASSERT(hexedit->buf != NULL);
+ rv = hexedit_resize_buffer(hexedit->buf, size);
+ if (W_ERROR_IS_OK(rv)) {
+ hexedit_refresh(hexedit->buf);
+ }
+
+ return rv;
+}
+
+
/* button box */
struct dialog_section_buttons {
struct dialog_section section;
@@ -2030,6 +2047,22 @@ static bool edit_on_submit(struct dialog *dia, struct dialog_section *section,
}
+static enum dialog_action edit_on_resize(struct dialog *dia,
+ struct dialog_section *section)
+{
+ struct dialog_section *data;
+ unsigned long size;
+ int rv;
+
+ data = dialog_find_section(dia, "data");
+ rv = dialog_input_ulong(dia, &size, "Resize", "Enter size of buffer");
+ if (rv == DIALOG_OK) {
+ dialog_section_hexedit_resize(data, size);
+ }
+
+ return DIALOG_IGNORE;
+}
+
int dialog_edit_value(TALLOC_CTX *ctx, struct registry_key *key,
uint32_t type, const struct value_item *vitem,
bool force_binary, WERROR *err,
@@ -2039,11 +2072,18 @@ int dialog_edit_value(TALLOC_CTX *ctx, struct registry_key *key,
struct dialog *dia;
struct dialog_section *section;
struct edit_req edit;
- struct button_spec spec[] = {
+ struct button_spec buttons[] = {
{.label = "OK", .action = DIALOG_OK},
{.label = "Cancel", .action = DIALOG_CANCEL},
{ 0 }
};
+ struct button_spec buttons_hexedit[] = {
+ {.label = "OK", .action = DIALOG_OK},
+ {.label = "Resize Buffer", .on_enter = edit_on_resize},
+ {.label = "Cancel", .action = DIALOG_CANCEL},
+ { 0 }
+ };
+
edit.key = key;
edit.vitem = vitem;
@@ -2100,7 +2140,11 @@ int dialog_edit_value(TALLOC_CTX *ctx, struct registry_key *key,
section = dialog_section_hsep_new(dia, 0);
dialog_append_section(dia, section);
- section = dialog_section_buttons_new(dia, spec);
+ if (edit.mode == REG_BINARY) {
+ section = dialog_section_buttons_new(dia, buttons_hexedit);
+ } else {
+ section = dialog_section_buttons_new(dia, buttons);
+ }
dialog_section_set_justify(section, SECTION_JUSTIFY_CENTER);
dialog_append_section(dia, section);