Changeset 5811:28f6eed531d7 in roaraudio
- Timestamp:
- 01/05/13 01:29:03 (11 years ago)
- Branch:
- default
- Phase:
- public
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/man1/roar-config.1
r5801 r5811 5 5 .SH NAME 6 6 7 roar-config \- get information of installed RoarAudio librar ys7 roar-config \- get information of installed RoarAudio libraries 8 8 9 9 .SH SYNOPSIS … … 17 17 roar-config [\-\-product PRODUCT] [\-\-provider PROVIDER] [\-\-universal] \-\-path PATH 18 18 19 roar-config \-\-render\-path PATH 20 19 21 .SH DESCRIPTION 20 22 21 23 This small tool prints information about installed versions and needed flags to work 22 with the RoarAudio librar ys.24 with the RoarAudio libraries. 23 25 24 26 .SH "OPTIONS" … … 61 63 62 64 .TP 65 \fB--render-path PATH\fR 66 Render the given path. The path can be any absolute path, a path relative to the user's home directory 67 (prefixed with ~/) or a path relative to a path as used by --path (prefixed with $ and path name). 68 69 .TP 63 70 \fB--libs\fR 64 71 Show linker flags (\-lxxx) needed to link library -
libroar/env.c
r5754 r5811 121 121 } 122 122 123 static char * __get_path(const char ** inpath) { 124 char buf_path[64]; 125 size_t i; 126 127 (*inpath)++; 128 129 for (i = 0; i < sizeof(buf_path); i++) { 130 if ( (*inpath)[i] == '/' || (*inpath)[i] == 0 ) { 131 break; 132 } else { 133 buf_path[i] = (*inpath)[i]; 134 } 135 } 136 137 if ( i == sizeof(buf_path) ) { 138 roar_err_set(ROAR_ERROR_NOSPC); 139 return NULL; 140 } 141 142 buf_path[i] = 0; 143 144 (*inpath) += i; 145 146 return roar_libroar_get_path(buf_path, 0, NULL, NULL); 147 } 148 123 149 int roar_env_render_path_r(char * out, size_t len, const char * inpath) { 124 150 size_t inlen; … … 126 152 size_t homelen = 0; 127 153 const char * home; 128 enum { UNKNOWN, COPY, HOME } mode = UNKNOWN; 154 const char * prefix = NULL; 155 char * prefix_path = NULL; 156 enum { UNKNOWN, COPY, HOME, PREFIX } mode = UNKNOWN; 129 157 130 158 if ( len == 0 && inpath == NULL ) … … 159 187 needlen = inlen + homelen - 1; 160 188 mode = HOME; 161 } 162 163 if ( len < (needlen + 1) ) 164 return -1; 189 prefix = home; 190 inpath++; 191 } else if ( inpath[0] == '$' ) { 192 prefix_path = __get_path(&inpath); 193 if ( prefix_path == NULL ) 194 return -1; 195 needlen = roar_mm_strlen(inpath) + roar_mm_strlen(prefix_path) + 1; 196 mode = PREFIX; 197 prefix = prefix_path; 198 } 199 200 if ( len < (needlen + 1) ) { 201 if ( prefix_path != NULL ) 202 roar_mm_free(prefix_path); 203 roar_err_set(ROAR_ERROR_NOSPC); 204 return -1; 205 } 165 206 166 207 switch (mode) { … … 170 211 break; 171 212 case HOME: 172 roar_mm_strlcpy(out, home, len); 173 roar_mm_strlcat(out, inpath+1, len); // strip only ~, so we have the / if home is not /-terminated. 213 case PREFIX: 214 roar_mm_strlcpy(out, prefix, len); 215 roar_mm_strlcat(out, inpath, len); // strip only ~, so we have the / if home is not /-terminated. 174 216 break; 175 217 default: 218 if ( prefix_path != NULL ) 219 roar_mm_free(prefix_path); 220 roar_err_set(ROAR_ERROR_NOTSUP); 176 221 return -1; 177 222 break; 178 223 } 179 224 225 if ( prefix_path != NULL ) 226 roar_mm_free(prefix_path); 180 227 return 0; 181 228 } -
roarclients/roar-config.c
r5810 r5811 142 142 } 143 143 144 void print_renderpath(const char * path) { 145 char buf[1024]; 146 147 if ( roar_env_render_path_r(buf, sizeof(buf), path) != 0 ) { 148 fprintf(stderr, "Error: Can not render path: %s: %s\n", path, roar_errorstring); 149 return; 150 } 151 printf("%s\n", buf); 152 } 153 144 154 void usage (void) { 145 155 printf("Usage: roar-config --version\n" 146 156 " roar-config --compare-versions VERSIONA OPERATOR VERSIONB\n" 147 157 " roar-config [{--output-pc|--output-normal}] [--libs] [--cflags] [LIB]\n" 148 " roar-config [--product PRODUCT] [--provider PROVIDER] [--universal] --path PATH\n"); 158 " roar-config [--product PRODUCT] [--provider PROVIDER] [--universal] --path PATH\n" 159 " roar-config --render-path PATH\n"); 149 160 150 161 printf("\nOptions:\n\n"); … … 158 169 " --provider PROVIDER - Provider string for --path\n" 159 170 " --universal - Use universal path for --path\n" 171 " --render-path PATH - Print a rendered path\n" 160 172 " --libs - Show linker flags (-lxxx) needed to link library\n" 161 173 " --cflags - Show compiler flags needed to link library\n" … … 199 211 } else if ( !strcmp(argv[i], "--path") ) { 200 212 print_path(argv[++i], null_as_universal, product, provider); 213 } else if ( !strcmp(argv[i], "--render-path") ) { 214 print_renderpath(argv[++i]); 201 215 } else if ( !strcmp(argv[i], "--libs") ) { 202 216 libs = 1;
Note: See TracChangeset
for help on using the changeset viewer.