Feísimo script, ese no es ni un Java o Perl Guy, usalo así perl
Código:
MakeCurlGue.pl /usr/include/curl.h > CurlGlue.java
no existe constante CURL_OPT por lo que puse que extraiga todas las que empiezan con CURL modificalo a discresión, Far from be perfert too!
Código Perl:
Ver original#!/usr/bin/perl
# Hack to create CurlGlue.java from curl.h
# Reads a preprocessed compiler output from STDIN and parses with
# a regex for the wanted defines, then writes them to STDOUT.
open(IN
, "+<${ARGV[0]}") or die $!;
while(<IN>) {
if(/^#define LIBCURL_VERSION \"(\d+\.\d+\.\d+.*)\"$/) {
$curl_ver = $1;
}
}
/*
* The curl class is a JNI wrapper for libcurl.
* Please bear with me, I'm no true java dude (yet) - Daniel S.
* Improve what you think is bad and send the updates to the libcurl list!
*
* This is meant as a raw, crude and low-level interface to libcurl.
* If you want fancy stuff, build upon this.
*/
public class CurlGlue
{
// start of generated list - this list is up-to-date as of Curl $curl_ver
EOTXT
%hash = ();
while(<IN>) {
if(/^\s*#define\s*(CURL[\w_]+)\s+(.+)\s*/o or /^\s*(CURL[\w_]+)\s*=\s*((?!char).*)\s*,/o or /^\s*(CURL[\w_]+)\s*,\s*((?!char).*)/o) {
$key = $1;
$hash{$key} = ($2 && $2 !~ /^\s*=?\s*,\s*$/) ? $2 : 'null';
$hash{$key} =~s!^\
s*,?/\
*\
s*(\d+).*!$1!g
; $hash{$key} =~ s!\
s*/\
*.*!!go
; $hash{$key} =~ s/\s+$//go;
$hash{$key} =~ s/\b${_}\b/$hash{$_}/g for (keys %hash); if($hash{$key} =~ /(\d+)\s*\+\s*(\d+)/o) {
$hash{$key} = $1+$2;
}
}
}
foreach $key (keys %hash){ $hash{$key} =~ s/\b${_}\b/$hash{$_}/g for (keys %hash); print "\tpublic static final int $key".(($hash{$key} && $hash{$key} !~ m'^null|\s*,\s*$'go
)?" = ${hash{$key}};":";")."\n"; }
// end of generated list
public CurlGlue() {
try {
cur
........................
e.printStackTrace();
}
}
}
EOTXT