ppcrcd/yaboot: cfg.c yaboot.c

sparky cvs at pld-linux.org
Wed Jun 15 23:58:02 CEST 2005


Author: sparky
Date: Wed Jun 15 23:57:56 2005
New Revision: 6093

Modified:
   ppcrcd/yaboot/cfg.c
   ppcrcd/yaboot/yaboot.c
Log:
- added onboot text displaying, for help files
  (like F1, F2 in syslinux)
- text file is specified in yaboot.conf symilarly to image


Modified: ppcrcd/yaboot/cfg.c
==============================================================================
--- ppcrcd/yaboot/cfg.c	(original)
+++ ppcrcd/yaboot/cfg.c	Wed Jun 15 23:57:56 2005
@@ -72,6 +72,7 @@
 CONFIG cf_image[] =
 {
      {cft_strg, "image", NULL},
+     {cft_strg, "text", NULL},
      {cft_strg, "label", NULL},
      {cft_strg, "alias", NULL},
      {cft_flag, "single-key", NULL},
@@ -106,7 +107,7 @@
 static struct IMAGES {
      CONFIG table[sizeof (cf_image) / sizeof (cf_image[0])];
      struct IMAGES *next;
-} *images = NULL;
+} *images = NULL, *texts = NULL;
 
 void cfg_error (char *msg,...)
 {
@@ -305,6 +306,21 @@
 	  curr_table = ((*p)->table);
 	  memcpy (curr_table, cf_image, sizeof (cf_image));
      }
+     else if (!strcasecmp (item, "text")) {
+	  struct IMAGES **p = &texts;
+
+	  while (*p)
+	       p = &((*p)->next);
+	  *p = (struct IMAGES *)malloc (sizeof (struct IMAGES));
+	  if (*p == NULL) {
+	       prom_printf("malloc error in cfg_set\n");
+	       return -1;
+	  }
+	  (*p)->next = 0;
+	  curr_table = ((*p)->table);
+	  memcpy (curr_table, cf_image, sizeof (cf_image));
+     }
+
      for (walk = curr_table; walk->type != cft_end; walk++) {
 	  if (walk->name && !strcasecmp (walk->name, item)) {
 	       if (value && walk->type != cft_strg)
@@ -384,6 +400,17 @@
 	       return ret;
 	  }
      }
+     for (p = texts; p; p = p->next) {
+	  label = cfg_get_strg_i (p->table, "label");
+	  alias = cfg_get_strg_i (p->table, "alias");
+	  if (!strcmp (label, image) || (alias && !strcmp (alias, image))) {
+	       ret = cfg_get_strg_i (p->table, item);
+	       if (!ret)
+		    ret = cfg_get_strg_i (cf_options, item);
+	       return ret;
+	  }
+     }
+
      return 0;
 }
 

Modified: ppcrcd/yaboot/yaboot.c
==============================================================================
--- ppcrcd/yaboot/yaboot.c	(original)
+++ ppcrcd/yaboot/yaboot.c	Wed Jun 15 23:57:56 2005
@@ -267,7 +267,7 @@
 #endif /* CONFIG_COLOR_TEXT */
 
 
-void print_message_file(char *filename)
+void print_message_file(char *filename, int paging)
 {
      char *msg = NULL; 
      char *p, *endp;
@@ -301,19 +301,50 @@
 	  prom_printf("%s:%d,", msgfile.dev, msgfile.part);
 	  prom_perror(result, msgfile.file);
 	  goto done;
-     } else
-	  opened = 1;
+     }
+     gunzip_file = file;
+     gunzip_test_header();
+     opened = 1;
 
-     msg = malloc(2001);
+     msg = malloc(2001 - paging * 1000); /* 2000 for not paged messages, 1000 for paged*/
      if (!msg)
 	  goto done;
      else
-	  memset(msg, 0, 2001);
+	  memset(msg, 0, (2001 - paging * 1000));
 
-     if (file.fs->read(&file, 2000, msg) <= 0)
+     if ( ( compressed_file ?
+            gunzip_read(msg, (2000 - paging * 1000)) :
+            file.fs->read(&file, (2000 - paging * 1000), msg) 
+          ) <= 0)
 	  goto done;
-     else
-	  prom_printf("%s", msg);
+     
+     if ( paging && (*(msg + 999) != 0) ) {
+	     // file longer than 1000 and paging is 1
+	     char *last_nl;
+	     int len = 0;
+
+	     while ( *(msg + 999) != 0 ) {
+		     last_nl = strrchr(msg, '\n');
+		     *last_nl = 0;
+		     
+		     prom_printf("\r             \r%s\n[Press a key]", msg);
+		     len += last_nl - msg + 1;
+		     
+		     memset(msg, 0, 1001);
+		     if ( compressed_file ) {
+			     gunzip_seek(len);
+			     gunzip_read(msg, 1000);
+		     } else {
+			     file.fs->seek(&file, len);
+			     file.fs->read(&file, 1000, msg);
+		     }
+
+		     // wait until key
+		     while ( prom_nbgetchar() == -1 );
+	     }
+	     prom_printf("\r             \r%s", msg);
+     } else
+	     prom_printf("%s", msg);
 
 done:
      if (opened)
@@ -429,7 +460,7 @@
 
      p = cfg_get_strg(0, "message");
      if (p)
-	  print_message_file(p);
+	  print_message_file(p, 0);
 
      result = 1;
     
@@ -715,7 +746,15 @@
 			 check_password ("This image is restricted.");
 	       }
 	       params->args = make_params(label, params->args);
-	  }
+	  } else {  // no *p
+		  p = cfg_get_strg(imagename, "text");
+		  if (p && *p) {
+			  if(!defdevice) defdevice = boot.dev;
+			  prom_printf("\n");
+			  print_message_file(p, 1);
+			  return 0;
+		  }
+	  }	  
      }
 
      if (!strcmp (imagename, "help")) {



More information about the pld-cvs-commit mailing list