| 1 | # -*- Mode: CPerl -*- | ||||||||||
| 2 | |||||||||||
| 3 | ############################################################################# | ||||||||||
| 4 | # | ||||||||||
| 5 | # File: Getopt::Gen::cmdline_h.pm | ||||||||||
| 6 | # Author: Bryan Jurish <Gen/cmdline_pod.pm> | ||||||||||
| 7 | # Description: template for gengetopt-style c headers | ||||||||||
| 8 | # | ||||||||||
| 9 | ############################################################################# | ||||||||||
| 10 | |||||||||||
| 11 | package Getopt::Gen::cmdline_h; | ||||||||||
| 12 | 1 | ▶ | use Getopt::Gen qw(:utils); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | |||||||||||
| 14 | # fill_in(%args) | ||||||||||
| 15 | # + provides 'SOURCE', 'TYPE', and 'PREPEND' | ||||||||||
| 16 | 0 | ▶ | sub fill_in { | ||||||||
|
Subroutine
fill_in: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 17 | 0 | my ($og,%args) = @_; | |||||||||
| 18 | |||||||||||
| 19 | ## -- get initial position of DATA | ||||||||||
| 20 | 0 | my $datapos = tell(DATA); | |||||||||
| 21 | |||||||||||
| 22 | 0 | my $prepend = 'use Getopt::Gen qw(:utils);'; | |||||||||
| 23 | 0 | ▶ | if (exists($args{PREPEND})) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 24 | 0 | $prepend .= $args{PREPEND}; | |||||||||
| 25 | 0 | delete($args{PREPEND}); | |||||||||
| 26 | } | ||||||||||
| 27 | |||||||||||
| 28 | 0 | my $rc = Getopt::Gen::fill_in($og, | |||||||||
| 29 | TYPE=>'FILEHANDLE', | ||||||||||
| 30 | SOURCE=>\*DATA, | ||||||||||
| 31 | PREPEND=>$prepend, | ||||||||||
| 32 | BROKEN_ARG=>{SOURCE=>__PACKAGE__."::DATA"}, | ||||||||||
| 33 | %args); | ||||||||||
| 34 | |||||||||||
| 35 | ## -- reset DATA | ||||||||||
| 36 | 0 | seek(DATA,$datapos,0); | |||||||||
| 37 | |||||||||||
| 38 | 0 | return $rc; | |||||||||
| 39 | } | ||||||||||
| 40 | |||||||||||
| 41 | 1 | 1; | |||||||||
| 42 | |||||||||||
| 43 | ############################################################### | ||||||||||
| 44 | # POD docs | ||||||||||
| 45 | ############################################################### | ||||||||||
| 46 | =pod | ||||||||||
| 47 | |||||||||||
| 48 | =head1 NAME | ||||||||||
| 49 | |||||||||||
| 50 | Getopt::Gen::cmdline_h.pm - built-in template for generating C header files. | ||||||||||
| 51 | |||||||||||
| 52 | =head1 SYNOPSIS | ||||||||||
| 53 | |||||||||||
| 54 | use Getopt::Gen; | ||||||||||
| 55 | |||||||||||
| 56 | $og = Getopt::Gen::cmdline_h->new(%args); | ||||||||||
| 57 | $og->parse($options_file); | ||||||||||
| 58 | $og->fill_in(%extra_text_template_fill_in_args); | ||||||||||
| 59 | |||||||||||
| 60 | =cut | ||||||||||
| 61 | |||||||||||
| 62 | ############################################################### | ||||||||||
| 63 | # DESCRIPTION | ||||||||||
| 64 | ############################################################### | ||||||||||
| 65 | =pod | ||||||||||
| 66 | |||||||||||
| 67 | =head1 DESCRIPTION | ||||||||||
| 68 | |||||||||||
| 69 | Generate C header files | ||||||||||
| 70 | from option specifications. | ||||||||||
| 71 | |||||||||||
| 72 | =cut | ||||||||||
| 73 | |||||||||||
| 74 | ############################################################### | ||||||||||
| 75 | # METHODS | ||||||||||
| 76 | ############################################################### | ||||||||||
| 77 | =pod | ||||||||||
| 78 | |||||||||||
| 79 | =head1 METHODS | ||||||||||
| 80 | |||||||||||
| 81 | Most are inherited from L<Getopt::Gen>. | ||||||||||
| 82 | |||||||||||
| 83 | =over 4 | ||||||||||
| 84 | |||||||||||
| 85 | =item * C<fill_in(%args)> | ||||||||||
| 86 | |||||||||||
| 87 | Just like the Getopt::Gen method, except you do | ||||||||||
| 88 | not need to specify 'TYPE' or 'SOURCE' parameters. | ||||||||||
| 89 | |||||||||||
| 90 | =back | ||||||||||
| 91 | |||||||||||
| 92 | =cut | ||||||||||
| 93 | |||||||||||
| 94 | ############################################################### | ||||||||||
| 95 | # Bugs | ||||||||||
| 96 | ############################################################### | ||||||||||
| 97 | =pod | ||||||||||
| 98 | |||||||||||
| 99 | =head1 BUGS | ||||||||||
| 100 | |||||||||||
| 101 | Probably many. | ||||||||||
| 102 | |||||||||||
| 103 | =cut | ||||||||||
| 104 | |||||||||||
| 105 | ############################################################### | ||||||||||
| 106 | # Footer | ||||||||||
| 107 | ############################################################### | ||||||||||
| 108 | =pod | ||||||||||
| 109 | |||||||||||
| 110 | =head1 ACKNOWLEDGEMENTS | ||||||||||
| 111 | |||||||||||
| 112 | perl by Larry Wall. | ||||||||||
| 113 | |||||||||||
| 114 | 'gengetopt' was originally written by Roberto Arturo Tena Sanchez, | ||||||||||
| 115 | and it is currently maintained by Lorenzo Bettini. | ||||||||||
| 116 | |||||||||||
| 117 | =head1 AUTHOR | ||||||||||
| 118 | |||||||||||
| 119 | Bryan Jurish E<lt>Gen/cmdline_pod.pmE<gt> | ||||||||||
| 120 | |||||||||||
| 121 | =head1 SEE ALSO | ||||||||||
| 122 | |||||||||||
| 123 | perl(1). | ||||||||||
| 124 | Getopt::Gen(3pm). | ||||||||||
| 125 | Getopt::Gen::cmdline_c(3pm). | ||||||||||
| 126 | Getopt::Gen::cmdline_pod(3pm). | ||||||||||
| 127 | Text::Template(3pm). | ||||||||||
| 128 | |||||||||||
| 129 | =cut | ||||||||||
| 130 | |||||||||||
| 131 | |||||||||||
| 132 | ############################################################### | ||||||||||
| 133 | # TEMPLATE DATA | ||||||||||
| 134 | ############################################################### | ||||||||||
| 135 | __DATA__ | ||||||||||