Improve gettext support. Stylistic fixes and error handling fixes while
on it.
This commit is contained in:
		
							parent
							
								
									215c90cb82
								
							
						
					
					
						commit
						9c4b5c13e6
					
				
					 184 changed files with 1175 additions and 959 deletions
				
			
		|  | @ -221,17 +221,17 @@ grub_xnu_writetree_toheap (grub_addr_t *target, grub_size_t *size) | |||
| 
 | ||||
|   driverkey = (struct grub_xnu_devtree_key *) grub_malloc (sizeof (*driverkey)); | ||||
|   if (! driverkey) | ||||
|     return grub_error (GRUB_ERR_OUT_OF_MEMORY, "can't write device tree"); | ||||
|     return grub_errno; | ||||
|   driverkey->name = grub_strdup ("DeviceTree"); | ||||
|   if (! driverkey->name) | ||||
|     return grub_error (GRUB_ERR_OUT_OF_MEMORY, "can't write device tree"); | ||||
|     return grub_errno; | ||||
|   driverkey->datasize = sizeof (*extdesc); | ||||
|   driverkey->next = memorymap->first_child; | ||||
|   memorymap->first_child = driverkey; | ||||
|   driverkey->data = extdesc | ||||
|     = (struct grub_xnu_extdesc *) grub_malloc (sizeof (*extdesc)); | ||||
|   if (! driverkey->data) | ||||
|     return grub_error (GRUB_ERR_OUT_OF_MEMORY, "can't write device tree"); | ||||
|     return grub_errno; | ||||
| 
 | ||||
