home *** CD-ROM | disk | FTP | other *** search
/ MACD 4 / MACD4.iso / Emulatory / AROS / utility / gettagdata.c < prev    next >
Encoding:
C/C++ Source or Header  |  1978-03-06  |  2.5 KB  |  97 lines

  1. /*
  2.     $Id: gettagdata.c,v 1.4 1996/10/24 22:51:46 aros Exp $
  3.     $Log: gettagdata.c,v $
  4.     Revision 1.4  1996/10/24 22:51:46  aros
  5.     Use proper Amiga datatypes (eg: ULONG not unsigned long)
  6.  
  7.     Revision 1.3  1996/10/24 15:51:36  aros
  8.     Use the official AROS macros over the __AROS versions.
  9.  
  10.     Revision 1.2  1996/10/23 14:08:59  aros
  11.     Formatted
  12.  
  13.     Added parens to all assignments which are used truth expressions
  14.  
  15.     Revision 1.1  1996/10/22 04:45:59  aros
  16.     Some more utility.library functions.
  17.  
  18.     Desc: GetTagData()
  19.     Lang: english
  20. */
  21. #include "utility_intern.h"
  22.  
  23. /*****************************************************************************
  24.  
  25.     NAME */
  26.     #include <utility/tagitem.h>
  27.     #include <clib/utility_protos.h>
  28.  
  29.     AROS_LH3(ULONG, GetTagData,
  30.  
  31. /*  SYNOPSIS */
  32.     AROS_LHA(Tag             , tagValue, D0),
  33.     AROS_LHA(ULONG           , defaultVal, D1),
  34.     AROS_LHA(struct TagItem *, tagList, A0),
  35.  
  36. /*  LOCATION */
  37.     struct UtilityBase *, UtilityBase, 6, Utility)
  38.  
  39. /*  FUNCTION
  40.     Searches the TagList for the Tag specified, if it exists, then
  41.     returns the ti_Data field of that Tag, otherwise returns the
  42.     supplied default value.
  43.  
  44.     INPUTS
  45.     tagValue    -    Tag to search for.
  46.     defaultVal  -    Default value for the Tag.
  47.     tagList     -    Pointer to first TagItem in the list.
  48.  
  49.     RESULT
  50.     The data value if the Tag exists, or the default value if it
  51.     doesn't.
  52.  
  53.     NOTES
  54.     If the input TagList doesn't exist (eg for some reason equals
  55.     NULL), then the return value will be NULL. This way you can
  56.     check for broken code, whereas returing the default would allow
  57.     code that is possibly buggy to still seem to work. (Until you
  58.     tried to do anything special at least).
  59.  
  60.     EXAMPLE
  61.  
  62.     struct Window *window;        \* The Window we are creating *\
  63.     struct TagItem *wintags;    \* Tags for this window *\
  64.  
  65.     \* Find out the value for the WA_Left tag *\
  66.     window->Left = GetTagData( WA_Left, 320, wintags )
  67.  
  68.     BUGS
  69.  
  70.     SEE ALSO
  71.     utility/tagitem.h
  72.  
  73.     INTERNALS
  74.  
  75.     HISTORY
  76.     29-10-95    digulla automatically created from
  77.                 utility_lib.fd and clib/utility_protos.h
  78.     11-08-96    iaint   Moved into AROS source tree.
  79.  
  80. *****************************************************************************/
  81. {
  82.     AROS_LIBFUNC_INIT
  83.     struct TagItem *ti = NULL;
  84.  
  85.     /*
  86.     If we can find the Tag in the supplied list, then return the
  87.     ti_Data fields value.
  88.  
  89.     If the tag is not in the list, just return the default value.
  90.     */
  91.     if (tagList && (ti = FindTagItem(tagValue, tagList)))
  92.     return ti->ti_Data;
  93.  
  94.     return defaultVal;
  95.     AROS_LIBFUNC_EXIT
  96. } /* GetTagData */
  97.