/*********************************************************************** * * Copyright (C) 2005-2006 Novell, Inc. All Rights Reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; version 2.1 * of the License. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, Novell, Inc. * * To contact Novell about this file by physical or electronic mail, * you may find current contact information at www.novell.com. * ***********************************************************************/ #include "FirefoxPasswordManager.h" #include "Common.h" char lastErrorMesg[10000]; void PrintMessage( int level, char *mesg , ...) { va_list vl; va_start( vl , mesg ); vsprintf( lastErrorMesg , mesg , vl ); va_end( vl ); // if we are not debugging then print DEBUG level messages #ifdef DEBUG printf("%s", lastErrorMesg ); #else if( level != MESG_DEBUG ) { //printf("%s", lastErrorMesg ); } #endif } /** * Converts given string to lower case.... * */ void StrLwr(char *str) { int n=strlen(str); for(int i=0; i=65 && str[i]<=90 ) str[i]+=32; } } /** * Checks if specified directory exists * * return MC_TRUE if directory exists else MC_FALSE * */ int IsDirectoryExists( char *path ) { if( path == NULL ) return 0; #ifdef WIN32 DWORD attr = GetFileAttributes(path); if( (attr == -1) || !(attr & FILE_ATTRIBUTE_DIRECTORY ) ) { PrintMessage(MESG_ERROR, "\n IsDirectoryExists : Directory does not exist : [%s] ", path); return 0; } return 1; #else char *program = (char*) malloc(strlen(path)+20); if( program == NULL ) return 0; strcpy(program, "test -d "); strcat(program, path); int result= system(program); free(program); if( result != 0 ) { PrintMessage(MESG_ERROR, "\n IsDirectoryExists : Directory does not exist : [%s] ", path); return 0; } return 1; #endif }