|
Packit Service |
ed5168 |
#!/usr/bin/env perl
|
|
Packit Service |
ed5168 |
|
|
Packit Service |
ed5168 |
# Copyright © 2011 Red Hat, Inc
|
|
Packit Service |
ed5168 |
#
|
|
Packit Service |
ed5168 |
# This library is free software; you can redistribute it and/or
|
|
Packit Service |
ed5168 |
# modify it under the terms of the GNU Lesser General Public
|
|
Packit Service |
ed5168 |
# License as published by the Free Software Foundation; either
|
|
Packit Service |
ed5168 |
# version 2 of the licence, or (at your option) any later version.
|
|
Packit Service |
ed5168 |
#
|
|
Packit Service |
ed5168 |
# This library is distributed in the hope that it will be useful,
|
|
Packit Service |
ed5168 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
ed5168 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
ed5168 |
# Lesser General Public License for more details.
|
|
Packit Service |
ed5168 |
#
|
|
Packit Service |
ed5168 |
# You should have received a copy of the GNU Lesser General Public
|
|
Packit Service |
ed5168 |
# License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
|
Packit Service |
ed5168 |
#
|
|
Packit Service |
ed5168 |
# Author: Kalev Lember <kalevlember@gmail.com>
|
|
Packit Service |
ed5168 |
|
|
Packit Service |
ed5168 |
|
|
Packit Service |
ed5168 |
if (@ARGV != 2) {
|
|
Packit Service |
ed5168 |
die "Usage: data-to-c.pl <filename> <variable>\n";
|
|
Packit Service |
ed5168 |
}
|
|
Packit Service |
ed5168 |
|
|
Packit Service |
ed5168 |
$file = $ARGV[0];
|
|
Packit Service |
ed5168 |
|
|
Packit Service |
ed5168 |
open (FILE, $file) || die "Cannot open $file: $!\n";
|
|
Packit Service |
ed5168 |
|
|
Packit Service |
ed5168 |
printf ("const char %s[] = \"", $ARGV[1]);
|
|
Packit Service |
ed5168 |
while (my $line = <FILE>) {
|
|
Packit Service |
ed5168 |
foreach my $c (split //, $line) {
|
|
Packit Service |
ed5168 |
printf ("\\x%02x", ord ($c));
|
|
Packit Service |
ed5168 |
}
|
|
Packit Service |
ed5168 |
}
|
|
Packit Service |
ed5168 |
print "\";\n";
|
|
Packit Service |
ed5168 |
|
|
Packit Service |
ed5168 |
close (FILE);
|