Init basesystem source codes.
[staging/basesystem.git] / nsframework / backup_manager / config / createhdr.pl
1 #!/usr/bin/perl
2 use strict;
3 use warnings;
4
5 sub getlist($$)
6 {
7   my $xmlfile = shift(@_);
8   my $xpath = shift(@_);
9
10   $xmlfile =~ s/([\[\]\*\(\)])/\\$1/g;
11
12   open(my $rs, "xmllint --xpath \"$xpath\" $xmlfile |") or die "Cannot open $xmlfile:$!";
13   my $result = join('', <$rs>);
14   close $rs;
15   $result =~ s/^ +//;
16   my @result_array = split(/ +/, $result);
17   return @result_array;
18 }
19
20 if ($#ARGV < 0 || !(-f $ARGV[0])) {
21   print "No such file or directory.\n";
22   exit 1;
23 }
24
25 my @item_array = getlist($ARGV[0], '//item/@name');
26
27 print<<'HEADER';
28 /*
29  * @copyright Copyright (c) 2017-2020 TOYOTA MOTOR CORPORATION.
30  *
31  * Licensed under the Apache License, Version 2.0 (the "License");
32  * you may not use this file except in compliance with the License.
33  * You may obtain a copy of the License at
34  *
35  *      http://www.apache.org/licenses/LICENSE-2.0
36  *
37  * Unless required by applicable law or agreed to in writing, software
38  * distributed under the License is distributed on an "AS IS" BASIS,
39  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
40  * See the License for the specific language governing permissions and
41  * limitations under the License.
42  */
43 /**
44  * @file ns_backup_id.h
45  * @brief backup id define
46  */
47
48 #ifndef BACKUP_MANAGER_CONFIG_NS_BACKUP_ID_H_
49 #define BACKUP_MANAGER_CONFIG_NS_BACKUP_ID_H_
50
51 /** @addtogroup BaseSystem
52  *  @{
53  */
54 /** @addtogroup native_service
55  *  @ingroup BaseSystem
56  *  @{
57  */
58 /** @addtogroup backup_manager
59  *  @ingroup native_service
60  *  @{
61  */
62
63 HEADER
64
65 foreach my $item (@item_array) {
66   if ($item =~ /^name="(.+)"$/) {
67     printf("#define %s \"%s\"\n", $1, $1);
68   }
69   else {
70     print "Invalid input:$item\n";
71     exit 1;
72   }
73 }
74
75 print<<'FOOTER';
76
77 /**@}*/  // end of backup_manager
78 /**@}*/  // end of native_service
79 /**@}*/  // end of BaseSystem
80
81 #endif  // BACKUP_MANAGER_CONFIG_NS_BACKUP_ID_H_
82 FOOTER
83
84 0;