f_setup.story_file = strdup(argv[zoptind]);
f_setup.story_name = strdup(basename(argv[zoptind]));
+ if (argv[optind+1] != NULL)
+ f_setup.blorb_file = strdup(argv[optind+1]);
+
+ if (argv[zoptind+1] != NULL)
+ f_setup.blorb_file = strdup(argv[zoptind+1]);
+
/* Now strip off the extension */
p = strrchr(f_setup.story_name, '.');
if ( p != NULL )
*/
if (isblorb(fp)) { /* Now we know to look */
f_setup.exec_in_blorb = 1; /* for zcode in the blorb */
- blorb_fp = fopen(filename, "rb");
+ blorb_fp = fp;
} else {
- len1 = strlen(filename) + strlen(EXT_BLORB);
- len2 = strlen(filename) + strlen(EXT_BLORB3);
-
- mystring = malloc(len2 * sizeof(char) + 1);
- strncpy(mystring, filename, len1 * sizeof(char));
- p = strrchr(mystring, '.');
- if (p != NULL)
- *p = '\0';
-
- strncat(mystring, EXT_BLORB, len1 * sizeof(char));
-
- /* Done monkeying with the initial file. */
fclose(fp);
- fp = NULL;
+ if (f_setup.blorb_file != NULL)
+ mystring = strdup(f_setup.blorb_file);
+ else {
+ len1 = strlen(filename) + strlen(EXT_BLORB);
+ len2 = strlen(filename) + strlen(EXT_BLORB3);
+ mystring = malloc(len2 * sizeof(char) + 1);
+ strncpy(mystring, filename, len1 * sizeof(char));
+ p = strrchr(mystring, '.');
+ if (p != NULL) *p = '\0';
+ strncat(mystring, EXT_BLORB, len1 * sizeof(char));
+ }
/* Check if foo.blb is there. */
- if (f_setup.blorb_file != NULL)
+ if ((fp = fopen(mystring, "rb")) == NULL) {
- p = strrchr(mystring, '.');
+ mystring = strdup(f_setup.blorb_file);
+ else {
- if ((blorb_fp = fopen(mystring, "rb")) == NULL) {
+ p = strrchr(mystring, '.');
- if (p != NULL)
- *p = '\0';
- strncat(mystring, EXT_BLORB3, len2 * sizeof(char));
- blorb_fp = fopen(mystring, "rb");
+ if (p != NULL) *p = '\0';
+ strncat(mystring, EXT_BLORB3, len2 * sizeof(char));
+ }
- }
- if (blorb_fp == NULL || !isblorb(fp)) /* No matching blorbs found. */
+ if (!(fp = fopen(mystring, "rb")))
+ return bb_err_NoBlorb;
+ }
+ if (!isblorb(fp)) {
+ fclose(fp);
return bb_err_NoBlorb;
-
+ }
/* At this point we know that we're using a naked zcode file */
/* with resources in a separate Blorb file. */
+ blorb_fp = fp;
f_setup.use_blorb = 1;
}
f_setup.story_file = strdup(argv[zoptind]);
f_setup.story_name = strdup(basename(argv[zoptind]));
+ if (argv[optind+1] != NULL)
+ f_setup.blorb_file = strdup(argv[optind+1]);
+
+ if (argv[zoptind+1] != NULL)
+ f_setup.blorb_file = strdup(argv[zoptind+1]);
+
/* Now strip off the extension */
p = strrchr(f_setup.story_name, '.');
if ( p != NULL )