Changeset 540
- Timestamp:
- Apr 24, 2011, 10:33:34 AM (11 years ago)
- Location:
- abuse/trunk
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
abuse/trunk/.gitignore
r161 r540 16 16 abuse.6 17 17 src/abuse 18 src/abuse-tool -
abuse/trunk/src/Makefile.am
r509 r540 3 3 SUBDIRS = lisp net imlib sdlport 4 4 5 bin_PROGRAMS = abuse 5 bin_PROGRAMS = abuse abuse-tool 6 6 7 7 abuse_SOURCES = \ … … 69 69 abuse_DEPENDENCIES = $(EXTRALIBS) 70 70 71 abuse_tool_SOURCES = \ 72 tool/abuse-tool.cpp 73 abuse_tool_LDADD = imlib/libimlib.a 74 abuse_tool_DEPENDENCIES = $(abuse_tool_LDADD) 75 71 76 INCLUDES = -I$(srcdir) -I $(srcdir)/lisp -I$(srcdir)/imlib \ 72 77 -I$(srcdir)/net $(SDL_CFLAGS) -
abuse/trunk/src/imlib/specs.cpp
r539 r540 25 25 #include "image.h" 26 26 #include "palette.h" 27 #include "pcxread.h"28 27 #include "specs.h" 29 28 #include "dprint.h" … … 963 962 } 964 963 965 void spec_directory::extract(char const *name)966 {967 jFILE fp(name, "rb");968 if (fp.open_failure())969 {970 fprintf(stderr, "Spec: ERROR - could not open %s\n", name);971 return;972 }973 974 spec_directory dir(&fp);975 if (dir.total <= 0)976 {977 fprintf(stderr, "Spec: ERROR - no signature or no data in %s\n", name);978 return;979 }980 981 char const *out = "SPEC.DIR";982 mkdir(out, S_IRUSR | S_IWUSR | S_IXUSR);983 if (chdir(out))984 {985 fprintf(stderr, "Spec: ERROR - could not create or cd to %s\n", out);986 return;987 }988 989 palette *pal = NULL;990 991 for (int i = 0; i < dir.total; i++)992 {993 spec_entry *se = dir.entries[i];994 995 FILE *fp2 = fopen(se->name, "wb");996 if (!fp2)997 {998 fprintf(stderr, "Spec: ERROR - could not write to %s\n", se->name);999 continue;1000 }1001 1002 fp.seek(se->offset, SEEK_SET);1003 uint8_t buf[1024];1004 size_t todo = se->size;1005 while (todo > 0)1006 {1007 fp.read(buf, Min(todo, 1024));1008 fwrite(buf, Min(todo, 1024), 1, fp2);1009 todo -= Min(todo, 1024);1010 }1011 fclose(fp2);1012 1013 fprintf(stderr, "Spec: %s (type %i): %i bytes\n",1014 se->name, se->type, (int)se->size);1015 1016 /* If it's a palette, keep it */1017 if (!pal && se->type == SPEC_PALETTE)1018 pal = new palette(se, &fp);1019 }1020 1021 /* If we have a palette, output all images */1022 for (int i = 0; pal && i < dir.total; i++)1023 {1024 char buf[1024];1025 spec_entry *se = dir.entries[i];1026 1027 switch (se->type)1028 {1029 case SPEC_IMAGE:1030 case SPEC_FORETILE:1031 case SPEC_BACKTILE:1032 case SPEC_CHARACTER:1033 case SPEC_CHARACTER2:1034 sprintf(buf, "%s-export.pcx", se->name);1035 image *im = new image(&fp, se);1036 write_PCX(im, pal, buf);1037 delete im;1038 fprintf(stderr, "Spec: %s is an image\n", buf);1039 break;1040 }1041 }1042 1043 /* Clean up */1044 delete pal;1045 }1046 1047 964 void note_open_fd(int fd, char const *str) 1048 965 { -
abuse/trunk/src/imlib/specs.h
r539 r540 207 207 void delete_entries(); // if the directory was created by hand instead of by file 208 208 ~spec_directory(); 209 210 static void extract(char const *name);211 209 } ; 212 210 -
abuse/trunk/src/sdlport/setup.cpp
r539 r540 336 336 } 337 337 } 338 else if (ii + 1 < argc && !strcasecmp(argv[ii], "-export"))339 {340 spec_directory::extract(argv[++ii]);341 exit(0);342 }343 338 else if( !strcasecmp( argv[ii], "-h" ) || !strcasecmp( argv[ii], "--help" ) ) 344 339 {
Note: See TracChangeset
for help on using the changeset viewer.