Skip to content

Commit

Permalink
Defined usage() function
Browse files Browse the repository at this point in the history
  • Loading branch information
soh-cah-toa committed Jun 4, 2011
1 parent c6109bc commit 7d81a67
Showing 1 changed file with 29 additions and 4 deletions.
33 changes: 29 additions & 4 deletions frontend/hbdb/main.c
Expand Up @@ -32,16 +32,15 @@ machine.
#include "parrot/api.h"
#include "imcc/api.h"

/* TODO Define usage() function */

static void fail (Parrot_PMC interp);
static void load_bytecode(Parrot_PMC interp, const char * const file, Parrot_PMC *pbc);
static void usage (void);

/*
=item C<int main(int argc, char *argv[])>
Entry point of C<hbdb>. Reads source code from file in C<argv[1]>.
Entry point of C<hbdb>.
=cut
Expand Down Expand Up @@ -74,6 +73,8 @@ main(int argc, char *argv[])
/* Get filename */
file = argv[argc - 1];

usage();

/* Load bytecode */
if (file) {
load_bytecode(interp, file, &pbc);
Expand Down Expand Up @@ -151,7 +152,7 @@ load_bytecode(Parrot_PMC interp, const char * const file, Parrot_PMC *pbc)
{
Parrot_String ps_file;

/* Get filename */
/* Convert file's type to Parrot_String */
if (!Parrot_api_string_import_ascii(interp, file, &ps_file)) {
fail(interp);
}
Expand All @@ -178,6 +179,30 @@ load_bytecode(Parrot_PMC interp, const char * const file, Parrot_PMC *pbc)

/*
=item C<static void usage(void)>
Displays a helpful message about standard usage and an explanation of all
the command line arguments and switches.
=cut
*/

static void
usage(void)
{
puts("Usage: hbdb [options] [file]\n");
puts("Options:");
puts(" -h, --help Displays help information");
puts(" -l, --license Displays license information\n");
puts("File:");
puts(" Must be either a bytecode file (.pbc) or PIR file (.pir)");

exit(EXIT_SUCCESS);
}

/*
=back
=head1 SEE ALSO
Expand Down

0 comments on commit 7d81a67

Please sign in to comment.