libcmml: cmml-fortune.c File Reference

# cmml-fortune.c File Reference

`#include "config.h"`
`#include <stdio.h>`
`#include <stdlib.h>`
`#include <fcntl.h>`
`#include <ctype.h>`
`#include <string.h>`
`#include <unistd.h>`
`#include <cmml.h>`

## Defines
#define | DEFAULT_DURATION "00:30"
#define | DEFAULT_ENCODING "UTF-8"
#define | DEFAULT_SHORT_COMMAND "fortune -s -n 80"
#define | DEFAULT_LONG_COMMAND "fortune -l"
#define | BUFSIZE 10000
## Functions
static void | PrintUsage (char *prog)
static char * | get_fortune (char *command)
int | main (int argc, char *argv[])

## Detailed Description

cmml-fortune: generates a valid CMML document with random content.

    Usage: cmml-fortune [options]
    Generate a random CMML file using an external program
    to provide text (fortune cookies by default).

    Possible options:
      -d timespec, --duration timespec
                     Specify the duration of the generated CMML file
                     ('00:30' by default)
      -e encoding, --encoding encoding
                     Specify the encoding of the generated CMML file
                     ('UTF-8' by default)

      -o filename, --output filename
                     Specify the output filename. The file is written
                     to standard output by default.

      -s command,  --short-command command
                     Specify the command to use to generate short text
                     for the title and anchors ('fortune -s -n 80' by default)
      -l command,  --long-command command
                     Specify the command to use to generate long text
                     for descriptions ('fortune -l' by default)
      -h, --help     Display this help and exit
      -v, --version  Display version information and exit

## Define Documentation

#define DEFAULT_DURATION "00:30"

DEFAULT_DURATION: default duration of created CMML file

Referenced by main(), and PrintUsage().

#define DEFAULT_ENCODING "UTF-8"

DEFAULT_ENCODING: default encoding format of created CMML file

Referenced by main(), and PrintUsage().

#define DEFAULT_SHORT_COMMAND "fortune -s -n 80"

DEFAULT_SHORT_COMMAND: default command to create short descriptions

Referenced by main(), and PrintUsage().

#define DEFAULT_LONG_COMMAND "fortune -l"

DEFAULT_LONG_COMMAND: default command to create long descriptions

Referenced by main(), and PrintUsage().

#define BUFSIZE 10000

BUFSIZE: default buffer size for printing

## Function Documentation

static void PrintUsage | ( | char * | prog | ) | `[static]`

PrintUsage: prints out help on how to use this program

Parameters:

  | prog | the program's name

References DEFAULT_DURATION, DEFAULT_ENCODING, DEFAULT_LONG_COMMAND, and DEFAULT_SHORT_COMMAND.

static char* get_fortune | ( | char * | command | ) | `[static]`

get_fortune: generates random text using the given command

Parameters:

  | command | the command to use to generate text

Returns:
  the generated text

References BUFSIZE.

Referenced by main().

int main | ( | int | argc,
|  | char * | argv[] |
| ) |  |  |

main function of cmml-fortune.

References CMML_Clip::anchor_href, CMML_Clip::anchor_text, BUFSIZE, cmml_clip_destroy(), cmml_clip_new(), cmml_clip_pretty_snprint(), cmml_head_destroy(), cmml_head_new(), cmml_head_pretty_snprint(), cmml_npt_snprint(), cmml_preamble_destroy(), cmml_preamble_new(), cmml_preamble_snprint(), cmml_time_new(), DEFAULT_DURATION, DEFAULT_ENCODING, DEFAULT_LONG_COMMAND, DEFAULT_SHORT_COMMAND, CMML_Clip::desc_text, get_fortune(), outfile, PrintUsage(), CMML_Time::sec, CMML_Time::t, and CMML_Head::title.