X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?p=rmac;a=blobdiff_plain;f=direct.c;h=53d7c6ae48aeab8126bc826e24abda4edaf3c3e6;hp=9070a4165ea8d88e64978f3c10b360141ab3fdf5;hb=d6e84696385fe3dd07665c50b2285659cfce9b22;hpb=07781922aefc9551dfb3c9f3e957962dcaef92ff diff --git a/direct.c b/direct.c index 9070a41..53d7c6a 100644 --- a/direct.c +++ b/direct.c @@ -559,7 +559,7 @@ int d_noclear(void) // -// Include binary file +// Include binary file (can add addition size & position params, comma separated) // int d_incbin(void) { @@ -586,6 +586,7 @@ int d_incbin(void) // failed) try list of include files passed in the enviroment string or by // the "-d" option. TOKEN filename = tok[1]; + if ((fd = open(string[filename], _OPEN_INC)) < 0) { for(i=0; nthpath("RMACPATH", i, buf1)!=0; i++) @@ -608,6 +609,7 @@ int d_incbin(void) allright: tok += 2; + if (*tok != EOL) { // Check size parameter (can be omitted) @@ -637,6 +639,7 @@ allright: close(fd); return ERROR; } + lseek(fd, pos, SEEK_SET); size -= pos; } @@ -647,17 +650,18 @@ allright: } } else - return(comma_error); + return error(comma_error); } else pos = lseek(fd, 0L, SEEK_SET); } else { - //size_pos_fallthrough: + // size & pos not given, so assume offset of 0 and all of the binary size = lseek(fd, 0L, SEEK_END); pos = lseek(fd, 0L, SEEK_SET); } + chcheck(size); DEBUG { printf("INCBIN: File '%s' is %li bytes.\n", string[filename], size); }