Foros del Web » Programación para mayores de 30 ;) » Programación General »

MakeCurlGlue.pl Biding de curl para java

Estas en el tema de MakeCurlGlue.pl Biding de curl para java en el foro de Programación General en Foros del Web. Buenas, estoy trabajando con java y la libreria libcurl de c, necesito utilizar un biding para poder usarla mediante java. Mi problema con perl esque ...
  #1 (permalink)  
Antiguo 18/03/2010, 07:13
 
Fecha de Ingreso: septiembre-2009
Mensajes: 25
Antigüedad: 14 años, 7 meses
Puntos: 0
MakeCurlGlue.pl Biding de curl para java

Buenas, estoy trabajando con java y la libreria libcurl de c, necesito utilizar un biding para poder usarla mediante java. Mi problema con perl esque en el binding para java tengo un fichero llamado MakeCurlGlue.pl, que CREO q debo ejecutar en linux con el siguiente comando:

perl MakeCurlGue.pl < /usr/include/curl.h > CurlGlue.java

El problema esque en CurlGlue deberian de aparecer una serie de definiciones d eterminos k no me aparecen, esta parte:

// start of generated list - this list is up-to-date as of Curl
public static final int CURLOPT_ ## name = CURLOPTTYPE_ ## type + number;
public static final int CURLOPT_/**/name = type + number;
// end of generated list

Y el fichero MakeCurlGlue.pl que lo genera, contiene lo siguiente:

#!/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]}");
while(<IN>) {
if(/^#define LIBCURL_VERSION \"(\d+\.\d+\.\d+.*)\"$/) {
$curl_ver = $1;
}
}
close(IN);

print <<EOTXT;
/*
* 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

while(<STDIN>) {
if($_ =~ /(CURLOPT_(.*)) += (.*)/) {
$var= $1;
$expr = $3;
$f=$3;
if($expr =~ / *(\d+) *\+ *(\d+)/) {
$expr = $1+$2;
}

# nah, keep the CURL prefix to make them look like other
# languages' defines
# $var =~ s/^CURL//g;

$var =~ s/ $//g;

print " public static final int $var = $expr;\n";
}
}

print <<EOTXT;
// end of generated list

public CurlGlue() {
try {
cur
........................
e.printStackTrace();
}
}

}

EOTXT

Lo que necesito saber es porque no lo esta generado bien, que hace exactamente la parte del while, espero que puedan ayudarme, un saludo.
  #2 (permalink)  
Antiguo 11/04/2010, 01:14
 
Fecha de Ingreso: enero-2010
Mensajes: 191
Antigüedad: 14 años, 3 meses
Puntos: 7
Respuesta: MakeCurlGlue.pl Biding de curl para java

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
  1. #!/usr/bin/perl
  2. # Hack to create CurlGlue.java from curl.h
  3. # Reads a preprocessed compiler output from STDIN and parses with
  4. # a regex for the wanted defines, then writes them to STDOUT.
  5.  
  6. open(IN, "+<${ARGV[0]}") or die $!;
  7.  
  8. seek IN,0,0;
  9. while(<IN>) {
  10. if(/^#define LIBCURL_VERSION \"(\d+\.\d+\.\d+.*)\"$/) {
  11. $curl_ver = $1;
  12. }
  13. }
  14.  
  15.  
  16. print <<EOTXT;
  17. /*
  18. * The curl class is a JNI wrapper for libcurl.
  19. * Please bear with me, I'm no true java dude (yet) - Daniel S.
  20. * Improve what you think is bad and send the updates to the libcurl list!
  21. *
  22. * This is meant as a raw, crude and low-level interface to libcurl.
  23. * If you want fancy stuff, build upon this.
  24. */
  25.  
  26. public class CurlGlue
  27. {
  28. // start of generated list - this list is up-to-date as of Curl $curl_ver
  29.  
  30. EOTXT
  31.  
  32. seek IN,0,0;
  33.  
  34. %hash = ();
  35.  
  36. while(<IN>) {
  37.     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) {
  38.         $key = $1;
  39.         $hash{$key} = ($2 && $2 !~ /^\s*=?\s*,\s*$/) ? $2 : 'null';
  40.         $hash{$key} =~s!^\s*,?/\*\s*(\d+).*!$1!g;
  41.         $hash{$key} =~ s!\s*/\*.*!!go;
  42.         $hash{$key} =~ s/\s+$//go;
  43.         $hash{$key} =~ s/\b${_}\b/$hash{$_}/g for (keys %hash);
  44.         if($hash{$key} =~ /(\d+)\s*\+\s*(\d+)/o) {
  45.             $hash{$key} = $1+$2;
  46.         }
  47.     }
  48. }
  49.  
  50. foreach $key (keys %hash){
  51.     $hash{$key} =~ s/\b${_}\b/$hash{$_}/g for (keys %hash);
  52.     print "\tpublic static final int $key".(($hash{$key} && $hash{$key} !~ m'^null|\s*,\s*$'go)?" = ${hash{$key}};":";")."\n";
  53. }
  54.  
  55. print <<EOTXT;
  56. // end of generated list
  57.  
  58. public CurlGlue() {
  59. try {
  60. cur
  61. ........................
  62. e.printStackTrace();
  63. }
  64. }
  65.  
  66. }
  67.  
  68. EOTXT
  69.  
  70. close IN;

Última edición por abcdefghi; 11/04/2010 a las 01:20

Etiquetas: curl, java
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 11:56.