UI_STRING.pod 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. =pod
  2. =head1 NAME
  3. UI_STRING, UI_string_types, UI_get_string_type,
  4. UI_get_input_flags, UI_get0_output_string,
  5. UI_get0_action_string, UI_get0_result_string, UI_get_result_string_length,
  6. UI_get0_test_string, UI_get_result_minsize,
  7. UI_get_result_maxsize, UI_set_result, UI_set_result_ex
  8. - User interface string parsing
  9. =head1 SYNOPSIS
  10. #include <openssl/ui.h>
  11. typedef struct ui_string_st UI_STRING;
  12. enum UI_string_types {
  13. UIT_NONE = 0,
  14. UIT_PROMPT, /* Prompt for a string */
  15. UIT_VERIFY, /* Prompt for a string and verify */
  16. UIT_BOOLEAN, /* Prompt for a yes/no response */
  17. UIT_INFO, /* Send info to the user */
  18. UIT_ERROR /* Send an error message to the user */
  19. };
  20. enum UI_string_types UI_get_string_type(UI_STRING *uis);
  21. int UI_get_input_flags(UI_STRING *uis);
  22. const char *UI_get0_output_string(UI_STRING *uis);
  23. const char *UI_get0_action_string(UI_STRING *uis);
  24. const char *UI_get0_result_string(UI_STRING *uis);
  25. int UI_get_result_string_length(UI_STRING *uis);
  26. const char *UI_get0_test_string(UI_STRING *uis);
  27. int UI_get_result_minsize(UI_STRING *uis);
  28. int UI_get_result_maxsize(UI_STRING *uis);
  29. int UI_set_result(UI *ui, UI_STRING *uis, const char *result);
  30. int UI_set_result_ex(UI *ui, UI_STRING *uis, const char *result, int len);
  31. =head1 DESCRIPTION
  32. The B<UI_STRING> gets created internally and added to a B<UI> whenever
  33. one of the functions UI_add_input_string(), UI_dup_input_string(),
  34. UI_add_verify_string(), UI_dup_verify_string(),
  35. UI_add_input_boolean(), UI_dup_input_boolean(), UI_add_info_string(),
  36. UI_dup_info_string(), UI_add_error_string() or UI_dup_error_string()
  37. is called.
  38. For a B<UI_METHOD> user, there's no need to know more.
  39. For a B<UI_METHOD> creator, it is of interest to fetch text from these
  40. B<UI_STRING> objects as well as adding results to some of them.
  41. UI_get_string_type() is used to retrieve the type of the given
  42. B<UI_STRING>.
  43. UI_get_input_flags() is used to retrieve the flags associated with the
  44. given B<UI_STRING>.
  45. UI_get0_output_string() is used to retrieve the actual string to
  46. output (prompt, info, error, ...).
  47. UI_get0_action_string() is used to retrieve the action description
  48. associated with a B<UIT_BOOLEAN> type B<UI_STRING>.
  49. For all other B<UI_STRING> types, NULL is returned.
  50. See L<UI_add_input_boolean(3)>.
  51. UI_get0_result_string() and UI_get_result_string_length() are used to
  52. retrieve the result of a prompt and its length.
  53. This is only useful for B<UIT_PROMPT> and B<UIT_VERIFY> type strings.
  54. For all other B<UI_STRING> types, UI_get0_result_string() returns NULL
  55. and UI_get_result_string_length() returns -1.
  56. UI_get0_test_string() is used to retrieve the string to compare the
  57. prompt result with.
  58. This is only useful for B<UIT_VERIFY> type strings.
  59. For all other B<UI_STRING> types, NULL is returned.
  60. UI_get_result_minsize() and UI_get_result_maxsize() are used to
  61. retrieve the minimum and maximum required size of the result.
  62. This is only useful for B<UIT_PROMPT> and B<UIT_VERIFY> type strings.
  63. For all other B<UI_STRING> types, -1 is returned.
  64. UI_set_result_ex() is used to set the result value of a prompt and its length.
  65. For B<UIT_PROMPT> and B<UIT_VERIFY> type UI strings, this sets the
  66. result retrievable with UI_get0_result_string() by copying the
  67. contents of B<result> if its length fits the minimum and maximum size
  68. requirements.
  69. For B<UIT_BOOLEAN> type UI strings, this sets the first character of
  70. the result retrievable with UI_get0_result_string() to the first
  71. B<ok_char> given with UI_add_input_boolean() or UI_dup_input_boolean()
  72. if the B<result> matched any of them, or the first of the
  73. B<cancel_chars> if the B<result> matched any of them, otherwise it's
  74. set to the NUL char C<\0>.
  75. See L<UI_add_input_boolean(3)> for more information on B<ok_chars> and
  76. B<cancel_chars>.
  77. UI_set_result() does the same thing as UI_set_result_ex(), but calculates
  78. its length internally.
  79. It expects the string to be terminated with a NUL byte, and is therefore
  80. only useful with normal C strings.
  81. =head1 RETURN VALUES
  82. UI_get_string_type() returns the UI string type.
  83. UI_get_input_flags() returns the UI string flags.
  84. UI_get0_output_string() returns the UI string output string.
  85. UI_get0_action_string() returns the UI string action description
  86. string for B<UIT_BOOLEAN> type UI strings, NULL for any other type.
  87. UI_get0_result_string() returns the UI string result buffer for
  88. B<UIT_PROMPT> and B<UIT_VERIFY> type UI strings, NULL for any other
  89. type.
  90. UI_get_result_string_length() returns the UI string result buffer's
  91. content length for B<UIT_PROMPT> and B<UIT_VERIFY> type UI strings,
  92. -1 for any other type.
  93. UI_get0_test_string() returns the UI string action description
  94. string for B<UIT_VERIFY> type UI strings, NULL for any other type.
  95. UI_get_result_minsize() returns the minimum allowed result size for
  96. the UI string for B<UIT_PROMPT> and B<UIT_VERIFY> type strings,
  97. -1 for any other type.
  98. UI_get_result_maxsize() returns the minimum allowed result size for
  99. the UI string for B<UIT_PROMPT> and B<UIT_VERIFY> type strings,
  100. -1 for any other type.
  101. UI_set_result() returns 0 on success or when the UI string is of any
  102. type other than B<UIT_PROMPT>, B<UIT_VERIFY> or B<UIT_BOOLEAN>, -1 on
  103. error.
  104. =head1 SEE ALSO
  105. L<UI(3)>
  106. =head1 COPYRIGHT
  107. Copyright 2001-2018 The OpenSSL Project Authors. All Rights Reserved.
  108. Licensed under the Apache License 2.0 (the "License"). You may not use
  109. this file except in compliance with the License. You can obtain a copy
  110. in the file LICENSE in the source distribution or at
  111. L<https://www.openssl.org/source/license.html>.
  112. =cut