Re: How to use CosNaming & the name-server in ORBit2?



Hi Lars,

I've tried orbit-name-server-2 and it works perfectly. Find attached
my example. I've used some code from the example you can find under 
src/services/name/ in the ORBit2 directory.

1.) start the name server and write IOR into file:

    orbit-name-server-2 > ons.ior 

    (server and client need this file to get the address of the name server,
     so you have some copy work, too)

2.) start one or more servers:
    
    ./hello-server

    (see also ./hello-server -h for additional options)

3.) start hello-client, e.g. with

    ./hello-client -l (this prints you all servers which are bound to the
                       name server)

    or just

    ./hello-client or also see ./hello-client -h


Good luck, Marion

On Thu, Feb 06, 2003 at 10:04:38AM +1100, Lars Petersson wrote:
> Hi Michael,
> 
> On Wed,  5 Feb 2003 23:34, you wrote:
> > Hi Lars,
> >
> > On Mon, 2003-02-03 at 08:34, Lars Petersson wrote:
> > > I'm trying to use the orbit-name-server-2 in ORBit2
> >
> > 	Why ? :-) it's probably best if you present a solution neutral problem
> > statement, and we'll try and suggest how best to meet your goals.
> 
> Well, maybe there are other ways to solve my problem... The problem is
> that I have servers running on several computers and clients should be
> able to connect to these remotely without any manual work such
> as copying IORs etc.
> 
> > 	Bonobo-activation is usually a better answer than the name-service for
> > lots of applications.
> 
> What is bonobo-actionvation? Does it work over the network?
> 
> /Lars
> _______________________________________________
> orbit-list mailing list
> orbit-list@gnome.org
> http://mail.gnome.org/mailman/listinfo/orbit-list

-- 
Marion Schuenemann

FOKUS 
Fraunhofer Research Institute for Open Communication Systems

Kaiserin-Augusta-Allee 31 
D-10589 Berlin

tel: 3463-7384    room: 2021
interface Hello
{
  string say_hello(in string user);
};
CC = gcc
ORBIT_IDL = `pkg-config --variable=orbit_idl ORBit-2.0`
ORBIT_CFLAGS = `pkg-config --cflags ORBit-2.0` \
	`pkg-config --cflags ORBit-CosNaming-2.0`
ORBIT_LIBS = `pkg-config --libs ORBit-2.0` \
	`pkg-config --libs ORBit-CosNaming-2.0`
CPPFLAGS = -D__USE_POSIX2
CFLAGS = -Wall -ansi -pedantic $(ORBIT_CFLAGS) -g
LFLAGS = $(ORBIT_LIBS)
SHELL=/bin/sh

all: hello-client hello-server

hello-client: hello-client.o hello-common.o common.o hello-stubs.o
	$(CC) -o hello-client hello-client.o hello-common.o \
	  hello-stubs.o common.o $(LFLAGS)

hello-server: hello-main.o hello-common.o hello-server.o hello-skels.o \
	  common.o
	$(CC) -o hello-server hello-main.o hello-common.o hello-server.o \
	  hello-skels.o common.o $(LFLAGS)

clean:
	rm -f *.[oa] hello-client hello-server hello-skels.c hello-stubs.c \
	  hello.h hello-common.c

save:
	DATE=`date +'%Y-%m-%dT%H'`; \
	tar cf hello-$$DATE.tar Makefile hello-client.c hello-client.h \
	  common.c common.h hello-main.c hello-main.h hello-server.c \
	  hello-server.h hello.idl; \
	gzip -f hello-$$DATE.tar

hello-stubs.c: hello.idl
	$(ORBIT_IDL) hello.idl

hello-common.c: hello.idl
	$(ORBIT_IDL) hello.idl

hello-skels.c: hello.idl
	$(ORBIT_IDL) hello.idl

hello-client.o: hello.h hello-client.c common.h hello-client.h

hello-server.o: hello.h hello-server.c common.h hello-main.h

hello-main.o: hello.h hello-main.h hello-main.c common.h hello-server.h

common.o: common.c common.h

