Lines Matching refs:map
1 /* $NetBSD: map.c,v 1.4 2025/09/05 21:16:23 christos Exp $ */
31 #include "rewrite-map.h"
44 struct rewrite_map *map = NULL;
57 * Go to the end of the map invocation (the right closing brace)
62 * '%' marks the beginning of a new map
68 * of an old map
89 * Copy the map invocation
100 * Isolate the map name (except for variable deref)
119 * Check for special map types
166 * Isolate the argument of the map (except for variable deref)
182 * Compile the substitution pattern of the map argument
193 * Create the map
195 map = calloc( sizeof( struct rewrite_map ), 1 );
196 if ( map == NULL ) {
200 memset( map, 0, sizeof( struct rewrite_map ) );
203 if ( ldap_pvt_thread_mutex_init( &map->lm_mutex ) ) {
219 map->lm_subst = subst;
224 * Parses special map types
237 map->lm_type = REWRITE_MAP_SUBCONTEXT;
238 map->lm_name = strdup( s + 1 );
239 if ( map->lm_name == NULL ) {
243 map->lm_data = rewrite_context_find( info, s + 1 );
244 if ( map->lm_data == NULL ) {
263 map->lm_type = REWRITE_MAP_SETW_SESN_VAR;
264 map->lm_name = strdup( s + 3 );
266 map->lm_type = REWRITE_MAP_SET_SESN_VAR;
267 map->lm_name = strdup( s + 2 );
271 map->lm_type = REWRITE_MAP_SETW_OP_VAR;
272 map->lm_name = strdup( s + 2 );
274 map->lm_type = REWRITE_MAP_SET_OP_VAR;
275 map->lm_name = strdup( s + 1 );
278 if ( map->lm_name == NULL ) {
289 map->lm_type = REWRITE_MAP_GET_SESN_VAR;
290 map->lm_name = strdup( s + 2 );
292 map->lm_type = REWRITE_MAP_GET_OP_VAR;
293 map->lm_name = strdup( s + 1 );
295 if ( map->lm_name == NULL ) {
305 map->lm_type = REWRITE_MAP_GET_PARAM;
306 map->lm_name = strdup( s + 1 );
307 if ( map->lm_name == NULL ) {
314 * Built-in map
317 map->lm_type = REWRITE_MAP_BUILTIN;
318 map->lm_name = strdup( s );
319 if ( map->lm_name == NULL ) {
323 map->lm_data = rewrite_builtin_map_find( info, s );
324 if ( map->lm_data == NULL ) {
338 if ( map ) {
341 ldap_pvt_thread_mutex_destroy( &map->lm_mutex );
345 if ( map->lm_name ) {
346 free( map->lm_name );
347 map->lm_name = NULL;
349 free( map );
350 map = NULL;
354 return map;
358 * Applies the new map type
364 struct rewrite_map *map,
373 assert( map != NULL );
380 switch ( map->lm_type ) {
383 ( struct rewrite_context * )map->lm_data,
397 rc = rewrite_var_set( &op->lo_vars, map->lm_name,
401 if ( map->lm_type == REWRITE_MAP_SET_OP_VAR ) {
416 var = rewrite_var_find( op->lo_vars, map->lm_name );
436 map->lm_name, key->bv_val );
438 if ( map->lm_type == REWRITE_MAP_SET_SESN_VAR ) {
452 map->lm_name, val );
456 rc = rewrite_param_get( info, map->lm_name, val );
460 struct rewrite_builtin_map *bmap = map->lm_data;
483 struct rewrite_builtin_map *map = ( struct rewrite_builtin_map * )tmp;
485 assert( map != NULL );
487 if ( map->lb_mapper && map->lb_mapper->rm_destroy )
488 map->lb_mapper->rm_destroy( map->lb_private );
490 free( map->lb_name );
491 free( map );
499 struct rewrite_map *map;
504 map = *pmap;
507 ldap_pvt_thread_mutex_lock( &map->lm_mutex );
510 if ( map->lm_name ) {
511 free( map->lm_name );
512 map->lm_name = NULL;
515 if ( map->lm_subst ) {
516 rewrite_subst_destroy( &map->lm_subst );
520 ldap_pvt_thread_mutex_unlock( &map->lm_mutex );
521 ldap_pvt_thread_mutex_destroy( &map->lm_mutex );
524 free( map );
557 const rewrite_mapper *map
569 mappers[num_mappers++] = map;
575 const rewrite_mapper *map
581 if ( mappers[i] == map ) {