home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / misc / emu / AROSdev.lha / AROS / rom / exec / findname.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-09  |  2.6 KB  |  114 lines

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