Changeset 88
- Timestamp:
- 03/06/07 20:35:18 (18 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Makefile
r81 r88 11 11 12 12 CC=gcc 13 OPTS=-std=gnu89 -pedantic -Wall -ggdb13 OPTS=-std=gnu89 -pedantic -Wall 14 14 INC=-I/usr/local/include 15 15 LIB=-L/usr/local/lib 16 16 17 17 UNAME := $(shell uname) 18 if eq ($(UNAME),FreeBSD)18 ifneq ($(UNAME),Linux) 19 19 LIB:=$(LIB) -liconv 20 20 endif -
trunk/src/reglookup.c
r85 r88 24 24 25 25 #include <stdlib.h> 26 #include <sysexits.h> 26 27 #include <stdio.h> 27 28 #include <string.h> … … 409 410 copy = (char*)malloc((next-cur+1)*sizeof(char)); 410 411 if(copy == NULL) 411 bailOut( 2, "ERROR: Memory allocation problem.\n");412 bailOut(EX_OSERR, "ERROR: Memory allocation problem.\n"); 412 413 413 414 memcpy(copy, cur, next-cur); … … 417 418 ret_val[ret_cur] = NULL; 418 419 else 419 bailOut( 2, "ERROR: Registry maximum depth exceeded.\n");420 bailOut(EX_DATAERR, "ERROR: Registry maximum depth exceeded.\n"); 420 421 } 421 422 cur = next+1; … … 430 431 ret_val[ret_cur] = NULL; 431 432 else 432 bailOut( 2, "ERROR: Registry maximum depth exceeded.\n");433 bailOut(EX_DATAERR, "ERROR: Registry maximum depth exceeded.\n"); 433 434 } 434 435 … … 575 576 */ 576 577 quoted_name = quote_string(vk->valuename, common_special_chars); 578 if (quoted_name == NULL) 579 { 580 quoted_name = malloc(1*sizeof(char)); 581 if(quoted_name == NULL) 582 bailOut(EX_OSERR, "ERROR: Could not allocate sufficient memory.\n"); 583 quoted_name[0] = '\0'; 584 } 577 585 578 586 if(quoted_value == NULL) … … 693 701 694 702 if(root == NULL) 695 bailOut( 3, "ERROR: root cannot be NULL.\n");703 bailOut(EX_DATAERR, "ERROR: root cannot be NULL.\n"); 696 704 697 705 do … … 701 709 path = iter2Path(iter); 702 710 if(path == NULL) 703 bailOut( 2, "ERROR: Could not construct iterator's path.\n");711 bailOut(EX_OSERR, "ERROR: Could not construct iterator's path.\n"); 704 712 705 713 if(!type_filter_enabled || (key_type == type_filter)) … … 717 725 /* We're done with this sub-tree, going up and hitting other branches. */ 718 726 if(!regfi_iterator_up(iter)) 719 bailOut( 3, "ERROR: could not traverse iterator upward.\n");727 bailOut(EX_DATAERR, "ERROR: could not traverse iterator upward.\n"); 720 728 721 729 cur = regfi_iterator_cur_key(iter); 722 730 if(cur == NULL) 723 bailOut( 3, "ERROR: unexpected NULL for key.\n");731 bailOut(EX_DATAERR, "ERROR: unexpected NULL for key.\n"); 724 732 725 733 sub = regfi_iterator_next_subkey(iter); … … 732 740 */ 733 741 if(!regfi_iterator_down(iter)) 734 bailOut( 3, "ERROR: could not traverse iterator downward.\n");742 bailOut(EX_DATAERR, "ERROR: could not traverse iterator downward.\n"); 735 743 736 744 cur = sub; … … 802 810 803 811 if((value == NULL) || (tmp_path_joined == NULL)) 804 bailOut( 2, "ERROR: Unexpected error before printValue.\n");812 bailOut(EX_OSERR, "ERROR: Unexpected error before printValue.\n"); 805 813 806 814 printValue(value, tmp_path_joined); … … 816 824 817 825 if(!regfi_iterator_down(iter)) 818 bailOut( 2, "ERROR: Unexpected error on traversing path filter key.\n");826 bailOut(EX_DATAERR, "ERROR: Unexpected error on traversing path filter key.\n"); 819 827 820 828 return 2; … … 858 866 { 859 867 usage(); 860 bailOut( 1, "ERROR: Requires at least one argument.\n");868 bailOut(EX_USAGE, "ERROR: Requires at least one argument.\n"); 861 869 } 862 870 … … 869 877 { 870 878 usage(); 871 bailOut( 1, "ERROR: '-p' option requires parameter.\n");879 bailOut(EX_USAGE, "ERROR: '-p' option requires parameter.\n"); 872 880 } 873 881 if((path_filter = strdup(argv[argi])) == NULL) 874 bailOut( 2, "ERROR: Memory allocation problem.\n");882 bailOut(EX_OSERR, "ERROR: Memory allocation problem.\n"); 875 883 876 884 path_filter_enabled = true; … … 881 889 { 882 890 usage(); 883 bailOut( 1, "ERROR: '-t' option requires parameter.\n");891 bailOut(EX_USAGE, "ERROR: '-t' option requires parameter.\n"); 884 892 } 885 893 if((type_filter = regfi_type_str2val(argv[argi])) < 0) 886 894 { 887 895 fprintf(stderr, "ERROR: Invalid type specified: %s.\n", argv[argi]); 888 bailOut( 1, "");896 bailOut(EX_USAGE, ""); 889 897 } 890 898 type_filter_enabled = true; … … 904 912 usage(); 905 913 fprintf(stderr, "ERROR: Unrecognized option: %s\n", argv[argi]); 906 bailOut( 1, "");914 bailOut(EX_USAGE, ""); 907 915 } 908 916 } 909 917 if((registry_file = strdup(argv[argi])) == NULL) 910 bailOut( 2, "ERROR: Memory allocation problem.\n");918 bailOut(EX_OSERR, "ERROR: Memory allocation problem.\n"); 911 919 912 920 f = regfi_open(registry_file); … … 914 922 { 915 923 fprintf(stderr, "ERROR: Couldn't open registry file: %s\n", registry_file); 916 bailOut( 3, "");924 bailOut(EX_NOINPUT, ""); 917 925 } 918 926 919 927 iter = regfi_iterator_new(f); 920 928 if(iter == NULL) 921 bailOut( 3, "ERROR: Couldn't create registry iterator.\n");929 bailOut(EX_OSERR, "ERROR: Couldn't create registry iterator.\n"); 922 930 923 931 if(print_header) … … 942 950 printKeyTree(iter); 943 951 else if(retr_path_ret != 0) 944 bailOut( 4, "ERROR: Unknown error occurred in retrieving path.\n");952 bailOut(EX_DATAERR, "ERROR: Unknown error occurred in retrieving path.\n"); 945 953 } 946 954 else
Note: See TracChangeset
for help on using the changeset viewer.