• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1@echo off
2rem ***************************************************************************
3rem *                                  _   _ ____  _
4rem *  Project                     ___| | | |  _ \| |
5rem *                             / __| | | | |_) | |
6rem *                            | (__| |_| |  _ <| |___
7rem *                             \___|\___/|_| \_\_____|
8rem *
9rem * Copyright (C) Steve Holme, <steve_holme@hotmail.com>.
10rem *
11rem * This software is licensed as described in the file COPYING, which
12rem * you should have received as part of this distribution. The terms
13rem * are also available at https://curl.se/docs/copyright.html.
14rem *
15rem * You may opt to use, copy, modify, merge, publish, distribute and/or sell
16rem * copies of the Software, and permit persons to whom the Software is
17rem * furnished to do so, under the terms of the COPYING file.
18rem *
19rem * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20rem * KIND, either express or implied.
21rem *
22rem * SPDX-License-Identifier: curl
23rem *
24rem ***************************************************************************
25
26:begin
27  rem Check we are running on a Windows NT derived OS
28  if not "%OS%" == "Windows_NT" goto nodos
29
30  rem Set our variables
31  setlocal
32  set CHECK_LIB=TRUE
33  set CHECK_SRC=TRUE
34  set CHECK_TESTS=TRUE
35  set CHECK_EXAMPLES=TRUE
36  set SRC_DIR=
37  set CUR_DIR=%cd%
38  set ARG0_DIR=%~dp0
39
40:parseArgs
41  if "%~1" == "" goto prerequisites
42
43  if /i "%~1" == "-?" (
44    goto syntax
45  ) else if /i "%~1" == "-h" (
46    goto syntax
47  ) else if /i "%~1" == "-help" (
48    goto syntax
49  ) else if /i "%~1" == "lib" (
50    set CHECK_LIB=TRUE
51    set CHECK_SRC=FALSE
52    set CHECK_TESTS=FALSE
53    set CHECK_EXAMPLES=FALSE
54  ) else if /i "%~1" == "src" (
55    set CHECK_LIB=FALSE
56    set CHECK_SRC=TRUE
57    set CHECK_TESTS=FALSE
58    set CHECK_EXAMPLES=FALSE
59  ) else if /i "%~1" == "tests" (
60    set CHECK_LIB=FALSE
61    set CHECK_SRC=FALSE
62    set CHECK_TESTS=TRUE
63    set CHECK_EXAMPLES=FALSE
64  ) else if /i "%~1" == "examples" (
65    set CHECK_LIB=FALSE
66    set CHECK_SRC=FALSE
67    set CHECK_TESTS=FALSE
68    set CHECK_EXAMPLES=TRUE
69  ) else (
70    if not defined SRC_DIR (
71      set SRC_DIR=%~1%
72    ) else (
73      goto unknown
74    )
75  )
76
77  shift & goto parseArgs
78
79:prerequisites
80  rem Check we have Perl in our path
81  perl --version <NUL 1>NUL 2>&1
82  if errorlevel 1 (
83    rem It isn't so check we have it installed and set the path if it is
84    if exist "%SystemDrive%\Perl" (
85      set "PATH=%SystemDrive%\Perl\bin;%PATH%"
86    ) else (
87      if exist "%SystemDrive%\Perl64" (
88        set "PATH=%SystemDrive%\Perl64\bin;%PATH%"
89      ) else (
90        goto noperl
91      )
92    )
93  )
94
95:configure
96  if "%SRC_DIR%" == "" (
97    rem Are we being executed from the "projects" or main directory?
98    if "%CUR_DIR%\" == "%ARG0_DIR%" (
99      set SRC_DIR=..
100    ) else if exist projects (
101      if exist docs (
102        if exist lib (
103          if exist src (
104            if exist tests (
105              set SRC_DIR=.
106            )
107          )
108        )
109      )
110    )
111  )
112  if not exist "%SRC_DIR%" goto nosrc
113
114:start
115  if "%CHECK_SRC%" == "TRUE" (
116    rem Check the src directory
117    if exist %SRC_DIR%\src (
118      for /f "delims=" %%i in ('dir "%SRC_DIR%\src\*.c.*" /b 2^>NUL') do @perl "%SRC_DIR%\scripts\checksrc.pl" "-D%SRC_DIR%\src" -Wtool_hugehelp.c "%%i"
119      for /f "delims=" %%i in ('dir "%SRC_DIR%\src\*.h.*" /b 2^>NUL') do @perl "%SRC_DIR%\scripts\checksrc.pl" "-D%SRC_DIR%\src" "%%i"
120    )
121  )
122
123  if "%CHECK_LIB%" == "TRUE" (
124    rem Check the lib directory
125    if exist %SRC_DIR%\lib (
126      for /f "delims=" %%i in ('dir "%SRC_DIR%\lib\*.c.*" /b 2^>NUL') do @perl "%SRC_DIR%\scripts\checksrc.pl" "-D%SRC_DIR%\lib" "%%i"
127      for /f "delims=" %%i in ('dir "%SRC_DIR%\lib\*.h.*" /b 2^>NUL') do @perl "%SRC_DIR%\scripts\checksrc.pl" "-D%SRC_DIR%\lib" -Wcurl_config.h.cmake -Wcurl_config.h.in -Wcurl_config.h "%%i"
128    )
129
130    rem Check the lib\vauth directory
131    if exist %SRC_DIR%\lib\vauth (
132      for /f "delims=" %%i in ('dir "%SRC_DIR%\lib\vauth\*.c.*" /b 2^>NUL') do @perl "%SRC_DIR%\scripts\checksrc.pl" "-D%SRC_DIR%\lib\vauth" "%%i"
133      for /f "delims=" %%i in ('dir "%SRC_DIR%\lib\vauth\*.h.*" /b 2^>NUL') do @perl "%SRC_DIR%\scripts\checksrc.pl" "-D%SRC_DIR%\lib\vauth" "%%i"
134    )
135
136    rem Check the lib\vquic directory
137    if exist %SRC_DIR%\lib\vquic (
138      for /f "delims=" %%i in ('dir "%SRC_DIR%\lib\vquic\*.c.*" /b 2^>NUL') do @perl "%SRC_DIR%\scripts\checksrc.pl" "-D%SRC_DIR%\lib\vquic" "%%i"
139      for /f "delims=" %%i in ('dir "%SRC_DIR%\lib\vquic\*.h.*" /b 2^>NUL') do @perl "%SRC_DIR%\scripts\checksrc.pl" "-D%SRC_DIR%\lib\vquic" "%%i"
140    )
141
142    rem Check the lib\vssh directory
143    if exist %SRC_DIR%\lib\vssh (
144      for /f "delims=" %%i in ('dir "%SRC_DIR%\lib\vssh\*.c.*" /b 2^>NUL') do @perl "%SRC_DIR%\scripts\checksrc.pl" "-D%SRC_DIR%\lib\vssh" "%%i"
145      for /f "delims=" %%i in ('dir "%SRC_DIR%\lib\vssh\*.h.*" /b 2^>NUL') do @perl "%SRC_DIR%\scripts\checksrc.pl" "-D%SRC_DIR%\lib\vssh" "%%i"
146    )
147
148    rem Check the lib\vtls directory
149    if exist %SRC_DIR%\lib\vtls (
150      for /f "delims=" %%i in ('dir "%SRC_DIR%\lib\vtls\*.c.*" /b 2^>NUL') do @perl "%SRC_DIR%\scripts\checksrc.pl" "-D%SRC_DIR%\lib\vtls" "%%i"
151      for /f "delims=" %%i in ('dir "%SRC_DIR%\lib\vtls\*.h.*" /b 2^>NUL') do @perl "%SRC_DIR%\scripts\checksrc.pl" "-D%SRC_DIR%\lib\vtls" "%%i"
152    )
153  )
154
155  if "%CHECK_TESTS%" == "TRUE" (
156    rem Check the tests\libtest directory
157    if exist %SRC_DIR%\tests\libtest (
158      for /f "delims=" %%i in ('dir "%SRC_DIR%\tests\libtest\*.c.*" /b 2^>NUL') do @perl "%SRC_DIR%\scripts\checksrc.pl" "-D%SRC_DIR%\tests\libtest" "%%i"
159      for /f "delims=" %%i in ('dir "%SRC_DIR%\tests\libtest\*.h.*" /b 2^>NUL') do @perl "%SRC_DIR%\scripts\checksrc.pl" "-D%SRC_DIR%\tests\libtest" "%%i"
160    )
161
162    rem Check the tests\unit directory
163    if exist %SRC_DIR%\tests\unit (
164      for /f "delims=" %%i in ('dir "%SRC_DIR%\tests\unit\*.c.*" /b 2^>NUL') do @perl "%SRC_DIR%\scripts\checksrc.pl" "-D%SRC_DIR%\tests\unit" "%%i"
165      for /f "delims=" %%i in ('dir "%SRC_DIR%\tests\unit\*.h.*" /b 2^>NUL') do @perl "%SRC_DIR%\scripts\checksrc.pl" "-D%SRC_DIR%\tests\unit" "%%i"
166    )
167
168    rem Check the tests\server directory
169    if exist %SRC_DIR%\tests\server (
170      for /f "delims=" %%i in ('dir "%SRC_DIR%\tests\server\*.c.*" /b 2^>NUL') do @perl "%SRC_DIR%\scripts\checksrc.pl" "-D%SRC_DIR%\tests\server" "%%i"
171      for /f "delims=" %%i in ('dir "%SRC_DIR%\tests\server\*.h.*" /b 2^>NUL') do @perl "%SRC_DIR%\scripts\checksrc.pl" "-D%SRC_DIR%\tests\server" "%%i"
172    )
173  )
174
175  if "%CHECK_EXAMPLES%" == "TRUE" (
176    rem Check the docs\examples directory
177    if exist %SRC_DIR%\docs\examples (
178      for /f "delims=" %%i in ('dir "%SRC_DIR%\docs\examples\*.c.*" /b 2^>NUL') do @perl "%SRC_DIR%\scripts\checksrc.pl" "-D%SRC_DIR%\docs\examples" -ASNPRINTF "%%i"
179    )
180  )
181
182  goto success
183
184:syntax
185  rem Display the help
186  echo.
187  echo Usage: checksrc [what] [directory]
188  echo.
189  echo What to scan:
190  echo.
191  echo lib       - Scan the libcurl source
192  echo src       - Scan the command-line tool source
193  echo tests     - Scan the library tests and unit tests
194  echo examples  - Scan the examples
195  echo.
196  echo directory - Specifies the curl source directory
197  goto success
198
199:unknown
200  echo.
201  echo Error: Unknown argument '%1'
202  goto error
203
204:nodos
205  echo.
206  echo Error: Only a Windows NT based Operating System is supported
207  goto error
208
209:noperl
210  echo.
211  echo Error: Perl is not installed
212  goto error
213
214:nosrc
215  echo.
216  echo Error: "%SRC_DIR%" does not exist
217  goto error
218
219:error
220  if "%OS%" == "Windows_NT" endlocal
221  exit /B 1
222
223:success
224  endlocal
225  exit /B 0
226