- Timestamp:
- Nov 24, 2010, 12:09:32 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20101103/ppConfigDump/src/ppConfigDump.c
r24187 r29821 26 26 void dump(const char *filename, // Filename to which to dump 27 27 const char *description, // Description of what's being dumped 28 psMetadata *md // Metadata to dump 28 psMetadata *md, // Metadata to dump 29 const char *compressMode 29 30 ) 30 31 { … … 38 39 die(PS_EXIT_SYS_ERROR); 39 40 } 41 42 # if (PS_SLURP_GZIP) 43 44 char modeString[4]; 45 46 if (compressMode) { 47 if (strlen(compressMode) > 2) { 48 psErrorStackPrint(stderr, "invalid compression options %s!\n", compressMode); 49 die(PS_EXIT_CONFIG_ERROR); 50 } 51 snprintf (modeString, 4, "w%s", compressMode); 52 } else { 53 strcpy (modeString, "w0"); 54 } 55 56 gzFile file = gzdopen (STDOUT_FILENO, modeString); 57 if (file == Z_NULL) { 58 psErrorStackPrint(stderr, "Failed to open file\n"); 59 die(PS_EXIT_SYS_ERROR); 60 } 61 int nbytes = gzwrite (file, string, strlen(string)); 62 if (nbytes != strlen(string)) { 63 psErrorStackPrint(stderr, "Failed to write contents of configuration file %s", filename); 64 psFree(string); 65 gzclose(file); 66 die(PS_EXIT_SYS_ERROR); 67 } 68 psFree(string); 69 if (gzclose(file) != Z_OK) { 70 psErrorStackPrint(stderr, "Failed to close file, %s\n", filename); 71 die(PS_EXIT_SYS_ERROR); 72 } 73 # else 40 74 fprintf(stdout, "%s", string); 75 # endif 41 76 psFree(string); 42 } else if (!psMetadataConfigWrite(md, filename )) {77 } else if (!psMetadataConfigWrite(md, filename, compressMode)) { 43 78 psErrorStackPrint(stderr, "Can't write %s to %s\n", description, filename); 44 79 die(PS_EXIT_SYS_ERROR); … … 62 97 arguments = psMetadataAlloc(); 63 98 psMetadataAddStr(arguments, PS_LIST_TAIL, "-file", 0, "FITS file to use for camera determination", NULL); 99 psMetadataAddStr(arguments, PS_LIST_TAIL, "-compress", 0, "output compression mode", NULL); 100 psMetadataAddBool(arguments, PS_LIST_TAIL, "-z", 0, "default compression", false); 64 101 psMetadataAddStr(arguments, PS_LIST_TAIL, "-dump-user", 0, "Filename for user configuration", NULL); 65 102 psMetadataAddStr(arguments, PS_LIST_TAIL, "-dump-site", 0, "Filename for site configuration", NULL); … … 84 121 psArgumentHelp(arguments); 85 122 die(PS_EXIT_CONFIG_ERROR); 123 } 124 125 const char *defaultCompressMode = "7f"; 126 const char *compressMode = psMetadataLookupStr(NULL, arguments, "-compress"); // compression 127 bool defaultCompression = psMetadataLookupBool(NULL, arguments, "-z"); // compression? 128 if (!compressMode && defaultCompression) { 129 compressMode = defaultCompressMode; 86 130 } 87 131 … … 122 166 123 167 const char *userName = psMetadataLookupStr(NULL, arguments, "-dump-user"); // User filename 124 dump(userName, "user configuration", config->user );168 dump(userName, "user configuration", config->user, compressMode); 125 169 126 170 const char *siteName = psMetadataLookupStr(NULL, arguments, "-dump-site"); // Site filename 127 dump(siteName, "site configuration", config->site );171 dump(siteName, "site configuration", config->site, compressMode); 128 172 129 173 const char *systemName = psMetadataLookupStr(NULL, arguments, "-dump-system"); // System filename 130 dump(systemName, "system configuration", config->system );174 dump(systemName, "system configuration", config->system, compressMode); 131 175 132 176 const char *camName = psMetadataLookupStr(NULL, arguments, "-dump-camera"); // Camera filename 133 dump(camName, "camera configuration", config->camera );177 dump(camName, "camera configuration", config->camera, compressMode); 134 178 135 179 const char *formatName = psMetadataLookupStr(NULL, arguments, "-dump-format"); // Format filename 136 dump(formatName, "camera format", config->format );180 dump(formatName, "camera format", config->format, compressMode); 137 181 138 182 const char *recipesName = psMetadataLookupStr(NULL, arguments, "-dump-recipes"); // Recipes filename 139 dump(recipesName, "recipes", config->recipes );183 dump(recipesName, "recipes", config->recipes, compressMode); 140 184 141 185 recipeArgs = psMetadataLookupMetadata(NULL, arguments, "-dump-recipe"); … … 148 192 } 149 193 const char *recipeFile = psMetadataLookupStr(NULL, recipeArgs, "filename"); // Filename for recipe 150 dump(recipeFile, "recipe", recipe );194 dump(recipeFile, "recipe", recipe, compressMode); 151 195 } 152 196
Note:
See TracChangeset
for help on using the changeset viewer.
