Contiki-Inga 3.x
dsc.h
Go to the documentation of this file.
1 /**
2  * \file
3  * Declaration of the DSC program description structure.
4  * \author Adam Dunkels <adam@dunkels.com>
5  *
6  */
7 
8 /**
9  * \addtogroup loader
10  * @{
11  */
12 
13 /**
14  * \page dsc The program description structure
15  *
16  * 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 
28 /*
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  *
59  *
60  */
61 #ifndef DSC_H_
62 #define DSC_H_
63 
64 #include "ctk/ctk.h"
65 
66 /**
67  * The DSC program description structure.
68  *
69  * The DSC structure is used for describing a Contiki program. It
70  * includes a short textual description of the program, either the
71  * name of the program on disk, or a pointer to the init() function,
72  * and an icon for the program.
73  */
74 struct dsc {
75  char *description; /**< A text string containing a one-line
76  description of the program */
77 
78 #if WITH_LOADER_ARCH
79  char *prgname; /**< The name of the program on disk. */
80 #else /* WITH_LOADER_ARCH */
81  struct process *process; /**< A pointer to the program's process. */
82 #endif /* WITH_LOADER_ARCH */
83 
84 #if CTK_CONF_ICONS
85  struct ctk_icon *icon; /**< A pointer to the ctk_icon structure for
86  the DSC. */
87 #endif /* CTK_CONF_ICONS */
88 
89 #if WITH_LOADER_ARCH
90  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. */
94 #endif /* WITH_LOADER_ARCH */
95 };
96 
97 /**
98  * Instantiating macro for the DSC structure.
99  *
100  * \param dscname The name of the C variable which is to contain the
101  * DSC.
102  *
103  * \param description A one-line text describing the program.
104  *
105  * \param prgname The name of the program on disk.
106  *
107  * \param initfunc A pointer to the initialization function of the
108  * program.
109  *
110  * \param icon A pointer to the CTK icon.
111  */
112 #if WITH_LOADER_ARCH
113 #if CTK_CONF_ICONS
114 #define DSC(dscname, description, prgname, process, icon) \
115  CLIF const struct dsc dscname = {description, prgname, icon}
116 #else /* CTK_CONF_ICONS */
117 #define DSC(dscname, description, prgname, process, icon) \
118  CLIF const struct dsc dscname = {description, prgname}
119 #endif /* CTK_CONF_ICONS */
120 #else /* WITH_LOADER_ARCH */
121 #if CTK_CONF_ICONS
122 #define DSC(dscname, description, prgname, process, icon) \
123  PROCESS_NAME(process); \
124  const struct dsc dscname = {description, &process, icon}
125 #else /* CTK_CONF_ICONS */
126 #define DSC(dscname, description, prgname, process, icon) \
127  PROCESS_NAME(process); \
128  const struct dsc dscname = {description, &process}
129 #endif /* CTK_CONF_ICONS */
130 #endif /* WITH_LOADER_ARCH */
131 
132 #define DSC_HEADER(name) extern struct dsc name
133 
134 #ifndef NULL
135 #define NULL 0
136 #endif /* NULL */
137 
138 /** @} */
139 
140 #endif /*DSC_H__ */