troubles with usersub 
Author Message
 troubles with usersub

I'm trying to bind the yp_??? routines into Perl (4.019) and can't get
things to work.  For example, the routine yp_get_default_domain()
wants to be passwd a pointer to a valid (char *) variable.   In C this is:
        char *domain;
        yp_get_default_domain(&domain);
        printf("domain=%s\n", domain);

Anybody care to tell the proper way to put a wrapper on this?
Do I need to allocate a string and strcpy() or what?

Here's what "mus" dumps out (edited somewhat) given a ypclnt.mus file with
        CASE int yp_get_default_domain
        O       char*           outdomain
        END

#include "EXTERN.h"
#include "perl.h"
char *savestr();
#undef bool
static enum usersubs { US_yp_get_default_domain };
static int usersub();

int init_ypclnt()
{
  char *filename = "ypclnt.c";
  make_usub("yp_get_default_domain", US_yp_get_default_domain, usersub,
      filename);

Quote:
};

static int usersub(ix, sp, items)
     int ix;
     register int sp;
     register int items;
{
  STR **st = stack->ary_array + sp;
  register int i;
  register char *tmps;
  register STR *Str;            /* used in str_get and str_gnum macros */

  switch (ix) {
    case US_yp_get_default_domain:
        if (items != 1)
            fatal("Usage: &yp_get_default_domain($outdomain)");
        else {
            int retval;
            char outdomain[133];

            retval = yp_get_default_domain(outdomain);
            str_numset(st[0], (double) retval);
            str_set(st[1], (char*) outdomain);
        }
        return sp;

  default:
    fatal("Unimplemented user-defined subroutine");
  }
  return sp;

Quote:
}

--



Sun, 18 Sep 1994 07:27:44 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Need help with setuid scripts which use usersub.o

2. How to get $; from usersub

3. HELP: with usersub callback

4. How to pass a function in a usersub?

5. How to return lists from a usersub() routine

6. usersub functions in a different package.

7. call eval from usersub.c

8. calling do_eval from usersub

9. sort usersub.

10. usersub advice requested

11. usersub

12. usersub: How To

 

 
Powered by phpBB® Forum Software