optiontable.pl 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. #!/usr/bin/env perl
  2. print <<HEAD
  3. /***************************************************************************
  4. * _ _ ____ _
  5. * Project ___| | | | _ \\| |
  6. * / __| | | | |_) | |
  7. * | (__| |_| | _ <| |___
  8. * \\___|\\___/|_| \\_\\_____|
  9. *
  10. * Copyright (C) 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. * SPDX-License-Identifier: curl
  24. *
  25. ***************************************************************************/
  26. /* This source code is generated by optiontable.pl - DO NOT EDIT BY HAND */
  27. #include "curl_setup.h"
  28. #include "easyoptions.h"
  29. /* all easy setopt options listed in alphabetical order */
  30. struct curl_easyoption Curl_easyopts[] = {
  31. HEAD
  32. ;
  33. my $lastnum=0;
  34. sub add {
  35. my($opt, $type, $num)=@_;
  36. my $name;
  37. # remove all spaces from the type
  38. $type =~ s/ //g;
  39. my $ext = $type;
  40. if($opt =~ /OBSOLETE/) {
  41. # skip obsolete options
  42. next;
  43. }
  44. if($opt =~ /^CURLOPT_(.*)/) {
  45. $name=$1;
  46. }
  47. $ext =~ s/CURLOPTTYPE_//;
  48. $ext =~ s/CBPOINT/CBPTR/;
  49. $ext =~ s/POINT\z//;
  50. $type = "CURLOT_$ext";
  51. $opt{$name} = $opt;
  52. $type{$name} = $type;
  53. push @names, $name;
  54. if($num < $lastnum) {
  55. print STDERR "ERROR: $opt has bad number: $num < $lastnum\n";
  56. exit 2;
  57. }
  58. else {
  59. $lastnum = $num;
  60. }
  61. }
  62. my $fl;
  63. while(<STDIN>) {
  64. my $l = $_;
  65. if($fl) {
  66. # continued deprecation
  67. if($l =~ /(.*)\),/) {
  68. $fl .= $1;
  69. # the end
  70. my @p=split(/, */, $fl);
  71. add($p[0], $p[1], $p[2]);
  72. undef $fl;
  73. }
  74. else {
  75. # another line to append
  76. chomp $l;
  77. $fl .= $l;
  78. }
  79. }
  80. if(/^ *CURLOPTDEPRECATED\((.*)/) {
  81. $fl = $1;
  82. chomp $fl;
  83. }
  84. if(/^ *CURLOPT\(([^,]*), ([^,]*), (\d+)\)/) {
  85. my($opt, $type, $num)=($1,$2,$3);
  86. add($opt, $type, $num);
  87. }
  88. # alias for an older option
  89. # old = new
  90. if(/^#define (CURLOPT_[^ ]*) *(CURLOPT_\S*)/) {
  91. my ($o, $n)=($1, $2);
  92. # skip obsolete ones
  93. if($n !~ /OBSOLETE/) {
  94. $o =~ s/^CURLOPT_//;
  95. $n =~ s/^CURLOPT_//;
  96. $alias{$o} = $n;
  97. push @names, $o,
  98. }
  99. }
  100. }
  101. for my $name (sort @names) {
  102. my $oname = $name;
  103. my $a = $alias{$name};
  104. my $flag = "0";
  105. if($a) {
  106. $name = $alias{$name};
  107. $flag = "CURLOT_FLAG_ALIAS";
  108. }
  109. $o = sprintf(" {\"%s\", %s, %s, %s},\n",
  110. $oname, $opt{$name}, $type{$name}, $flag);
  111. if(length($o) < 80) {
  112. print $o;
  113. }
  114. else {
  115. printf(" {\"%s\", %s,\n %s, %s},\n",
  116. $oname, $opt{$name}, $type{$name}, $flag);
  117. }
  118. }
  119. print <<FOOT
  120. {NULL, CURLOPT_LASTENTRY, CURLOT_LONG, 0} /* end of table */
  121. };
  122. #ifdef DEBUGBUILD
  123. /*
  124. * Curl_easyopts_check() is a debug-only function that returns non-zero
  125. * if this source file is not in sync with the options listed in curl/curl.h
  126. */
  127. int Curl_easyopts_check(void)
  128. {
  129. return ((CURLOPT_LASTENTRY%10000) != ($lastnum + 1));
  130. }
  131. #endif
  132. FOOT
  133. ;