344 {
347 long output_columns;
348 char *description_text, *description_contents;
349 unsigned long flags;
350
352 long processing_definitions;
354 long conversions;
356 long edit_definitions;
358 long equation_definitions;
360 long evaluate_definitions;
362 long scan_definitions;
364 long print_definitions;
366 long format_definitions;
369 long filter_definitions;
371 long time_filter_definitions;
374 long match_definitions;
376 long rpntest_definitions;
378 long numbertest_definitions;
380 long system_definitions;
382 long rpnexpression_definitions;
385 long clip_definitions, fclip_definitions;
387 long sparse_definitions;
389 long sample_definitions;
391 long definitions;
393 long cast_definitions;
394
396 char *inputfile, *outputfile;
397
398 int64_t n_rows, j;
399 long i, k, i_arg, summarize, verbose, index = 0, tmpfile_used, nowarnings, udfCounter;
400 long page_number, accept;
401 SCANNED_ARG *s_arg;
402 char s[SDDS_MAXLINE];
403
404 char **rpn_definitions_file, *stringResult;
405 long rpn_definitions_files;
406 int32_t test_result;
407 long original_parameters;
408 double result;
409 long i_page_memory, table_number_memory, n_rows_memory, row_deletion, skip_page;
410 long random_number_seed;
411 unsigned long pipeFlags, majorOrderFlag;
412
413 char **retain_column, **delete_column;
414 long retain_columns, delete_columns, rename_columns, edit_column_requests;
416 STRING_PAIR *rename_column;
417 char **orig_column_name, **new_column_name;
418 long *orig_column_flag;
419 int32_t orig_column_names;
420
421 char **retain_parameter, **delete_parameter;
422 long retain_parameters, delete_parameters, rename_parameters, edit_parameter_requests;
424 STRING_PAIR *rename_parameter;
425 char **orig_parameter_name, **new_parameter_name;
426 long *orig_parameter_flag;
427 int32_t orig_parameter_names;
428
429 char **retain_array, **delete_array;
430 long retain_arrays, delete_arrays, rename_arrays, edit_array_requests;
432 STRING_PAIR *rename_array;
433 char **orig_array_name, **new_array_name;
434 long *orig_array_flag;
435 int32_t orig_array_names;
436 short columnMajorOrder = -1;
437
438 int threads = 1;
439
440 char buffer[SDDS_MAXLINE];
441
443
444 argc =
scanargs(&s_arg, argc, argv);
445 argc = add_sddsfile_arguments(&s_arg, argc);
446
447 random_number_seed = (long)time((time_t *)NULL);
448 random_number_seed = 2 * (random_number_seed / 2) + 1;
449#if defined(_WIN32)
450 random_1(-labs((
double)random_number_seed));
451#else
452 random_1(-FABS((
double)random_number_seed));
453#endif
454
455 retain_column = delete_column = NULL;
456 retain_columns = delete_columns = rename_columns = edit_column_requests = 0;
457 rename_column = NULL;
458 edit_column_request = NULL;
459
460 retain_parameter = delete_parameter = NULL;
461 retain_parameters = delete_parameters = rename_parameters = edit_parameter_requests = 0;
462 rename_parameter = NULL;
463 edit_parameter_request = NULL;
464
465 retain_array = delete_array = NULL;
466 retain_arrays = delete_arrays = rename_arrays = edit_array_requests = 0;
467 rename_array = NULL;
468 edit_array_request = NULL;
469
470 description_text = description_contents = NULL;
471 new_parameter_name = new_column_name = new_array_name = NULL;
472
473 if (argc < 3) {
474 char **ptr;
475 ptr = usageArray;
476 while (*ptr) {
477 fprintf(stderr, "%s", *ptr);
478 ptr++;
479 }
480 show_process_modes(stderr);
481 exit(EXIT_FAILURE);
482 }
483
484 inputfile = outputfile = NULL;
485 rpn_definitions_file = NULL;
486 rpn_definitions_files = 0;
487 summarize = verbose = nowarnings = udfCounter = 0;
488
489 processing_definition = NULL;
490 processing_definitions = 0;
491 conversion = NULL;
492 conversions = 0;
493 edit_definition = NULL;
494 edit_definitions = 0;
495 equation_definition = NULL;
496 equation_definitions = 0;
497 evaluate_definition = NULL;
498 evaluate_definitions = 0;
499 scan_definition = NULL;
500 scan_definitions = 0;
501 print_definition = NULL;
502 print_definitions = 0;
503 format_definition = NULL;
504 format_definitions = 0;
505 filter_definition = NULL;
506 filter_definitions = 0;
507 time_filter_definition = NULL;
508 time_filter_definitions = 0;
509 match_definition = NULL;
510 match_definitions = 0;
511 rpntest_definition = NULL;
512 rpntest_definitions = 0;
513 numbertest_definition = NULL;
514 numbertest_definitions = 0;
515 system_definition = NULL;
516 system_definitions = 0;
517 rpnexpression_definition = NULL;
518 rpnexpression_definitions = 0;
519 clip_definition = NULL;
520 fclip_definition = NULL;
521 clip_definitions = fclip_definitions = 0;
522 sparse_definition = NULL;
523 sparse_definitions = 0;
524 sample_definition = NULL;
525 sample_definitions = 0;
526 cast_definition = NULL;
527 cast_definitions = 0;
528 definition = NULL;
529 definitions = 0;
530 ifnot_item.items = 0;
531 ifis_item.items = 0;
532 pipeFlags = 0;
533
534 for (i_arg = 1; i_arg < argc; i_arg++) {
535 if (s_arg[i_arg].arg_type == OPTION) {
537 switch (
match_string(s_arg[i_arg].list[0], option, N_OPTIONS, 0)) {
538 case SET_MAJOR_ORDER:
539 majorOrderFlag = 0;
540 s_arg[i_arg].n_items--;
541 if (s_arg[i_arg].n_items > 0 &&
542 (!
scanItemList(&majorOrderFlag, s_arg[i_arg].list + 1, &s_arg[i_arg].n_items, 0,
543 "row", -1, NULL, 0, SDDS_ROW_MAJOR_ORDER,
544 "column", -1, NULL, 0, SDDS_COLUMN_MAJOR_ORDER, NULL)))
545 SDDS_Bomb(
"invalid -majorOrder syntax/values");
546 if (majorOrderFlag & SDDS_COLUMN_MAJOR_ORDER)
547 columnMajorOrder = 1;
548 else if (majorOrderFlag & SDDS_ROW_MAJOR_ORDER)
549 columnMajorOrder = 0;
550 break;
551 case SET_MATCH:
552 if (s_arg[i_arg].n_items < 3)
554 match_definition = (
MATCH_DEFINITION **)
trealloc(match_definition,
sizeof(*match_definition) * (match_definitions + 1));
555 if (!(match_definition[match_definitions] = process_new_match_definition(s_arg[i_arg].list + 1, s_arg[i_arg].n_items - 1)))
557 add_definition(&definition, &definitions, (void *)match_definition[match_definitions], IS_MATCH_DEFINITION);
558 match_definitions++;
559 break;
560 case SET_FILTER:
561 if (s_arg[i_arg].n_items < 3)
563 filter_definition = (
FILTER_DEFINITION **)
trealloc(filter_definition,
sizeof(*filter_definition) * (filter_definitions + 1));
564 if (!(filter_definition[filter_definitions] = process_new_filter_definition(s_arg[i_arg].list + 1, s_arg[i_arg].n_items - 1)))
566 add_definition(&definition, &definitions, (void *)filter_definition[filter_definitions], IS_FILTER_DEFINITION);
567 filter_definitions++;
568 break;
569 case SET_TIME_FILTER:
570 if (s_arg[i_arg].n_items < 3)
573 if (!(time_filter_definition[time_filter_definitions] = process_new_time_filter_definition(s_arg[i_arg].list + 1, s_arg[i_arg].n_items - 1)))
575 add_definition(&definition, &definitions, (void *)time_filter_definition[time_filter_definitions], IS_TIME_FILTER_DEFINITION);
576 time_filter_definitions++;
577 break;
578 case SET_RPN_DEFNS_FILES:
579 if (s_arg[i_arg].n_items < 2)
580 SDDS_Bomb(
"invalid -rpndefinitionsfiles syntax");
581 rpn_definitions_file =
trealloc(rpn_definitions_file,
sizeof(*rpn_definitions_file) * (rpn_definitions_files + s_arg[i_arg].n_items));
582 for (i = 1; i < s_arg[i_arg].n_items; i++)
583 if (!
fexists(rpn_definitions_file[rpn_definitions_files + i - 1] = s_arg[i_arg].list[i]))
584 SDDS_Bomb(
"one or more rpn definitions files do not exist");
585 rpn_definitions_files += s_arg[i_arg].n_items - 1;
586 break;
587 case SET_RPN_EXPRESSION:
588 if (s_arg[i_arg].n_items < 2 && s_arg[i_arg].n_items > 4)
589 SDDS_Bomb(
"invalid -rpnexpression syntax");
590 rpnexpression_definition = (
RPNEXPRESSION_DEFINITION **)
trealloc(rpnexpression_definition,
sizeof(*rpnexpression_definition) * (rpnexpression_definitions + 1));
591 if (!(rpnexpression_definition[rpnexpression_definitions] = process_new_rpnexpression_definition(s_arg[i_arg].list + 1, s_arg[i_arg].n_items - 1)))
592 SDDS_Bomb(
"invalid -rpnexpression syntax");
593 add_definition(&definition, &definitions, (void *)rpnexpression_definition[rpnexpression_definitions], IS_RPNEXPRESSION_DEFINITION);
594 rpnexpression_definitions++;
595 break;
596 case SET_DEFINITION:
597 if (s_arg[i_arg].n_items < 4)
599 equation_definition = (
EQUATION_DEFINITION **)
trealloc(equation_definition,
sizeof(*equation_definition) * (equation_definitions + 1));
600 if (!(equation_definition[equation_definitions] = process_new_equation_definition(s_arg[i_arg].list + 1, s_arg[i_arg].n_items - 1)))
602 equation_definition[equation_definitions]->redefinition = 0;
603 add_definition(&definition, &definitions, (void *)equation_definition[equation_definitions], IS_EQUATION_DEFINITION);
604 equation_definitions++;
605 break;
606 case SET_REDEFINITION:
607 if (s_arg[i_arg].n_items < 4)
608 SDDS_Bomb(
"invalid -redefinition syntax");
609 equation_definition = (
EQUATION_DEFINITION **)
trealloc(equation_definition,
sizeof(*equation_definition) * (equation_definitions + 1));
610 if (!(equation_definition[equation_definitions] = process_new_equation_definition(s_arg[i_arg].list + 1, s_arg[i_arg].n_items - 1)))
611 SDDS_Bomb(
"invalid -redefinition syntax");
612 equation_definition[equation_definitions]->redefinition = 1;
613 add_definition(&definition, &definitions, (void *)equation_definition[equation_definitions], IS_EQUATION_DEFINITION);
614 equation_definitions++;
615 break;
616 case SET_EVALUATE:
617 if (s_arg[i_arg].n_items < 4)
619 evaluate_definition = (
EVALUATE_DEFINITION **)
trealloc(evaluate_definition,
sizeof(*evaluate_definition) * (evaluate_definitions + 1));
620 if (!(evaluate_definition[evaluate_definitions] = process_new_evaluate_definition(s_arg[i_arg].list + 1, s_arg[i_arg].n_items - 1)))
622 add_definition(&definition, &definitions, (void *)evaluate_definition[evaluate_definitions], IS_EVALUATE_DEFINITION);
623 evaluate_definitions++;
624 break;
625 case SET_TEST:
626 if (s_arg[i_arg].n_items < 3 && s_arg[i_arg].n_items > 5)
628 rpntest_definition = (
RPNTEST_DEFINITION **)
trealloc(rpntest_definition,
sizeof(*rpntest_definition) * (rpntest_definitions + 1));
629 if (!(rpntest_definition[rpntest_definitions] = process_new_rpntest_definition(s_arg[i_arg].list + 1, s_arg[i_arg].n_items - 1)))
631 add_definition(&definition, &definitions, (void *)rpntest_definition[rpntest_definitions], IS_RPNTEST_DEFINITION);
632 rpntest_definitions++;
633 break;
634 case SET_SUMMARIZE:
635 summarize = 1;
636 break;
637 case SET_VERBOSE:
638 verbose = 1;
639 break;
640 case SET_NOWARNINGS:
641 nowarnings = 1;
642 break;
643 case SET_PROCESS:
644 processing_definition = (
PROCESSING_DEFINITION **)
trealloc(processing_definition,
sizeof(*processing_definition) * (processing_definitions + 1));
645 if (!(processing_definition[processing_definitions] = record_processing_definition(s_arg[i_arg].list + 1, s_arg[i_arg].n_items - 1)))
646 SDDS_Bomb(
"invalid -process syntax--parsing problem");
647 add_definition(&definition, &definitions, (void *)processing_definition[processing_definitions], IS_PROCESSING_DEFINITION);
648 processing_definitions++;
649 break;
650 case SET_CONVERT_UNITS:
651 if (s_arg[i_arg].n_items != 6)
652 SDDS_Bomb(
"invalid -convertunits syntax--wrong number of items");
654 if (!(conversion[conversions] = process_conversion_definition(s_arg[i_arg].list + 1, s_arg[i_arg].n_items - 1)))
655 SDDS_Bomb(
"invalid -convertunits syntax");
656 add_definition(&definition, &definitions, (void *)conversion[conversions], IS_CONVERSION_DEFINITION);
657 conversions++;
658 break;
659 case SET_NUMBERTEST:
660
661 if (s_arg[i_arg].n_items < 3)
663 numbertest_definition = (
NUMBERTEST_DEFINITION **)
trealloc(numbertest_definition,
sizeof(*numbertest_definition) * (numbertest_definitions + 1));
664 if (!(numbertest_definition[numbertest_definitions] = process_new_numbertest_definition(s_arg[i_arg].list + 1, s_arg[i_arg].n_items - 1)))
666 add_definition(&definition, &definitions, (void *)numbertest_definition[numbertest_definitions], IS_NUMBERTEST_DEFINITION);
667 numbertest_definitions++;
668 break;
669 case SET_SCAN:
670 if (s_arg[i_arg].n_items < 5)
672 scan_definition = (
SCAN_DEFINITION **)
trealloc(scan_definition,
sizeof(*scan_definition) * (scan_definitions + 1));
673 if (!(scan_definition[scan_definitions] = process_new_scan_definition(s_arg[i_arg].list + 1, s_arg[i_arg].n_items - 1)))
675 add_definition(&definition, &definitions, (void *)scan_definition[scan_definitions], IS_SCAN_DEFINITION);
676 scan_definitions++;
677 break;
678 case SET_PRINT:
679 if (s_arg[i_arg].n_items < 4)
681 print_definition = (
PRINT_DEFINITION **)
trealloc(print_definition,
sizeof(*print_definition) * (print_definitions + 1));
682 if (!(print_definition[print_definitions] = process_new_print_definition(s_arg[i_arg].list + 1, s_arg[i_arg].n_items - 1)))
684 print_definition[print_definitions]->reprint = 0;
685 add_definition(&definition, &definitions, (void *)print_definition[print_definitions], IS_PRINT_DEFINITION);
686 print_definitions++;
687 break;
688 case SET_REPRINT:
689 if (s_arg[i_arg].n_items < 4)
691 print_definition = (
PRINT_DEFINITION **)
trealloc(print_definition,
sizeof(*print_definition) * (print_definitions + 1));
692 if (!(print_definition[print_definitions] = process_new_print_definition(s_arg[i_arg].list + 1, s_arg[i_arg].n_items - 1)))
694 print_definition[print_definitions]->reprint = 1;
695 add_definition(&definition, &definitions, (void *)print_definition[print_definitions], IS_PRINT_DEFINITION);
696 print_definitions++;
697 break;
698 case SET_EDIT:
699 if (s_arg[i_arg].n_items < 5)
701 edit_definition = (
EDIT_DEFINITION **)
trealloc(edit_definition,
sizeof(*edit_definition) * (edit_definitions + 1));
702 if (!(edit_definition[edit_definitions] = process_new_edit_definition(s_arg[i_arg].list + 1, s_arg[i_arg].n_items - 1, 0)))
704 add_definition(&definition, &definitions, (void *)edit_definition[edit_definitions], IS_EDIT_DEFINITION);
705 edit_definitions++;
706 break;
707 case SET_REEDIT:
708 if (s_arg[i_arg].n_items < 4)
710 edit_definition = (
EDIT_DEFINITION **)
trealloc(edit_definition,
sizeof(*edit_definition) * (edit_definitions + 1));
711 if (!(edit_definition[edit_definitions] = process_new_edit_definition(s_arg[i_arg].list + 1, s_arg[i_arg].n_items - 1, 1)))
713 edit_definition[edit_definitions]->reedit = 1;
714 add_definition(&definition, &definitions, (void *)edit_definition[edit_definitions], IS_EDIT_DEFINITION);
715 edit_definitions++;
716 break;
717 case SET_SYSTEM:
718 if (s_arg[i_arg].n_items < 4)
720 system_definition = (
SYSTEM_DEFINITION **)
trealloc(system_definition,
sizeof(*system_definition) * (system_definitions + 1));
721 if (!(system_definition[system_definitions] = process_new_system_definition(s_arg[i_arg].list + 1, s_arg[i_arg].n_items - 1)))
723 add_definition(&definition, &definitions, (void *)system_definition[system_definitions], IS_SYSTEM_DEFINITION);
724 system_definitions++;
725 break;
726 case SET_IFNOT:
727 if (s_arg[i_arg].n_items < 3)
729 add_ifitem(&ifnot_item, s_arg[i_arg].list + 1, s_arg[i_arg].n_items - 1);
730 break;
731 case SET_IFIS:
732 if (s_arg[i_arg].n_items < 3)
734 add_ifitem(&ifis_item, s_arg[i_arg].list + 1, s_arg[i_arg].n_items - 1);
735 break;
736 case SET_CLIP:
737 clip_definition = (
CLIP_DEFINITION **)
trealloc(clip_definition,
sizeof(*clip_definition) * (clip_definitions + 1));
738 if (!(clip_definition[clip_definitions] = process_new_clip_definition(s_arg[i_arg].list + 1, s_arg[i_arg].n_items - 1)))
740 add_definition(&definition, &definitions, (void *)clip_definition[clip_definitions], IS_CLIP_DEFINITION);
741 clip_definitions++;
742 break;
743 case SET_FCLIP:
744 fclip_definition = (
FCLIP_DEFINITION **)
trealloc(fclip_definition,
sizeof(*fclip_definition) * (fclip_definitions + 1));
745 if (!(fclip_definition[fclip_definitions] = process_new_fclip_definition(s_arg[i_arg].list + 1, s_arg[i_arg].n_items - 1)))
747 add_definition(&definition, &definitions, (void *)fclip_definition[fclip_definitions], IS_FCLIP_DEFINITION);
748 fclip_definitions++;
749 break;
750 case SET_SPARSE:
751 sparse_definition = (
SPARSE_DEFINITION **)
trealloc(sparse_definition,
sizeof(*sparse_definition) * (sparse_definitions + 1));
752 if (!(sparse_definition[sparse_definitions] = process_new_sparse_definition(s_arg[i_arg].list + 1, s_arg[i_arg].n_items - 1)))
754 add_definition(&definition, &definitions, (void *)sparse_definition[sparse_definitions], IS_SPARSE_DEFINITION);
755 sparse_definitions++;
756 break;
757 case SET_SAMPLE:
758 sample_definition = (
SAMPLE_DEFINITION **)
trealloc(sample_definition,
sizeof(*sample_definition) * (sample_definitions + 1));
759 if (!(sample_definition[sample_definitions] = process_new_sample_definition(s_arg[i_arg].list + 1, s_arg[i_arg].n_items - 1)))
761 add_definition(&definition, &definitions, (void *)sample_definition[sample_definitions], IS_SAMPLE_DEFINITION);
762 sample_definitions++;
763 break;
764 case SET_PIPE:
765 if (!
processPipeOption(s_arg[i_arg].list + 1, s_arg[i_arg].n_items - 1, &pipeFlags))
767 break;
768 case SET_FORMAT:
769 if (s_arg[i_arg].n_items < 4)
771 format_definition = (
FORMAT_DEFINITION **)
trealloc(format_definition,
sizeof(*format_definition) * (format_definitions + 1));
772 if (!(format_definition[format_definitions] = process_new_format_definition(s_arg[i_arg].list + 1, s_arg[i_arg].n_items - 1)))
774 add_definition(&definition, &definitions, (void *)format_definition[format_definitions], IS_FORMAT_DEFINITION);
775 format_definitions++;
776 break;
777 case SET_CAST:
778 if (s_arg[i_arg].n_items != 5)
780 cast_definition = (
CAST_DEFINITION **)
trealloc(cast_definition,
sizeof(*cast_definition) * (cast_definitions + 1));
781 if (!(cast_definition[cast_definitions] = process_new_cast_definition(s_arg[i_arg].list + 1, s_arg[i_arg].n_items - 1)))
783 add_definition(&definition, &definitions, (void *)cast_definition[cast_definitions], IS_CAST_DEFINITION);
784 cast_definitions++;
785 break;
786 case SET_DELETE:
787 if (s_arg[i_arg].n_items < 3)
789 switch (
match_string(s_arg[i_arg].list[1], mode_name, MODES, 0)) {
790 case COLUMN_MODE:
791 delete_column =
trealloc(delete_column,
sizeof(*delete_column) * (delete_columns + s_arg[i_arg].n_items - 2));
792 for (i = 2; i < s_arg[i_arg].n_items; i++)
793 delete_column[i - 2 + delete_columns] = s_arg[i_arg].list[i];
794 delete_columns += s_arg[i_arg].n_items - 2;
795 break;
796 case PARAMETER_MODE:
797 delete_parameter =
trealloc(delete_parameter,
sizeof(*delete_parameter) * (delete_parameters + s_arg[i_arg].n_items - 2));
798 for (i = 2; i < s_arg[i_arg].n_items; i++)
799 delete_parameter[i - 2 + delete_parameters] = s_arg[i_arg].list[i];
800 delete_parameters += s_arg[i_arg].n_items - 2;
801 break;
802 case ARRAY_MODE:
803 delete_array =
trealloc(delete_array,
sizeof(*delete_array) * (delete_arrays + s_arg[i_arg].n_items - 2));
804 for (i = 2; i < s_arg[i_arg].n_items; i++)
805 delete_array[i - 2 + delete_arrays] = s_arg[i_arg].list[i];
806 delete_arrays += s_arg[i_arg].n_items - 2;
807 break;
808 default:
809 SDDS_Bomb(
"invalid -delete syntax: specify column or parameter keyword");
810 break;
811 }
812 break;
813 case SET_RETAIN:
814 if (s_arg[i_arg].n_items < 3)
816 switch (
match_string(s_arg[i_arg].list[1], mode_name, MODES, 0)) {
817 case COLUMN_MODE:
818 retain_column =
trealloc(retain_column,
sizeof(*retain_column) * (retain_columns + s_arg[i_arg].n_items - 2));
819 for (i = 2; i < s_arg[i_arg].n_items; i++)
820 retain_column[i - 2 + retain_columns] = s_arg[i_arg].list[i];
821 retain_columns += s_arg[i_arg].n_items - 2;
822 break;
823 case PARAMETER_MODE:
824 retain_parameter =
trealloc(retain_parameter,
sizeof(*retain_parameter) * (retain_parameters + s_arg[i_arg].n_items - 2));
825 for (i = 2; i < s_arg[i_arg].n_items; i++)
826 retain_parameter[i - 2 + retain_parameters] = s_arg[i_arg].list[i];
827 retain_parameters += s_arg[i_arg].n_items - 2;
828 break;
829 case ARRAY_MODE:
830 retain_array =
trealloc(retain_array,
sizeof(*retain_array) * (retain_arrays + s_arg[i_arg].n_items - 2));
831 for (i = 2; i < s_arg[i_arg].n_items; i++)
832 retain_array[i - 2 + retain_arrays] = s_arg[i_arg].list[i];
833 retain_arrays += s_arg[i_arg].n_items - 2;
834 break;
835 default:
836 SDDS_Bomb(
"invalid -retain syntax: specify column or parameter keyword");
837 break;
838 }
839 break;
840 case SET_DESCRIPTION:
841 s_arg[i_arg].n_items -= 1;
842 if (!
scanItemList(&flags, s_arg[i_arg].list + 1, &s_arg[i_arg].n_items, 0,
844 "contents",
SDDS_STRING, &description_contents, 1, 0, NULL))
845 SDDS_Bomb(
"invalid -description syntax");
846 break;
847 case SET_THREADS:
848 if (s_arg[i_arg].n_items != 2 ||
849 !sscanf(s_arg[i_arg].list[1], "%d", &threads) || threads < 1)
851 break;
852 default:
853 snprintf(buffer, SDDS_MAXLINE, "unknown switch: %s", s_arg[i_arg].list[0]);
855 break;
856 }
857 } else {
858 if (inputfile == NULL)
859 inputfile = s_arg[i_arg].list[0];
860 else if (outputfile == NULL)
861 outputfile = s_arg[i_arg].list[0];
862 else {
863 fprintf(stderr, "argument %s is invalid: too many filenames (sddsprocess)\n", s_arg[i_arg].list[0]);
864 exit(EXIT_FAILURE);
865 }
866 }
867 }
868
869 processFilenames(
"sddsprocess", &inputfile, &outputfile, pipeFlags, nowarnings, &tmpfile_used);
870
871 if (rpn_definitions_files) {
872 rpn(rpn_definitions_file[0]);
873 if (rpn_check_error())
874 exit(EXIT_FAILURE);
875 for (i = 1; i < rpn_definitions_files; i++) {
876 sprintf(s, "\"%s,s\" @", rpn_definitions_file[i]);
877 rpn(s);
878 if (rpn_check_error())
879 exit(EXIT_FAILURE);
880 }
881 } else {
882 rpn(getenv("RPN_DEFNS"));
883 if (rpn_check_error())
884 exit(EXIT_FAILURE);
885 }
886 i_page_memory = rpn_create_mem("i_page", 0);
887 table_number_memory = rpn_create_mem("table_number", 0);
888 n_rows_memory = rpn_create_mem("n_rows", 0);
889
892 exit(EXIT_FAILURE);
893 }
894 if (!check_ifitems(&SDDS_input, &ifnot_item, 0, !nowarnings) ||
895 !check_ifitems(&SDDS_input, &ifis_item, 1, !nowarnings))
896 exit(EXIT_SUCCESS);
897 original_parameters = SDDS_input.layout.n_parameters;
898
899 if (!description_text)
901 if (!
SDDS_InitializeOutput(&SDDS_output, SDDS_input.layout.data_mode.mode, 1, description_text, description_contents, outputfile)) {
903 exit(EXIT_FAILURE);
904 }
905 if (columnMajorOrder != -1)
906 SDDS_output.layout.data_mode.column_major = columnMajorOrder;
907 else
908 SDDS_output.layout.data_mode.column_major = SDDS_input.layout.data_mode.column_major;
910
911#ifdef DEBUG
912 fprintf(stderr, "Getting column, parameter, and array names from input file.\n");
913#endif
916 exit(EXIT_FAILURE);
917 }
918 if (orig_column_names && !(new_column_name = process_name_options(orig_column_name, &orig_column_flag, orig_column_names, delete_column, delete_columns, retain_column, retain_columns, rename_column, rename_columns, edit_column_request, edit_column_requests)))
919 exit(EXIT_FAILURE);
920
923 exit(EXIT_FAILURE);
924 }
925
926#ifdef DEBUG
927 fprintf(stderr, "processing name options\n");
928#endif
929 if (orig_parameter_names && !(new_parameter_name = process_name_options(orig_parameter_name, &orig_parameter_flag, orig_parameter_names, delete_parameter, delete_parameters, retain_parameter, retain_parameters, rename_parameter, rename_parameters, edit_parameter_request, edit_parameter_requests)))
930 exit(EXIT_FAILURE);
931
934 exit(EXIT_FAILURE);
935 }
936 if (orig_array_names && !(new_array_name = process_name_options(orig_array_name, &orig_array_flag, orig_array_names, delete_array, delete_arrays, retain_array, retain_arrays, rename_array, rename_arrays, edit_array_request, edit_array_requests)))
937 exit(EXIT_FAILURE);
938
939#ifdef DEBUG
940 for (i = 0; i < orig_parameter_names; i++) {
941 fprintf(stderr, "parameter %s goes to %s\n", orig_parameter_name[i], orig_parameter_flag[i] ? new_parameter_name[i] : "<deleted>");
942 }
943 for (i = 0; i < orig_array_names; i++) {
944 fprintf(stderr, "array %s goes to %s\n", orig_array_name[i], orig_array_flag[i] ? new_array_name[i] : "<deleted>");
945 }
946 for (i = 0; i < orig_column_names; i++) {
947 fprintf(stderr, "column %s goes to %s\n", orig_column_name[i], orig_column_flag[i] ? new_column_name[i] : "<deleted>");
948 }
949#endif
950
951#ifdef DEBUG
952 fprintf(stderr, "Transferring definitions to new file.\n");
953#endif
954 for (i = 0; i < orig_parameter_names; i++) {
955 if (orig_parameter_flag[i]) {
957 fprintf(stderr, "unable to transfer parameter %s to %s\n", orig_parameter_name[i], new_parameter_name[i]);
959 exit(EXIT_FAILURE);
960 }
961 }
962 }
963 for (i = 0; i < orig_array_names; i++) {
964 if (orig_array_flag[i]) {
966 fprintf(stderr, "unable to transfer array %s to %s\n", orig_array_name[i], new_array_name[i]);
968 exit(EXIT_FAILURE);
969 }
970 }
971 }
972 output_columns = 0;
973 for (i = 0; i < orig_column_names; i++) {
974 if (orig_column_flag[i]) {
975 output_columns++;
977 fprintf(stderr, "unable to transfer column %s to %s\n", orig_column_name[i], new_column_name[i]);
979 exit(EXIT_FAILURE);
980 }
981 }
982 }
983 for (i = 0; i < orig_column_names; i++) {
984 free(new_column_name[i]);
985 free(orig_column_name[i]);
986 }
987 free(new_column_name);
988 free(orig_column_name);
989
990 expandDefinitions(&definition, &definitions, &SDDS_output);
991
992 for (i = 0; i < definitions; i++) {
993 switch (definition[i].type) {
994 case IS_EQUATION_DEFINITION:
996 sprintf(s, "%sUDF%ld", equation_ptr->name, udfCounter++);
999 SDDS_Bomb(
"string copying failed (making udf name)");
1000 if (equation_ptr->equation[0] == '@') {
1001 if (equation_ptr->equation[1] == '@') {
1002
1006 fprintf(stderr, "Error (sddsprocess): parameter %s does not exist or is not string type\n", equation_ptr->equation + 2);
1007 exit(EXIT_FAILURE);
1008 }
1009 } else {
1013 fprintf(stderr, "Error (sddsprocess): parameter %s does not exist or is not string type\n", equation_ptr->equation + 1);
1014 exit(EXIT_FAILURE);
1015 }
1016 }
1017 } else {
1018 if (strstr(equation_ptr->equation, "xstr") == NULL)
1019 create_udf(equation_ptr->udf_name, equation_ptr->equation);
1020 else
1021
1022 equation_ptr->udf_name = equation_ptr->equation;
1023 }
1024 if (equation_ptr->redefinition) {
1025 if (equation_ptr->is_parameter) {
1027 equation_ptr->redefinition = 0;
1029 equation_ptr->redefinition = 0;
1030 }
1031 if (equation_ptr->redefinition == 0) {
1032 if (equation_ptr->is_parameter) {
1035 fprintf(stderr, "Bad parameter string: %s\n", equation_ptr->text);
1036 exit(EXIT_FAILURE);
1037 }
1040 fprintf(stderr, "Bad column string: %s\n", equation_ptr->text);
1041 exit(EXIT_FAILURE);
1042 }
1043 } else {
1044 if (equation_ptr->is_parameter) {
1046 fprintf(stderr, "can't redefine parameter %s--non-numeric\n", equation_ptr->name);
1047 exit(EXIT_FAILURE);
1048 }
1049 if (equation_ptr->argc && !SDDS_RedefineParameterCL(&SDDS_output, equation_ptr->name, equation_ptr->argv, equation_ptr->argc)) {
1050 fprintf(stderr, "can't redefine parameter %s as requested\n", equation_ptr->name);
1051 exit(EXIT_FAILURE);
1052 }
1053 } else {
1055 fprintf(stderr, "can't redefine column %s--non-numeric\n", equation_ptr->name);
1056 exit(EXIT_FAILURE);
1057 }
1058 if (equation_ptr->argc && !SDDS_RedefineColumnCL(&SDDS_output, equation_ptr->name, equation_ptr->argv, equation_ptr->argc)) {
1059 fprintf(stderr, "can't redefine column %s as requested\n", equation_ptr->name);
1060 exit(EXIT_FAILURE);
1061 }
1062 }
1063 }
1064 break;
1065 case IS_EDIT_DEFINITION:
1068 if (index < 0)
1069 edit_ptr->reedit = 0;
1070 else if (!edit_ptr->reedit) {
1071 fprintf(stderr, "Can't define new -edit %s %s--already exists (sddsprocess)\n", edit_ptr->is_parameter ? "parameter" : "column", edit_ptr->new_name);
1072 exit(EXIT_FAILURE);
1073 }
1074 if (!edit_ptr->reedit) {
1075 if (!(edit_ptr->is_parameter ? SDDS_ProcessParameterString(&SDDS_output, edit_ptr->text, SDDS_WRITEONLY_DEFINITION) : SDDS_ProcessColumnString(&SDDS_output, edit_ptr->text, SDDS_WRITEONLY_DEFINITION))) {
1076 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors);
1077 exit(EXIT_FAILURE);
1078 }
1079 } else {
1081 fprintf(stderr, "Can't reedit %s %s--not string type (sddsprocess)\n", edit_ptr->is_parameter ? "parameter" : "column", edit_ptr->new_name);
1082 exit(EXIT_FAILURE);
1083 }
1084 if (edit_ptr->argc && !(edit_ptr->is_parameter ? SDDS_RedefineParameterCL(&SDDS_output, edit_ptr->new_name, edit_ptr->argv, edit_ptr->argc) : SDDS_RedefineColumnCL(&SDDS_output, edit_ptr->new_name, edit_ptr->argv, edit_ptr->argc))) {
1085 fprintf(stderr, "Can't reedit %s %s as requested (sddsprocess)\n", edit_ptr->is_parameter ? "parameter" : "column", edit_ptr->new_name);
1086 exit(EXIT_FAILURE);
1087 }
1088 }
1089 break;
1090 case IS_SCAN_DEFINITION:
1092 if (scan_ptr->is_parameter) {
1095 exit(EXIT_FAILURE);
1096 }
1099 exit(EXIT_FAILURE);
1100 }
1101 break;
1102 case IS_PRINT_DEFINITION:
1105 if (index < 0)
1106 print_ptr->reprint = 0;
1107 else if (!print_ptr->reprint) {
1108 fprintf(stderr, "Can't define new -print %s %s--already exists (sddsprocess)\n", print_ptr->is_parameter ? "parameter" : "column", print_ptr->new_name);
1109 exit(EXIT_FAILURE);
1110 }
1111 if (!print_ptr->reprint) {
1112 if (!(print_ptr->is_parameter ? SDDS_ProcessParameterString(&SDDS_output, print_ptr->text, SDDS_WRITEONLY_DEFINITION) : SDDS_ProcessColumnString(&SDDS_output, print_ptr->text, SDDS_WRITEONLY_DEFINITION))) {
1113 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors);
1114 exit(EXIT_FAILURE);
1115 }
1116 } else {
1118 fprintf(stderr, "Can't reprint %s %s--not string type (sddsprocess)\n", print_ptr->is_parameter ? "parameter" : "column", print_ptr->new_name);
1119 exit(EXIT_FAILURE);
1120 }
1121 }
1122 break;
1123 case IS_PROCESSING_DEFINITION:
1125 if (!complete_processing_definitions(&processing_ptr, 1, &SDDS_output)) {
1126 fprintf(stderr, "error: problem completing processing definition\n");
1129 exit(EXIT_FAILURE);
1130 }
1131 break;
1132 case IS_CONVERSION_DEFINITION:
1134 if (conversion_ptr->is_parameter) {
1136 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors | SDDS_EXIT_PrintErrors);
1138 exit(EXIT_FAILURE);
1142 else
1143 fprintf(stderr, "error: unknown error processing conversion for parameter %s\n", conversion_ptr->name);
1144 exit(EXIT_FAILURE);
1145 }
1146 } else {
1148 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors | SDDS_EXIT_PrintErrors);
1150 exit(EXIT_FAILURE);
1154 else
1155 fprintf(stderr, "error: unknown error processing conversion for column %s\n", conversion_ptr->name);
1156 exit(EXIT_FAILURE);
1157 }
1158 }
1159 break;
1160 case IS_SYSTEM_DEFINITION:
1162 if (system_ptr->is_parameter) {
1165 exit(EXIT_FAILURE);
1166 }
1169 exit(EXIT_FAILURE);
1170 }
1171 break;
1172 case IS_FORMAT_DEFINITION:
1174 if (strcmp(format_ptr->source, format_ptr->target)) {
1175 if (format_ptr->is_parameter) {
1178 exit(EXIT_FAILURE);
1179 }
1181 fprintf(stderr, "Problem setting up to format %s from %s\n", format_ptr->target, format_ptr->source);
1183 exit(EXIT_FAILURE);
1184 }
1185 }
1186 break;
1187 case IS_EVALUATE_DEFINITION:
1190 if (index >= 0) {
1191 fprintf(stderr, "Can't define new -evaluate %s %s--already exists (sddsprocess)\n", evaluate_ptr->is_parameter ? "parameter" : "column", evaluate_ptr->name);
1192 exit(EXIT_FAILURE);
1193 }
1195 fprintf(stderr, "Can't evaluate %s %s--doesn't exist (sddsprocess)\n", evaluate_ptr->is_parameter ? "parameter" : "column", evaluate_ptr->source);
1196 exit(EXIT_FAILURE);
1197 }
1199 fprintf(stderr, "Can't evaluate %s %s--not string type (sddsprocess)\n", evaluate_ptr->is_parameter ? "parameter" : "column", evaluate_ptr->source);
1200 exit(EXIT_FAILURE);
1201 }
1203 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors);
1204 exit(EXIT_FAILURE);
1205 }
1206 break;
1207 case IS_FILTER_DEFINITION:
1208 case IS_MATCH_DEFINITION:
1209 case IS_RPNTEST_DEFINITION:
1210 case IS_RPNEXPRESSION_DEFINITION:
1211 case IS_CLIP_DEFINITION:
1212 case IS_FCLIP_DEFINITION:
1213 case IS_SPARSE_DEFINITION:
1214 case IS_SAMPLE_DEFINITION:
1215 case IS_NUMBERTEST_DEFINITION:
1216 case IS_TIME_FILTER_DEFINITION:
1217 break;
1218 case IS_CAST_DEFINITION:
1219 if (!complete_cast_definition(&SDDS_output, (
CAST_DEFINITION *)definition[i].structure, &SDDS_input)) {
1221 exit(EXIT_FAILURE);
1222 }
1223 break;
1224 default:
1225 fprintf(stderr, "error: unknown definition type code %ld seen--this shouldn't happen!\n", definition[i].type);
1226 exit(EXIT_FAILURE);
1227 break;
1228 }
1229 }
1230
1233 exit(EXIT_FAILURE);
1234 }
1235
1238 exit(EXIT_FAILURE);
1239 }
1240
1241 if (summarize) {
1242 for (i = 0; i < definitions; i++) {
1243 switch (definition[i].type) {
1244 case IS_EQUATION_DEFINITION:
1246 fprintf(stderr, "%s %s created from equation %s:\n %s\n", equation_ptr->is_parameter ? "parameter" : "column", equation_ptr->name, equation_ptr->equation, equation_ptr->text);
1247 break;
1248 case IS_EVALUATE_DEFINITION:
1250 fprintf(stderr, "evaluating to %s %s from %s\n", evaluate_ptr->is_parameter ? "parameter" : "column", evaluate_ptr->name, evaluate_ptr->source);
1251 break;
1252 case IS_EDIT_DEFINITION:
1254 fprintf(stderr, "%s %s edit from %s using %s:\n %s\n", edit_ptr->is_parameter ? "parameter" : "column", edit_ptr->new_name, edit_ptr->source, edit_ptr->edit_command, edit_ptr->text);
1255 break;
1256 case IS_SCAN_DEFINITION:
1258 fprintf(stderr, "%s %s scanned from %s using %s:\n %s\n", scan_ptr->is_parameter ? "parameter" : "column", scan_ptr->new_name, scan_ptr->source, scan_ptr->sscanf_string, scan_ptr->text);
1259 break;
1260 case IS_PRINT_DEFINITION:
1262 fprintf(stderr, "printing to %s %s from ", print_ptr->is_parameter ? "parameter" : "column", print_ptr->new_name);
1263 for (j = 0; j < print_ptr->sources; j++)
1264 fprintf(stderr, "%s ", print_ptr->source[j]);
1265 fprintf(stderr, ":\n %s\n", print_ptr->text);
1266 break;
1267 case IS_PROCESSING_DEFINITION:
1269 fprintf(stderr, "column %s will be processed to give %s in parameter %s\n", processing_ptr->column_name, processing_ptr->description, processing_ptr->parameter_name);
1270 break;
1271 case IS_CONVERSION_DEFINITION:
1273 fprintf(stderr, "%s %s will be converted to %s using factor %e\n", conversion_ptr->is_parameter ? "parameter" : "column", conversion_ptr->name, conversion_ptr->new_units, conversion_ptr->factor);
1274 break;
1275 case IS_FILTER_DEFINITION:
1277 show_filters(filter_ptr->is_parameter ? "parameter" : "column", filter_ptr->filter_term, filter_ptr->filter_terms);
1278 break;
1279 case IS_TIME_FILTER_DEFINITION:
1281 fprintf(stderr, "Time filter: <%s> %22.15e, %22.15e\n", time_filter_ptr->name, time_filter_ptr->before, time_filter_ptr->after);
1282 case IS_MATCH_DEFINITION:
1284 show_matches(match_ptr->is_parameter ? "parameter" : "column", match_ptr->match_term, match_ptr->match_terms);
1285 break;
1286 case IS_RPNTEST_DEFINITION:
1288 if (rpntest_ptr->autostop)
1289 fprintf(stderr, "%s-based autostop rpn test:\n %s\n", rpntest_ptr->is_parameter ? "parameter" : "column", rpntest_ptr->expression);
1290 else
1291 fprintf(stderr, "%s-based rpn test:\n %s\n", rpntest_ptr->is_parameter ? "parameter" : "column", rpntest_ptr->expression);
1292 break;
1293 case IS_NUMBERTEST_DEFINITION:
1295 fprintf(stderr, "%s-based number test:\n %s %s%s\n", numbertest_ptr->is_parameter ? "parameter" : "column", numbertest_ptr->name, numbertest_ptr->flags & NUMSCANFILTER_INVERT ? " inverted" : "", numbertest_ptr->flags & NUMSCANFILTER_STRICT ? " strict" : "");
1296 break;
1297 case IS_RPNEXPRESSION_DEFINITION:
1299 fprintf(stderr, "%srepeated rpn expression:\n %s\n", (rpnexpression_ptr->repeat ? "" : "un"), rpnexpression_ptr->expression);
1300 break;
1301 case IS_SYSTEM_DEFINITION:
1303 fprintf(stderr, "%s %s system-call from %s:\n %s\n", system_ptr->is_parameter ? "parameter" : "column", system_ptr->new_name, system_ptr->source, system_ptr->text);
1304 break;
1305 case IS_FORMAT_DEFINITION:
1307 fprintf(stderr, "formating %s %s from %s using ", format_ptr->is_parameter ? "parameter" : "column", format_ptr->target, format_ptr->source);
1308 fprintf(stderr, "string: %s double: %s long: %s\n", format_ptr->stringFormat ? format_ptr->stringFormat : "<none>", format_ptr->doubleFormat ? format_ptr->doubleFormat : "<none>", format_ptr->longFormat ? format_ptr->longFormat : "<none>");
1309 break;
1310 case IS_CLIP_DEFINITION:
1312 fprintf(stderr, "page clip operation:\n head = %" PRId64 " tail = %" PRId64 " invert = %hd\n", clip_ptr->head, clip_ptr->tail, clip_ptr->invert);
1313 break;
1314 case IS_FCLIP_DEFINITION:
1316 fprintf(stderr, "page clip operation:\n head = %f tail = %f invert = %hd\n", fclip_ptr->fhead, fclip_ptr->ftail, fclip_ptr->invert);
1317 break;
1318 case IS_SPARSE_DEFINITION:
1320 fprintf(stderr, "page sparse operation:\n interval = %" PRId64 " offset = %" PRId64 "\n", sparse_ptr->interval, sparse_ptr->offset);
1321 break;
1322 case IS_SAMPLE_DEFINITION:
1324 fprintf(stderr, "page sample operation:\n fraction = %.8g\n", sample_ptr->fraction);
1325 break;
1326 case IS_CAST_DEFINITION:
1328 fprintf(stderr, "%s %s cast from %s to type %s\n", cast_ptr->isParameter ? "parameter" : "column", cast_ptr->newName, cast_ptr->source, cast_ptr->newTypeName);
1329 break;
1330 default:
1331 fprintf(stderr, "error: unknown definition type code %ld seen--this shouldn't happen!\n", definition[i].type);
1332 exit(EXIT_FAILURE);
1333 break;
1334 }
1335 }
1336 }
1337
1341 exit(EXIT_FAILURE);
1342 }
1345 exit(EXIT_FAILURE);
1346 }
1348 if (!nowarnings)
1349 fprintf(stderr, "warning: no rows selected for page %" PRId32 "\n", SDDS_output.page_number);
1350 if (n_rows == 0)
1352 else
1353 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors | SDDS_EXIT_PrintErrors);
1354 }
1355 if (verbose) {
1356 fprintf(stderr, "page number %ld read in, with %" PRId64 " rows of data\n", page_number, n_rows);
1357 for (i = 0; i < original_parameters; i++) {
1358 SDDS_PrintTypedValue(SDDS_output.parameter[i], 0, SDDS_output.layout.parameter_definition[i].type, NULL, stderr, 0);
1359 fputc('\n', stderr);
1360 }
1361 }
1362 rpn_store((double)page_number, NULL, table_number_memory);
1363 rpn_store((double)page_number, NULL, i_page_memory);
1364 row_deletion = skip_page = 0;
1365 i = -1;
1366 while (++i < definitions && !skip_page) {
1367 rpn_store((double)n_rows, NULL, n_rows_memory);
1368 switch (definition[i].type) {
1369 case IS_CONVERSION_DEFINITION:
1371 if (conversion_ptr->is_parameter) {
1374 exit(EXIT_FAILURE);
1375 }
1378 exit(EXIT_FAILURE);
1379 }
1380 if (verbose)
1381 fprintf(stderr, "conversion done: %s %s from %s to %s using factor %e\n", conversion_ptr->is_parameter ? "parameter" : "column", conversion_ptr->name, conversion_ptr->old_units, conversion_ptr->new_units, conversion_ptr->factor);
1382 break;
1383 case IS_PROCESSING_DEFINITION:
1386 if (!process_column(&SDDS_output, processing_ptr, &result, &stringResult, !nowarnings, threads))
1387 exit(EXIT_FAILURE);
1389 if (!
SDDS_SetParameters(&SDDS_output, SDDS_SET_BY_NAME | SDDS_PASS_BY_VALUE, processing_ptr->parameter_name, result, NULL)) {
1391 exit(EXIT_FAILURE);
1392 }
1393 rpn_store(result, NULL, processing_ptr->memory_number);
1394 if (verbose)
1395 fprintf(stderr, "processing result: %s = %e\n", processing_ptr->parameter_name, result);
1396 } else {
1397 if (!
SDDS_SetParameters(&SDDS_output, SDDS_SET_BY_NAME | SDDS_PASS_BY_VALUE, processing_ptr->parameter_name, stringResult, NULL)) {
1399 exit(EXIT_FAILURE);
1400 }
1401 if (verbose)
1402 fprintf(stderr, "processing result: %s = %s\n", processing_ptr->parameter_name, stringResult);
1403 free(stringResult);
1404 }
1405 } else {
1406 if (!(stringResult = process_string_column(&SDDS_output, processing_ptr, !nowarnings)) ||
1407 !
SDDS_SetParameters(&SDDS_output, SDDS_SET_BY_NAME | SDDS_PASS_BY_VALUE, processing_ptr->parameter_name, stringResult, NULL)) {
1409 exit(EXIT_FAILURE);
1410 }
1411 free(stringResult);
1412 }
1413 break;
1414 case IS_EDIT_DEFINITION:
1416 if (edit_ptr->is_parameter) {
1417 if (!edit_parameter_value(&SDDS_output, edit_ptr->new_name, edit_ptr->source, edit_ptr->edit_command)) {
1418 fprintf(stderr, "couldn't edit %s to make %s\n", edit_ptr->source, edit_ptr->new_name);
1419 exit(EXIT_FAILURE);
1420 }
1421 } else if (n_rows && !edit_column_value(&SDDS_output, edit_ptr->new_name, edit_ptr->source, edit_ptr->edit_command)) {
1422 fprintf(stderr, "couldn't edit %s to make %s\n", edit_ptr->source, edit_ptr->new_name);
1423 exit(EXIT_FAILURE);
1424 }
1425 if (verbose)
1426 fprintf(stderr, "edited %s %s to produce %s, using edit-command %s\n", edit_ptr->is_parameter ? "parameter" : "column", edit_ptr->source, edit_ptr->new_name, edit_ptr->edit_command);
1427 break;
1428 case IS_SCAN_DEFINITION:
1430 if (scan_ptr->is_parameter) {
1431 if (!scan_parameter_value(&SDDS_output, scan_ptr->new_name, scan_ptr->source, scan_ptr->sscanf_string, scan_ptr->edit)) {
1432 fprintf(stderr, "couldn't scan %s to make %s\n", scan_ptr->source, scan_ptr->new_name);
1433 exit(EXIT_FAILURE);
1434 }
1435 } else if (n_rows && !scan_column_value(&SDDS_output, scan_ptr->new_name, scan_ptr->source, scan_ptr->sscanf_string, scan_ptr->edit)) {
1436 fprintf(stderr, "couldn't scan %s to make %s\n", scan_ptr->source, scan_ptr->new_name);
1437 exit(EXIT_FAILURE);
1438 }
1439 if (verbose)
1440 fprintf(stderr, "scanned %s %s to produce %s, using sscanf string %s\n", scan_ptr->is_parameter ? "parameter" : "column", scan_ptr->source, scan_ptr->new_name, scan_ptr->sscanf_string);
1441 break;
1442 case IS_PRINT_DEFINITION:
1444 if (print_ptr->is_parameter) {
1445 if (!print_parameter_value(&SDDS_output, print_ptr->new_name, print_ptr->source, print_ptr->sources, print_ptr->printf_string)) {
1446 fprintf(stderr, "couldn't print to make parameter %s\n", print_ptr->new_name);
1447 exit(EXIT_FAILURE);
1448 }
1449 } else if (n_rows && !print_column_value(&SDDS_output, print_ptr->new_name, print_ptr->source, print_ptr->sources, print_ptr->printf_string)) {
1450 fprintf(stderr, "couldn't print to make column %s\n", print_ptr->new_name);
1451 exit(EXIT_FAILURE);
1452 }
1453 break;
1454 case IS_EQUATION_DEFINITION:
1456 if (equation_ptr->is_parameter) {
1457 if (!SDDS_ComputeParameter(&SDDS_output,
SDDS_GetParameterIndex(&SDDS_output, equation_ptr->name), equation_ptr->udf_name)) {
1459 exit(EXIT_FAILURE);
1460 }
1461 } else if (n_rows) {
1462 k = i++;
1463 while (i < definitions && definition[i].type == IS_EQUATION_DEFINITION) {
1465 if (equation_ptr->is_parameter)
1466 break;
1467 else
1468 i++;
1469 }
1470 if (!SDDS_ComputeSetOfColumns(&SDDS_output, k, i, definition)) {
1472 exit(EXIT_FAILURE);
1473 }
1474 i--;
1475 }
1476 if (verbose)
1477 fprintf(stderr, "computed %s %s using expression %s\n", equation_ptr->is_parameter ? "parameter" : "column", equation_ptr->name, equation_ptr->equation);
1478 break;
1479 case IS_EVALUATE_DEFINITION:
1481 if (evaluate_ptr->is_parameter) {
1482 if (!SDDS_EvaluateParameter(&SDDS_output, evaluate_ptr)) {
1484 exit(EXIT_FAILURE);
1485 }
1486 } else if (n_rows) {
1487 if (!SDDS_EvaluateColumn(&SDDS_output, evaluate_ptr)) {
1489 exit(EXIT_FAILURE);
1490 }
1491 }
1492 if (verbose)
1493 fprintf(stderr, "computed %s %s using expressions from %s\n", evaluate_ptr->is_parameter ? "parameter" : "column", evaluate_ptr->name, evaluate_ptr->source);
1494 break;
1495 case IS_FORMAT_DEFINITION:
1497 if (format_ptr->is_parameter) {
1498 if (!format_parameter_value(&SDDS_output, format_ptr)) {
1499 fprintf(stderr, "couldn't format parameter %s\n", format_ptr->target);
1500 exit(EXIT_FAILURE);
1501 }
1502 } else if (n_rows && !format_column_value(&SDDS_output, format_ptr)) {
1503 fprintf(stderr, "couldn't format column %s\n", format_ptr->target);
1504 exit(EXIT_FAILURE);
1505 }
1506 if (verbose)
1507 fprintf(stderr, "formatted %s %s\n", format_ptr->is_parameter ? "parameter" : "column", format_ptr->target);
1508 break;
1509 case IS_TIME_FILTER_DEFINITION:
1511 if (time_filter_ptr->is_parameter) {
1514 fprintf(stderr, "error: unknown or non-numeric parameter %s given for time filter\n", time_filter_ptr->name);
1515 exit(EXIT_FAILURE);
1516 }
1518
1519 if (!accept)
1520 skip_page = 1;
1521 if (time_filter_ptr->flags & TIMEFILTER_INVERT_GIVEN)
1522 skip_page = !skip_page;
1523 if (skip_page) {
1524 if (verbose)
1525 fputs(" * page outside parameter filter--continuing to next page", stderr);
1526 continue;
1527 }
1528 } else if (n_rows) {
1529 int64_t nleft;
1530 if (verbose) {
1531 fprintf(stderr, " * applying time filter (column %s)", time_filter_ptr->name);
1532 fflush(stderr);
1533 }
1534 if ((nleft =
SDDS_FilterRowsOfInterest(&SDDS_output, time_filter_ptr->name, time_filter_ptr->after, time_filter_ptr->before, time_filter_ptr->flags & TIMEFILTER_INVERT_GIVEN ? SDDS_NEGATE_EXPRESSION : SDDS_AND)) < 0) {
1536 exit(EXIT_FAILURE);
1537 }
1538 if (verbose) {
1539 fprintf(stderr, "---%" PRId64 " rows left\n", nleft);
1540 fflush(stderr);
1541 }
1542 row_deletion = 1;
1543 }
1544 break;
1545 case IS_FILTER_DEFINITION:
1547 filter_term = filter_ptr->filter_term;
1548 for (j = 0; j < filter_ptr->filter_terms; j++) {
1549 if (filter_term[j].lowerPar && !
SDDS_GetParameterAsDouble(&SDDS_input, filter_term[j].lowerPar, &(filter_term[j].lower))) {
1550 fprintf(stderr, "Error: unable to get parameter %s value for the lower filter from input file.\n", filter_term[j].lowerPar);
1552 exit(EXIT_FAILURE);
1553 }
1554 if (filter_term[j].upperPar && !
SDDS_GetParameterAsDouble(&SDDS_input, filter_term[j].upperPar, &(filter_term[j].upper))) {
1555 fprintf(stderr, "Error: unable to get parameter %s value for the upper filter from input file.\n", filter_term[j].upperPar);
1557 exit(EXIT_FAILURE);
1558 }
1559 if (filter_term[j].upper < filter_term[j].lower) {
1560 fprintf(stderr, "Error: invalid %s filter provided.\n", filter_term[j].name);
1561 exit(EXIT_FAILURE);
1562 }
1563 }
1564 if (filter_ptr->is_parameter) {
1565 accept = 1;
1566 filter_term = filter_ptr->filter_term;
1567 for (j = 0; j < filter_ptr->filter_terms; j++) {
1570 fprintf(stderr, "error: unknown or non-numeric parameter %s given for filter\n", filter_term[j].name);
1571 exit(EXIT_FAILURE);
1572 }
1574 }
1575 if (!accept) {
1576 if (verbose)
1577 fputs(" * page failed parameter matching--continuing to next page", stderr);
1578 skip_page = 1;
1579 continue;
1580 }
1581 } else if (n_rows) {
1582 int64_t nleft;
1583 filter_term = filter_ptr->filter_term;
1584 for (j = 0; j < filter_ptr->filter_terms; j++) {
1585 if (verbose) {
1586 fprintf(stderr, " * applying filter term %" PRId64 " (column %s)", j, filter_term[j].name);
1587 fflush(stderr);
1588 }
1589 if ((nleft =
SDDS_FilterRowsOfInterest(&SDDS_output, filter_term[j].name, filter_term[j].lower, filter_term[j].upper, filter_term[j].logic)) < 0) {
1591 exit(EXIT_FAILURE);
1592 }
1593 if (verbose) {
1594 fprintf(stderr, "---%" PRId64 " rows left\n", nleft);
1595 fflush(stderr);
1596 }
1597 }
1598 row_deletion = 1;
1599 }
1600 if (verbose)
1601 fprintf(stderr, "applied %s filter\n", filter_ptr->is_parameter ? "parameter" : "column");
1602 break;
1603 case IS_MATCH_DEFINITION:
1605 if (match_ptr->is_parameter) {
1606 accept = 1;
1607 match_term = match_ptr->match_term;
1608 for (j = 0; j < match_ptr->match_terms; j++) {
1611 fprintf(stderr, "error: unknown or numeric parameter %s given for match\n", match_term[j].name);
1612 exit(EXIT_FAILURE);
1613 }
1615 char **ppc;
1617 strcpy(s, *ppc);
1618 } else {
1619 char *pc;
1621 sprintf(s, "%c", *pc);
1622 }
1623 accept =
SDDS_Logic(accept, (match_term[j].logic & SDDS_NOCASE_COMPARE ?
wild_match_ci(s, match_term[j].
string) :
wild_match(s, match_term[j].
string)), match_term[j].logic);
1624 }
1625 if (!accept) {
1626 if (verbose)
1627 fputs(" * page failed parameter matching--continuing to next page", stderr);
1628 skip_page = 1;
1629 continue;
1630 }
1631 } else if (n_rows) {
1632 match_term = match_ptr->match_term;
1633 for (j = 0; j < match_ptr->match_terms; j++)
1636 exit(EXIT_FAILURE);
1637 }
1638 row_deletion = 1;
1639 }
1640 if (verbose)
1641 fprintf(stderr, "applied %s match\n", match_ptr->is_parameter ? "parameter" : "column");
1642 break;
1643 case IS_RPNTEST_DEFINITION:
1645 SDDS_StoreParametersInRpnMemories(&SDDS_output);
1646 if (rpntest_ptr->is_parameter) {
1647 rpn_clear();
1648 rpn(rpntest_ptr->expression);
1649 if (rpn_check_error())
1650 exit(EXIT_FAILURE);
1651 if (!pop_log(&test_result))
1652 SDDS_Bomb(
"aborted due to rpn logical stack/result error for parameter-based test");
1653 rpn_clear();
1654 if (!test_result) {
1655 if (!rpntest_ptr->autostop) {
1656 if (verbose)
1657 fputs(" * page failed rpn test--continuing to next page", stderr);
1658 skip_page = 1;
1659 continue;
1660 } else {
1661 if (verbose)
1662 fputs(" * page failed rpn test--ignore remainder of file", stderr);
1663 exit(EXIT_FAILURE);
1664 }
1665 }
1666 } else if (n_rows) {
1667 if (!SDDS_FilterRowsWithRpnTest(&SDDS_output, rpntest_ptr->expression)) {
1669 exit(EXIT_FAILURE);
1670 }
1671 row_deletion = 1;
1672 }
1673 if (verbose)
1674 fprintf(stderr, "applied %s-based rpn test:\n %s\n", rpntest_ptr->is_parameter ? "parameter" : "column", rpntest_ptr->expression);
1675 break;
1676 case IS_NUMBERTEST_DEFINITION:
1678 if (numbertest_ptr->is_parameter) {
1679 skip_page = !ParameterScansAsNumber(&SDDS_output, numbertest_ptr->name, numbertest_ptr->flags & NUMSCANFILTER_INVERT);
1680 } else if (n_rows) {
1683 exit(EXIT_FAILURE);
1684 }
1685 row_deletion = 1;
1686 }
1687 if (verbose)
1688 fprintf(stderr, "applied %s-based %s%snumber test\n", numbertest_ptr->is_parameter ? "parameter" : "column", numbertest_ptr->flags & NUMSCANFILTER_INVERT ? " inverted " : "", numbertest_ptr->flags & NUMSCANFILTER_STRICT ? " strict " : "");
1689 break;
1690 case IS_SYSTEM_DEFINITION:
1692 if (system_ptr->is_parameter) {
1693 if (!system_parameter_value(&SDDS_output, system_ptr->new_name, system_ptr->source)) {
1694 fprintf(stderr, "couldn't system %s to make %s\n", system_ptr->source, system_ptr->new_name);
1696 exit(EXIT_FAILURE);
1697 }
1698 } else if (n_rows && !system_column_value(&SDDS_output, system_ptr->new_name, system_ptr->source)) {
1699 fprintf(stderr, "couldn't system %s to make %s\n", system_ptr->source, system_ptr->new_name);
1701 exit(EXIT_FAILURE);
1702 }
1703 if (verbose)
1704 fprintf(stderr, "systemed %s %s to produce %s\n", system_ptr->is_parameter ? "parameter" : "column", system_ptr->source, system_ptr->new_name);
1705 break;
1706 case IS_RPNEXPRESSION_DEFINITION:
1708 if (rpnexpression_ptr->repeat == -1)
1709 continue;
1710 SDDS_StoreParametersInRpnMemories(&SDDS_output);
1711 SDDS_StoreColumnsInRpnArrays(&SDDS_output);
1712 rpn(rpnexpression_ptr->expression);
1713 if (rpn_check_error())
1714 exit(EXIT_FAILURE);
1715 rpn_clear();
1716 if (verbose)
1717 fprintf(stderr, "executed rpn expression:\n %s\n", rpnexpression_ptr->expression);
1718 if (!rpnexpression_ptr->repeat)
1719 rpnexpression_ptr->repeat = -1;
1720 break;
1721 case IS_CLIP_DEFINITION:
1722 if (n_rows) {
1725 (clip_ptr->head &&
1726 !
SDDS_AssertRowFlags(&SDDS_output, SDDS_INDEX_LIMITS, (int64_t)0, (int64_t)(clip_ptr->head - 1), clip_ptr->invert ? 1 : 0)) ||
1727 (n_rows >= clip_ptr->tail && clip_ptr->tail && !
SDDS_AssertRowFlags(&SDDS_output, SDDS_INDEX_LIMITS, (int64_t)(n_rows - clip_ptr->tail), (int64_t)(n_rows - 1), clip_ptr->invert ? 1 : 0))) {
1729 exit(EXIT_FAILURE);
1730 }
1731 row_deletion = 1;
1732 }
1733 break;
1734 case IS_FCLIP_DEFINITION:
1735 if (n_rows) {
1737 fclip_ptr->head = fclip_ptr->fhead * n_rows;
1738 fclip_ptr->tail = fclip_ptr->ftail * n_rows;
1740 (fclip_ptr->head &&
1741 !
SDDS_AssertRowFlags(&SDDS_output, SDDS_INDEX_LIMITS, (int64_t)0, (int64_t)(fclip_ptr->head - 1), fclip_ptr->invert ? 1 : 0)) ||
1742 (n_rows >= fclip_ptr->tail && fclip_ptr->tail && !
SDDS_AssertRowFlags(&SDDS_output, SDDS_INDEX_LIMITS, (int64_t)(n_rows - fclip_ptr->tail), (int64_t)(n_rows - 1), fclip_ptr->invert ? 1 : 0))) {
1744 exit(EXIT_FAILURE);
1745 }
1746 row_deletion = 1;
1747 }
1748 break;
1749 case IS_SPARSE_DEFINITION:
1750 if (n_rows) {
1751 int32_t *sparse_row_flag;
1753 sparse_row_flag =
tmalloc(
sizeof(*sparse_row_flag) * n_rows);
1754 for (j = 0; j < n_rows; j++)
1755 sparse_row_flag[j] = 0;
1756 for (j = sparse_ptr->offset; j < n_rows; j += sparse_ptr->interval)
1757 sparse_row_flag[j] = 1;
1760 exit(EXIT_FAILURE);
1761 }
1762 free(sparse_row_flag);
1763 row_deletion = 1;
1764 }
1765 break;
1766 case IS_SAMPLE_DEFINITION:
1767 if (n_rows) {
1768 int32_t *sample_row_flag;
1770 sample_row_flag =
tmalloc(
sizeof(*sample_row_flag) * n_rows);
1771 for (j = 0; j < n_rows; j++)
1772 sample_row_flag[j] =
random_1(1) < sample_ptr->fraction ? 1 : 0;
1775 exit(EXIT_FAILURE);
1776 }
1777 free(sample_row_flag);
1778 row_deletion = 1;
1779 }
1780 break;
1781 case IS_CAST_DEFINITION:
1783 if (cast_ptr->isParameter) {
1784 if (!cast_parameter_value(&SDDS_output, cast_ptr))
1785 exit(EXIT_FAILURE);
1786 } else if (n_rows && !cast_column_value(&SDDS_output, cast_ptr)) {
1787 exit(EXIT_FAILURE);
1788 }
1789 break;
1790 default:
1791 fprintf(stderr, "error: unknown definition type code %ld seen--this shouldn't happen!\n", definition[i].type);
1792 exit(EXIT_FAILURE);
1793 break;
1794 }
1795 if (n_rows && row_deletion) {
1798 exit(EXIT_FAILURE);
1799 }
1802 if (!nowarnings)
1803 fprintf(stderr, "warning: no rows selected for page %" PRId32 "\n", SDDS_output.page_number);
1806 continue;
1807 }
1808 if (verbose)
1809 fprintf(stderr, " %" PRId64 " rows left\n", n_rows);
1810 }
1811 }
1812 if (skip_page)
1813 continue;
1814 if (verbose)
1815 fprintf(stderr, " %" PRId64 " rows selected for output\n", n_rows);
1818 exit(EXIT_FAILURE);
1819 }
1820 }
1821
1822 if (page_number == 0) {
1823 fprintf(stderr, "Error: problem reading input file\n");
1825 exit(EXIT_FAILURE);
1826 }
1827
1830 exit(EXIT_FAILURE);
1831 }
1832
1834 exit(EXIT_FAILURE);
1836
1837 if (processing_definition)
1838 free_processing_definiton(processing_definition, processing_definitions);
1839 if (equation_definition)
1840 free_equation_definition(equation_definition, equation_definitions);
1841
1842 return EXIT_SUCCESS;
1843}
int32_t SDDS_CopyPage(SDDS_DATASET *SDDS_target, SDDS_DATASET *SDDS_source)
int32_t SDDS_SetParameters(SDDS_DATASET *SDDS_dataset, int32_t mode,...)
int32_t SDDS_ChangeParameterInformation(SDDS_DATASET *SDDS_dataset, char *field_name, void *memory, int32_t mode,...)
Modifies a specific field in a parameter definition within the SDDS dataset.
int32_t SDDS_ChangeColumnInformation(SDDS_DATASET *SDDS_dataset, char *field_name, void *memory, int32_t mode,...)
Modifies a specific field in a column definition within the SDDS dataset.
int32_t SDDS_InitializeOutput(SDDS_DATASET *SDDS_dataset, int32_t data_mode, int32_t lines_per_row, const char *description, const char *contents, const char *filename)
Initializes the SDDS output dataset.
int32_t SDDS_WritePage(SDDS_DATASET *SDDS_dataset)
Writes the current data table to the output file.
int32_t SDDS_WriteLayout(SDDS_DATASET *SDDS_dataset)
Writes the SDDS layout header to the output file.
int32_t SDDS_ProcessParameterString(SDDS_DATASET *SDDS_dataset, char *string, int32_t mode)
Process a parameter definition string.
int32_t SDDS_ProcessColumnString(SDDS_DATASET *SDDS_dataset, char *string, int32_t mode)
Process a column definition string.
int32_t SDDS_TransferColumnDefinition(SDDS_DATASET *target, SDDS_DATASET *source, char *name, char *newName)
Transfers a column definition from a source dataset to a target dataset.
int32_t SDDS_TransferArrayDefinition(SDDS_DATASET *target, SDDS_DATASET *source, char *name, char *newName)
Transfers an array definition from a source dataset to a target dataset.
int32_t SDDS_TransferParameterDefinition(SDDS_DATASET *target, SDDS_DATASET *source, char *name, char *newName)
Transfers a parameter definition from a source dataset to a target dataset.
int32_t SDDS_GetParameterType(SDDS_DATASET *SDDS_dataset, int32_t index)
Retrieves the data type of a parameter in the SDDS dataset by its index.
PARAMETER_DEFINITION * SDDS_GetParameterDefinition(SDDS_DATASET *SDDS_dataset, char *name)
Retrieves the definition of a specified parameter from the SDDS dataset.
char ** SDDS_GetParameterNames(SDDS_DATASET *SDDS_dataset, int32_t *number)
Retrieves the names of all parameters in the SDDS dataset.
int32_t SDDS_GetParameterIndex(SDDS_DATASET *SDDS_dataset, char *name)
Retrieves the index of a named parameter in the SDDS dataset.
int32_t SDDS_GetColumnIndex(SDDS_DATASET *SDDS_dataset, char *name)
Retrieves the index of a named column in the SDDS dataset.
int32_t SDDS_ColumnCount(SDDS_DATASET *page)
Retrieves the number of columns in the SDDS dataset.
int32_t SDDS_CheckColumn(SDDS_DATASET *SDDS_dataset, char *name, char *units, int32_t type, FILE *fp_message)
Checks if a column exists in the SDDS dataset with the specified name, units, and type.
char ** SDDS_GetColumnNames(SDDS_DATASET *SDDS_dataset, int32_t *number)
Retrieves the names of all columns in the SDDS dataset.
void SDDS_PrintErrors(FILE *fp, int32_t mode)
Prints recorded error messages to a specified file stream.
int32_t SDDS_DeleteParameterFixedValues(SDDS_DATASET *SDDS_dataset)
Deletes fixed values from all parameters in the SDDS dataset.
void SDDS_ClearErrors()
Clears all recorded error messages from the SDDS error stack.
int32_t SDDS_ApplyFactorToColumn(SDDS_DATASET *SDDS_dataset, char *name, double factor)
Applies a scaling factor to all elements of a specific column in the SDDS dataset.
void SDDS_RegisterProgramName(const char *name)
Registers the executable program name for use in error messages.
int32_t SDDS_NumberOfErrors()
Retrieves the number of errors recorded by SDDS library routines.
int32_t SDDS_ApplyFactorToParameter(SDDS_DATASET *SDDS_dataset, char *name, double factor)
Applies a scaling factor to a specific parameter in the SDDS dataset.
int32_t SDDS_GetColumnType(SDDS_DATASET *SDDS_dataset, int32_t index)
Retrieves the data type of a column in the SDDS dataset by its index.
void SDDS_Bomb(char *message)
Terminates the program after printing an error message and recorded errors.
int32_t SDDS_CheckParameter(SDDS_DATASET *SDDS_dataset, char *name, char *units, int32_t type, FILE *fp_message)
Checks if a parameter exists in the SDDS dataset with the specified name, units, and type.
char ** SDDS_GetArrayNames(SDDS_DATASET *SDDS_dataset, int32_t *number)
Retrieves the names of all arrays in the SDDS dataset.
int32_t SDDS_CopyString(char **target, const char *source)
Copies a source string to a target string with memory allocation.
int32_t SDDS_PrintTypedValue(void *data, int64_t index, int32_t type, char *format, FILE *fp, uint32_t mode)
Prints a data value of a specified type using an optional printf format string.
#define SDDS_STRING
Identifier for the string data type.
void * trealloc(void *old_ptr, uint64_t size_of_block)
Reallocates a memory block to a new size.
void * tmalloc(uint64_t size_of_block)
Allocates a memory block of the specified size with zero initialization.
char * delete_chars(char *s, char *t)
Removes all occurrences of characters found in string t from string s.
double random_1(long iseed)
Generate a uniform random double in [0,1] using a custom seed initialization.
long fexists(const char *filename)
Checks if a file exists.
long match_string(char *string, char **option, long n_options, long mode)
Matches a given string against an array of option strings based on specified modes.
long replaceFileAndBackUp(char *file, char *replacement)
Replaces a file with a replacement file and creates a backup of the original.
int scanargs(SCANNED_ARG **scanned, int argc, char **argv)
long processPipeOption(char **item, long items, unsigned long *flags)
void processFilenames(char *programName, char **input, char **output, unsigned long pipeFlags, long noWarnings, long *tmpOutputUsed)
void free_scanargs(SCANNED_ARG **scanned, int argc)
long scanItemList(unsigned long *flags, char **item, long *items, unsigned long mode,...)
Scans a list of items and assigns values based on provided keywords and types.
int wild_match_ci(char *string, char *template)
Determine whether one string is a case-insensitive wildcard match for another.
int wild_match(char *string, char *template)
Determine whether one string is a wildcard match for another.