2
0

optiontable.pl 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. #!/usr/bin/env perl
  2. print <<HEAD
  3. /***************************************************************************
  4. * _ _ ____ _
  5. * Project ___| | | | _ \| |
  6. * / __| | | | |_) | |
  7. * | (__| |_| | _ <| |___
  8. * \___|\___/|_| \_\_____|
  9. *
  10. * Copyright (C) 1998 - 2022, 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. while(<STDIN>) {
  35. if(/^ *CURLOPT\(([^,]*), ([^,]*), (\d+)\)/) {
  36. my($opt, $type, $num)=($1,$2,$3);
  37. my $name;
  38. my $ext = $type;
  39. if($opt =~ /OBSOLETE/) {
  40. # skip obsolete options
  41. next;
  42. }
  43. if($opt =~ /^CURLOPT_(.*)/) {
  44. $name=$1;
  45. }
  46. $ext =~ s/CURLOPTTYPE_//;
  47. $ext =~ s/CBPOINT/CBPTR/;
  48. $ext =~ s/POINT\z//;
  49. $type = "CURLOT_$ext";
  50. $opt{$name} = $opt;
  51. $type{$name} = $type;
  52. push @names, $name;
  53. if($num < $lastnum) {
  54. print STDERR "ERROR: $opt has bad number\n";
  55. exit 2;
  56. }
  57. else {
  58. $lastnum = $num;
  59. }
  60. }
  61. # alias for an older option
  62. # old = new
  63. if(/^#define (CURLOPT_[^ ]*) *(CURLOPT_\S*)/) {
  64. my ($o, $n)=($1, $2);
  65. # skip obsolete ones
  66. if($n !~ /OBSOLETE/) {
  67. $o =~ s/^CURLOPT_//;
  68. $n =~ s/^CURLOPT_//;
  69. $alias{$o} = $n;
  70. push @names, $o,
  71. }
  72. }
  73. }
  74. for my $name (sort @names) {
  75. my $oname = $name;
  76. my $a = $alias{$name};
  77. my $flag = "0";
  78. if($a) {
  79. $name = $alias{$name};
  80. $flag = "CURLOT_FLAG_ALIAS";
  81. }
  82. $o = sprintf(" {\"%s\", %s, %s, %s},\n",
  83. $oname, $opt{$name}, $type{$name}, $flag);
  84. if(length($o) < 80) {
  85. print $o;
  86. }
  87. else {
  88. printf(" {\"%s\", %s,\n %s, %s},\n",
  89. $oname, $opt{$name}, $type{$name}, $flag);
  90. }
  91. }
  92. print <<FOOT
  93. {NULL, CURLOPT_LASTENTRY, CURLOT_LONG, 0} /* end of table */
  94. };
  95. #ifdef DEBUGBUILD
  96. /*
  97. * Curl_easyopts_check() is a debug-only function that returns non-zero
  98. * if this source file is not in sync with the options listed in curl/curl.h
  99. */
  100. int Curl_easyopts_check(void)
  101. {
  102. return ((CURLOPT_LASTENTRY%10000) != ($lastnum + 1));
  103. }
  104. #endif
  105. FOOT
  106. ;