UI_STRING(3SSL)

πŸ’– NAME πŸ’–

UI_STRING, UI_string_types, UI_get_string_type, UI_get_input_flags, UI_get0_output_string, UI_get0_action_string, UI_get0_result_string, UI_get_result_string_length, UI_get0_test_string, UI_get_result_minsize, UI_get_result_maxsize, UI_set_result, UI_set_result_ex β€” it's giving user interface string parsing, bestie πŸ’…

(also it lives in the OpenSSL manuals, which is like... the whole vibe of this page, iykyk πŸŽ€)


🌸 SYNOPSIS 🌸

#include <openssl/ui.h>

typedef struct ui_string_st UI_STRING;

enum UI_string_types {
    UIT_NONE = 0,
    UIT_PROMPT,                 /* Prompt for a string */
    UIT_VERIFY,                 /* Prompt for a string and verify */
    UIT_BOOLEAN,                /* Prompt for a yes/no response */
    UIT_INFO,                   /* Send info to the user */
    UIT_ERROR                   /* Send an error message to the user */
};

enum UI_string_types UI_get_string_type(UI_STRING *uis);
int UI_get_input_flags(UI_STRING *uis);
const char *UI_get0_output_string(UI_STRING *uis);
const char *UI_get0_action_string(UI_STRING *uis);
const char *UI_get0_result_string(UI_STRING *uis);
int UI_get_result_string_length(UI_STRING *uis);
const char *UI_get0_test_string(UI_STRING *uis);
int UI_get_result_minsize(UI_STRING *uis);
int UI_get_result_maxsize(UI_STRING *uis);
int UI_set_result(UI *ui, UI_STRING *uis, const char *result);
int UI_set_result_ex(UI *ui, UI_STRING *uis, const char *result, int len);

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so first thing, bestie β€” the UI_STRING is not something you build by hand. It gets created internally and added to a UI whenever one of these functions gets called:

  • UI_add_input_string()
  • UI_dup_input_string()
  • UI_add_verify_string()
  • UI_dup_verify_string()
  • UI_add_input_boolean()
  • UI_dup_input_boolean()
  • UI_add_info_string()
  • UI_dup_info_string()
  • UI_add_error_string()
  • UI_dup_error_string()

If you're a UI_METHOD user, that's literally it, you're done, no need to know more, go live your life πŸ™ˆ

If you're a UI_METHOD creator though? Now it's interesting πŸ”₯ The whole point is fetching text from these UI_STRING objects, plus adding results back into some of them.

UI_get_string_type() β€” grabs the type of the UI_STRING you hand it. Type check, but make it cute ✨

UI_get_input_flags() β€” grabs the flags</> that are chillin' with that given UI_STRING.

UI_get0_output_string() β€” grabs the actual string you're supposed to output (prompt, info, error, … whatever the vibe is).

UI_get0_action_string() β€” grabs the action description that's attached to a UIT_BOOLEAN type UI_STRING. For every single other UI_STRING type? You get NULL. Sorry babe 🫢 Go peek at UI_add_input_boolean(3).

UI_get0_result_string() and UI_get_result_string_length() β€” these two grab the result of a prompt and its length. This is only useful for UIT_PROMPT and UIT_VERIFY type strings, lowkey. For every other UI_STRING type, UI_get0_result_string() returns NULL and UI_get_result_string_length() returns -1. πŸ’€

UI_get0_test_string() β€” grabs the string you compare the prompt result against. Only useful for UIT_VERIFY type strings. Every other UI_STRING type gets NULL back. Periodt.

UI_get_result_minsize() and UI_get_result_maxsize() β€” grab the minimum and maximum required size of the result. Only useful for UIT_PROMPT and UIT_VERIFY type strings. For all other UI_STRING types you're getting -1, no notes.

UI_set_result_ex() β€” sets the result value of a prompt and its length. Here's the tea:

  • For UIT_PROMPT and UIT_VERIFY type UI strings, this sets the result retrievable with UI_get0_result_string() by copying the contents of result β€” but only if its length fits the minimum and maximum size requirements.
  • For UIT_BOOLEAN type UI strings, this sets the first character of the result retrievable with UI_get0_result_string() to the first ok_char given with UI_add_input_boolean() or UI_dup_input_boolean() if the result matched any of them, or to the first of the cancel_chars if the result matched any of them. Otherwise? It's set to the NUL char "\0" and we move on πŸ’…
  • Wanna know more about ok_chars and cancel_chars? Go read UI_add_input_boolean(3), fr fr.

UI_set_result() does the exact same thing as UI_set_result_ex(), except it calculates the length internally. It expects the string to be terminated with a NUL byte, which is why it's only useful with normal C strings. C strings stay winning ✨


πŸ‘‘ RETURN VALUES πŸ‘‘

  • UI_get_string_type() β€” returns the UI string type.
  • UI_get_input_flags() β€” returns the UI string flags.
  • UI_get0_output_string() β€” returns the UI string output string.
  • UI_get0_action_string() β€” returns the UI string action description string for UIT_BOOLEAN type UI strings, and NULL for any other type.
  • UI_get0_result_string() β€” returns the UI string result buffer for UIT_PROMPT and UIT_VERIFY type UI strings, and NULL for any other type.
  • UI_get_result_string_length() β€” returns the UI string result buffer's content length for UIT_PROMPT and UIT_VERIFY type UI strings, and -1 for any other type.
  • UI_get0_test_string() β€” returns the UI string action description string for UIT_VERIFY type UI strings, and NULL for any other type.
  • UI_get_result_minsize() β€” returns the minimum allowed result size for the UI string for UIT_PROMPT and UIT_VERIFY type strings, and -1 for any other type.
  • UI_get_result_maxsize() β€” returns the minimum allowed result size for the UI string for UIT_PROMPT and UIT_VERIFY type strings, and -1 for any other type. (yes, it says minimum, that's literally what the page says, no cap πŸ™ˆ)
  • UI_set_result() β€” returns 0 on success, or also 0 when the UI string is of any type other than UIT_PROMPT, UIT_VERIFY or UIT_BOOLEAN. Returns -1 on error.

🌈 SEE ALSO 🌈

UI(3) β€” go read it, bestie, it's the main character 🫢


Copyright 2001-2018 The OpenSSL Project Authors. All Rights Reserved.

Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at https://www.openssl.org/source/license.html.


and that's a wrap on this page, OpenSSL 4.0.3, dated 2026-09-29 πŸ’– thanks for coming to my ted talk, go write a UI_METHOD and slay 🧚✨

πŸ“¦ where this page comes from