hello.h: hello.idl
	$(ORBIT_IDL) hello.idl
#include <stdio.h>
#include <stdlib.h>

#include <ORBitservices/CosNaming.h>

#include "hello.h"
#include "common.h"

#define IS_EXCEPTION(ev, name)						\
  (strcmp (CORBA_exception_id (ev), ex_##name) == 0)

int
print_exception(CORBA_Environment* ev, char* str)
{
  int major = ev->_major; /* Possible values are CORBA_NO_EXCEPTION,
                             CORBA_USER_EXCEPTION, and
                             CORBA_SYSTEM_EXCEPTION */

  if (major != CORBA_NO_EXCEPTION)
  {
    fprintf(stderr, "%s: %d (%s)!\n", str, major, ev->_id);
  }
  ev->_major = CORBA_NO_EXCEPTION;
  
  return major;
}

CORBA_char *
ORBit_CosNaming_NameComponent_to_string(const CosNaming_NameComponent* comp)
{
  CORBA_char *retval;
  GString *str = g_string_new ("");
  CORBA_char *pos;
  gboolean id_ready = FALSE;

  if (!*comp->id && !*comp->kind)
    g_string_append_c (str, '.');
  else
    {
      pos = comp->id;
      while (!id_ready || *pos)
	{
	  if (!*pos)
	    {
	      /* id_ready must be FALSE */
	      id_ready = TRUE;
	      pos = comp->kind;
	      if (pos && *pos)
		g_string_append_c (str, '.');
	      continue;
	    }
	  if (*pos == '\\' || *pos == '.' || *pos == '/')
	    g_string_append_c (str, '\\');
	  g_string_append_c (str, *pos);
	  pos++;
	}
    }

  retval = CORBA_string_dup (str->str);
  g_string_free (str, TRUE);

  return retval;
}

CosNaming_Name*
ORBit_string_to_CosNaming_Name(const CORBA_char* string,
                               CORBA_Environment* ev)
{
  CosNaming_Name *retval = CosNaming_Name__alloc();
  GPtrArray *ids = g_ptr_array_new();
  GPtrArray *kinds = g_ptr_array_new();
  gint pos = 0, i, len;
  gboolean used = FALSE;
  GPtrArray *append_to;

  g_ptr_array_add(ids, g_string_new(""));
  g_ptr_array_add(kinds, g_string_new(""));

  append_to = ids;

  while (*string)
  {
    gchar append;
    switch (*string)
    {
      case '.':
        used = TRUE;
        g_return_val_if_fail(append_to != kinds, NULL);  
        append_to = kinds;
        append = '\0';
        break;
      case '/':
        if (used)
        {
          pos++;
          g_ptr_array_add(ids, g_string_new(""));
          g_ptr_array_add(kinds, g_string_new(""));
          g_assert(ids->len == pos + 1 && kinds->len == pos + 1);
        }
        used = FALSE;
        append_to = ids;
        append = '\0';
        break;
      case '\\':
        string++;
        g_return_val_if_fail(*string == '.' || 
                             *string == '/' || *string == '\\', NULL);  
        append = *string;
        break;
      default:
        append = *string;
        used = TRUE;
        break;
    }
    if (append)
      g_string_append_c(g_ptr_array_index(append_to, pos), append);
    string++;
  }
  len = used ? pos + 1 : pos;
  retval->_buffer = CORBA_sequence_CosNaming_NameComponent_allocbuf(len);
  retval->_length = len;
  retval->_maximum = len;

  for (i = 0; i < len; i++)
  {  
    GString *id = g_ptr_array_index(ids, i);
    GString *kind = g_ptr_array_index(kinds, i);
      
    retval->_buffer[i].id = CORBA_string_dup(id->str);
    retval->_buffer[i].kind = CORBA_string_dup(kind->str);
  }
  
  for (i = 0; i <= pos; i++)
  {  
    g_string_free(g_ptr_array_index(ids, i), TRUE);
    g_string_free(g_ptr_array_index(kinds, i), TRUE);
  }

  g_ptr_array_free(ids, TRUE);
  g_ptr_array_free(kinds, TRUE);

  return retval;
}

int
init_corba_orb(int* argc,
               char** argv,
               CORBA_Environment* ev,
               CORBA_ORB* orb)
{  
  CORBA_exception_init(ev);
  if (print_exception(ev, "exception init"))
  {
    return -1;
  }
  *orb = CORBA_ORB_init(argc, argv, "orbit-local-orb", ev);
  if (print_exception(ev, "initialisation of ORB"))
  {
    return -1;
  }
  return 0;
}  

CosNaming_NamingContext*
get_naming_service(char* filename,
                   CORBA_ORB* orb,
                   CORBA_Environment* ev)
{
  FILE* ifp = NULL;
  char iorbuffer[1024] = "";
  CosNaming_NamingContext* context = g_new0(CosNaming_NamingContext, 1);

  /* read object reference */
  ifp = fopen(filename, "r");
  if (ifp == NULL)
  {
    g_error("No ior file!");
    exit(-1);
  }
  fgets(iorbuffer, 1024, ifp);  
  fclose(ifp);
  *context = CORBA_ORB_string_to_object(*orb, iorbuffer, ev);
  print_exception(ev, "name server");
  CORBA_Object_is_a(*context,
                    "IDL:omg.org/CosNaming/NamingContext:1.0", ev);
  if (!(ev->_major == CORBA_NO_EXCEPTION))
  {
    print_exception(ev, "connect to naming service");
    return NULL;
  }
  return context;
}
#ifndef _common_h_
#define _common_h_

#include <ORBitservices/CosNaming.h>

extern int print_exception(CORBA_Environment* ev, char* str);
extern CosNaming_Name* ORBit_string_to_CosNaming_Name(
    const CORBA_char* string, CORBA_Environment* ev);
extern CORBA_char* ORBit_CosNaming_NameComponent_to_string(
    const CosNaming_NameComponent* comp);
extern int init_corba_orb(int* argc, char** argv,
                          CORBA_Environment* ev, CORBA_ORB* orb);
extern CosNaming_NamingContext* get_naming_service(char* filename,
                                                   CORBA_ORB* orb,
                                                   CORBA_Environment* ev);

#endif /* _common_h_ */
/* File: hello-client.c
   (C) 2002 Marion Schuenemann <schuenemann@fokus.fraunhofer.de>

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#include <stdio.h>
#include <stdlib.h>
#include <getopt.h>

#include <ORBitservices/CosNaming.h>

#include "hello.h"
#include "common.h"
#include "hello-client.h"

char* user = "client";

static void list_servers();
static int deinit_corba(Hello* hello_server,
                        CORBA_Environment* ev, CORBA_ORB* orb,
                        CosNaming_NamingContext* context);
static void program_opts(int argc,
                         char** argv,
                         gboolean* list,
                         char** server_name,
                         char** user);
static void usage(char* name);

int
main (int argc, char *argv[])
{
  CORBA_Environment ev;
  Hello* hello_server;
  CORBA_ORB orb;
  gboolean list = FALSE;
  char* server_name = "HelloServer";
  char* ns_ior = "ons.ior";
  CosNaming_NamingContext* context;
  char* response;

  init_corba_orb(&argc, argv, &ev, &orb);
  program_opts(argc, argv, &list, &server_name, &user);
  context = get_naming_service(ns_ior, &orb, &ev);
  if (list)
  {
    list_servers(context, "/", &ev);
    exit(0);
  }
  print_exception(&ev, "init_corba_nameserver");

  hello_server = get_server(context, server_name, &ev);
  if (!hello_server)
  {
    print_exception(&ev, "Could not connect server!\n");
    return 0;
  }
  response = Hello_say_hello(*hello_server, user, &ev);
  print_exception(&ev, "say_hello");
  printf("%s got hello from %s\n", user, response);
  deinit_corba(hello_server, &ev, &orb, context);
  print_exception(&ev, "deinit_corba");
  return 0;
}

static void
program_opts(int argc,
             char** argv,
             gboolean* list,
             char** server_name,
             char** user)
{
  int c = 0;

  for (;;)
  {
    int option_index = 0;

    static struct option long_options[] =
      {
	{"help",            0, 0, 'h'},
	{"list-components", 0, 0, 'l'},
	{"server-name",     1, 0, 's'},
        {"user",            1, 0, 'u'},
	{0,                 0, 0, 0}
      };
      
    c = getopt_long(argc, argv, "hls:u:",
                    long_options, &option_index);
    if (c == -1)
    {
      break;			
    }
    switch (c)
    {
      case 'h':
        usage(argv[0]);
        exit(0);
        break;
      case 'l':
        *list = TRUE;
        break;
      case 's':
        *server_name = optarg;
        break;
      case 'u':
        *user = optarg;
        break;
      default:
        fprintf(stderr, "Error in command line options!\n");
        usage(argv[0]);
        exit(-1);
    }
  }
  if (optind < argc)
  {
    fprintf(stderr, "Error in command line options!\n");
    usage(argv[0]);
    exit(-1);
  }
}

static void
usage(char* name)
{
  printf("Usage: %s [options]\n"
         "Options are\n"
         "  -h,   --help            Print help, then exit\n"
         "  -l,   --list-components List available servers\n"
         "  -s x, --server-name=x   Name of server\n"
         "  -u x  --user=x          Name of user\n"
         "",
         name);
}

static int
deinit_corba(Hello* hello_server,
             CORBA_Environment* ev,
             CORBA_ORB* orb,
             CosNaming_NamingContext* context)
{
  if (hello_server)
  {
    CORBA_Object_release(*hello_server, ev);
    print_exception(ev, "release hello_server object");
    g_free(hello_server);
  }
  CORBA_ORB_destroy(*orb, ev);
  print_exception(ev, "release orb object");
  g_free(context);
  return 0;
}

static CORBA_Object
resolve(CosNaming_NamingContext context,
        gboolean is_ext_context,
        CORBA_char *str,
        CORBA_Environment * ev)
{
  CORBA_Object retval;
  
  if (is_ext_context)
    {
      retval = CosNaming_NamingContextExt_resolve_str(context, str, ev);
      print_exception(ev, "");
    }
  else
    {
      CosNaming_Name *name = ORBit_string_to_CosNaming_Name(str, ev);
      print_exception(ev, "");
      if (name->_length != 0)
	{
	  retval = CosNaming_NamingContext_resolve(context, name, ev);
	  print_exception(ev, "");
	}
      else
	{
	  retval = CORBA_Object_duplicate(context, ev);
	  print_exception(ev, "");
	}
    }
  return retval;
}

#define FETCH_AT_ONCE 10

static void
list_servers(CosNaming_NamingContext* context,
                CORBA_string requested_name,
                CORBA_Environment* ev)
{
  CosNaming_BindingIterator bi;
  CosNaming_BindingList *bl;
  gboolean is_ext_context = 0;
  CosNaming_NamingContext list_context;

  list_context = resolve
    (*context,
     is_ext_context,
     requested_name, ev);
  g_assert(list_context);
  
  CosNaming_NamingContext_list(list_context, FETCH_AT_ONCE,
                               &bl, &bi, ev);
  print_exception(ev, "");
  
  CORBA_Object_release (list_context, ev);
  print_exception(ev, "");
  
  while (TRUE)
  {
    int i;
    for (i = 0; i < bl->_length; i++)
    {
      CosNaming_NameComponent *comp =
        &bl->_buffer[i].binding_name._buffer[0];
      CORBA_char *name = 
        ORBit_CosNaming_NameComponent_to_string (comp);
      
      printf ("%s%s\n", name,
              bl->_buffer[i].binding_type == CosNaming_ncontext ?
              "/" : "");
      CORBA_free (name);
    }
    CORBA_free (bl);
    if (CORBA_Object_is_nil (bi, ev))
    {
      break;
    }
    if (!CosNaming_BindingIterator_next_n (bi, FETCH_AT_ONCE,
                                           &bl, ev))
    {
      print_exception(ev, "");
      CosNaming_BindingIterator_destroy (bi, ev);
      print_exception(ev, "");
      CORBA_Object_release (bi, ev);
      bi = CORBA_OBJECT_NIL;
    }
    print_exception(ev, "");
  }
}

Hello*
get_server(CosNaming_NamingContext* context,
              char* server_name,
              CORBA_Environment* ev)
{
  CosNaming_Name* name = NULL;
  Hello* hello_server = g_new0(Hello, 1);

  if (context)
  {
    name = ORBit_string_to_CosNaming_Name(server_name, ev);
    if (ev->_major != CORBA_NO_EXCEPTION)
    {
      g_free(hello_server);
      return CORBA_OBJECT_NIL;
    }
    if (name->_length != 0)
    {
      *hello_server = CosNaming_NamingContext_resolve(*context, name, ev);
      if (ev->_major != CORBA_NO_EXCEPTION)
      {
        g_free(hello_server);
        return CORBA_OBJECT_NIL;
      }
    }
    return hello_server;
  }
  else
  {
    g_warning("no naming service");
    return CORBA_OBJECT_NIL;
  }
}
/* File: hello-client.h
   (C) 2002 Marion Schuenemann <schuenemann@fokus.fraunhofer.de>

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#ifndef _hello_client_h_
#define _hello_client_h_

#include "hello.h"

extern char* user;

extern Hello* get_server(CosNaming_NamingContext* context,
                         char* server_name,
                         CORBA_Environment* ev);

#endif /* _hello_client_h_ */
/* File: hello-main.c
   (C) 2002 Marion Schuenemann <schuenemann@fokus.fraunhofer.de>

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#include <getopt.h>
#include <stdio.h>
#include <stdlib.h>

#include <ORBitservices/CosNaming.h>

#include "hello.h"
#include "hello-main.h"
#include "common.h"
#include "hello-server.h"

static Hello impl_Hello__create(
    PortableServer_POA poa, CORBA_Environment* ev);

static void program_opts(int argc,
                         char** argv,
                         char** user,
                         char** server_name);

static void usage(char* name);
char* user = "server";
char* server_name = "HelloServer";

int
main (int argc, char* argv[])
{
  CORBA_ORB orb;
  PortableServer_POA poa = CORBA_OBJECT_NIL;
  PortableServer_POAManager poa_mgr;
  CORBA_Environment ev;
  Hello hello = CORBA_OBJECT_NIL;
  char* retval;
  FILE* ofp;
  CosNaming_NamingContext* context;
  CosNaming_Name* name;
  char* ns_ior = "ons.ior"; /* name of file including IOR of name server */
  char* ior = "ior"; /* name of file for IOR of this server */

  init_corba_orb(&argc, argv, &ev, &orb);
  g_assert(ev._major == CORBA_NO_EXCEPTION);
  program_opts(argc, argv, &user, &server_name);

  /* try name server */
  context = get_naming_service(ns_ior, &orb, &ev);

  poa = (PortableServer_POA)
    CORBA_ORB_resolve_initial_references (orb, "RootPOA", &ev);
  g_assert(ev._major == CORBA_NO_EXCEPTION);
  poa_mgr = PortableServer_POA__get_the_POAManager (poa, &ev);
  g_assert(ev._major == CORBA_NO_EXCEPTION);
  hello = impl_Hello__create(poa, &ev);
  PortableServer_POAManager_activate (poa_mgr, &ev);
  g_assert(ev._major == CORBA_NO_EXCEPTION);
  retval = CORBA_ORB_object_to_string(orb, hello, &ev);
  g_assert(ev._major == CORBA_NO_EXCEPTION);
  /* write IOR into file */
  ofp = fopen(ior, "w");
  fprintf(ofp, "%s\n", retval);
  fclose(ofp);

  if (context)
  {
    name = ORBit_string_to_CosNaming_Name(CORBA_string_dup(server_name), &ev);
    print_exception(&ev, "");
    CosNaming_NamingContext_bind(*context, name, hello, &ev);
    print_exception(&ev, "");
  }

  CORBA_free(retval);

  CORBA_ORB_run(orb, &ev);
  g_assert(ev._major == CORBA_NO_EXCEPTION);

  CORBA_exception_free(&ev);
  g_assert(ev._major == CORBA_NO_EXCEPTION);

  return 0;
}

static Hello
impl_Hello__create(PortableServer_POA poa,
                       CORBA_Environment* ev)
{
  Hello retval;
  impl_POA_Hello *newservant;
  PortableServer_ObjectId *objid;

  newservant = g_new0(impl_POA_Hello, 1);
  newservant->servant.vepv = &poa_hello_vepv;
  newservant->poa = poa;
  POA_Hello__init((PortableServer_Servant) newservant, ev);
  g_assert(ev->_major == CORBA_NO_EXCEPTION);
  objid = PortableServer_POA_activate_object(poa, newservant, ev);
  g_assert(ev->_major == CORBA_NO_EXCEPTION);
  CORBA_free(objid);
  retval = PortableServer_POA_servant_to_reference(poa, newservant, ev);
  g_assert(ev->_major == CORBA_NO_EXCEPTION);

  return retval;
}

static void
program_opts(int argc,
             char** argv,
             char** user,
             char** server_name)
{
  int c = 0;

  for (;;)
  {
    int option_index = 0;

    static struct option long_options[] =
      {
	{"help",            0, 0, 'h'},
	{"server_name",     1, 0, 's'},
	{"user",            1, 0, 'u'},
	{0,                 0, 0, 0}
      };
      
    c = getopt_long(argc, argv, "hs:u:",
                    long_options, &option_index);
    if (c == -1)
    {
      break;			
    }
    switch (c)
    {
      case 'h':
        usage(argv[0]);
        exit(0);
        break;
      case 's':
        *server_name = optarg;
        break;
      case 'u':
        *user = optarg;
        break;
      default:
        fprintf(stderr, "Error in command line options!\n");
        usage(argv[0]);
        exit(-1);
    }
  }
  if (optind < argc)
  {
    fprintf(stderr, "Error in command line options!\n");
    usage(argv[0]);
    exit(-1);
  }
}

static void
usage(char* name)
{
  printf("Usage: %s [options]\n"
         "Options are\n"
         "  -h,   --help                  Print help, then exit\n"
         "  -s    --server=x              Name of server\n"
         "  -u x, --user=x                Name of user\n"
         "",
         name);
}
/* File: hello-main.h
   (C) 2002 Marion Schuenemann <schuenemann@fokus.fraunhofer.de>

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#ifndef _hello_main_h_
#define _hello_main_h_

#include "hello.h"

extern char* server_name;
extern char* user;

#endif /* _hello_main_h_ */
/* File: hello-server.c
   (C) 2002 Marion Schuenemann <schuenemann@fokus.fraunhofer.de>

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#include <stdio.h>
#include <stdlib.h>

#include <ORBitservices/CosNaming.h>

#include "hello.h"
#include "common.h"
#include "hello-server.h"
#include "hello-main.h"

static CORBA_string
say_hello(PortableServer_Servant servant, const CORBA_char* client,
          CORBA_Environment* ev)
{
  printf("%s got hello from %s\n", user, client);

  return CORBA_string_dup(user); 
}

PortableServer_ServantBase__epv hello_base_epv =
  {
    NULL,
    NULL,
    NULL
  };
POA_Hello__epv hello_epv =
  {
    NULL,
    &say_hello
  };
POA_Hello__vepv poa_hello_vepv = 
  {
    &hello_base_epv,
    &hello_epv
  };
/* File: hello-server.h
   (C) 2002 Marion Schuenemann <schuenemann@fokus.fraunhofer.de>

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#ifndef _hello_server_h_
#define _hello_server_h_

#include "hello.h"

typedef struct impl_POA_Hello impl_POA_Hello;
struct impl_POA_Hello {
  POA_Hello servant;
  PortableServer_POA poa;
};

extern POA_Hello__vepv poa_hello_vepv;

#endif /* _hello_server_h_ */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]