15
15
// You should have received a copy of the GNU Lesser General Public License
16
16
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
18
// sample_work_generator.C: an example BOINC work generator.
18
// sample_work_generator.cpp: an example BOINC work generator.
19
19
// This work generator has the following properties
20
20
// (you may need to change some or all of these):
141
void usage(char *name) {
142
fprintf(stderr, "This is an example BOINC work generator.\n"
143
"This work generator has the following properties\n"
144
"(you may need to change some or all of these):\n"
145
"- Runs as a daemon, and creates an unbounded supply of work.\n"
146
" It attempts to maintain a \"cushion\" of 100 unsent job instances.\n"
147
" (your app may not work this way; e.g. you might create work in batches)\n"
148
"- Creates work for the application \"uppercase\".\n"
149
"- Creates a new input file for each job;\n"
150
" the file (and the workunit names) contain a timestamp\n"
151
" and sequence number, so that they're unique.\n\n"
152
"Usage: %s [OPTION]...\n\n"
154
" [ -d X ] Sets debug level to X.\n"
155
" [ -h | --help ] Shows this help text.\n"
156
" [ -v | --version ] Shows version information.\n",
139
161
int main(int argc, char** argv) {
142
164
for (i=1; i<argc; i++) {
143
if (!strcmp(argv[i], "-d")) {
144
log_messages.set_debug_level(atoi(argv[++i]));
165
if (is_arg(argv[i], "d")) {
167
log_messages.printf(MSG_CRITICAL, "%s requires an argument\n\n", argv[--i]);
171
int dl = atoi(argv[i]);
172
log_messages.set_debug_level(dl);
173
if (dl == 4) g_print_queries = true;
174
} else if (is_arg(argv[i], "h") || is_arg(argv[i], "help")) {
177
} else if (is_arg(argv[i], "v") || is_arg(argv[i], "version")) {
178
printf("%s\n", SVN_VERSION);
146
log_messages.printf(MSG_CRITICAL,
147
"bad cmdline arg: %s", argv[i]
181
log_messages.printf(MSG_CRITICAL, "unknown command line argument: %s\n\n", argv[i]);
152
if (config.parse_file("..")) {
187
retval = config.parse_file();
153
189
log_messages.printf(MSG_CRITICAL,
154
"can't read config file\n"
190
"Can't parse config.xml: %s\n", boincerror(retval)
167
203
log_messages.printf(MSG_CRITICAL, "can't find app\n");
170
if (read_file_malloc("../templates/uc_wu", wu_template)) {
206
if (read_file_malloc(config.project_path("templates/uc_wu"), wu_template)) {
171
207
log_messages.printf(MSG_CRITICAL, "can't read WU template\n");