xref: /curl/src/mk-file-embed.pl (revision 6478a36b)
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
26my $varname = "var";
27if($ARGV[0] eq "--var") {
28    shift;
29    $varname = shift @ARGV;
30}
31
32my $varname_upper = uc($varname);
33
34print <<HEAD
35/*
36 * NEVER EVER edit this manually, fix the mk-file-embed.pl script instead!
37 */
38#ifndef CURL_DECLARED_${varname_upper}
39#define CURL_DECLARED_${varname_upper}
40extern const unsigned char ${varname}[];
41#endif
42const unsigned char ${varname}[] = {
43HEAD
44    ;
45
46while (<STDIN>) {
47    my $line = $_;
48    foreach my $n (split //, $line) {
49        my $ord = ord($n);
50        printf("%s,", $ord);
51        if($ord == 10) {
52             printf("\n");
53        }
54    }
55}
56
57print <<ENDLINE
580
59};
60ENDLINE
61    ;
62