File: readvaluesfile.pl

package info (click to toggle)
thunderbird 1%3A52.9.1-1~deb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 1,709,148 kB
  • sloc: cpp: 5,081,792; ansic: 2,051,951; python: 458,733; java: 241,615; xml: 193,600; asm: 178,649; sh: 81,881; makefile: 24,702; perl: 16,874; objc: 4,389; yacc: 1,816; ada: 1,697; lex: 1,257; pascal: 1,251; cs: 879; exp: 499; php: 436; lisp: 258; awk: 152; sed: 51; ruby: 47; csh: 27
file content (135 lines) | stat: -rw-r--r-- 2,060 bytes parent folder | download | duplicates (18)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135


sub read_values_file {
  
  my $path = shift;
  my %h;

  open(F,$path) || die "Can't open values file $path";

  while(<F>){
    
    chop; 
 
    s/#.*$//g;
    s/\"//g;
    s/\r//g;
   
    next if ! $_;

    @column = split(/,/,$_);
    
    my $value_name = $column[0];

    my $c_type_str =  $column[1];
    my $c_autogen = ($c_type_str =~ /\(a\)/);

    my $c_type = $c_type_str;
    $c_type =~ s/\(.\)//;

    my $python_type =  $column[2];
    my $components = $column[3];
    my $enum_values = $column[4];

    my @components;
    if($components ne "unitary"){
      @components = split(/;/,$components);
    } else {
      @components = ();
    }

    my @enums;
    if($enum_values) {
      @enums  = split(/;/,$enum_values);

    } else {
      @enums = ();
    }

    $h{$value_name} = { C => [$c_autogen,$c_type],
			perl => $perl_type,
			python => $python_type,
			components=>[@components],
			enums=>[@enums]
		      };
  }

  return %h;
}

sub read_properties_file {
  
  my $path = shift;
  my %h;

  open(F,$path) || die "Can't open properties file $path";

  while(<F>){
    
    chop; 
 
    s/#.*$//g;
    s/\"//g;
    s/\r//g;
   
    next if ! $_;

    @column = split(/,/,$_);
    
    my $property_name = $column[0];

    my $lic_value = $column[1];
    my $default_value = $column[2];
    
    $h{$property_name} = { lic_value => $lic_value,
			   default_value => $default_value
			 };
  }

  return %h;
}

sub read_parameters_file {
  
  my $path = shift;
  my %h;

  open(F,$path) || die "Can't open parameters file $path";

  while(<F>){
    
    chop; 
 
    s/#.*$//g;
    s/\"//g;
    s/\r//g;
   
    next if ! $_;

    @column = split(/\,/,$_);
  
    my $parameter_name = $column[0];

    my $enumConst = $column[1];
    my $data_type = $column[2];
    my $enum_string = $column[3];

    my @enums;
    if($enum_string){
      @enums =  split(/;/,$enum_string);
    }
    
    $h{$parameter_name} = { C => $data_type,
			   kindEnum => $enumConst,
			   enums => [@enums]
			 };
  }

  close(F);

  return %h;
}



1;