X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Futil.c;h=a5f904dbfdea2e90137728ad12fcc7b6af7e2d55;hp=4795dbcc6aca0358795bafb460ff5a032d58ee04;hb=afe1be4dbdf142513f6ac1d92e6a20bdc4b20c80;hpb=9e58ff9c5c3bd46a796a20fc6c304cdab489f334 diff --git a/src/util.c b/src/util.c index 4795dbcc6..a5f904dbf 100644 --- a/src/util.c +++ b/src/util.c @@ -2651,6 +2651,53 @@ finish: close_nointr_nofail(fd); } +void status_printf(const char *format, ...) { + va_list ap; + + assert(format); + + va_start(ap, format); + status_vprintf(format, ap); + va_end(ap); +} + +void status_welcome(void) { + +#if defined(TARGET_FEDORA) + char *r; + + if (read_one_line_file("/etc/system-release", &r) < 0) + return; + + truncate_nl(r); + + /* This tries to mimic the color magic the old Red Hat sysinit + * script did. */ + + if (startswith(r, "Red Hat")) + status_printf("Welcome to \x1B[0;31m%s\x1B[0m!\n", r); /* Red for RHEL */ + else if (startswith(r, "Fedora")) + status_printf("Welcome to \x1B[0;34m%s\x1B[0m!\n", r); /* Blue for Fedora */ + else + status_printf("Welcome to %s!\n", r); + + free(r); + +#elif defined(TARGET_SUSE) + char *r; + + if (read_one_line_file("/etc/SuSE-release", &r) < 0) + return; + + truncate_nl(r); + + status_printf("Welcome to \x1B[0;32m%s\x1B[0m!\n", r); /* Green for SUSE */ + free(r); +#else +#warning "You probably should add a welcome text logic here." +#endif +} + static const char *const ioprio_class_table[] = { [IOPRIO_CLASS_NONE] = "none", [IOPRIO_CLASS_RT] = "realtime",