Back to index

lightning-sunbird  0.9+nobinonly
Defines | Functions | Variables
tmpltest.c File Reference
#include <stdio.h>
#include <sys/types.h>
#include "ldap-int.h"
#include "disptmpl.h"
#include "srchpref.h"

Go to the source code of this file.

Defines

#define NULLSTRINGIFNULL(s)   ( s == NULL ? "(null)" : s )

Functions

void dump_tmpl ()
void dump_srchpref ()
int main (int argc, char **argv)
void dump_tmpl (struct ldap_disptmpl *tmpl)
void dump_srchpref (struct ldap_searchobj *so)

Variables

static char * syn_name []
static char * syn_type []
static char * includeattrs [] = { "objectClass", "sn", NULL }
static char * item_opts []
static unsigned long item_opt_vals []

Define Documentation

#define NULLSTRINGIFNULL (   s)    ( s == NULL ? "(null)" : s )

Definition at line 64 of file tmpltest.c.


Function Documentation

Here is the caller graph for this function:

void dump_srchpref ( struct ldap_searchobj so)

Definition at line 269 of file tmpltest.c.

{
    int i;
    struct ldap_searchattr *sa;
    struct ldap_searchmatch *sm;

    printf( "Object type prompt:  %s\n",
           NULLSTRINGIFNULL( so->so_objtypeprompt ));
    printf( "Options:             %s\n",
           LDAP_IS_SEARCHOBJ_OPTION_SET( so, LDAP_SEARCHOBJ_OPT_INTERNAL ) ?
           "internal" : "NONE" );
    printf( "Prompt:              %s\n", NULLSTRINGIFNULL( so->so_prompt ));
    printf( "Scope:               " );
    switch ( so->so_defaultscope ) {
    case LDAP_SCOPE_BASE:
       printf( "LDAP_SCOPE_BASE" );
       break;
    case LDAP_SCOPE_ONELEVEL:
       printf( "LDAP_SCOPE_ONELEVEL" );
       break;
    case LDAP_SCOPE_SUBTREE:
       printf( "LDAP_SCOPE_SUBTREE" );
       break;
    default:
       printf("*** unknown!" );
    }
    puts( "\n" );
    printf( "Filter prefix:       %s\n",
           NULLSTRINGIFNULL( so->so_filterprefix ));
    printf( "Filter tag:          %s\n",
           NULLSTRINGIFNULL( so->so_filtertag ));
    printf( "Default select attr: %s\n",
           NULLSTRINGIFNULL( so->so_defaultselectattr ));
    printf( "Default select text: %s\n",
           NULLSTRINGIFNULL( so->so_defaultselecttext ));
    printf( "Searchable attributes ---- \n" );
    for ( sa = so->so_salist; sa != NULL; sa = sa->sa_next ) {
       printf( "  Label: %s\n", NULLSTRINGIFNULL( sa->sa_attrlabel ));
       printf( "  Attribute: %s\n", NULLSTRINGIFNULL( sa->sa_attr ));
       printf( "  Select attr: %s\n", NULLSTRINGIFNULL( sa->sa_selectattr ));
       printf( "  Select text: %s\n", NULLSTRINGIFNULL( sa->sa_selecttext ));
       printf( "  Match types ---- \n" );
       for ( i = 0, sm = so->so_smlist; sm != NULL; i++, sm = sm->sm_next ) {
           if (( sa->sa_matchtypebitmap >> i ) & 1 ) {
              printf( "    %s (%s)\n",
                     NULLSTRINGIFNULL( sm->sm_matchprompt ),
                     NULLSTRINGIFNULL( sm->sm_filter ));
           }
       }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void dump_tmpl ( struct ldap_disptmpl tmpl)

Definition at line 151 of file tmpltest.c.

{
    struct ldap_tmplitem    *rowp, *colp;
    int                            i, rowcnt, colcnt;
    char                    **fetchattrs;
    struct ldap_oclist             *ocp;
    struct ldap_adddeflist  *adp;

    printf( "** Template \"%s\" (plural \"%s\", icon \"%s\")\n",
           NULLSTRINGIFNULL( tmpl->dt_name ),
           NULLSTRINGIFNULL( tmpl->dt_pluralname ),
           NULLSTRINGIFNULL( tmpl->dt_iconname ));

    printf( "object class list:\n" );
    for ( ocp = tmpl->dt_oclist; ocp != NULL; ocp = ocp->oc_next ) {
       for ( i = 0; ocp->oc_objclasses[ i ] != NULL; ++i ) {
           printf( "%s%s", i == 0 ? "  " : " & ",
                  NULLSTRINGIFNULL( ocp->oc_objclasses[ i ] ));
       }
       putchar( '\n' );
    }
    putchar( '\n' );

    printf( "template options:          " );
    if ( tmpl->dt_options == 0L ) {
       printf( "NONE\n" );
    } else {
       printf( "%s %s %s\n", LDAP_IS_DISPTMPL_OPTION_SET( tmpl,
              LDAP_DTMPL_OPT_ADDABLE ) ? "addable" : "",
              LDAP_IS_DISPTMPL_OPTION_SET( tmpl, LDAP_DTMPL_OPT_ALLOWMODRDN )
              ? "modrdn" : "",
              LDAP_IS_DISPTMPL_OPTION_SET( tmpl, LDAP_DTMPL_OPT_ALTVIEW )
              ? "altview" : "" );
    }

    printf( "authenticate as attribute: %s\n", tmpl->dt_authattrname != NULL ?
           tmpl->dt_authattrname : "<default>" );

    printf( "default RDN attribute:     %s\n", tmpl->dt_defrdnattrname != NULL ?
           tmpl->dt_defrdnattrname : "NONE" );

    printf( "default add location:      %s\n", tmpl->dt_defaddlocation != NULL ?
           tmpl->dt_defaddlocation : "NONE" );

    printf( "\nnew entry value default rules:\n" );
    for ( adp = tmpl->dt_adddeflist; adp != NULL; adp = adp->ad_next ) {
       if ( adp->ad_source == LDAP_ADSRC_CONSTANTVALUE ) {
           printf( "  attribute %s <-- constant value \"%s\"\n",
              NULLSTRINGIFNULL( adp->ad_attrname),
              NULLSTRINGIFNULL( adp->ad_value ));
       } else {
           printf( "  attribute %s <-- adder's DN\n",
                  NULLSTRINGIFNULL( adp->ad_attrname ));
       }
    }
    putchar( '\n' );

    printf( "\nfetch attributes & values:\n" );
    if (( fetchattrs = ldap_tmplattrs( tmpl, includeattrs, 1,
              LDAP_SYN_OPT_DEFER )) == NULL ) {
       printf( "  <none>\n" );
    } else {
       for ( i = 0; fetchattrs[ i ] != NULL; ++i ) {
           printf( "  %s\n", fetchattrs[ i ] );
           free( fetchattrs[ i ] );
       }
       free( (char *)fetchattrs );
    }

    printf( "\nfetch attributes only:\n" );
    if (( fetchattrs = ldap_tmplattrs( tmpl, NULL, 0,
              LDAP_SYN_OPT_DEFER )) == NULL ) {
       printf( "  <none>\n" );
    } else {
       for ( i = 0; fetchattrs[ i ] != NULL; ++i ) {
           printf( "  %s\n", fetchattrs[ i ] );
           free( fetchattrs[ i ] );
       }
       free( (char *)fetchattrs );
    }

    printf( "\ntemplate items:\n" );
    rowcnt = 0;
    for ( rowp = ldap_first_tmplrow( tmpl ); rowp != NULLTMPLITEM;
           rowp = ldap_next_tmplrow( tmpl, rowp )) {
       ++rowcnt;
       colcnt = 0;
       for ( colp = ldap_first_tmplcol( tmpl, rowp ); colp != NULLTMPLITEM;
              colp = ldap_next_tmplcol( tmpl, rowp, colp )) {
           ++colcnt;
           printf( "  %2d-%d: %s (%s%s", rowcnt, colcnt,
              syn_name[ colp->ti_syntaxid & 0x0000FFFF ],
              syn_type[ LDAP_GET_SYN_TYPE( colp->ti_syntaxid ) >> 24 ],
              (( LDAP_GET_SYN_OPTIONS( colp->ti_syntaxid ) &
              LDAP_SYN_OPT_DEFER ) != 0 ) ? ",defer" : "" );

           for ( i = 0; item_opts[ i ] != NULL; ++i ) {
              if ( LDAP_IS_TMPLITEM_OPTION_SET( colp, item_opt_vals[ i ] )) {
                  printf( ",%s", NULLSTRINGIFNULL( item_opts[ i ] ));
              }
           }

           printf( "), %s, %s", NULLSTRINGIFNULL( colp->ti_attrname ),
                  NULLSTRINGIFNULL( colp->ti_label ));
           if ( colp->ti_args != NULL ) {
              printf( ",args=" );
              for ( i = 0; colp->ti_args[ i ] != NULL; ++i ) {
                  printf( "<%s>", NULLSTRINGIFNULL( colp->ti_args[ i ] ));
              }
           }

           putchar( '\n' );
       }
    }
}

Here is the call graph for this function:

int main ( int  argc,
char **  argv 
)

Definition at line 68 of file tmpltest.c.

{
    struct ldap_disptmpl    *templates, *dtp;
    struct ldap_searchobj   *so, *sop;
    int                            err;

#ifdef MACOS
       ccommand( &argv );
       for ( argc = 0; argv[ argc ] != NULL; ++argc ) {
           ;
       }
       cshow( stdout );
#endif /* MACOS */

    if (( err = ldap_init_templates( "ldaptemplates.conf", &templates ))
           != 0 ) {
       fprintf( stderr, "ldap_init_templates failed (%d)\n", err );
       exit( 1 );
    }

    if (( err = ldap_init_searchprefs( "ldapsearchprefs.conf", &so ))
           != 0 ) {
       fprintf( stderr, "ldap_init_searchprefs failed (%d)\n", err );
       exit( 1 );
    }

    if ( argc == 1 ) {
       printf( "*** Display Templates:\n" );
       for ( dtp = ldap_first_disptmpl( templates ); dtp != NULLDISPTMPL;
              dtp = ldap_next_disptmpl( templates, dtp )) {
           dump_tmpl( dtp );
           printf( "\n\n" );
       }

       printf( "\n\n*** Search Objects:\n" );
       for ( sop = ldap_first_searchobj( so ); sop != NULLSEARCHOBJ;
                  sop = ldap_next_searchobj( so, sop )) {
           dump_srchpref( sop );
           printf( "\n\n" );
       }

    } else {
       if (( dtp = ldap_oc2template( ++argv, templates )) == NULL ) {
           fprintf( stderr, "no matching template found\n" );
       } else {
           dump_tmpl( dtp );
       }
    }


    ldap_free_templates( templates );
    ldap_free_searchprefs( so );

    exit( 0 );
}

Here is the call graph for this function:


Variable Documentation

char* includeattrs[] = { "objectClass", "sn", NULL } [static]

Definition at line 137 of file tmpltest.c.

unsigned long item_opt_vals[] [static]
char* item_opts[] [static]
Initial value:
 {
    "ro", "sort", "1val", "hide", "required", "hideiffalse", NULL
}

Definition at line 139 of file tmpltest.c.

char* syn_name[] [static]
Initial value:
 {
    "?", "CIS", "MLS", "DN", "BOOL", "JPEG", "JPEGBTN", "FAX", "FAXBTN",
    "AUDIOBTN", "TIME", "DATE", "URL", "SEARCHACT", "LINKACT", "ADDDNACT",
    "VERIFYACT",
}

Definition at line 125 of file tmpltest.c.

char* syn_type[] [static]
Initial value:
 {
    "?", "txt", "img", "?", "bool", "?", "?", "?", "btn",
    "?", "?", "?", "?", "?", "?", "?",
    "action", "?"
}

Definition at line 131 of file tmpltest.c.