Skip to main content
summaryrefslogtreecommitdiffstats
blob: 3e78b0b2ef8bbfa5818257ee8a6e88e377d01b88 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/*******************************************************************************
 * Copyright (c) 2010, 2011 Wind River Systems, Inc. and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * and Eclipse Distribution License v1.0 which accompany this distribution.
 * The Eclipse Public License is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * and the Eclipse Distribution License is available at
 * http://www.eclipse.org/org/documents/edl-v10.php.
 * You may elect to redistribute this code under either of these licenses.
 *
 * Contributors:
 *     Wind River Systems - initial API and implementation
 *******************************************************************************/

/*
 * Path Map service.
 * The service manages file path mapping rules.
 */

#ifndef D_pathmap
#define D_pathmap

#include <config.h>
#include <framework/context.h>
#include <framework/protocol.h>

/*
 * Convert a file name to canonic form that is suitable for file name comparisons.
 * Unlike canonicalize_file_name() or realpath(), the function can be used for remote files.
 * Return pointer to a static array with converted name.
 */
extern char * canonic_path_map_file_name(const char * fnm);

#if SERVICE_PathMap

typedef struct PathMapRule PathMapRule;
typedef struct PathMapRuleAttribute PathMapRuleAttribute;

struct PathMapRuleAttribute {
    PathMapRuleAttribute * next;
    char * name;        /* Attribute name */
    char * value;       /* Attribute value as JSON string */
};

/* Path map attribute names */
#define PATH_MAP_ID             "ID"
#define PATH_MAP_SOURCE         "Source"
#define PATH_MAP_DESTINATION    "Destination"
#define PATH_MAP_CONTEXT        "Context"
#define PATH_MAP_HOST           "Host"
#define PATH_MAP_PROTOCOL       "Protocol"

/*
 * Path map events listener.
 */
typedef struct PathMapEventListener {
    void (*mapping_changed)(Channel * c, void * args);
} PathMapEventListener;

/*
 * Add path map events listener.
 */
extern void add_path_map_event_listener(PathMapEventListener * listener, void * args);

/*
 * Remove path map events listener.
 */
extern void rem_path_map_event_listener(PathMapEventListener * listener);

/*
 * Iterate all path mapping rules registerd for given client,
 * channel == NULL iterates rules that were created by create_path_mapping() function.
 */
typedef void IteratePathMapsCallBack(PathMapRule *, void *);
extern void iterate_path_map_rules(Channel * channel, IteratePathMapsCallBack * callback, void * args);

/*
 * Get path mapping rule attributes.
 */
extern PathMapRuleAttribute * get_path_mapping_attributes(PathMapRule * map);

/*
 * Create new path mapping rule with given attributes.
 * Caller should allocate attributes using myalloc.h functions.
 * Path Map service will free attributes memory using loc_free().
 */
extern PathMapRule * create_path_mapping(PathMapRuleAttribute * attrs);

/*
 * Change path mapping rule attributes to given attributes.
 * Caller should allocate attributes using myalloc.h functions.
 * Path Map service will free attributes memory using loc_free().
 * The function compares existing attributes with new ones,
 * and calls listeners only if attributes are different.
 */
extern void change_path_mapping_attributes(PathMapRule * map, PathMapRuleAttribute * attrs);

/*
 * Delete a path mapping rule.
 */
extern void delete_path_mapping(PathMapRule * bp);

#define PATH_MAP_TO_CLIENT 1
#define PATH_MAP_TO_LOCAL  2
#define PATH_MAP_TO_TARGET 3

/*
 * Translate debug file name to local or target file name using file path mapping table of given channel.
 * Return pointer to static buffer that contains translated file name.
 */
extern char * apply_path_map(Channel * channel, Context * ctx, char * file_name, int mode);

/*
 * Read new path map from the given input stream.
 * The function is used by forwarding value-add server,
 * and it is not intended for use by other clients.
 */
extern void set_path_map(Channel * channel, InputStream * inp);

extern void ini_path_map_service(Protocol * proto);

#endif /* SERVICE_PathMap */

#endif /* D_pathmap */

Back to the top