[AD] datedit argument list |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
Ok, I've put a lot of options to datedit_save_datafile in a struct for
easier extension in the future. For now, it just contains all the fields
as seperate integers (similar to the way they were passed to the file),
but they could be combined in a single int as flags.
The patch updates both the grabber and the dat utility. Tested under Linux.
I'll post a patch for the options list later.
Evert
diff -p -r -b -C3 allegro/tools/dat.c allegro_mod1/tools/dat.c
*** allegro/tools/dat.c Wed Jul 3 22:18:12 2002
--- allegro_mod1/tools/dat.c Sun Sep 22 11:45:21 2002
*************** static int do_save_dependencies(DATAFILE
*** 678,683 ****
--- 678,684 ----
int main(int argc, char *argv[])
{
+ DATEDIT_SAVE_OPTIONS options;
int c, colorconv_mode = 0;
install_allegro(SYSTEM_NONE, &errno, atexit);
*************** int main(int argc, char *argv[])
*** 975,982 ****
}
}
if ((!err) && ((changed) || (opt_compression >= 0) || (opt_strip >= 0)))
! if (!datedit_save_datafile(datafile, opt_datafile, opt_strip, opt_compression, opt_verbose, TRUE, FALSE, opt_password))
err = 1;
if ((!err) && (opt_headername))
--- 976,989 ----
}
}
+ options.strip = opt_strip;
+ options.pack = opt_compression;
+ options.verbose = opt_verbose;
+ options.write_msg = TRUE;
+ options.backup = FALSE;
+
if ((!err) && ((changed) || (opt_compression >= 0) || (opt_strip >= 0)))
! if (!datedit_save_datafile(datafile, opt_datafile, options, opt_password))
err = 1;
if ((!err) && (opt_headername))
diff -p -r -b -C3 allegro/tools/datedit.c allegro_mod1/tools/datedit.c
*** allegro/tools/datedit.c Wed Jul 3 22:18:12 2002
--- allegro_mod1/tools/datedit.c Sun Sep 22 11:37:23 2002
*************** static void save_binary(DATAFILE *dat, i
*** 181,187 ****
/* export a child datafile */
static int export_datafile(AL_CONST DATAFILE *dat, AL_CONST char *filename)
{
! return datedit_save_datafile((DATAFILE *)dat->dat, filename, -1, -1, FALSE, FALSE, FALSE, NULL);
}
--- 181,189 ----
/* export a child datafile */
static int export_datafile(AL_CONST DATAFILE *dat, AL_CONST char *filename)
{
! DATEDIT_SAVE_OPTIONS options = {-1, -1, FALSE, FALSE, FALSE};
!
! return datedit_save_datafile((DATAFILE *)dat->dat, filename, options, NULL);
}
*************** int datedit_packtype(int pack)
*** 1020,1040 ****
/* saves a datafile */
! int datedit_save_datafile(DATAFILE *dat, AL_CONST char *name, int strip, int pack, int verbose, int write_msg, int backup, AL_CONST char *password)
{
char *pretty_name;
char backup_name[256];
PACKFILE *f;
packfile_password(password);
! strip = datedit_striptype(strip);
! pack = datedit_packtype(pack);
strcpy(backup_name, datedit_pretty_name(name, "bak", TRUE));
pretty_name = datedit_pretty_name(name, "dat", FALSE);
! if (write_msg)
datedit_msg("Writing %s", pretty_name);
delete_file(backup_name);
--- 1022,1044 ----
/* saves a datafile */
! int datedit_save_datafile(DATAFILE *dat, AL_CONST char *name, AL_CONST DATEDIT_SAVE_OPTIONS options, AL_CONST char *password)
{
char *pretty_name;
char backup_name[256];
+ int strip;
+ int pack;
PACKFILE *f;
packfile_password(password);
! strip = datedit_striptype(options.strip);
! pack = datedit_packtype(options.pack);
strcpy(backup_name, datedit_pretty_name(name, "bak", TRUE));
pretty_name = datedit_pretty_name(name, "dat", FALSE);
! if (options.write_msg)
datedit_msg("Writing %s", pretty_name);
delete_file(backup_name);
*************** int datedit_save_datafile(DATAFILE *dat,
*** 1046,1052 ****
pack_mputl(DAT_MAGIC, f);
file_datasize = 12;
! save_datafile(dat, (pack >= 2), (pack >= 1), strip, verbose, (strip <= 0), f);
if (strip <= 0) {
datedit_set_property(&datedit_info, DAT_NAME, "GrabberInfo");
--- 1050,1056 ----
pack_mputl(DAT_MAGIC, f);
file_datasize = 12;
! save_datafile(dat, (pack >= 2), (pack >= 1), strip, options.verbose, (strip <= 0), f);
if (strip <= 0) {
datedit_set_property(&datedit_info, DAT_NAME, "GrabberInfo");
*************** int datedit_save_datafile(DATAFILE *dat,
*** 1063,1072 ****
return FALSE;
}
else {
! if (!backup)
delete_file(backup_name);
! if (verbose) {
int file_filesize = file_size(pretty_name);
datedit_msg("%-28s%7d bytes into %-7d (%d%%)", "- GLOBAL COMPRESSION -",
file_datasize, file_filesize, percent(file_datasize, file_filesize));
--- 1067,1076 ----
return FALSE;
}
else {
! if (!options.backup)
delete_file(backup_name);
! if (options.verbose) {
int file_filesize = file_size(pretty_name);
datedit_msg("%-28s%7d bytes into %-7d (%d%%)", "- GLOBAL COMPRESSION -",
file_datasize, file_filesize, percent(file_datasize, file_filesize));
diff -p -r -b -C3 allegro/tools/datedit.h allegro_mod1/tools/datedit.h
*** allegro/tools/datedit.h Wed Jul 3 22:18:12 2002
--- allegro_mod1/tools/datedit.h Sun Sep 22 11:28:50 2002
*************** typedef struct DATEDIT_MENU_INFO
*** 74,79 ****
--- 74,89 ----
+
+ typedef struct DATEDIT_SAVE_OPTIONS {
+ int strip;
+ int pack;
+ int verbose;
+ int write_msg;
+ int backup;
+ } DATEDIT_SAVE_OPTIONS;
+
+
#define DATEDIT_MENU_FILE 1
#define DATEDIT_MENU_OBJECT 2
#define DATEDIT_MENU_HELP 4
*************** AL_CONST char *datedit_grab_ext(int type
*** 119,125 ****
AL_CONST char *datedit_export_ext(int type);
DATAFILE *datedit_load_datafile(AL_CONST char *name, int compile_sprites, AL_CONST char *password);
! int datedit_save_datafile(DATAFILE *dat, AL_CONST char *name, int strip, int pack, int verbose, int write_msg, int backup, AL_CONST char *password);
int datedit_save_header(AL_CONST DATAFILE *dat, AL_CONST char *name, AL_CONST char *headername, AL_CONST char *progname, AL_CONST char *prefix, int verbose);
void datedit_export_name(AL_CONST DATAFILE *dat, AL_CONST char *name, AL_CONST char *ext, char *buf);
--- 129,135 ----
AL_CONST char *datedit_export_ext(int type);
DATAFILE *datedit_load_datafile(AL_CONST char *name, int compile_sprites, AL_CONST char *password);
! int datedit_save_datafile(DATAFILE *dat, AL_CONST char *name, AL_CONST DATEDIT_SAVE_OPTIONS options, AL_CONST char *password);
int datedit_save_header(AL_CONST DATAFILE *dat, AL_CONST char *name, AL_CONST char *headername, AL_CONST char *progname, AL_CONST char *prefix, int verbose);
void datedit_export_name(AL_CONST DATAFILE *dat, AL_CONST char *name, AL_CONST char *ext, char *buf);
diff -p -r -b -C3 allegro/tools/grabber.c allegro_mod1/tools/grabber.c
*** allegro/tools/grabber.c Wed Jul 3 22:18:12 2002
--- allegro_mod1/tools/grabber.c Sun Sep 22 11:33:26 2002
*************** static int merger(void)
*** 1757,1762 ****
--- 1757,1763 ----
/* do the actual work of saving a file */
static int save(int strip)
{
+ DATEDIT_SAVE_OPTIONS options;
char buf[FILENAME_LENGTH], buf2[256];
int err = FALSE;
*************** static int save(int strip)
*** 1780,1786 ****
update_info();
! if (!datedit_save_datafile(datafile, data_file, strip, -1, TRUE, FALSE, (main_dlg[DLG_BACKUPCHECK].flags & D_SELECTED), password))
err = TRUE;
else
modified(0);
--- 1781,1793 ----
update_info();
! options.strip = strip;
! options.pack = -1;
! options.verbose = TRUE;
! options.write_msg = FALSE;
! options.backup = (main_dlg[DLG_BACKUPCHECK].flags & D_SELECTED);
!
! if (!datedit_save_datafile(datafile, data_file, options, password))
err = TRUE;
else
modified(0);