示例#1
0
int MpXResourceFlag (const char *application, const char *name, int deflt)
{
    char *res;
    if ((res = MpXResource(application,name)))
        return (strcmp_ignore_case(res,  "on") == 0) || 
               (strcmp_ignore_case(res,   "1") == 0) ||
               (strcmp_ignore_case(res,"true") == 0) ||
               (strcmp_ignore_case(res, "yes") == 0);
    else 
        return deflt;
}
示例#2
0
//----------------------------------------------------------------//
ZIPFSZipFileEntry* ZIPFSZipFile_FindEntry ( ZIPFSZipFile* self, char const* filename ) {

	ZIPFSZipFileDir* dir;
	ZIPFSZipFileEntry* entry;
	int i;
	
	i = strlen ( filename ) - 1;
	if ( filename [ i ] == '/' ) return 0;
	
	dir = ZIPFSZipFile_FindDir ( self, filename );
	if ( !dir ) return 0;
	
	for ( ; i >= 0; --i ) {
		if ( filename [ i ] == '/' ) {
			filename = &filename [ i + 1 ];
			break;
		}
	}
	
	entry = dir->mChildFiles;
	for ( ; entry; entry = entry->mNext ) {
		if ( strcmp_ignore_case ( entry->mName, filename ) == 0 ) break;
	}

	return entry;
}
示例#3
0
int MpXResourceFlag (const char *application, const char *name, const char* value)
{
    char *res;
    if ((res = MpXResource(application,name)))
        return (strcmp_ignore_case(res,value) == 0);
    else 
        return 0;
}
示例#4
0
//----------------------------------------------------------------//
int zipfs_mount_virtual ( const char* path, const char* archive ) {

	// delete the path if it exists
	int result;
	ZIPFSVirtualPath* cursor = sVirtualPaths;
	ZIPFSVirtualPath* virtualPath;
	ZIPFSVirtualPath* list = 0;
	
	if ( !path ) return -1;
	path = zipfs_get_abs_dirpath ( path );
	
	while ( cursor ) {
		virtualPath = cursor;
		cursor = cursor->mNext;
		
		if ( strcmp_ignore_case ( virtualPath->mPath, path ) == 0 ) {
			ZIPFSVirtualPath_Delete ( virtualPath );
		}
		else {
			list = ZIPFSVirtualPath_PushFront ( virtualPath, list );
		}
	}
	
	cursor = list;
	sVirtualPaths = 0;
	
	while ( cursor ) {
		virtualPath = cursor;
		cursor = cursor->mNext;
		
		sVirtualPaths = ZIPFSVirtualPath_PushFront ( virtualPath, sVirtualPaths );
	}

	if ( !archive ) return 0;

	virtualPath = ZIPFSVirtualPath_New ();
	if ( !virtualPath ) goto error;

	result = ZIPFSVirtualPath_SetPath ( virtualPath, path );
	if ( result ) goto error;
	
	result = ZIPFSVirtualPath_SetArchive ( virtualPath, zipfs_get_abs_filepath ( archive ));
	if ( result ) goto error;

	sVirtualPaths = ZIPFSVirtualPath_PushFront ( virtualPath, sVirtualPaths );

	return 0;

error:

	if ( virtualPath ) {
		ZIPFSVirtualPath_Delete ( virtualPath );
	}
	return -1;
}
示例#5
0
static bool GetColorByName (const string &p, int &r, int &g, int &b)
{
  r = g = b = 0x0000;

  // empty string
  if (p.empty()) return false;

  // hexadecimal string value
  if ( p[0] == '#' ) {
    if ( p.size() == 13 ) {
      r = (((((H(p[1]) << 4) | H(p[2]))  << 4) | H(p[3])) << 4) | H(p[4]);
      g = (((((H(p[5]) << 4) | H(p[6]))  << 4) | H(p[7])) << 4) | H(p[8]);
      b = (((((H(p[9]) << 4) | H(p[10])) << 4) | H(p[11]))<< 4) | H(p[12]);
    } else if ( p.size() == 10 ) {
      r = ((((H(p[1]) << 4) | H(p[2])) << 4) | H(p[3])) << 4;
      g = ((((H(p[4]) << 4) | H(p[5])) << 4) | H(p[6])) << 4;
      b = ((((H(p[7]) << 4) | H(p[8])) << 4) | H(p[9])) << 4;
    } else if ( p.size() == 7 ) {
      r = ((H(p[1]) << 4) | H(p[2])) << 8;
      g = ((H(p[3]) << 4) | H(p[4])) << 8;
      b = ((H(p[5]) << 4) | H(p[6])) << 8;
    } else if ( p.size() == 4 ) {
      r = H(p[1]) << 12;
      g = H(p[2]) << 12;
      b = H(p[3]) << 12;
    } else {
      r = g = b = 0;
      return false;
    }      
    return true;    
  } 
  
  // look up name in data base
  if (Mp.theDisplay != NULL) {
    // use X database (rgb.txt) if there is a connection to the X server
    XColor col, screen_col;
    if ( XLookupColor(Mp.theDisplay,
                      Mp.theColormap, 
                      p.c_str(), &col, &screen_col) ) {
      r = col.red;
      g = col.green;
      b = col.blue;
      return true;
    }
  } 

  // look up name in MATPACK data base $MATPACK/cmaps/color.tbl
  // (which is in fact a copy of the X database (rgb.txt). 
  // But this way we can work with color names 
  // without an X server connection!
  const char *Home = getenv("MATPACK");
  string Path = Home;
  Path += "/cmaps/color.tbl";
  ifstream s( Path.c_str() );
  if (s.fail()) return false;
  int rx,gx,bx;
  string name;
  while (! s.eof()) {
    s >> rx >> gx >> bx >> name;
    if ( strcmp_ignore_case(p.c_str(),name.c_str()) == 0 )  {
      r = rx << 8; 
      g = gx << 8; 
      b = bx << 8;
      return true;
    } 
  }

  return false;
}