xref: /curl/tests/test1135.pl (revision c3860658)
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
28use strict;
29use warnings;
30
31my $sort = 0;
32
33# we may get the dir root pointed out
34my $root = shift @ARGV;
35while(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
51if(!defined $root) {
52    $root = ".";
53}
54
55$root = "$root/include/curl";
56opendir(D, "$root") || die "Cannot open directory $root: $!\n";
57my @dir = readdir(D);
58closedir(D);
59
60my @incs;
61foreach (sort(@dir)) {
62    if($_ =~ /\.h$/) {
63        push(@incs, "$root/$_");
64    }
65}
66
67my $verbose=0;
68my $summary=0;
69my $misses=0;
70
71my @syms;
72my %doc;
73my %rem;
74
75my @out;
76foreach 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
108if($sort) {
109    @out = sort(@out);
110}
111
112foreach (@out) {
113    print("$_\n");
114}
115