}
#endif
-/* Format a single argument for being put on a Windows command line.
+/** Format a single argument for being put on a Windows command line.
* Returns a newly allocated string */
static char *
-format_cmdline_argument(const char *arg)
+format_win_cmdline_argument(const char *arg)
{
char *formatted_arg;
char need_quotes;
return formatted_arg;
}
-/* Format a command line for use on Windows, which takes the command as a
+/** Format a command line for use on Windows, which takes the command as a
* string rather than string array. Follows the rules from "Parsing C++
* Command-Line Arguments" in MSDN. Algorithm based on list2cmdline in the
* Python subprocess module. Returns a newly allocated string */
char *
-tor_join_cmdline(const char *argv[])
+tor_join_win_cmdline(const char *argv[])
{
smartlist_t *argv_list;
char *joined_argv;
/* Format each argument and put the result in a smartlist */
argv_list = smartlist_create();
for (i=0; argv[i] != NULL; i++) {
- smartlist_add(argv_list, (void *)format_cmdline_argument(argv[i]));
+ smartlist_add(argv_list, (void *)format_win_cmdline_argument(argv[i]));
}
/* Join the arguments with whitespace */
/* Windows expects argv to be a whitespace delimited string, so join argv up
*/
- joined_argv = tor_join_cmdline(argv);
+ joined_argv = tor_join_win_cmdline(argv);
ZeroMemory(&(process_handle->pid), sizeof(PROCESS_INFORMATION));
ZeroMemory(&siStartInfo, sizeof(STARTUPINFO));
#endif // MS_WINDOWS
}
-/* Get the exit code of a process specified by <b>process_handle</b> and store
+/** Get the exit code of a process specified by <b>process_handle</b> and store
* it in <b>exit_code</b>, if set to a non-NULL value. If <b>block</b> is set
* to true, the call will block until the process has exited. Otherwise if
* the process is still running, the function will return
}
#endif
-/* Read from stdout of a process until the process exits. */
+/** Read from stdout of a process until the process exits. */
ssize_t
tor_read_all_from_process_stdout(const process_handle_t process_handle,
char *buf, size_t count)
#endif
}
-/* Read from stdout of a process until the process exits. */
+/** Read from stdout of a process until the process exits. */
ssize_t
tor_read_all_from_process_stderr(const process_handle_t process_handle,
char *buf, size_t count)
#endif
}
-/* Split buf into lines, and add to smartlist. The buffer <b>buf</b> will be
+/** Split buf into lines, and add to smartlist. The buffer <b>buf</b> will be
* modified. The resulting smartlist will consist of pointers to buf, so there
- * is no need to free the contents of sl. <b>buf</b> must be a NULL terminated
+ * is no need to free the contents of sl. <b>buf</b> must be a NUL-terminated
* string. <b>len</b> should be set to the length of the buffer excluding the
- * NULL. Non-printable characters (including NULL) will be replaced with "." */
-
+ * NUL. Non-printable characters (including NUL) will be replaced with "." */
int
tor_split_lines(smartlist_t *sl, char *buf, int len)
{
buf[cur] = '\0';
/* Point cur to the next line */
cur++;
- /* Line starts at start and ends with a null */
+ /* Line starts at start and ends with a nul */
break;
} else {
if (!TOR_ISPRINT(buf[cur]))
}
}
/* We are at the end of the line or end of string. If in_line is true there
- * is a line which starts at buf+start and ends at a NULL. cur points to
- * the character after the NULL. */
+ * is a line which starts at buf+start and ends at a NUL. cur points to
+ * the character after the NUL. */
if (in_line)
smartlist_add(sl, (void *)(buf+start));
in_line = 0;
* Test that we can properly format q Windows command line
*/
static void
-test_util_join_cmdline(void *ptr)
+test_util_join_win_cmdline(void *ptr)
{
- /* Based on some test cases from "Parsing C++ Command-Line Arguments" in MSDN
- * but we don't exercise all quoting rules because tor_join_cmdline will try
- * to only generate simple cases for the child process to parse; i.e. we
- * never embed quoted strings in arguments. */
+ /* Based on some test cases from "Parsing C++ Command-Line Arguments" in
+ * MSDN but we don't exercise all quoting rules because tor_join_win_cmdline
+ * will try to only generate simple cases for the child process to parse;
+ * i.e. we never embed quoted strings in arguments. */
const char *argvs[][4] = {
{"a", "bb", "CCC", NULL}, // Normal
for (i=0; cmdlines[i]!=NULL; i++) {
log_info(LD_GENERAL, "Joining argvs[%d], expecting <%s>", i, cmdlines[i]);
- joined_argv = tor_join_cmdline(argvs[i]);
+ joined_argv = tor_join_win_cmdline(argvs[i]);
tt_str_op(joined_argv, ==, cmdlines[i]);
tor_free(joined_argv);
}
UTIL_TEST(spawn_background_ok, 0),
UTIL_TEST(spawn_background_fail, 0),
UTIL_TEST(spawn_background_partial_read, 0),
- UTIL_TEST(join_cmdline, 0),
+ UTIL_TEST(join_win_cmdline, 0),
UTIL_TEST(split_lines, 0),
END_OF_TESTCASES
};