Contiki 3.x
dsc.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2003, Adam Dunkels.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above
11  * copyright notice, this list of conditions and the following
12  * disclaimer in the documentation and/or other materials provided
13  * with the distribution.
14  * 3. The name of the author may not be used to endorse or promote
15  * products derived from this software without specific prior
16  * written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
19  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
22  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
24  * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  *
30  * This file is part of the Contiki desktop environment
31  *
32  *
33  */
34 
35 /**
36  * \file
37  * Declaration of the DSC program description structure.
38  * \author Adam Dunkels <adam@dunkels.com>
39  *
40  */
41 
42 /**
43  * \addtogroup loader
44  * @{
45  */
46 
47 /**
48  * \page dsc The program description structure
49  *
50  * The Contiki DSC structure is used for describing programs. It
51  * includes a string describing the program, the name of the program
52  * file on disk (or a pointer to the programs initialization function
53  * for systems without disk support), a bitmap icon and a text version
54  * of the same icon.
55  *
56  * The DSC is saved into a file which can be loaded by programs such
57  * as the "Directory" application which reads all DSC files on disk
58  * and presents the icons and descriptions in a window.
59  *
60  */
61 
62 #ifndef DSC_H_
63 #define DSC_H_
64 
65 #include "ctk/ctk.h"
66 
67 /**
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  */
75 struct dsc {
76  char *description; /**< A text string containing a one-line
77  description of the program */
78 
79 #if WITH_LOADER_ARCH
80  char *prgname; /**< The name of the program on disk. */
81 #else /* WITH_LOADER_ARCH */
82  struct process *process; /**< A pointer to the program's process. */
83 #endif /* WITH_LOADER_ARCH */
84 
85 #if CTK_CONF_ICONS
86  struct ctk_icon *icon; /**< A pointer to the ctk_icon structure for
87  the DSC. */
88 #endif /* CTK_CONF_ICONS */
89 
90 #if WITH_LOADER_ARCH
91  void *loadaddr; /**< The loading address of the DSC. Used by
92  the LOADER_UNLOAD() function when
93  deallocating the memory allocated for the
94  DSC when loading it. */
95 #endif /* WITH_LOADER_ARCH */
96 };
97 
98 /**
99  * Instantiating macro for the DSC structure.
100  *
101  * \param dscname The name of the C variable which is to contain the
102  * DSC.
103  *
104  * \param description A one-line text describing the program.
105  *
106  * \param prgname The name of the program on disk.
107  *
108  * \param initfunc A pointer to the initialization function of the
109  * program.
110  *
111  * \param icon A pointer to the CTK icon.
112  */
113 #if WITH_LOADER_ARCH
114 #if CTK_CONF_ICONS
115 #define DSC(dscname, description, prgname, process, icon) \
116  CLIF const struct dsc dscname = {description, prgname, icon}
117 #else /* CTK_CONF_ICONS */
118 #define DSC(dscname, description, prgname, process, icon) \
119  CLIF const struct dsc dscname = {description, prgname}
120 #endif /* CTK_CONF_ICONS */
121 #else /* WITH_LOADER_ARCH */
122 #if CTK_CONF_ICONS
123 #define DSC(dscname, description, prgname, process, icon) \
124  PROCESS_NAME(process); \
125  const struct dsc dscname = {description, &process, icon}
126 #else /* CTK_CONF_ICONS */
127 #define DSC(dscname, description, prgname, process, icon) \
128  PROCESS_NAME(process); \
129  const struct dsc dscname = {description, &process}
130 #endif /* CTK_CONF_ICONS */
131 #endif /* WITH_LOADER_ARCH */
132 
133 #define DSC_HEADER(name) extern struct dsc name
134 
135 #ifndef NULL
136 #define NULL 0
137 #endif /* NULL */
138 
139 /** @} */
140 
141 #endif /*DSC_H__ */
The DSC program description structure.
Definition: dsc.h:75
char * description
A text string containing a one-line description of the program.
Definition: dsc.h:76
void * loadaddr
The loading address of the DSC.
Definition: dsc.h:91
char * prgname
The name of the program on disk.
Definition: dsc.h:80
CTK header file.