2 * Copyright (C) 2009-2010 Red Hat Inc.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 (* Please read generator/README first. *)
28 (* Handling for function flags. *)
29 let progress_message =
30 "This long-running command can generate progress notification messages
31 so that the caller can display a progress bar or indicator.
32 To receive these messages, the caller must register a progress
33 event callback. See L<guestfs(3)/GUESTFS_EVENT_PROGRESS>."
35 let protocol_limit_warning =
36 "Because of the message protocol, there is a transfer limit
37 of somewhere between 2MB and 4MB. See L<guestfs(3)/PROTOCOL LIMITS>."
39 let deprecation_notice ?(prefix = "") flags =
42 find_map (function DeprecatedBy str -> Some str | _ -> None) flags in
44 sprintf "I<This function is deprecated.>
45 In new code, use the L</%s%s> call instead.
47 Deprecated functions will not be removed from the API, but the
48 fact that they are deprecated indicates that there are problems
49 with correct use of these functions." prefix alt in
55 let this_year = 1900 + (localtime (time ())).tm_year in
56 if this_year > 2009 then sprintf "2009-%04d" this_year else "2009"
58 (* Generate a header block in a number of standard styles. *)
60 CStyle | CPlusPlusStyle | HashStyle | OCamlStyle | HaskellStyle
62 type license = GPLv2plus | LGPLv2plus
64 let generate_header ?(extra_inputs = []) comment license =
65 let inputs = "generator/generator_*.ml" :: extra_inputs in
66 let c = match comment with
67 | CStyle -> pr "/* "; " *"
68 | CPlusPlusStyle -> pr "// "; "//"
69 | HashStyle -> pr "# "; "#"
70 | OCamlStyle -> pr "(* "; " *"
71 | HaskellStyle -> pr "{- "; " "
72 | ErlangStyle -> pr "%% "; "% " in
73 pr "libguestfs generated file\n";
74 pr "%s WARNING: THIS FILE IS GENERATED FROM:\n" c;
75 List.iter (pr "%s %s\n" c) inputs;
76 pr "%s ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST.\n" c;
78 pr "%s Copyright (C) %s Red Hat Inc.\n" c copyright_years;
82 pr "%s This program is free software; you can redistribute it and/or modify\n" c;
83 pr "%s it under the terms of the GNU General Public License as published by\n" c;
84 pr "%s the Free Software Foundation; either version 2 of the License, or\n" c;
85 pr "%s (at your option) any later version.\n" c;
87 pr "%s This program is distributed in the hope that it will be useful,\n" c;
88 pr "%s but WITHOUT ANY WARRANTY; without even the implied warranty of\n" c;
89 pr "%s MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" c;
90 pr "%s GNU General Public License for more details.\n" c;
92 pr "%s You should have received a copy of the GNU General Public License along\n" c;
93 pr "%s with this program; if not, write to the Free Software Foundation, Inc.,\n" c;
94 pr "%s 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n" c;
97 pr "%s This library is free software; you can redistribute it and/or\n" c;
98 pr "%s modify it under the terms of the GNU Lesser General Public\n" c;
99 pr "%s License as published by the Free Software Foundation; either\n" c;
100 pr "%s version 2 of the License, or (at your option) any later version.\n" c;
102 pr "%s This library is distributed in the hope that it will be useful,\n" c;
103 pr "%s but WITHOUT ANY WARRANTY; without even the implied warranty of\n" c;
104 pr "%s MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n" c;
105 pr "%s Lesser General Public License for more details.\n" c;
107 pr "%s You should have received a copy of the GNU Lesser General Public\n" c;
108 pr "%s License along with this library; if not, write to the Free Software\n" c;
109 pr "%s Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\n" c;
112 | CStyle -> pr " */\n"
116 | OCamlStyle -> pr " *)\n"
117 | HaskellStyle -> pr "-}\n"