blob: 15f408c9f1bd8759e5386f8a6fb716493f6ed99b [file] [log] [blame]
adamdunkels1e45c6d2003-09-02 21:47:27 +00001/**
2 * \file
3 * Declaration of the DSC program description structure.
4 * \author Adam Dunkels <adam@dunkels.com>
5 *
adamdunkelse937ded2003-10-01 07:53:57 +00006 */
7
8/**
9 * \addtogroup loader
10 * @{
11 */
12
13/**
14 * \page dsc The program description structure
15 *
adamdunkels1e45c6d2003-09-02 21:47:27 +000016 * The Contiki DSC structure is used for describing programs. It
17 * includes a string describing the program, the name of the program
18 * file on disk (or a pointer to the programs initialization function
19 * for systems without disk support), a bitmap icon and a text version
20 * of the same icon.
21 *
22 * The DSC is saved into a file which can be loaded by programs such
23 * as the "Directory" application which reads all DSC files on disk
24 * and presents the icons and descriptions in a window.
25 *
26 */
27
adamdunkels43c3d1d2003-04-17 19:00:00 +000028/*
29 * Copyright (c) 2003, Adam Dunkels.
30 * All rights reserved.
31 *
32 * Redistribution and use in source and binary forms, with or without
33 * modification, are permitted provided that the following conditions
34 * are met:
35 * 1. Redistributions of source code must retain the above copyright
36 * notice, this list of conditions and the following disclaimer.
37 * 2. Redistributions in binary form must reproduce the above
38 * copyright notice, this list of conditions and the following
39 * disclaimer in the documentation and/or other materials provided
40 * with the distribution.
41 * 3. The name of the author may not be used to endorse or promote
42 * products derived from this software without specific prior
43 * written permission.
44 *
45 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
46 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
47 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
48 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
49 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
50 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
51 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
52 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
53 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
54 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
55 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
56 *
57 * This file is part of the Contiki desktop environment
58 *
oliverschmidta40eac52005-03-18 00:40:30 +000059 * $Id: dsc.h,v 1.7 2005/03/18 00:40:30 oliverschmidt Exp $
adamdunkels43c3d1d2003-04-17 19:00:00 +000060 *
61 */
62#ifndef __DSC_H__
63#define __DSC_H__
64
65#include "ctk.h"
66
adamdunkels1e45c6d2003-09-02 21:47:27 +000067/**
68 * The DSC program description structure.
69 *
70 * The DSC structure is used for describing a Contiki program. It
71 * includes a short textual description of the program, either the
72 * name of the program on disk, or a pointer to the init() function,
73 * and an icon for the program.
74 */
adamdunkels43c3d1d2003-04-17 19:00:00 +000075struct dsc {
adamdunkels1e45c6d2003-09-02 21:47:27 +000076 char *description; /**< A text string containing a one-line
77 description of the program */
adamdunkels43c3d1d2003-04-17 19:00:00 +000078
79#if WITH_LOADER_ARCH
adamdunkels1e45c6d2003-09-02 21:47:27 +000080 char *prgname; /**< The name of the program on disk. */
adamdunkels43c3d1d2003-04-17 19:00:00 +000081#else /* WITH_LOADER_ARCH */
adamdunkels1e45c6d2003-09-02 21:47:27 +000082 void (*init)(char *arg); /**< A pointer to the initialization
83 function of the program .*/
adamdunkels43c3d1d2003-04-17 19:00:00 +000084#endif /* WITH_LOADER_ARCH */
85
adamdunkels1e45c6d2003-09-02 21:47:27 +000086 struct ctk_icon *icon; /**< A pointer to the ctk_icon structure for
87 the DSC. */
88
adamdunkels43c3d1d2003-04-17 19:00:00 +000089#if WITH_LOADER_ARCH
adamdunkels1e45c6d2003-09-02 21:47:27 +000090 void *loadaddr; /**< The loading address of the DSC. Used by
91 the LOADER_UNLOAD() function when
92 deallocating the memory allocated for the
93 DSC when loading it. */
adamdunkels43c3d1d2003-04-17 19:00:00 +000094#endif /* WITH_LOADER_ARCH */
95};
96
oliverschmidta40eac52005-03-18 00:40:30 +000097#if CTK_CONF_ICONS
98#define DSC_ICON(icon) icon
99#else
100#define DSC_ICON(icon) NULL
101#endif
102
adamdunkels1e45c6d2003-09-02 21:47:27 +0000103/**
104 * Intantiating macro for the DSC structure.
105 *
106 * \param dscname The name of the C variable which is to contain the
107 * DSC.
108 *
109 * \param description A one-line text describing the program.
110 *
111 * \param prgname The name of the program on disk.
112 *
113 * \param initfunc A pointer to the initialization function of the
114 * program.
115 *
116 * \param icon A pointer to the CTK icon.
117 */
adamdunkels43c3d1d2003-04-17 19:00:00 +0000118#if WITH_LOADER_ARCH
119#define DSC(dscname, description, prgname, initfunc, icon) \
oliverschmidta40eac52005-03-18 00:40:30 +0000120 const struct dsc dscname = {description, prgname, DSC_ICON(icon)}
adamdunkels43c3d1d2003-04-17 19:00:00 +0000121#else /* WITH_LOADER_ARCH */
122#define DSC(dscname, description, prgname, initfunc, icon) \
adamdunkels8bb5cca2003-08-24 22:41:31 +0000123 void initfunc(char *arg); \
oliverschmidta40eac52005-03-18 00:40:30 +0000124 const struct dsc dscname = {description, initfunc, DSC_ICON(icon)}
adamdunkels43c3d1d2003-04-17 19:00:00 +0000125#endif /* WITH_LOADER_ARCH */
126
127#define DSC_HEADER(name) extern struct dsc name;
128
adamdunkels8bb5cca2003-08-24 22:41:31 +0000129#ifndef NULL
130#define NULL 0
131#endif /* NULL */
132
adamdunkelse937ded2003-10-01 07:53:57 +0000133/** @} */
134
adamdunkels43c3d1d2003-04-17 19:00:00 +0000135#endif /* _DSC_H__ */