optiontable.pl 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. #!/usr/bin/env perl
  2. print <<HEAD
  3. /***************************************************************************
  4. * _ _ ____ _
  5. * Project ___| | | | _ \| |
  6. * / __| | | | |_) | |
  7. * | (__| |_| | _ <| |___
  8. * \___|\___/|_| \_\_____|
  9. *
  10. * Copyright (C) 1998 - 2021, Daniel Stenberg, <daniel@haxx.se>, et al.
  11. *
  12. * This software is licensed as described in the file COPYING, which
  13. * you should have received as part of this distribution. The terms
  14. * are also available at https://curl.se/docs/copyright.html.
  15. *
  16. * You may opt to use, copy, modify, merge, publish, distribute and/or sell
  17. * copies of the Software, and permit persons to whom the Software is
  18. * furnished to do so, under the terms of the COPYING file.
  19. *
  20. * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  21. * KIND, either express or implied.
  22. *
  23. ***************************************************************************/
  24. /* This source code is generated by optiontable.pl - DO NOT EDIT BY HAND */
  25. #include "curl_setup.h"
  26. #include "easyoptions.h"
  27. /* all easy setopt options listed in alphabetical order */
  28. struct curl_easyoption Curl_easyopts[] = {
  29. HEAD
  30. ;
  31. my $lastnum=0;
  32. while(<STDIN>) {
  33. if(/^ *CURLOPT\(([^,]*), ([^,]*), (\d+)\)/) {
  34. my($opt, $type, $num)=($1,$2,$3);
  35. my $name;
  36. my $ext = $type;
  37. if($opt =~ /OBSOLETE/) {
  38. # skip obsolete options
  39. next;
  40. }
  41. if($opt =~ /^CURLOPT_(.*)/) {
  42. $name=$1;
  43. }
  44. $ext =~ s/CURLOPTTYPE_//;
  45. $ext =~ s/CBPOINT/CBPTR/;
  46. $ext =~ s/POINT\z//;
  47. $type = "CURLOT_$ext";
  48. $opt{$name} = $opt;
  49. $type{$name} = $type;
  50. push @names, $name;
  51. if($num < $lastnum) {
  52. print STDERR "ERROR: $opt has bad number\n";
  53. exit 2;
  54. }
  55. else {
  56. $lastnum = $num;
  57. }
  58. }
  59. # alias for an older option
  60. # old = new
  61. if(/^#define (CURLOPT_[^ ]*) *(CURLOPT_\S*)/) {
  62. my ($o, $n)=($1, $2);
  63. # skip obsolete ones
  64. if($n !~ /OBSOLETE/) {
  65. $o =~ s/^CURLOPT_//;
  66. $n =~ s/^CURLOPT_//;
  67. $alias{$o} = $n;
  68. push @names, $o,
  69. }
  70. }
  71. }
  72. for my $name (sort @names) {
  73. my $oname = $name;
  74. my $a = $alias{$name};
  75. my $flag = "0";
  76. if($a) {
  77. $name = $alias{$name};
  78. $flag = "CURLOT_FLAG_ALIAS";
  79. }
  80. $o = sprintf(" {\"%s\", %s, %s, %s},\n",
  81. $oname, $opt{$name}, $type{$name}, $flag);
  82. if(length($o) < 80) {
  83. print $o;
  84. }
  85. else {
  86. printf(" {\"%s\", %s,\n %s, %s},\n",
  87. $oname, $opt{$name}, $type{$name}, $flag);
  88. }
  89. }
  90. print <<FOOT
  91. {NULL, CURLOPT_LASTENTRY, 0, 0} /* end of table */
  92. };
  93. #ifdef DEBUGBUILD
  94. /*
  95. * Curl_easyopts_check() is a debug-only function that returns non-zero
  96. * if this source file is not in sync with the options listed in curl/curl.h
  97. */
  98. int Curl_easyopts_check(void)
  99. {
  100. return (CURLOPT_LASTENTRY != ($lastnum + 1));
  101. }
  102. #endif
  103. FOOT
  104. ;