summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2011-10-12 22:16:34 +0100
committerJim Meyering <meyering@redhat.com>2011-10-14 18:32:44 +0200
commitfae153a5d7c1c029ab600ac60d47e2d3c86b6976 (patch)
tree7e01cbca999c04fc7f99f491baaac49cee8aa68e
parent959d4c2875216d26b2d113cc7119dd8623493e34 (diff)
downloadparted-fae153a5d7c1c029ab600ac60d47e2d3c86b6976.tar.gz
parted: strlist print functions can now send output to any FILE *
This changes the two strlist print functions so that instead of just sending output to stdout, they can send it to any FILE *. Now the caller can send errors to stderr instead of stdout.
-rw-r--r--parted/command.c4
-rw-r--r--parted/strlist.c18
-rw-r--r--parted/strlist.h4
-rw-r--r--parted/ui.c4
4 files changed, 15 insertions, 15 deletions
diff --git a/parted/command.c b/parted/command.c
index 5a05854..2c31efb 100644
--- a/parted/command.c
+++ b/parted/command.c
@@ -119,7 +119,7 @@ void
command_print_summary (Command* cmd)
{
fputs (" ", stdout);
- str_list_print_wrap (cmd->summary, screen_width(), 2, 8);
+ str_list_print_wrap (cmd->summary, screen_width(), 2, 8, stdout);
putchar ('\n');
}
@@ -129,7 +129,7 @@ command_print_help (Command* cmd)
command_print_summary (cmd);
if (cmd->help) {
fputs ("\n\t", stdout);
- str_list_print_wrap (cmd->help, screen_width(), 8, 8);
+ str_list_print_wrap (cmd->help, screen_width(), 8, 8, stdout);
}
}
diff --git a/parted/strlist.c b/parted/strlist.c
index 798d5ae..54ff8c8 100644
--- a/parted/strlist.c
+++ b/parted/strlist.c
@@ -188,10 +188,10 @@ wchar_to_str (const wchar_t* str, size_t count)
#endif /* !ENABLE_NLS */
static void
-print_wchar (const wchar_t* str, size_t count)
+print_wchar (const wchar_t* str, size_t count, FILE *fp)
{
char* tmp = wchar_to_str (str, count);
- printf ("%s", tmp);
+ fprintf (fp, "%s", tmp);
free (tmp);
}
@@ -373,13 +373,13 @@ str_list_convert (const StrList* list)
}
void
-str_list_print (const StrList* list)
+str_list_print (const StrList* list, FILE *fp)
{
const StrList* walk;
for (walk=list; walk; walk=walk->next) {
if (walk->str)
- print_wchar (walk->str, 0);
+ print_wchar (walk->str, 0, fp);
}
}
@@ -430,7 +430,7 @@ is_space (wchar_t c)
void
str_list_print_wrap (const StrList* list, int line_length, int offset,
- int indent)
+ int indent, FILE *fp)
{
const StrList* walk;
const wchar_t* str;
@@ -481,19 +481,19 @@ str_list_print_wrap (const StrList* list, int line_length, int offset,
cut_right++);
if (cut_left > 0)
- print_wchar (str, cut_left + 1);
+ print_wchar (str, cut_left + 1, fp);
str += cut_right;
str_len -= cut_right;
line_left = line_length - indent;
if (walk->next || *str)
- printf ("\n%*s", indent, "");
+ fprintf (fp, "\n%*s", indent, "");
else if (line_break)
- putchar ('\n');
+ fputc ('\n', fp);
}
- print_wchar (str, 0);
+ print_wchar (str, 0, fp);
line_left -= wchar_strlen (str);
}
}
diff --git a/parted/strlist.h b/parted/strlist.h
index 32ad8cc..7fe9bf3 100644
--- a/parted/strlist.h
+++ b/parted/strlist.h
@@ -53,9 +53,9 @@ extern StrList* str_list_join (StrList* a, StrList* b);
extern char* str_list_convert (const StrList* list);
extern char* str_list_convert_node (const StrList* list);
-extern void str_list_print (const StrList* list);
+extern void str_list_print (const StrList* list, FILE *fp);
extern void str_list_print_wrap (const StrList* list, int line_length,
- int offset, int indent);
+ int offset, int indent, FILE *fp);
extern int str_list_match_any (const StrList* list, const char* str);
extern int str_list_match_node (const StrList* list, const char* str);
extern StrList* str_list_match (const StrList* list, const char* str);
diff --git a/parted/ui.c b/parted/ui.c
index 6d2fde1..56c0304 100644
--- a/parted/ui.c
+++ b/parted/ui.c
@@ -625,7 +625,7 @@ _print_exception_text (PedException* ex)
": ", ex->message, "\n", NULL);
}
- str_list_print_wrap (text, screen_width (), 0, 0);
+ str_list_print_wrap (text, screen_width (), 0, 0, stderr);
str_list_destroy (text);
}
@@ -1541,7 +1541,7 @@ interactive_mode (PedDevice** dev, Command* cmd_list[])
print_using_dev (*dev);
list = str_list_create (_(banner_msg), NULL);
- str_list_print_wrap (list, screen_width (), 0, 0);
+ str_list_print_wrap (list, screen_width (), 0, 0, stdout);
str_list_destroy (list);
while (1) {