wok-6.x diff syslinux/stuff/extra/md5sum.c @ rev 20073
syslinux: shrink i18n.cfg
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Sun Sep 24 19:06:48 2017 +0200 (2017-09-24) |
parents | 0253b140a342 |
children | f063a9bbc7f4 |
line diff
1.1 --- a/syslinux/stuff/extra/md5sum.c Fri Sep 22 15:56:58 2017 +0200 1.2 +++ b/syslinux/stuff/extra/md5sum.c Sun Sep 24 19:06:48 2017 +0200 1.3 @@ -506,7 +506,7 @@ 1.4 int i; 1.5 1.6 for (i = 1; i < argc; i++) { 1.7 - if (!strcmp(argv[i], "-w") || !strcmp(argv[i], "--warm")) 1.8 + if (strstr(argv[i], "-w")) 1.9 warm = 1; 1.10 } 1.11 1.12 @@ -590,22 +590,40 @@ 1.13 { 1.14 const struct syslinux_keyboard_map *const kmap = syslinux_keyboard_map(); 1.15 size_t map_size, size, i; 1.16 - char *kbdmap, *msg; 1.17 + char *kbdmap, *msg, *kbdfile, *kbdname; 1.18 + int skip = 3; 1.19 1.20 if (argc < 3) 1.21 - usage("Usage: kbdmap archive.cpio mapfile [cmdline].."); 1.22 + usage("Usage: kbdmap [archive.cpio] [mapfile] [cmdline].."); 1.23 + 1.24 + if (loadfile(kbdfile = argv[1], (void **) &kbdmap, &map_size)) { 1.25 + kbdfile = "kbd"; 1.26 + skip--; 1.27 + } 1.28 + else { 1.29 + free(kbdmap); 1.30 + } 1.31 + 1.32 + if (strchr(kbdname = argv[skip-1],'=')) { 1.33 + for (i = --skip; argv[i]; i++) { 1.34 + if (!strncmp(argv[i], "kmap=", 5)) { 1.35 + kbdname = argv[i] + 5; 1.36 + break; 1.37 + } 1.38 + } 1.39 + } 1.40 1.41 // Save extra cmdline arguments 1.42 - setlinuxarg(1, argc - 3, argv + 3); 1.43 + setlinuxarg(1, argc - skip, argv + skip); 1.44 1.45 msg="Append to kernel parameters: "; 1.46 - for (i = 3; i < (size_t) argc; i++, msg = " ") 1.47 + for (i = skip; i < (size_t) argc; i++, msg = " ") 1.48 printf("%s%s",msg,argv[i]); 1.49 printf("\n\n Hit RETURN to continue.\n"); 1.50 1.51 msg = "Load error"; 1.52 if (kmap->version != 1 || 1.53 - loadfile(argv[1], (void **) &kbdmap, &map_size)) 1.54 + loadfile(kbdfile, (void **) &kbdmap, &map_size)) 1.55 goto kbdmap_error; 1.56 if (* (short *) kbdmap == 0x005D) { 1.57 void *p = malloc(map_size = * (long *) (kbdmap + 5)); 1.58 @@ -635,7 +653,7 @@ 1.59 len = 1 + strlen(name); 1.60 i += len; 1.61 i += ((-i)&3); 1.62 - if (!strcmp(name, argv[2])) { 1.63 + if (!strcmp(name, kbdname)) { 1.64 kbdmap += i; 1.65 break; 1.66 } 1.67 @@ -729,6 +747,9 @@ 1.68 } 1.69 1.70 /* Search for a boolean argument; return its position, or 0 if not present */ 1.71 +#if 1 1.72 +#define find_boolean(a,b) (find_argument(a,b) != NULL) 1.73 +#else 1.74 static int find_boolean(char **argv, const char *argument) 1.75 { 1.76 char **arg; 1.77 @@ -740,6 +761,7 @@ 1.78 1.79 return 0; 1.80 } 1.81 +#endif 1.82 1.83 static int got_config; 1.84 static char *custom_cmdline = ""; 1.85 @@ -754,12 +776,13 @@ 1.86 1.87 if (got_config) 1.88 goto done; 1.89 + got_config = -1; 1.90 sdi = syslinux_derivative_info(); 1.91 if (sdi->c.filesystem != SYSLINUX_FS_ISOLINUX) 1.92 goto fail; 1.93 disk_get_params(sdi->iso.drive_number, &diskinfo); 1.94 custom_buffer = disk_read_sectors(&diskinfo, 32768 / diskinfo.bps, 1); 1.95 - got_config = (16 + *(unsigned long *) (custom_buffer + 80)) 1.96 + got_config = (*(unsigned long *) (custom_buffer + 80)) 1.97 * 2048 / diskinfo.bps; 1.98 free(custom_buffer); 1.99 custom_buffer = disk_read_sectors(&diskinfo, got_config, 1); 1.100 @@ -775,10 +798,8 @@ 1.101 custom_initrdlen = strtoul(p + 7, &custom_initrdbase, 10); 1.102 custom_initrdbase += (got_config << 11) + 1 - (int) custom_buffer; 1.103 } 1.104 - return 1; 1.105 } 1.106 fail: 1.107 - got_config = -1; 1.108 done: 1.109 return got_config > 0; 1.110 } 1.111 @@ -788,7 +809,7 @@ 1.112 int n, len; 1.113 char *p; 1.114 1.115 - p = *data = malloc(len = custom_initrdlen); 1.116 + p = *data = malloc(custom_initrdlen); 1.117 if (!p) return 0; 1.118 for (len = custom_initrdlen; len != 0; len -= n, p += n) { 1.119 free(custom_buffer); 1.120 @@ -826,10 +847,10 @@ 1.121 return NULL; 1.122 1.123 for (arg = argv; *arg; arg++) { 1.124 - int len = strlen(*arg); 1.125 - memcpy(p, *arg, len); 1.126 - p[len] = ' '; 1.127 - p += len + 1; 1.128 + size = strlen(*arg); 1.129 + memcpy(p, *arg, size); 1.130 + p[size] = ' '; 1.131 + p += size + 1; 1.132 } 1.133 1.134 for (i = 0; i < 255; i++) { 1.135 @@ -947,6 +968,7 @@ 1.136 const char *initrd_name; 1.137 struct initramfs *initramfs; 1.138 struct setup_data *setup_data; 1.139 + char *errmsg; 1.140 char *cmdline; 1.141 char *boot_image; 1.142 void *kernel_data; 1.143 @@ -960,20 +982,20 @@ 1.144 openconsole(&dev_null_r, &dev_stdcon_w); 1.145 1.146 (void)argc; 1.147 - argp = argv + 1; 1.148 1.149 - while ((arg = *argp) && arg[0] == '-') { 1.150 + for (argp = argv + 1; (arg = *argp) && arg[0] == '-'; argp++) { 1.151 if (!strcmp("-dhcpinfo", arg)) { 1.152 opt_dhcpinfo = true; 1.153 } else { 1.154 - fprintf(stderr, "%s: unknown option: %s\n", progname, arg); 1.155 - return 1; 1.156 + errmsg = "%s: unknown option: %s\n"; 1.157 + goto unknown_option; 1.158 } 1.159 - argp++; 1.160 } 1.161 1.162 if (!arg) { 1.163 - fprintf(stderr, "%s: missing kernel name\n", progname); 1.164 + errmsg = "%s: missing kernel name\n"; 1.165 +unknown_option: 1.166 + fprintf(stderr, errmsg, progname, arg); 1.167 return 1; 1.168 } 1.169 1.170 @@ -982,8 +1004,8 @@ 1.171 errno = 0; 1.172 boot_image = malloc(strlen(kernel_name) + 12); 1.173 if (!boot_image) { 1.174 - fprintf(stderr, "Error allocating BOOT_IMAGE string: "); 1.175 - goto bail; 1.176 + errmsg = "Error allocating BOOT_IMAGE string: "; 1.177 + goto bailmsg; 1.178 } 1.179 strcpy(boot_image, "BOOT_IMAGE="); 1.180 strcpy(boot_image + 11, kernel_name); 1.181 @@ -1010,20 +1032,20 @@ 1.182 errno = 0; 1.183 cmdline = make_cmdline(argp); 1.184 if (!cmdline) { 1.185 - fprintf(stderr, "make_cmdline() failed: "); 1.186 - goto bail; 1.187 + errmsg = "make_cmdline() failed: "; 1.188 + goto bailmsg; 1.189 } 1.190 1.191 /* Initialize the initramfs chain */ 1.192 errno = 0; 1.193 initramfs = initramfs_init(); 1.194 if (!initramfs) { 1.195 - fprintf(stderr, "initramfs_init() failed: "); 1.196 - goto bail; 1.197 + errmsg = "initramfs_init() failed: "; 1.198 + goto bailmsg; 1.199 } 1.200 1.201 if ((arg = find_argument(argp, "initrd="))) { 1.202 - do { 1.203 + while (1) { 1.204 p = strchr(arg, ','); 1.205 if (p) 1.206 *p = '\0'; 1.207 @@ -1041,9 +1063,12 @@ 1.208 if (!opt_quiet) 1.209 printf("ok\n"); 1.210 1.211 - if (p) 1.212 - *p++ = ','; 1.213 - } while ((arg = p)); 1.214 + if (!p) 1.215 + break; 1.216 + 1.217 + *p++ = ','; 1.218 + arg = p; 1.219 + } 1.220 } 1.221 1.222 /* Append the DHCP info */ 1.223 @@ -1052,8 +1077,8 @@ 1.224 errno = 0; 1.225 if (initramfs_add_file(initramfs, dhcpdata, dhcplen, dhcplen, 1.226 "/dhcpinfo.dat", 0, 0755)) { 1.227 - fprintf(stderr, "Unable to add DHCP info: "); 1.228 - goto bail; 1.229 + errmsg = "Unable to add DHCP info: "; 1.230 + goto bailmsg; 1.231 } 1.232 } 1.233 1.234 @@ -1080,10 +1105,7 @@ 1.235 char *ep; 1.236 1.237 type = strtoul(arg + 5, &ep, 10); 1.238 - if (ep[0] != '=' || !ep[1]) 1.239 - continue; 1.240 - 1.241 - if (!type) 1.242 + if (!type || ep[0] != '=' || !ep[1]) 1.243 continue; 1.244 1.245 if (setup_data_file(setup_data, type, ep+1, opt_quiet)) 1.246 @@ -1095,24 +1117,24 @@ 1.247 errno = 0; 1.248 syslinux_boot_linux(kernel_data, kernel_len, initramfs, 1.249 setup_data, cmdline); 1.250 - fprintf(stderr, "syslinux_boot_linux() failed: "); 1.251 + errmsg = "syslinux_boot_linux() failed: "; 1.252 1.253 +bailmsg: 1.254 + fprintf(stderr, errmsg); 1.255 bail: 1.256 + errmsg = "Error %d"; 1.257 switch(errno) { 1.258 case ENOENT: 1.259 - fprintf(stderr, "File not found\n"); 1.260 + errmsg = "File not found"; 1.261 break; 1.262 case ENOMEM: 1.263 - fprintf(stderr, "Out of memory\n"); 1.264 - break; 1.265 - default: 1.266 - fprintf(stderr, "Error %d\n", errno); 1.267 - break; 1.268 + errmsg = "Out of memory"; 1.269 } 1.270 - fprintf(stderr, "%luM RAM found on this %s bits machine.\n", 1.271 + fprintf(stderr, errmsg, errno); 1.272 + fprintf(stderr, "\n%luM RAM and %s bit cpu found.\n%s: Boot aborted!\n", 1.273 memory_size() >> 10, 1.274 - cpu_has_feature(X86_FEATURE_LM) ? "64": "32"); 1.275 - fprintf(stderr, "%s: Boot aborted!\n", progname); 1.276 + cpu_has_feature(X86_FEATURE_LM) ? "64": "32", 1.277 + progname); 1.278 return 1; 1.279 } 1.280 1.281 @@ -1210,6 +1232,7 @@ 1.282 { "listarg", main_listarg }, 1.283 #endif 1.284 { "kbdmap", main_kbdmap }, 1.285 + { "kbd", main_kbdmap }, 1.286 { "ifmem", main_ifmem }, 1.287 { "linux", main_linux }, 1.288 { "md5sum", main_md5sum },