UI_STRING(3ossl)

πŸ’– NAME πŸ’–

okay bestie, gather round, this is the UI_STRING page for the 3ossl manual, and it's literally all about User interface string parsing ✨

The whole squad of functions and types living here:

  • 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

πŸŽ€ 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 🌸

So here's the tea, bestie πŸ’… β€” a UI_STRING gets created internally and gets added to a UI whenever one of these cuties 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, you genuinely don't need to know anything more. Like, go live your life πŸ¦‹. But if you're a UI_METHOD creator, you're gonna want to fetch text out of these UI_STRING objects and add results back into some of them. That's your main character moment, ngl πŸ‘‘

UI_get_string_type() β€” grabs the type of the given UI_STRING. Simple, iconic.

UI_get_input_flags() β€” grabs the flags hanging out with that UI_STRING.

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

UI_get0_action_string() β€” grabs the action description tied to a UIT_BOOLEAN type UI_STRING. For every other UI_STRING type? NULL, babes. Check UI_add_input_boolean(3) for the lore.

UI_get0_result_string() and UI_get_result_string_length() β€” these two retrieve the result of a prompt and its length. Only useful for UIT_PROMPT and UIT_VERIFY type strings, fr fr. For all other UI_STRING types, 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. For all other UI_STRING types, NULL is returned.

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, -1 is returned.

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

  • 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 β€” if its length fits the minimum and maximum size requirements. If it doesn't fit? No copy for you 🚫.
  • 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 the first of the cancel_chars if the result matched any of them. Otherwise it's set to the NUL char "\0".
Need more on ok_chars and cancel_chars? Go read UI_add_input_boolean(3), bestie 🫢

UI_set_result() β€” does the exact same thing as UI_set_result_ex(), except it calculates its length internally. It expects the string to be terminated with a NUL byte, which means it's only useful with normal C strings. That's it, that's the whole thing ✨


🌈 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, NULL for any other type.
  • UI_get0_result_string() β€” returns the UI string result buffer for UIT_PROMPT and UIT_VERIFY type UI strings, 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, -1 for any other type.
  • UI_get0_test_string() β€” returns the UI string action description string for UIT_VERIFY type UI strings, 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, -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, -1 for any other type.
not me reading that twice β€” yep, UI_get_result_maxsize() really does say minimum allowed result size in the docs, I'm just the messenger, don't shoot me 😭
  • UI_set_result() β€” returns 0 on success, or 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)


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, bestie 🫢 this was UI_STRING(3ossl) from 3.5.9, dated 2026-09-29 β€” go forth and parse those UI strings, you absolute icon πŸ’–βœ¨πŸŒΈ

πŸ“¦ where this page comes from