comparison srf2fastq/io_lib-1.12.2/io_lib/find.c @ 0:d901c9f41a6a default tip

Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
author dawe
date Tue, 07 Jun 2011 17:48:05 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:d901c9f41a6a
1 /*
2 * Copyright (c) Medical Research Council 1994. All rights reserved.
3 *
4 * Permission to use, copy, modify and distribute this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * this copyright and notice appears in all copies.
7 *
8 * This file was written by James Bonfield, Simon Dear, Rodger Staden,
9 * as part of the Staden Package at the MRC Laboratory of Molecular
10 * Biology, Hills Road, Cambridge, CB2 2QH, United Kingdom.
11 *
12 * MRC disclaims all warranties with regard to this software.
13 */
14
15 #include "io_lib/misc.h"
16 #include <stdio.h>
17 #include <stdlib.h>
18 #include <string.h>
19
20 /* 19/3/99 johnt - added Corba support */
21 #ifdef USE_CORBA
22 #include "stcorba.h"
23 #endif
24
25 #ifdef USE_BIOLIMS
26 #include "spBiolims.h"
27 #endif
28
29 char *myfind(char *file, char* searchpath, int (*found) (char *) )
30 {
31 static char wholePath[1024];
32 char *path;
33 char *f;
34
35 f = NULL;
36 if (found(file)) {
37 strcpy(wholePath,file);
38 f = wholePath;
39 } else if (searchpath != NULL) {
40 char *paths;
41 char *next;
42
43 paths = (char *) malloc(strlen(searchpath)+1);
44 strcpy(paths,searchpath);
45
46 path = paths;
47 next = strchr(path,':');
48 while( next && (*(next+1) == ':' )){
49 /* 26/03/99 johnt - allow : to be entered into path by using :: */
50 memmove(next,next+1,strlen(next+1)+1); /* shuffle up data [including \0]*/
51 next = strchr(next+1,':');
52 }
53 if(next)
54 *next = '\0';
55
56 while (path!= NULL) {
57
58 #ifdef USE_CORBA
59 /* 19/03/99 johnt - if it is a corba path - look there */
60 if( !strncmp( CORBATAG,path,strlen(CORBATAG))){
61 if(corba_found(wholePath,path+strlen(CORBATAG),file)){
62 f = wholePath;
63 break;
64 }
65 }
66 else
67 #endif
68 #ifdef USE_BIOLIMS
69 if( !strncmp( BIOLIMS_TAG,path,strlen(BIOLIMS_TAG))){
70 if(biolims_found(wholePath,path+strlen(BIOLIMS_TAG),file)){
71 f = wholePath;
72 break;
73 }
74 }
75 else
76 #endif
77 {
78 (void) strcpy(wholePath,path);
79 (void) strcat(wholePath,"/");
80 (void) strcat(wholePath,file);
81 if (found(wholePath)) {
82 f = wholePath;
83 break;
84 }
85 }
86 path = next;
87 if( path ){
88 path++;
89 next = strchr(path,':');
90 while( next && (*(next+1) == ':' )){
91 /* 26/03/99 johnt - allow : to be entered into path by using :: */
92 memmove(next,next+1,strlen(next+1)+1); /* shuffle up data */
93 next = strchr(next+1,':');
94 }
95 if(next)
96 *next='\0';
97 }
98 }
99 free(paths);
100 }
101
102 return f;
103 }