Contiki 2.5
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  * $Id: dsc.h,v 1.4 2008/10/14 12:46:39 nvt-se Exp $
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__ */