|   /* Allocate the space based on the size with dummy value. */ | ||||
|   *size = grub_xnu_writetree_get_size (grub_xnu_devtree_root, "/"); | ||||
|  | @ -269,15 +269,11 @@ grub_xnu_create_key (struct grub_xnu_devtree_key **parent, const char *name) | |||
|     return ret; | ||||
|   ret = (struct grub_xnu_devtree_key *) grub_zalloc (sizeof (*ret)); | ||||
|   if (! ret) | ||||
|     { | ||||
|       grub_error (GRUB_ERR_OUT_OF_MEMORY, "can't create key %s", name); | ||||
|       return 0; | ||||
|     } | ||||
|     return 0; | ||||
|   ret->name = grub_strdup (name); | ||||
|   if (! ret->name) | ||||
|     { | ||||
|       grub_free (ret); | ||||
|       grub_error (GRUB_ERR_OUT_OF_MEMORY, "can't create key %s", name); | ||||
|       return 0; | ||||
|     } | ||||
|   ret->datasize = -1; | ||||
|  | @ -303,15 +299,11 @@ grub_xnu_create_value (struct grub_xnu_devtree_key **parent, const char *name) | |||
|     } | ||||
|   ret = (struct grub_xnu_devtree_key *) grub_zalloc (sizeof (*ret)); | ||||
|   if (! ret) | ||||
|     { | ||||
|       grub_error (GRUB_ERR_OUT_OF_MEMORY, "can't create value %s", name); | ||||
|       return 0; | ||||
|     } | ||||
|     return 0; | ||||
|   ret->name = grub_strdup (name); | ||||
|   if (! ret->name) | ||||
|     { | ||||
|       grub_free (ret); | ||||
|       grub_error (GRUB_ERR_OUT_OF_MEMORY, "can't create value %s", name); | ||||
|       return 0; | ||||
|     } | ||||
|   ret->next = *parent; | ||||
|  | @ -351,7 +343,7 @@ grub_cmd_xnu_kernel (grub_command_t cmd __attribute__ ((unused)), | |||
|   grub_addr_t loadaddr_target; | ||||
| 
 | ||||
|   if (argc < 1) | ||||
|     return grub_error (GRUB_ERR_BAD_ARGUMENT, "file name required"); | ||||
|     return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected")); | ||||
| 
 | ||||
|   grub_xnu_unload (); | ||||
| 
 | ||||
|  | @ -391,7 +383,7 @@ grub_cmd_xnu_kernel (grub_command_t cmd __attribute__ ((unused)), | |||
|     } | ||||
| 
 | ||||
|   /* Load kernel. */ | ||||
|   err = grub_macho_load32 (macho, (char *) loadaddr - startcode, | ||||
|   err = grub_macho_load32 (macho, args[0], (char *) loadaddr - startcode, | ||||
| 			   GRUB_MACHO_NOBSS); | ||||
|   if (err) | ||||
|     { | ||||
|  | @ -461,7 +453,7 @@ grub_cmd_xnu_kernel64 (grub_command_t cmd __attribute__ ((unused)), | |||
|   grub_addr_t loadaddr_target; | ||||
| 
 | ||||
|   if (argc < 1) | ||||
|     return grub_error (GRUB_ERR_BAD_ARGUMENT, "file name required"); | ||||
|     return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected")); | ||||
| 
 | ||||
|   grub_xnu_unload (); | ||||
| 
 | ||||
|  | @ -504,7 +496,7 @@ grub_cmd_xnu_kernel64 (grub_command_t cmd __attribute__ ((unused)), | |||
|     } | ||||
| 
 | ||||
|   /* Load kernel. */ | ||||
|   err = grub_macho_load64 (macho, (char *) loadaddr - startcode, | ||||
|   err = grub_macho_load64 (macho, args[0], (char *) loadaddr - startcode, | ||||
| 			   GRUB_MACHO_NOBSS); | ||||
|   if (err) | ||||
|     { | ||||
|  | @ -573,7 +565,7 @@ grub_xnu_register_memory (const char *prefix, int *suffix, | |||
|   struct grub_xnu_extdesc *extdesc; | ||||
| 
 | ||||
|   if (! grub_xnu_heap_size) | ||||
|     return grub_error (GRUB_ERR_BAD_OS, "no xnu kernel loaded"); | ||||
|     return grub_error (GRUB_ERR_BAD_OS, N_("you need to load the kernel first")); | ||||
| 
 | ||||
|   chosen = grub_xnu_create_key (&grub_xnu_devtree_root, "chosen"); | ||||
|   if (! chosen) | ||||
|  | @ -584,24 +576,27 @@ grub_xnu_register_memory (const char *prefix, int *suffix, | |||
| 
 | ||||
|   driverkey = (struct grub_xnu_devtree_key *) grub_malloc (sizeof (*driverkey)); | ||||
|   if (! driverkey) | ||||
|     return grub_error (GRUB_ERR_OUT_OF_MEMORY, "can't register memory"); | ||||
|     return grub_errno; | ||||
|   if (suffix) | ||||
|     { | ||||
|       driverkey->name = grub_xasprintf ("%s%d", prefix, (*suffix)++); | ||||
|       if (!driverkey->name) | ||||
| 	return grub_error (GRUB_ERR_OUT_OF_MEMORY, "can't register memory"); | ||||
|     } | ||||
|     driverkey->name = grub_xasprintf ("%s%d", prefix, (*suffix)++); | ||||
|   else | ||||
|     driverkey->name = grub_strdup (prefix); | ||||
|   if (! driverkey->name) | ||||
|     return grub_error (GRUB_ERR_OUT_OF_MEMORY, "can't register extension"); | ||||
|   if (!driverkey->name) | ||||
|     { | ||||
|       grub_free (driverkey); | ||||
|       return grub_errno; | ||||
|     } | ||||
|   driverkey->datasize = sizeof (*extdesc); | ||||
|   driverkey->next = memorymap->first_child; | ||||
|   memorymap->first_child = driverkey; | ||||
|   driverkey->data = extdesc | ||||
|     = (struct grub_xnu_extdesc *) grub_malloc (sizeof (*extdesc)); | ||||
|   if (! driverkey->data) | ||||
|     return grub_error (GRUB_ERR_OUT_OF_MEMORY, "can't register extension"); | ||||
|     { | ||||
|       grub_free (driverkey->name); | ||||
|       grub_free (driverkey); | ||||
|       return grub_errno; | ||||
|     } | ||||
|   memorymap->first_child = driverkey; | ||||
|   extdesc->addr = addr; | ||||
|   extdesc->size = (grub_uint32_t) size; | ||||
|   return GRUB_ERR_NONE; | ||||
|  | @ -637,7 +632,8 @@ get_name_ptr (char *name) | |||
| 
 | ||||
| /* Load .kext. */ | ||||
| static grub_err_t | ||||
| grub_xnu_load_driver (char *infoplistname, grub_file_t binaryfile) | ||||
| grub_xnu_load_driver (char *infoplistname, grub_file_t binaryfile, | ||||
| 		      const char *filename) | ||||
| { | ||||
|   grub_macho_t macho; | ||||
|   grub_err_t err; | ||||
|  | @ -662,12 +658,12 @@ grub_xnu_load_driver (char *infoplistname, grub_file_t binaryfile) | |||
|   neededspace += namelen + 1; | ||||
| 
 | ||||
|   if (! grub_xnu_heap_size) | ||||
|     return grub_error (GRUB_ERR_BAD_OS, "no xnu kernel loaded"); | ||||
|     return grub_error (GRUB_ERR_BAD_OS, N_("you need to load the kernel first")); | ||||
| 
 | ||||
|   /* Compute the needed space. */ | ||||
|   if (binaryfile) | ||||
|     { | ||||
|       macho = grub_macho_file (binaryfile); | ||||
|       macho = grub_macho_file (binaryfile, filename); | ||||
|       if (! macho || ! grub_macho_contains_macho32 (macho)) | ||||
| 	{ | ||||
| 	  if (macho) | ||||
|  | @ -716,9 +712,9 @@ grub_xnu_load_driver (char *infoplistname, grub_file_t binaryfile) | |||
|       exthead->binaryaddr = buf_target + (buf - (grub_uint8_t *) buf0); | ||||
|       exthead->binarysize = machosize; | ||||
|       if (grub_xnu_is_64bit) | ||||
| 	err = grub_macho_readfile64 (macho, buf); | ||||
| 	err = grub_macho_readfile64 (macho, filename, buf); | ||||
|       else | ||||
| 	err = grub_macho_readfile32 (macho, buf); | ||||
| 	err = grub_macho_readfile32 (macho, filename, buf); | ||||
|       if (err) | ||||
| 	{ | ||||
| 	  grub_macho_close (macho); | ||||
|  | @ -776,10 +772,10 @@ grub_cmd_xnu_mkext (grub_command_t cmd __attribute__ ((unused)), | |||
|   int narchs, i; | ||||
| 
 | ||||
|   if (argc != 1) | ||||
|     return grub_error (GRUB_ERR_BAD_ARGUMENT, "file name required"); | ||||
|     return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected")); | ||||
| 
 | ||||
|   if (! grub_xnu_heap_size) | ||||
|     return grub_error (GRUB_ERR_BAD_OS, "no xnu kernel loaded"); | ||||
|     return grub_error (GRUB_ERR_BAD_OS, N_("you need to load the kernel first")); | ||||
| 
 | ||||
|   file = grub_file_open (args[0]); | ||||
|   if (! file) | ||||
|  | @ -890,10 +886,10 @@ grub_cmd_xnu_ramdisk (grub_command_t cmd __attribute__ ((unused)), | |||
|   grub_size_t size; | ||||
| 
 | ||||
|   if (argc != 1) | ||||
|     return grub_error (GRUB_ERR_BAD_ARGUMENT, "file name required"); | ||||
|     return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected")); | ||||
| 
 | ||||
|   if (! grub_xnu_heap_size) | ||||
|     return grub_error (GRUB_ERR_BAD_OS, "no xnu kernel loaded"); | ||||
|     return grub_error (GRUB_ERR_BAD_OS, N_("you need to load the kernel first")); | ||||
| 
 | ||||
|   file = grub_file_open (args[0]); | ||||
|   if (! file) | ||||
|  | @ -1072,7 +1068,7 @@ grub_xnu_scan_dir_for_kexts (char *dirname, const char *osbundlerequired, | |||
|   } | ||||
| 
 | ||||
|   if (! grub_xnu_heap_size) | ||||
|     return grub_error (GRUB_ERR_BAD_OS, "no xnu kernel loaded"); | ||||
|     return grub_error (GRUB_ERR_BAD_OS, N_("you need to load the kernel first")); | ||||
| 
 | ||||
|   device_name = grub_file_get_device_name (dirname); | ||||
|   dev = grub_device_open (device_name); | ||||
|  | @ -1190,14 +1186,15 @@ grub_xnu_load_kext_from_dir (char *dirname, const char *osbundlerequired, | |||
| 		grub_errno = GRUB_ERR_NONE; | ||||
| 
 | ||||
| 	      /* Load the extension. */ | ||||
| 	      grub_xnu_load_driver (plistname, binfile); | ||||
| 	      grub_xnu_load_driver (plistname, binfile, | ||||
| 				    binname); | ||||
| 	      grub_free (binname); | ||||
| 	      grub_free (binsuffix); | ||||
| 	    } | ||||
| 	  else | ||||
| 	    { | ||||
| 	      grub_dprintf ("xnu", "%s:0\n", plistname); | ||||
| 	      grub_xnu_load_driver (plistname, 0); | ||||
| 	      grub_xnu_load_driver (plistname, 0, 0); | ||||
| 	    } | ||||
| 	} | ||||
|       grub_free (plistname); | ||||
|  | @ -1220,7 +1217,7 @@ grub_cmd_xnu_kext (grub_command_t cmd __attribute__ ((unused)), | |||
|   grub_file_t binfile = 0; | ||||
| 
 | ||||
|   if (! grub_xnu_heap_size) | ||||
|     return grub_error (GRUB_ERR_BAD_OS, "no xnu kernel loaded"); | ||||
|     return grub_error (GRUB_ERR_BAD_OS, N_("you need to load the kernel first")); | ||||
| 
 | ||||
|   if (argc == 2) | ||||
|     { | ||||
|  | @ -1229,20 +1226,17 @@ grub_cmd_xnu_kext (grub_command_t cmd __attribute__ ((unused)), | |||
| 	{ | ||||
| 	  binfile = grub_file_open (args[1]); | ||||
| 	  if (! binfile) | ||||
| 	    { | ||||
| 	      grub_error (GRUB_ERR_BAD_OS, "can't open file"); | ||||
| 	      return GRUB_ERR_NONE; | ||||
| 	    } | ||||
| 	    return grub_errno; | ||||
| 	} | ||||
|       return grub_xnu_load_driver (grub_strcmp (args[0], "-") ? args[0] : 0, | ||||
| 				   binfile); | ||||
| 				   binfile, args[1]); | ||||
|     } | ||||
| 
 | ||||
|   /* load kext normally. */ | ||||
|   if (argc == 1) | ||||
|     return grub_xnu_load_kext_from_dir (args[0], 0, 10); | ||||
| 
 | ||||
|   return grub_error (GRUB_ERR_BAD_ARGUMENT, "file name required"); | ||||
|   return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected")); | ||||
| } | ||||
| 
 | ||||
| /* Load a directory containing kexts. */ | ||||
|  | @ -1254,7 +1248,7 @@ grub_cmd_xnu_kextdir (grub_command_t cmd __attribute__ ((unused)), | |||
|     return grub_error (GRUB_ERR_BAD_ARGUMENT, "directory name required"); | ||||
| 
 | ||||
|   if (! grub_xnu_heap_size) | ||||
|     return grub_error (GRUB_ERR_BAD_OS, "no xnu kernel loaded"); | ||||
|     return grub_error (GRUB_ERR_BAD_OS, N_("you need to load the kernel first")); | ||||
| 
 | ||||
|   if (argc == 1) | ||||
|     return grub_xnu_scan_dir_for_kexts (args[0], | ||||
|  | @ -1394,10 +1388,10 @@ grub_cmd_xnu_splash (grub_extcmd_context_t ctxt, | |||
| { | ||||
|   grub_err_t err; | ||||
|   if (argc != 1) | ||||
|     return grub_error (GRUB_ERR_BAD_ARGUMENT, "file name required"); | ||||
|     return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected")); | ||||
| 
 | ||||
|   if (! grub_xnu_heap_size) | ||||
|     return grub_error (GRUB_ERR_BAD_OS, "no xnu kernel loaded"); | ||||
|     return grub_error (GRUB_ERR_BAD_OS, N_("you need to load the kernel first")); | ||||
| 
 | ||||
|   if (ctxt->state[XNU_SPLASH_CMD_ARGINDEX_MODE].set && | ||||
|       grub_strcmp (ctxt->state[XNU_SPLASH_CMD_ARGINDEX_MODE].arg, | ||||
|  | @ -1420,7 +1414,7 @@ grub_cmd_xnu_resume (grub_command_t cmd __attribute__ ((unused)), | |||
| 		     int argc, char *args[]) | ||||
| { | ||||
|   if (argc != 1) | ||||
|     return grub_error (GRUB_ERR_BAD_ARGUMENT, "file name required"); | ||||
|     return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected")); | ||||
| 
 | ||||
|   return grub_xnu_resume (args[0]); | ||||
| } | ||||
|  | @ -1457,11 +1451,16 @@ GRUB_MOD_INIT(xnu) | |||
|   cmd_kext = grub_register_command ("xnu_kext", grub_cmd_xnu_kext, 0, | ||||
| 				    N_("Load XNU extension.")); | ||||
|   cmd_kextdir = grub_register_command ("xnu_kextdir", grub_cmd_xnu_kextdir, | ||||
| 				       /* TRANSLATORS: OSBundleRequired is a
 | ||||
| 					  variable name in xnu extensions | ||||
| 					  manifests. It behaves mostly like | ||||
| 					  GNU/Linux runlevels. | ||||
| 				       */ | ||||
| 				       N_("DIRECTORY [OSBundleRequired]"), | ||||
| 				       N_("Load XNU extension directory.")); | ||||
|   cmd_ramdisk = grub_register_command ("xnu_ramdisk", grub_cmd_xnu_ramdisk, 0, | ||||
| 				       N_("Load XNU ramdisk. " | ||||
| 					  "It will be seen as md0.")); | ||||
| 					  "It will be available in OS as md0.")); | ||||
|   cmd_splash = grub_register_extcmd ("xnu_splash", | ||||
| 				     grub_cmd_xnu_splash, 0, 0, | ||||
| 				     N_("Load a splash image for XNU."), | ||||
|  | @ -1469,7 +1468,8 @@ GRUB_MOD_INIT(xnu) | |||
| 
 | ||||
| #ifndef GRUB_MACHINE_EMU | ||||
|   cmd_resume = grub_register_command ("xnu_resume", grub_cmd_xnu_resume, | ||||
| 				      0, N_("Load XNU hibernate image.")); | ||||
| 				      0, N_("Load an image of hibernated" | ||||
| 					    " XNU image.")); | ||||
| #endif | ||||
| 
 | ||||
|   grub_cpu_xnu_init (); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue