/[baselayout]/trunk/src/runscript.c
Gentoo

Diff of /trunk/src/runscript.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 2744 Revision 2749
297 free (service); 297 free (service);
298} 298}
299 299
300static int write_prefix (int fd, const char *buffer, size_t bytes, bool *prefixed) { 300static int write_prefix (int fd, const char *buffer, size_t bytes, bool *prefixed) {
301 unsigned int i; 301 unsigned int i;
302 int j;
303 const char *ec; 302 const char *ec;
304 const char *ec_normal = ecolor (ecolor_normal); 303 const char *ec_normal = ecolor (ecolor_normal);
305 ssize_t ret = 0; 304 ssize_t ret = 0;
306 305
307 if (fd == fileno (stdout)) 306 if (fd == fileno (stdout))
314 if (buffer[i] == '\033') 313 if (buffer[i] == '\033')
315 *prefixed = true; 314 *prefixed = true;
316 315
317 if (! *prefixed) { 316 if (! *prefixed) {
318 ret += write (fd, ec, strlen (ec)); 317 ret += write (fd, ec, strlen (ec));
319 ret += write (fd, applet, strlen (applet)); 318 ret += write (fd, prefix, strlen (prefix));
320 for (j = strlen (applet); j < 11; j++)
321 ret += write (fd, " ", 1);
322 ret += write (fd, ec_normal, strlen (ec_normal)); 319 ret += write (fd, ec_normal, strlen (ec_normal));
323 ret += write (fd, " |", 2); 320 ret += write (fd, "|", 2);
324 *prefixed = true; 321 *prefixed = true;
325 } 322 }
326 323
327 if (buffer[i] == '\n') 324 if (buffer[i] == '\n')
328 *prefixed = false; 325 *prefixed = false;
1080 snprintf (pid, sizeof (pid), "%d", (int) getpid ()); 1077 snprintf (pid, sizeof (pid), "%d", (int) getpid ());
1081 setenv ("RC_RUNSCRIPT_PID", pid, 1); 1078 setenv ("RC_RUNSCRIPT_PID", pid, 1);
1082 1079
1083 /* eprefix is kinda klunky, but it works for our purposes */ 1080 /* eprefix is kinda klunky, but it works for our purposes */
1084 if (rc_is_env ("RC_PREFIX", "yes")) { 1081 if (rc_is_env ("RC_PREFIX", "yes")) {
1082 int l = 0;
1083 char *svc;
1084
1085 /* Get the longest service name */
1086 services = rc_services_in_runlevel (NULL);
1087 STRLIST_FOREACH (services, svc, i) {
1085 int l = strlen (applet); 1088 int ll = strlen (svc);
1086 if (l < 13) 1089 if (ll > l)
1087 l = 13; 1090 l = ll;
1091 }
1092 // rc_strlist_free (services);
1093
1088 prefix = rc_xmalloc (sizeof (char *) * l); 1094 svc = prefix = rc_xmalloc (sizeof (char *) * l);
1089 snprintf (prefix, l, "%s%s", applet, " "); 1095 svc += strlcpy (prefix, applet, l);
1096 i = l - strlen (prefix);
1097 memset (svc, ' ', i);
1098 memset (svc + i, 0, 1);
1090 eprefix (prefix); 1099 eprefix (prefix);
1091 } 1100 }
1092 1101
1093 /* If we're in parallel and we're not prefixing then we need the ebuffer */ 1102 /* If we're in parallel and we're not prefixing then we need the ebuffer */
1094 if (rc_is_env ("RC_PARALLEL", "yes") && ! rc_is_env ("RC_PREFIX", "yes")) { 1103 if (rc_is_env ("RC_PARALLEL", "yes") && ! rc_is_env ("RC_PREFIX", "yes")) {

Legend:
Removed from v.2744  
changed lines
  Added in v.2749

  ViewVC Help
Powered by ViewVC 1.1.20