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

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: findname.c,v 1.9 1996/10/24 15:50:48 aros Exp $
  4.     $Log: findname.c,v $
  5.     Revision 1.9  1996/10/24 15:50:48  aros
  6.     Use the official AROS macros over the __AROS versions.
  7.  
  8.     Revision 1.8  1996/10/21 20:47:33  aros
  9.     Changed struct SysBase to struct ExecBase
  10.  
  11.     Revision 1.7  1996/10/19 17:17:44  aros
  12.     Use the ANSI C function
  13.  
  14.     Revision 1.6  1996/09/12 13:23:23  digulla
  15.     Fixed a severe bug in the code. If nothing was found, the function returned
  16.     the list-header instead of NULL
  17.  
  18.     Revision 1.5  1996/08/13 13:56:01  digulla
  19.     Replaced AROS_LA by AROS_LHA
  20.     Replaced some AROS_LH*I by AROS_LH*
  21.     Sorted and added includes
  22.  
  23.     Revision 1.4  1996/08/01 17:41:10  digulla
  24.     Added standard header for all files
  25.  
  26.     Desc:
  27.     Lang: english
  28. */
  29. #define AROS_ALMOST_COMPATIBLE
  30. #include "exec_intern.h"
  31. #include <aros/libcall.h>
  32. #include <string.h>
  33.  
  34. /*****************************************************************************
  35.  
  36.     NAME */
  37.     #include <exec/lists.h>
  38.     #include <clib/exec_protos.h>
  39.  
  40.     AROS_LH2I(struct Node *, FindName,
  41.  
  42. /*  SYNOPSIS */
  43.     AROS_LHA(struct List *, list, A0),
  44.     AROS_LHA(UBYTE       *, name, A1),
  45.  
  46. /*  LOCATION */
  47.     struct ExecBase *, SysBase, 46, Exec)
  48.  
  49. /*  FUNCTION
  50.     Look for a node with a certain name in a list.
  51.  
  52.     INPUTS
  53.     list - Search this list.
  54.     name - This is the name to look for.
  55.  
  56.     RESULT
  57.  
  58.     NOTES
  59.     The search is case-sensitive, so "Hello" will not find a node
  60.     named "hello".
  61.  
  62.     The list must contain complete Nodes and no MinNodes.
  63.  
  64.     EXAMPLE
  65.     struct List * list;
  66.     struct Node * node;
  67.  
  68.     // Look for a node with the name "Hello"
  69.     node = FindName (list, "Hello");
  70.  
  71.     BUGS
  72.  
  73.     SEE ALSO
  74.  
  75.     INTERNALS
  76.  
  77.     HISTORY
  78.     26-08-95    digulla created after EXEC-Routine
  79.     26-10-95    digulla adjusted to new calling scheme
  80.  
  81. ******************************************************************************/
  82. {
  83.     AROS_LIBFUNC_INIT
  84.     struct Node * node;
  85.  
  86.     assert (list);
  87.     assert (name);
  88.  
  89.     /* Look through the list */
  90.     for (node=GetHead(list); node; node=GetSucc(node))
  91.     {
  92.     /* check the node. If we found it, stop */
  93.     if (!strcmp (node->ln_Name, name))
  94.         break;
  95.     }
  96.  
  97.     /*
  98.     If we found a node, this will contain the pointer to it. If we
  99.     didn't, this will be NULL (either because the list was
  100.     empty or because we tried all nodes in the list)
  101.     */
  102.     return node;
  103.     AROS_LIBFUNC_EXIT
  104. } /* FindName */
  105.  
  106.