MCPcopy Create free account
hub / github.com/Kitware/VTK / xmlShellReadline

Function xmlShellReadline

ThirdParty/libxml2/vtklibxml2/xmlcatalog.c:59–90  ·  view source on GitHub ↗

* * * Shell Interface * * * ************************************************************************/ * xmlShellReadline: * @prompt: the prompt value * * Read a string * * Returns a pointer to it or NULL on EOF the caller is expected to * free the returned string. */

Source from the content-addressed store, hash-verified

57 * free the returned string.
58 */
59static char *
60xmlShellReadline(const char *prompt) {
61#ifdef HAVE_LIBREADLINE
62 char *line_read;
63
64 /* Get a line from the user. */
65 line_read = readline (prompt);
66
67 /* If the line has any text in it, save it on the history. */
68 if (line_read && *line_read)
69 add_history (line_read);
70
71 return (line_read);
72#else
73 char line_read[501];
74 char *ret;
75 int len;
76
77 if (prompt != NULL)
78 fprintf(stdout, "%s", prompt);
79 fflush(stdout);
80 if (!fgets(line_read, 500, stdin))
81 return(NULL);
82 line_read[500] = 0;
83 len = strlen(line_read);
84 ret = (char *) malloc(len + 1);
85 if (ret != NULL) {
86 memcpy (ret, line_read, len + 1);
87 }
88 return(ret);
89#endif
90}
91
92static void usershell(void) {
93 char *cmdline = NULL, *cur;

Callers 1

usershellFunction · 0.70

Calls 1

fprintfFunction · 0.85

Tested by

no test coverage detected