IPC-XPA

 view release on metacpan or  search on metacpan

XPA.xs  view on Meta::CPAN

		ns = XPAGet(xpa, xtemplate, paramlist, mode, bufs, lens,
		    	names, messages, max_servers);
		/* convert result into something Perlish */
		EXTEND(SP, 2*ns);
		for ( i = 0 ; i < ns ; i++ )
		{
		  /* push the name of the server */
		  PUSHs( sv_2mortal(newSVpv(names[i],0)) );
  		  /* push a reference to the hash onto the stack */
		  PUSHs( sv_2mortal(newRV_noinc((SV*)
				    cdata2hash_Get(bufs[i],lens[i],names[i],
					       messages[i] ))) );
		  free( names[i] );
		  free( messages[i] );
		}
		/* free up memory that's no longer needed */
		Safefree( bufs );
		Safefree( lens );
		Safefree( names );
		Safefree( messages );

XPA.xs  view on Meta::CPAN

		ns = XPASet(xpa, xtemplate, paramlist, mode, buf, len,
		    	names, messages, max_servers);
		/* convert result into something Perlish */
		EXTEND(SP, 2*ns);
		for ( i = 0 ; i < ns ; i++ )
		{
		  /* push the name of the server */
		  PUSHs( sv_2mortal(newSVpv(names[i],0)) );
  		  /* Now, push a reference to the hash onto the stack */
		  PUSHs( sv_2mortal(newRV_noinc((SV*)
				    cdata2hash_Set(names[i], messages[i] ))) );
		  free( names[i] );
		  free( messages[i] );
		}
		/* free up memory that's no longer needed */
		Safefree( names );
		Safefree( messages );


void
_Info(xpa, xtemplate, paramlist, mode, max_servers )

XPA.xs  view on Meta::CPAN

		ns = XPAInfo(xpa, xtemplate, paramlist, mode,
		    	names, messages, max_servers);
		/* convert result into something Perlish */
		EXTEND(SP, 2*ns);
		for ( i = 0 ; i < ns ; i++ )
		{
		  /* push the name of the server */
		  PUSHs( sv_2mortal(newSVpv(names[i],0)) );
  		  /* Now, push a reference to the hash onto the stack */
		  PUSHs( sv_2mortal(newRV_noinc((SV*)
				    cdata2hash_Set(names[i], messages[i] ))) );
		  free( names[i] );
		  free( messages[i] );
		}
		/* free up memory that's no longer needed */
		Safefree( names );
		Safefree( messages );

void
_NSLookup(xpa, tname, ttype)
	IPC_XPA_RAW	xpa

XPA.xs  view on Meta::CPAN

		int ns;
	PPCODE:
		ns = XPANSLookup( xpa, tname, ttype, &xclasses, &names,
                                 &methods, &infos );
		/* convert result into something Perlish */
		EXTEND(SP, ns);
		for ( i = 0 ; i < ns ; i++ )
		{
  		  /* Now, push a reference to the hash onto the stack */
		  PUSHs( sv_2mortal(newRV_noinc((SV*)
				    cdata2hash_Lookup(xclasses[i],
						      names[i],
						      methods[i],
						      infos[i]
						       ))) );
		  free( xclasses[i] );
		  free( names[i] );
		  free( methods[i] );
		  free( infos[i] );
		}
		if ( ns > 0 )

XPA.xs  view on Meta::CPAN

		  /* older servers than 2.1 will react with an error
		     to the access command; they're there (because
		     we see the error) */
		  if ( messages[i] && OLD_SERVER(messages[i]) )
		  {
		    free( messages[i] );
		    messages[i] = NULL;
		  }
  		  /* Now, push a reference to the hash onto the stack */
		  PUSHs( sv_2mortal(newRV_noinc((SV*)
				    cdata2hash_Set(names[i], messages[i] ))) );
		  free( names[i] );
		  free( messages[i] );
		}
		/* free up memory that's no longer needed */
		Safefree( names );
		Safefree( messages );

util.c  view on Meta::CPAN

  /* the EOS position now contains a ',', and ptr is one
     past that.  fix that */
  *--ptr = '\0';

  return str;
}


/* convert XPAGet client data to a Perl hash */
HV *
cdata2hash_Get( char *buf, int len, char *name, char *message )
{
  SV *sv;
  SV *ref;
  /* create hash which will contain buf, name, message */
  HV *hash = newHV();

  /* buf may be big, so try to get perl to use it directly */
  sv = NEWSV(0,0);
  sv_usepvn( sv, buf, len );
  if ( NULL == hv_store( hash, "buf", 3, sv, 0 ) )

util.c  view on Meta::CPAN

  {
    if ( NULL == hv_store( hash, "message", 7, newSVpv( message, 0 ), 0 ) )
      croak( "error storing message for response\n" );
  }

  return hash;
}

/* convert XPASet/XPAInfo/XPAAccess client data to a Perl hash */
HV *
cdata2hash_Set( char *name, char *message )
{
  /* create hash which will contain name, message */
  HV *hash = newHV();

  if ( NULL == hv_store( hash, "name", 4, newSVpv( name, 0 ), 0 ) )
    croak( "error storing name for response\n" );

  if ( message )
  {
    if ( NULL == hv_store( hash, "message", 7, newSVpv( message, 0 ), 0 ) )
      croak( "error storing message for response\n" );
  }
  return hash;
}

/* convert XPALookup client data to a Perl hash */
HV *
cdata2hash_Lookup( char *class, char *name, char *method, char *info )
{
  /* create hash which will contain name, message */
  HV *hash = newHV();

  if ( NULL == hv_store( hash, "name", 4, newSVpv(name,0), 0 ) )
    croak( "error storing name for response\n" );

  if ( NULL == hv_store( hash, "class", 5, newSVpv(class,0), 0 ) )
    croak( "error storing class for response\n" );

util.h  view on Meta::CPAN

 * 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, see <http://www.gnu.org/licenses/>.
 *
 * -->8-->8-->8-->8-- */

char*	hash2str( HV* hash );
HV*	cdata2hash_Get( char *buf, int len, char *name, char *message );
HV *	cdata2hash_Set( char *name, char *message );
HV *	cdata2hash_Lookup( char *class, char *name, char *method, char
			   *info );



( run in 0.261 second using v1.01-cache-2.11-cpan-454fe037f31 )