/*************************************************************************\ * Copyright (c) 2002 The University of Chicago, as Operator of Argonne * National Laboratory. * Copyright (c) 2002 The Regents of the University of California, as * Operator of Los Alamos National Laboratory. * This file is distributed subject to a Software License Agreement found * in the file LICENSE that is included with this distribution. \*************************************************************************/ /* program: sddscollapse * purpose: take a SDDS file and create a new file with the * parameters turned into columns. Each row of the * new table is for a different table of the original * file. The columns of the original file are ignored. * * Michael Borland, 1994 $Log: sddscollapse.c,v $ Revision 1.15 2005/11/04 22:46:12 soliday Updated code to be compiled by a 64 bit processor. Revision 1.14 2002/08/14 17:12:41 soliday Added Open License Revision 1.13 2002/01/16 18:39:20 soliday Added missing SDDS_Terminate functions. Revision 1.12 2001/01/10 19:35:32 soliday Standardized usage message. Revision 1.11 1999/05/25 19:05:58 soliday Removed compiler warning on linux. Revision 1.10 1999/01/06 19:54:39 borland Fixed the version number in the usage message. Revision 1.9 1998/08/24 21:47:05 borland Removed the " processed by sddscollapse" description text from the output. Revision 1.8 1997/10/29 21:25:19 borland Now uses SDDS_ReadPageParse with huge sparsing factor, so that only one row is ever read per page of an input file. Reduces memory requires and increases speed. Revision 1.7 1997/09/15 15:34:34 borland Fixed bug in SDDS_SetRowValues call. Was passing &buffer instead of buffer. Can't see how it worked before... Revision 1.6 1996/10/30 18:08:19 borland Slight modification to check for pre-existing parameter. Revision 1.5 1996/10/12 17:31:22 borland Now detects pre-existence of PageNumber column in output and doesn't die when it can't create it for itself. Leaves the data in the column alone. * Revision 1.4 1995/11/13 19:28:54 borland * Fixed bug that involved using inputfile pointer in sprintf() without * testing whether it was NULL or not. * * Revision 1.3 1995/09/06 14:56:13 saunders * First test release of SDDS1.5 * */ #include "mdb.h" #include "scan.h" #include "SDDS.h" #define SET_PIPE 0 #define SET_NOWARNINGS 1 #define N_OPTIONS 2 char *option[N_OPTIONS] = { "pipe", "nowarnings", } ; char *USAGE="sddscollapse [] []\n\ [-pipe=[input][,output]]\n\ [-noWarnings]\n\n\ sddscollapse reads data pages from a SDDS file and writes a new SDDS file \ containing a single data page. This data page contains the parameters, \ with each parameter forming a column of the tabular data.\n\n\ Program by Michael Borland. (This is version 3, August 1998.)\n"; #define ROW_INCREMENT 100 int main(int argc, char **argv) { SDDS_DATASET SDDS_input, SDDS_output; char *inputfile, *outputfile, **column; long i, i_arg; long page_number, allocated_rows, noWarnings, setPageNumber; int32_t columns; SCANNED_ARG *s_arg; char s[SDDS_MAXLINE]; unsigned long pipeFlags; long buffer[16]; SDDS_RegisterProgramName(argv[0]); argc = scanargs(&s_arg, argc, argv); if (argc<2) bomb(NULL, USAGE); inputfile = outputfile = NULL; pipeFlags = noWarnings = 0; for (i_arg=1; i_arg0) { #ifdef DEBUG fprintf(stderr, "working on page %ld\n", page_number); #endif if (page_number>allocated_rows) { if (!SDDS_LengthenTable(&SDDS_output, ROW_INCREMENT)) { SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors); exit(1); } allocated_rows += ROW_INCREMENT; } for (i=0; i