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

Last change on this file since 2263 was 1461, checked in by Sam Hocevar, 16 years ago
  • Bwarf, typo in the no warranty clause.
  • Property svn:keywords set to Id
File size: 1.3 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 1461 2006-12-12 01:50:48Z sam $
7 *
8 *  This program is free software. It comes without any warranty, to
9 *  the extent permitted by applicable law. You can redistribute it
10 *  and/or modify it under the terms of the Do What The Fuck You Want
11 *  To Public License, Version 2, as published by Sam Hocevar. See
12 *  http://sam.zoy.org/wtfpl/COPYING for more details.
13 */
14
15/*
16 * This file contains export functions.
17 */
18
19#include "config.h"
20
21#if defined(HAVE_INTTYPES_H)
22#   include <inttypes.h>
23#endif
24#include <string.h>
25#include <stdio.h>
26#include <stdlib.h>
27#include <cucul.h>
28
29#include "toilet.h"
30#include "export.h"
31
32int export_list(void)
33{
34    char const * const * exports, * const * p;
35
36    printf("Available export formats:\n");
37
38    exports = cucul_get_export_list();
39    for(p = exports; *p; p += 2)
40        printf("\"%s\": %s\n", *p, *(p + 1));
41
42    return 0;
43}
44
45int export_set(context_t *cx, char const *format)
46{
47    char const * const * exports, * const * p;
48
49    cx->export = format;
50
51    exports = cucul_get_export_list();
52    for(p = exports; *p; p += 2)
53        if(!strcmp(*p, format))
54            return 0;
55
56    fprintf(stderr, "unknown export format `%s'\n", format);
57    return -1;
58}
59
Note: See TracBrowser for help on using the repository browser.