ext/bsdjail.c
changeset 5 41a1542b3b10
parent 2 0c24586f579a
equal deleted inserted replaced
4:9e4a97b20fcb 5:41a1542b3b10
     1 /*
     1 /*
     2  *  dict.c - Ruby LinkParser - Dict Class
     2  *  bsdjail.c - JParallel extension for FreeBSD jail(2) functions
     3  *  $Id$
     3  *  $Id$
     4  *  
     4  *  
     5  *  Authors:
     5  *  Authors:
     6  *    * Michael Granger <ged@FaerieMUD.org>
     6  *    * Michael Granger <ged@FaerieMUD.org>
     7  *  
     7  *    * Mahlon E. Smith <mahlon@martini.nu>
     8  *  Copyright (c) 2006 The FaerieMUD Consortium.
     8  *  
     9  *  
     9  *  Copyright (c) 2008, Michael Granger and Mahlon Smith
    10  *  This work is licensed under the Creative Commons Attribution License. To
    10  *  All rights reserved.
    11  *  view a copy of this license, visit
    11  *  
    12  *  http://creativecommons.org/licenses/by/1.0 or send a letter to Creative
    12  *  Redistribution and use in source and binary forms, with or without
    13  *  Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
    13  *  modification, are permitted provided that the following conditions are met:
    14  *  
    14  *  
    15  */
    15  *    * Redistributions of source code must retain the above copyright notice,
    16 
    16  *      this list of conditions and the following disclaimer.
    17 #include <ruby.h>
    17  *  
    18 #include <intern.h>
    18  *    * Redistributions in binary form must reproduce the above copyright notice,
    19 
    19  *      this list of conditions and the following disclaimer in the documentation
    20 #include <stdio.h>
    20  *      and/or other materials provided with the distribution.
    21 #include <sys/param.h>
    21  *  
    22 #include <sys/jail.h>
    22  *    * Neither the name of the author/s, nor the names of the project's
    23 #include <sys/types.h>
    23  *      contributors may be used to endorse or promote products derived from this
    24 #include <unistd.h>
    24  *      software without specific prior written permission.
    25 
    25  *  
       
    26  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
       
    27  *  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
       
    28  *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
       
    29  *  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
       
    30  *  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
       
    31  *  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
       
    32  *  SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
       
    33  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
       
    34  *  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
       
    35  *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
       
    36  *  
       
    37  */
       
    38 
       
    39 #include "bsdjail.h"
    26 
    40 
    27 VALUE rbjail_mBSD;
    41 VALUE rbjail_mBSD;
    28 VALUE rbjail_cBSDJail;
    42 VALUE rbjail_cBSDJail;
    29 
    43 
    30 
    44 
    31 /*
    45 /*
    32  *  Debug logging function
    46  *  Debug logging function
    33  */
    47  */
    34 void
    48 void
    35 #ifdef HAVE_STDARG_PROTOTYPES
    49 #ifdef HAVE_STDARG_PROTOTYPES
    36 rlink_debug(const char *fmt, ...)
    50 rbjail_debug(const char *fmt, ...)
    37 #else
    51 #else
    38 rlink_debug( const char *fmt, va_dcl )
    52 rbjail_debug( const char *fmt, va_dcl )
    39 #endif
    53 #endif
    40 {
    54 {
    41 	char buf[BUFSIZ], buf2[BUFSIZ];
    55 	char buf[BUFSIZ], buf2[BUFSIZ];
    42 	va_list	args;
    56 	va_list	args;
    43 
    57 
    44 	if ( !RTEST(ruby_debug) ) return;
    58 	if ( !RTEST(ruby_debug) ) return;
    45 
    59 
    46 	snprintf( buf, BUFSIZ, "Jail Debug>>> %s", fmt );
    60 	snprintf( buf, BUFSIZ, "Debug>>> %s", fmt );
    47 
    61 
    48 	va_init_list( args, fmt );
    62 	va_init_list( args, fmt );
    49 	vsnprintf( buf2, BUFSIZ, buf, args );
    63 	vsnprintf( buf2, BUFSIZ, buf, args );
    50 	fputs( buf2, stderr );
    64 	fputs( buf2, stderr );
    51 	fputs( "\n", stderr );
    65 	fputs( "\n", stderr );