metamod/mplugin.cpp
branchB-work
changeset 90 eca4db9206e4
parent 25 55418639a45d
child 96 a0b2f0bdabae
     1.1 --- a/metamod/mplugin.cpp	Mon Aug 16 21:35:10 2004 +0000
     1.2 +++ b/metamod/mplugin.cpp	Mon Aug 16 21:40:37 2004 +0000
     1.3 @@ -63,6 +63,15 @@
     1.4  	char *ptr_token;
     1.5  	char *cp;
     1.6  
     1.7 +	// skip whitespace at start of line
     1.8 +	while(*line==' ' || *line=='\t' ) line++;
     1.9 +
    1.10 +	// skip empty lines
    1.11 +	if(line[0]=='\0') {
    1.12 +		META_DEBUG(7, ("ini: Ignoring empty line: %s", line));
    1.13 +		RETURN_ERRNO(mFALSE, ME_BLANK);
    1.14 +	}
    1.15 +
    1.16  	if(line[0]=='#' || line[0]==';' || strstr(line, "//")==line) {
    1.17  		META_DEBUG(7, ("ini: Ignoring commented line: %s", line));
    1.18  		RETURN_ERRNO(mFALSE, ME_COMMENT);
    1.19 @@ -72,7 +81,11 @@
    1.20  	token=strtok_r(line, " \t", &ptr_token);
    1.21  	if(!token)
    1.22  		RETURN_ERRNO(mFALSE, ME_FORMAT);
    1.23 -	if(strcasecmp(token, PLATFORM)) {
    1.24 +	if(strcasecmp(token, PLATFORM) == 0) {
    1.25 +		pfspecific=0;
    1.26 +	} else if(strcasecmp(token, PLATFORM_SPC) == 0) {
    1.27 +		pfspecific=1;
    1.28 +	} else {
    1.29  		// plugin is not for this OS
    1.30  		META_DEBUG(7, ("ini: Ignoring entry for %s", token));
    1.31  		RETURN_ERRNO(mFALSE, ME_OSNOTSUP);
    1.32 @@ -371,11 +384,52 @@
    1.33  	snprintf(buf, sizeof(buf), "%s_i686.so", path);
    1.34  	if(stat(buf, &st) == 0 && S_ISREG(st.st_mode))
    1.35  		return(buf);
    1.36 +	snprintf(buf, sizeof(buf), "%s_amd64.so", path);
    1.37 +	if(stat(buf, &st) == 0 && S_ISREG(st.st_mode))
    1.38 +		return(buf);
    1.39  #endif /* linux */
    1.40  
    1.41  	return(NULL);
    1.42  }
    1.43  
    1.44 +// Check if a given plugin is the same but possibly for a
    1.45 +// different platform. A match is considered to be found if
    1.46 +// 1.  the filename without the path is the same, or
    1.47 +// 2a. for an attached plugin the logtag is the same, or
    1.48 +// 2b. the description is the same, or
    1.49 +// 3.  a significant part of the filename is the same.
    1.50 +// A significant part of a plugin name is currently defined to
    1.51 +// the the part up to the last underscore, if one exists.
    1.52 +// meta_errno values:
    1.53 +//  - none
    1.54 +mBOOL MPlugin::platform_match(MPlugin* other) {
    1.55 +	char *end, *other_end;
    1.56 +	int prefixlen;
    1.57 +
    1.58 +	if(status == PL_EMPTY || other->status == PL_EMPTY) return mFALSE;
    1.59 +
    1.60 +	if(strcmp(file, other->file) == 0) return mTRUE;
    1.61 +
    1.62 +	if(status >= PL_OPENED && other->status >= PL_OPENED &&
    1.63 +       strcmp(info->logtag, other->info->logtag) == 0 ) return mTRUE;
    1.64 +	if(*desc != '\0' && strcasecmp(desc,other->desc) == 0) return mTRUE;
    1.65 +
    1.66 +	end=strrchr(file, '_');
    1.67 +	if(end == NULL) end=strrchr(file, '.');
    1.68 +	other_end=strrchr(other->file, '_');
    1.69 +	if(other_end == NULL) other_end=strrchr(other->file, '.');
    1.70 +
    1.71 +	if(end == NULL || other_end == NULL) return mFALSE;
    1.72 +
    1.73 +	prefixlen=end-file;
    1.74 +	if((other_end-other->file) != prefixlen) return mFALSE;
    1.75 +
    1.76 +	if(strncmp(file,other->file, prefixlen) == 0) return mTRUE;
    1.77 +
    1.78 +	return mFALSE;
    1.79 +}
    1.80 +
    1.81 +
    1.82  // Load a plugin; query, check allowed time, attach.
    1.83  // meta_errno values:
    1.84  //  - ME_ARGUMENT	missing necessary fields in plugin