Disable a debug option
[platform/upstream/curl.git] / tests / extern-scan.pl
1 #!/usr/bin/env perl
2 #***************************************************************************
3 #                                  _   _ ____  _
4 #  Project                     ___| | | |  _ \| |
5 #                             / __| | | | |_) | |
6 #                            | (__| |_| |  _ <| |___
7 #                             \___|\___/|_| \_\_____|
8 #
9 # Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
10 #
11 # This software is licensed as described in the file COPYING, which
12 # you should have received as part of this distribution. The terms
13 # are also available at https://curl.se/docs/copyright.html.
14 #
15 # You may opt to use, copy, modify, merge, publish, distribute and/or sell
16 # copies of the Software, and permit persons to whom the Software is
17 # furnished to do so, under the terms of the COPYING file.
18 #
19 # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20 # KIND, either express or implied.
21 #
22 # SPDX-License-Identifier: curl
23 #
24 ###########################################################################
25 #
26 #
27
28 use strict;
29 use warnings;
30
31 my $sort = 0;
32
33 # we may get the dir root pointed out
34 my $root = shift @ARGV;
35 while(defined $root) {
36
37     if($root =~ /--heading=(.*)/) {
38         print "$1\n";
39         $root = shift @ARGV;
40         next;
41     }
42     elsif($root =~ /--sort/) {
43         $sort = 1;
44         $root = shift @ARGV;
45         next;
46     }
47
48     last;
49 }
50
51 if(!defined $root) {
52     $root = ".";
53 }
54
55 $root = "$root/include/curl";
56 opendir(D, "$root") || die "Cannot open directory $root: $!\n";
57 my @dir = readdir(D);
58 closedir(D);
59
60 my @incs;
61 foreach (sort(@dir)) {
62     if($_ =~ /\.h$/) {
63         push(@incs, "$root/$_");
64     }
65 }
66
67 my $verbose=0;
68 my $summary=0;
69 my $misses=0;
70
71 my @syms;
72 my %doc;
73 my %rem;
74
75 my @out;
76 foreach my $f (@incs) {
77     open H, "<$f" || die;
78     my $first = "";
79     while(<H>) {
80         s/CURL_DEPRECATED\(.*"\)//;
81         s/  */ /g;
82         if (/^(^CURL_EXTERN .*?)\(/) {
83             my $decl = $1;
84             $decl =~ s/\r$//;
85             $decl =~ /([a-z_]+)$/;
86             push(@out, "$1");
87         }
88         elsif (/^(^CURL_EXTERN .*)/) {
89             # handle two-line declarations
90             my $decl = $1;
91             $decl =~ s/\r$//;
92             $first = $decl;
93         }
94         elsif($first) {
95             if (/^ *(.*)\(/) {
96                 my $decl = $1;
97                 $decl =~ s/\r$//;
98                 $first .= $decl;
99                 $first =~ /([a-z_]+)$/;
100                 push(@out, "$1");
101             }
102             $first = "";
103         }
104     }
105     close H;
106 }
107
108 if($sort) {
109     @out = sort(@out);
110 }
111
112 foreach (@out) {
113     print("$_\n");
114 }