adamdunkels | 1e45c6d | 2003-09-02 21:47:27 +0000 | [diff] [blame] | 1 | /** |
| 2 | * \file |
| 3 | * Declaration of the DSC program description structure. |
| 4 | * \author Adam Dunkels <adam@dunkels.com> |
| 5 | * |
adamdunkels | e937ded | 2003-10-01 07:53:57 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | /** |
| 9 | * \addtogroup loader |
| 10 | * @{ |
| 11 | */ |
| 12 | |
| 13 | /** |
| 14 | * \page dsc The program description structure |
| 15 | * |
adamdunkels | 1e45c6d | 2003-09-02 21:47:27 +0000 | [diff] [blame] | 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 | |
adamdunkels | 43c3d1d | 2003-04-17 19:00:00 +0000 | [diff] [blame] | 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 | * |
oliverschmidt | a40eac5 | 2005-03-18 00:40:30 +0000 | [diff] [blame] | 59 | * $Id: dsc.h,v 1.7 2005/03/18 00:40:30 oliverschmidt Exp $ |
adamdunkels | 43c3d1d | 2003-04-17 19:00:00 +0000 | [diff] [blame] | 60 | * |
| 61 | */ |
| 62 | #ifndef __DSC_H__ |
| 63 | #define __DSC_H__ |
| 64 | |
| 65 | #include "ctk.h" |
| 66 | |
adamdunkels | 1e45c6d | 2003-09-02 21:47:27 +0000 | [diff] [blame] | 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 | */ |
adamdunkels | 43c3d1d | 2003-04-17 19:00:00 +0000 | [diff] [blame] | 75 | struct dsc { |
adamdunkels | 1e45c6d | 2003-09-02 21:47:27 +0000 | [diff] [blame] | 76 | char *description; /**< A text string containing a one-line |
| 77 | description of the program */ |
adamdunkels | 43c3d1d | 2003-04-17 19:00:00 +0000 | [diff] [blame] | 78 | |
| 79 | #if WITH_LOADER_ARCH |
adamdunkels | 1e45c6d | 2003-09-02 21:47:27 +0000 | [diff] [blame] | 80 | char *prgname; /**< The name of the program on disk. */ |
adamdunkels | 43c3d1d | 2003-04-17 19:00:00 +0000 | [diff] [blame] | 81 | #else /* WITH_LOADER_ARCH */ |
adamdunkels | 1e45c6d | 2003-09-02 21:47:27 +0000 | [diff] [blame] | 82 | void (*init)(char *arg); /**< A pointer to the initialization |
| 83 | function of the program .*/ |
adamdunkels | 43c3d1d | 2003-04-17 19:00:00 +0000 | [diff] [blame] | 84 | #endif /* WITH_LOADER_ARCH */ |
| 85 | |
adamdunkels | 1e45c6d | 2003-09-02 21:47:27 +0000 | [diff] [blame] | 86 | struct ctk_icon *icon; /**< A pointer to the ctk_icon structure for |
| 87 | the DSC. */ |
| 88 | |
adamdunkels | 43c3d1d | 2003-04-17 19:00:00 +0000 | [diff] [blame] | 89 | #if WITH_LOADER_ARCH |
adamdunkels | 1e45c6d | 2003-09-02 21:47:27 +0000 | [diff] [blame] | 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. */ |
adamdunkels | 43c3d1d | 2003-04-17 19:00:00 +0000 | [diff] [blame] | 94 | #endif /* WITH_LOADER_ARCH */ |
| 95 | }; |
| 96 | |
oliverschmidt | a40eac5 | 2005-03-18 00:40:30 +0000 | [diff] [blame] | 97 | #if CTK_CONF_ICONS |
| 98 | #define DSC_ICON(icon) icon |
| 99 | #else |
| 100 | #define DSC_ICON(icon) NULL |
| 101 | #endif |
| 102 | |
adamdunkels | 1e45c6d | 2003-09-02 21:47:27 +0000 | [diff] [blame] | 103 | /** |
| 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 | */ |
adamdunkels | 43c3d1d | 2003-04-17 19:00:00 +0000 | [diff] [blame] | 118 | #if WITH_LOADER_ARCH |
| 119 | #define DSC(dscname, description, prgname, initfunc, icon) \ |
oliverschmidt | a40eac5 | 2005-03-18 00:40:30 +0000 | [diff] [blame] | 120 | const struct dsc dscname = {description, prgname, DSC_ICON(icon)} |
adamdunkels | 43c3d1d | 2003-04-17 19:00:00 +0000 | [diff] [blame] | 121 | #else /* WITH_LOADER_ARCH */ |
| 122 | #define DSC(dscname, description, prgname, initfunc, icon) \ |
adamdunkels | 8bb5cca | 2003-08-24 22:41:31 +0000 | [diff] [blame] | 123 | void initfunc(char *arg); \ |
oliverschmidt | a40eac5 | 2005-03-18 00:40:30 +0000 | [diff] [blame] | 124 | const struct dsc dscname = {description, initfunc, DSC_ICON(icon)} |
adamdunkels | 43c3d1d | 2003-04-17 19:00:00 +0000 | [diff] [blame] | 125 | #endif /* WITH_LOADER_ARCH */ |
| 126 | |
| 127 | #define DSC_HEADER(name) extern struct dsc name; |
| 128 | |
adamdunkels | 8bb5cca | 2003-08-24 22:41:31 +0000 | [diff] [blame] | 129 | #ifndef NULL |
| 130 | #define NULL 0 |
| 131 | #endif /* NULL */ |
| 132 | |
adamdunkels | e937ded | 2003-10-01 07:53:57 +0000 | [diff] [blame] | 133 | /** @} */ |
| 134 | |
adamdunkels | 43c3d1d | 2003-04-17 19:00:00 +0000 | [diff] [blame] | 135 | #endif /* _DSC_H__ */ |