source: toilet/trunk/src/export.c @ 1367

Last change on this file since 1367 was 1321, checked in by Sam Hocevar, 17 years ago
  • Moved export stuff in export.c.
  • Bail out with an error if the requested export format is unsupported.
  • Property svn:keywords set to Id
File size: 1.2 KB
Line 
1/*
2 *  TOIlet        The Other Implementation’s letters
3 *  Copyright (c) 2006 Sam Hocevar <sam@zoy.org>
4 *                All Rights Reserved
5 *
6 *  $Id: export.c 1321 2006-11-10 07:56:55Z sam $
7 *
8 *  This program is free software; you can redistribute it and/or
9 *  modify it under the terms of the Do What The Fuck You Want To
10 *  Public License, Version 2, as published by Sam Hocevar. See
11 *  http://sam.zoy.org/wtfpl/COPYING for more details.
12 */
13
14/*
15 * This file contains export functions.
16 */
17
18#include "config.h"
19
20#if defined(HAVE_INTTYPES_H)
21#   include <inttypes.h>
22#endif
23#include <string.h>
24#include <stdio.h>
25#include <stdlib.h>
26#include <cucul.h>
27
28#include "toilet.h"
29#include "export.h"
30
31int export_list(void)
32{
33    char const * const * exports, * const * p;
34
35    printf("Available export formats:\n");
36
37    exports = cucul_get_export_list();
38    for(p = exports; *p; p += 2)
39        printf("\"%s\": %s\n", *p, *(p + 1));
40
41    return 0;
42}
43
44int export_set(context_t *cx, char const *format)
45{
46    char const * const * exports, * const * p;
47
48    cx->export = format;
49
50    exports = cucul_get_export_list();
51    for(p = exports; *p; p += 2)
52        if(!strcmp(*p, format))
53            return 0;
54
55    fprintf(stderr, "unknown export format `%s'\n", format);
56    return -1;
57}
58
Note: See TracBrowser for help on using the repository browser.