Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search

[REBOL] Accesing struct! after routine! exec

From: jvargas::whywire::net at: 2-Jun-2003 12:12

Hello All. I've been having problems with the following script when trying to access a subroutine in libc. I am using openbsd. Everything executes well but rebol crashes with a coredump when I try to access the fields of the struct! after calling the external function. REBOL[] stdclib: %/usr/lib/ clib: load/library stdclib c-string: func [ "Returns a null terminated c-string of size strsize" strsize [integer!] "The size of the string" /fill blank [char!] "Character to fill the blanks" /local str ][ if none? fill [ blank: #"." ] ; fill the blancs str: make string! strsize loop strsize [ insert str blank ] ; insert null to terminate the c-string poke str strsize #"^(null)" return str ] utsname: make struct! [ sysname [string!] nodename [string!] release [string!] version [string!] machine [string!] ] reduce [ c-string 256 c-string 256 c-string 256 c-string 256 c-string 256 c-string 256 ] uname: make routine! compose/deep [ name [struct! [(first utsname)]] return: [integer!] ] clib "_uname" uname utsname probe utsname Here are the c definitions: int uname (struct utsname *name ); #define SYS_NMLN 256 struct utsname { char sysname[SYS_NMLN]; /* Name of this OS. */ char nodename[SYS_NMLN]; /* Name of this network node. */ char release[SYS_NMLN]; /* Release level. */ char version[SYS_NMLN]; /* Version level. */ char machine[SYS_NMLN]; /* Hardware type. */ }; Ideas anyone??? Thanks for your help, Jaime -- The best way to predict the future is to invent it -- Steve Jobs