/* Parse ARG and return the textual representation. Add strings are concatenated and all values of the variables are filled in. */ char * grub_script_execute_argument_to_string (struct grub_script_arg *arg) { int size = 0; char *val; char *chararg; struct grub_script_arg *argi; /* First determine the size of the argument. */ for (argi = arg; argi; argi = argi->next) { if (argi->type == 1) { val = grub_env_get (argi->str); if (val) size += grub_strlen (val); } else size += grub_strlen (argi->str); } /* Create the argument. */ chararg = grub_malloc (size + 1); if (! chararg) return 0; *chararg = '\0'; /* First determine the size of the argument. */ for (argi = arg; argi; argi = argi->next) { if (argi->type == 1) { val = grub_env_get (argi->str); if (val) grub_strcat (chararg, val); } else grub_strcat (chararg, argi->str); } return chararg; }
/* Try to load an icon for the specified CLASS_NAME in the directory DIR. Returns 0 if the icon could not be loaded, or returns a pointer to a new bitmap if it was successful. */ static struct grub_video_bitmap * try_loading_icon (grub_gfxmenu_icon_manager_t mgr, const char *dir, const char *class_name) { char *path; int l; path = grub_malloc (grub_strlen (dir) + grub_strlen (class_name) + grub_strlen (icon_extension) + 3); if (! path) return 0; grub_strcpy (path, dir); l = grub_strlen (path); if (path[l-1] != '/') { path[l] = '/'; path[l+1] = 0; } grub_strcat (path, class_name); grub_strcat (path, icon_extension); struct grub_video_bitmap *raw_bitmap; grub_video_bitmap_load (&raw_bitmap, path); grub_free (path); grub_errno = GRUB_ERR_NONE; /* Critical to clear the error!! */ if (! raw_bitmap) return 0; struct grub_video_bitmap *scaled_bitmap; grub_video_bitmap_create_scaled (&scaled_bitmap, mgr->icon_width, mgr->icon_height, raw_bitmap, GRUB_VIDEO_BITMAP_SCALE_METHOD_BEST); grub_video_bitmap_destroy (raw_bitmap); if (! scaled_bitmap) return 0; return scaled_bitmap; }