Ver Mensaje Individual
  #2 (permalink)  
Antiguo 11/04/2010, 01:14
abcdefghi
 
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