revert between 56095 -> 55830 in arch
[AROS.git] / rom / oop / unused / addserver.c
blob409c38ef5721055775ad2f5dc31f3305aed00403
1 /*
2 Copyright © 1995-2016, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Add a server to the list of public servers
6 Lang: english
7 */
8 #include <exec/lists.h>
9 #include <exec/memory.h>
10 #include <proto/exec.h>
11 #include <string.h>
12 #include <aros/debug.h>
13 #include "intern.h"
15 /*****************************************************************************
17 NAME */
18 #include <proto/oop.h>
20 AROS_LH2(BOOL, OOP_AddServer,
22 /* SYNOPSIS */
23 AROS_LHA(OOP_Object *, serverPtr, A0),
24 AROS_LHA(STRPTR , serverID, A1),
26 /* LOCATION */
27 struct Library *, OOPBase, 12, OOP)
29 /* FUNCTION
30 Adds a server object to to the list of public servers.
31 Other processes might then obtain a pointer to the server,
32 and use the server to obtain proxies for objects the
33 server controls.
35 INPUTS
36 serverPtr - Pointer to a valid server object.
37 serverID - ID that identifies the server.
39 RESULT
40 TRUE if successful, FALSE otherwise.
42 NOTES
43 Probably not a good API. Implemented
44 just to show how one can call methods
45 across process-borders.
47 EXAMPLE
49 BUGS
51 SEE ALSO
52 OOP_FindServer(), OOP_RemoveServer()
54 INTERNALS
56 HISTORY
57 29-10-95 digulla automatically created from
58 intuition_lib.fd and clib/intuition_protos.h
60 *****************************************************************************/
62 AROS_LIBFUNC_INIT
64 EnterFunc(bug("OOP_AddServer(server=%p, serverID=%s)\n",
65 serverPtr, serverID));
67 if (serverPtr && serverID)
69 struct ServerNode *sn;
71 /* Allocate a listnode, so we can add the server to the list.
72 ** If objects have a node by default, then this won't be necessary.
74 sn = AllocMem(sizeof (struct ServerNode), MEMF_PUBLIC);
75 if (sn)
77 /* Copy the ID */
78 sn->sn_Node.ln_Name = AllocVec(strlen (serverID) + 1, MEMF_ANY);
79 if (sn->sn_Node.ln_Name)
81 sn->sn_Server = serverPtr;
83 strcpy(sn->sn_Node.ln_Name, serverID);
85 ObtainSemaphore( &GetOBase(OOPBase)->ob_ServerListLock );
87 AddTail((struct List *)&GetOBase(OOPBase)->ob_ServerList
88 ,(struct Node *)sn);
89 ReleaseSemaphore( & GetOBase(OOPBase)->ob_ServerListLock );
91 ReturnBool ("OOP_AddServer", TRUE);
94 FreeMem(sn, sizeof (struct ServerNode));
97 } /* if (valid parameters) */
99 ReturnBool ("OOP_AddServer", FALSE);
101 AROS_LIBFUNC_EXIT
102 } /* OOP_AddServer */