Example #1
0
BOOL Profile::PutString ( char *ItemName, char *Item ) {

   if ( !IsReady() ) 
      return ( FALSE ) ;

#ifdef __OS2__

   if ( !PrfWriteProfileData ( Handle, PSZ(Name), PSZ(ItemName), Item, strlen(Item)+1 ) ) {
      char Message [512] ;
      Log ( "Profile::PutString: Could not put INI item.  App %s, Item %s, Value %s.  %s", Name, ItemName, Item, InterpretWinError(0,Message) ) ;
      return ( FALSE ) ;
   } /* endif */

#else // __NT__

   if ( ProfileName[0] ) {
      if ( !WritePrivateProfileString ( Name, ItemName, Item, ProfileName ) ) {
         char Message [512] ;
         Log ( "Profile::PutString: Could not put INI item.  App %s, Item %s, Value %s.  %s", Name, ItemName, Item, InterpretWinError(0,Message) ) ;
         return ( FALSE ) ;
      } /* endif */
   } else {
      if ( !WriteProfileString ( Name, ItemName, Item ) ) {
         char Message [512] ;
         Log ( "Profile::PutString: Could not put INI item.  App %s, Item %s, Value %s.  %s", Name, ItemName, Item, InterpretWinError(0,Message) ) ;
         return ( FALSE ) ;
      } /* endif */
   } /* endif */

#endif // __OS2__ vs __NT__

   return ( TRUE ) ;

} /* endmethod */
Example #2
0
Group::Group(Dataset* dataset_ptr, const yat::String& parent_path, const yat::String& name)
{
  m_dataset_ptr = dataset_ptr;
  m_bChildren = false;
  m_path.printf("%s/%s", PSZ(parent_path), PSZ(name));
  m_path.replace("//", "/");
}
Example #3
0
//-------------------------------------------------------------------
// FileName::dir_copy
//-------------------------------------------------------------------
void FileName::dir_copy(const String &strDest, bool bCreateDir, mode_t modeDir, uid_t uid, gid_t gid) throw( Exception )
{
  FileName fnDst;

  // Create destination path
  fnDst.set(strDest);
  fnDst.mkdir(modeDir, uid, gid);

  if( bCreateDir )
  {
    // Create source directory name inside destination path
    fnDst.set(strDest + dir_name() + SEP_PATH);
    fnDst.mkdir(modeDir, uid, gid);
  }

  if( !fnDst.is_path_name() )
    throw BadPathException(PSZ(String::str_format(ERR_BAD_DEST_PATH, PSZ(fnDst.full_name()))),
                           "FileName::dir_copy");

  // Recursively copying sub-directories
  FileEnum dirEnum(full_name(), FileEnum::ENUM_DIR);
  while( dirEnum.find() )
    dirEnum.dir_copy(fnDst.path(), true, modeDir, uid, gid);

  // Copying directory files
  FileEnum fileEnum(full_name(), FileEnum::ENUM_FILE);
  while( fileEnum.find() )
    // Copy with metadata
    fileEnum.copy(fnDst.path(), true);
}
Example #4
0
void Dde_Server::Initiate ( HWND Owner, HWND Client, PDDEINIT pDdeInit ) {

  /**************************************************************************
   * Prepare to respond with a WM_DDE_INITIATEACK.                          *
   **************************************************************************/

   HMQ Queue = WinQueryWindowULong ( Owner, QWL_HMQ ) ;
   char Text [10] ;
   ULONG Size = 10 ;
   int Country = 1 ;
   if ( PrfQueryProfileData ( HINI_USERPROFILE, PSZ("PM_National"), PSZ("iCountry"), Text, &Size ) )
      Country = atoi ( Text ) ;

   CONVCONTEXT Conv ;
   Conv.cb = sizeof(Conv) ;
   Conv.fsContext = DDECTXT_CASESENSITIVE ;
   Conv.idCountry = Country ;
   Conv.usCodepage = WinQueryCp ( Queue ) ;
   Conv.usLangID = 0 ;
   Conv.usSubLangID = 0 ;

  /**************************************************************************
   * Respond if appropriate.                                                *
   **************************************************************************/

   Application.Initiate ( Owner, Client, pDdeInit, Conv ) ;
}
Example #5
0
BOOL Profile::GetString ( char *ItemName, char* &Item ) {

   if ( !IsReady() ) {
      Item = 0 ;
      return ( FALSE ) ;
   } /* endif */

   #ifdef __OS2__

      ULONG TrueSize ;
      if ( !PrfQueryProfileSize ( Handle, PSZ(Name), PSZ(ItemName), &TrueSize ) ) {
         Item = 0 ;
         return ( FALSE ) ;
      } /* endif */

      Item = new char [TrueSize+1] ;
      if ( Item == 0 ) {
         Log ( "Profile::GetString: Unable to allocate memory to hold string.  App %s, Item %s, TrueSize %i.", Name, ItemName, TrueSize ) ;
         return ( FALSE ) ;
      } /* endif */

      if ( !PrfQueryProfileData ( Handle, PSZ(Name), PSZ(ItemName), Item, &TrueSize ) ) {
         char Message [512] ;
         Log ( "Profile::GetString: Could not get INI item.  App %s, Item %s, TrueSize %i.  %s", Name, ItemName, TrueSize, InterpretWinError(0,Message) ) ;
         delete [] Item ;
         Item = 0 ;
         return ( FALSE ) ;
      } /* endif */

      Item[TrueSize] = 0 ;

   #else // __NT__

      char *Buffer = new char [0x1000] ;
      int Returned ( 0 ) ;
      if ( ProfileName[0] ) {
         Returned = GetPrivateProfileString ( Name, ItemName, "", Buffer, 0x1000, ProfileName ) ;
      } else {
         Returned = GetProfileString ( Name, ItemName, "", Buffer, 0x1000 ) ;
      } /* endif */

      Item = new char [Returned+1] ;
      if ( Item == 0 ) {
         Log ( "Profile::GetString: Unable to allocate memory to hold string.  App %s, Item %s, TrueSize %i.", Name, ItemName, Returned ) ;
         return ( FALSE ) ;
      } /* endif */

      strcpy ( Item, Buffer ) ;

      delete [] Buffer ;

   #endif // __OS2__ vs __NT__

   return ( TRUE ) ;

} /* endmethod */
Example #6
0
static MRESULT APIENTRY OK ( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 ) {

 /***************************************************************************
  * Find the instance data.                                                 *
  ***************************************************************************/

  PPROFILE_PARMS Parms = PPROFILE_PARMS ( WinQueryWindowPtr ( hwnd, QWL_USER ) ) ;

 /***************************************************************************
  * Verify the entered path.                                                *
  ***************************************************************************/

  BYTE Name [256] ;
  WinQueryDlgItemText ( hwnd, Parms->id+ENTRY, sizeof(Name), Name ) ;

  BYTE FullPath [256] ;
  if ( DosQueryPathInfo ( Name, FIL_QUERYFULLNAME, FullPath, sizeof(FullPath) ) ) {
    PSZ Message = PSZ ( "ERROR: Not a valid path." ) ;
    WinSetDlgItemText ( hwnd, Parms->id+ERR, Message ) ;
    WinAlarm ( HWND_DESKTOP, WA_ERROR ) ;
    WinSetFocus ( HWND_DESKTOP, WinWindowFromID ( hwnd, Parms->id+ENTRY ) ) ;
    return ( 0 ) ;
  }

  FILESTATUS3 Status ;
  if ( DosQueryPathInfo ( FullPath, FIL_STANDARD, &Status, sizeof(Status) ) ) {
    PSZ Message = PSZ ( "ERROR: Path does not exist." ) ;
    WinSetDlgItemText ( hwnd, Parms->id+ERR, Message ) ;
    WinAlarm ( HWND_DESKTOP, WA_ERROR ) ;
    WinSetFocus ( HWND_DESKTOP, WinWindowFromID ( hwnd, Parms->id+ENTRY ) ) ;
    return ( 0 ) ;
  }

  if ( ! ( Status.attrFile & FILE_DIRECTORY ) ) {
    PSZ Message = PSZ ( "ERROR: Specified path is not a directory." ) ;
    WinSetDlgItemText ( hwnd, Parms->id+ERR, Message ) ;
    WinAlarm ( HWND_DESKTOP, WA_ERROR ) ;
    WinSetFocus ( HWND_DESKTOP, WinWindowFromID ( hwnd, Parms->id+ENTRY ) ) ;
    return ( 0 ) ;
  }

 /***************************************************************************
  * Return the full path to the caller.                                     *
  ***************************************************************************/

  strncpy ( PCHAR(Parms->Path), PCHAR(FullPath), Parms->PathSize ) ;

 /***************************************************************************
  * Dismiss the dialog with a TRUE status.                                  *
  ***************************************************************************/

  WinDismissDlg ( hwnd, TRUE ) ;

  return ( 0 ) ;
}
Example #7
0
//----------------------------------------------------------------------------
// FileName::remove
//----------------------------------------------------------------------------
void FileName::remove() throw( Exception )
{
  if( !m_strFile.empty() )
  {
    if( unlink(PSZ(full_name())) )
    {
      String strErr = String::str_format(ERR_CANNOT_REMOVE_FILE, PSZ(full_name()));
      ThrowExceptionFromErrno(PSZ(strErr), "FileName::remove");
    }
  }
}
Example #8
0
void Profile::Reset ( char *ItemName ) { 
   #ifdef __OS2__
      PrfWriteProfileData ( Handle, PSZ(Name), PSZ(ItemName), 0, 0 ) ; 
   #else // __NT__
      if ( ProfileName[0] ) {
         WritePrivateProfileString ( Name, ItemName, 0, ProfileName ) ;
      } else {
         WriteProfileString ( Name, ItemName, 0 ) ;
      } /* endif */
   #endif // __OS2__ vs __NT__
} /* endmethod */
Example #9
0
//-----------------------------------------------------------------------------
// CfgFile::set_section
//-----------------------------------------------------------------------------
bool CfgFile::set_section(const String &strSection, bool bThrowException) throw( Exception )
{
	std::map<String, Section>::iterator it = m_dictSection.find(strSection);
	if( it != m_dictSection.end() )
		m_strSection = strSection;
	else if( bThrowException )
	    throw Exception("NO_DATA", PSZ(String::str_format("Section '%s' not found", PSZ(strSection))), "CfgFile::SetSection");
  else
    return false;
  return true;
}
Example #10
0
void Dde_Item::Advise ( HWND Server, HWND Client, BOOL Hot ) {

   if ( Hot ) {
      // Search for a matching entry in the hot link list.  Return if found.
      for ( int i=0; i<sizeof(HotLinks)/sizeof(HotLinks[0]); i++ ) {
         if ( ( HotLinks[i][0] == Server ) AND ( HotLinks[i][1] == Client ) ) {
            Log ( "WARNING: Link already established." ) ;
            PDDESTRUCT Response = MakeDDEObject ( Client, PSZ(Name), DDE_FACK, DDEFMT_TEXT, 0, 0 ) ;
            WinDdePostMsg ( Client, Server, WM_DDE_ACK, Response, DDEPM_RETRY ) ;
            return ;
         } /* endif */
      } /* endfor */
      // Search for an empty entry in the hot link list.  Use if not found.
      for ( i=0; i<sizeof(HotLinks)/sizeof(HotLinks[0]); i++ ) {
         if ( ( HotLinks[i][0] == 0 ) AND ( HotLinks[i][1] == 0 ) ) {
            HotLinks[i][0] = Server ;
            HotLinks[i][1] = Client ;
            PDDESTRUCT Response = MakeDDEObject ( Client, PSZ(Name), DDE_FACK, DDEFMT_TEXT, 0, 0 ) ;
            WinDdePostMsg ( Client, Server, WM_DDE_ACK, Response, DDEPM_RETRY ) ;
            return ;
         } /* endif */
      } /* endfor */

      Log ( "  WARNING: Hot link table full." ) ;

   } else {
      // Search for a matching entry in the warm link list.  Return if found.
      for ( int i=0; i<sizeof(WarmLinks)/sizeof(WarmLinks[0]); i++ ) {
         if ( ( WarmLinks[i][0] == Server ) AND ( WarmLinks[i][1] == Client ) ) {
            Log ( "WARNING: Link already established." ) ;
            PDDESTRUCT Response = MakeDDEObject ( Client, PSZ(Name), DDE_FACK, DDEFMT_TEXT, 0, 0 ) ;
            WinDdePostMsg ( Client, Server, WM_DDE_ACK, Response, DDEPM_RETRY ) ;
            return ;
         } /* endif */
      } /* endfor */
      // Search for an empty entry in the warm link list.  Use if not found.
      for ( i=0; i<sizeof(WarmLinks)/sizeof(WarmLinks[0]); i++ ) {
         if ( ( WarmLinks[i][0] == 0 ) AND ( WarmLinks[i][1] == 0 ) ) {
            WarmLinks[i][0] = Server ;
            WarmLinks[i][1] = Client ;
            PDDESTRUCT Response = MakeDDEObject ( Client, PSZ(Name), DDE_FACK, DDEFMT_TEXT, 0, 0 ) ;
            WinDdePostMsg ( Client, Server, WM_DDE_ACK, Response, DDEPM_RETRY ) ;
            return ;
         } /* endif */
      } /* endfor */

      Log ( "  WARNING: Warm link table full." ) ;

   } /* endif */

   // Reply with an error.
   PDDESTRUCT Response = MakeDDEObject ( Client, PSZ(Name), DDE_NOTPROCESSED, DDEFMT_TEXT, 0, 0 ) ;
   WinDdePostMsg ( Client, Server, WM_DDE_ACK, Response, DDEPM_RETRY ) ;
}
Example #11
0
//----------------------------------------------------------------------------
// SAXParsor::start
//----------------------------------------------------------------------------
void SAXParsor::start(const std::string& document_path, INodeAnalyser* pRootAnalyser)
{
  CDMA_STATIC_FUNCTION_TRACE("SAXParsor::start");
  static bool sbLibXmlInit = false;
  yat::log_info("cfg", "Loading XML file %s", PSZ(document_path));

  if( false == sbLibXmlInit )
  {
    // this initialize the library and check potential API mismatches
    // between the version it was compiled for and the actual shared
    // library used.
    // Since we can't initialize the library more than once
    // use a static bool to ensure this
    LIBXML_TEST_VERSION
    sbLibXmlInit = true;

    // Initialize threads stuff
    xmlInitThreads();

    // To ensure that library will work in a multithreaded program
    xmlInitParser();
  }

  // Read xml file and build document in memory
  xmlDoc *pDoc = xmlReadFile(PSZ(document_path), NULL, 0);
  if( NULL == pDoc )
  {
    THROW_LIBXML2_EXCEPTION("Error while loading document", "SAXParsor::Start");
  }
  // Apply xinclude subsitution
  int iRc = xmlXIncludeProcess(pDoc);
  if( iRc >= 0 )
  {
    xmlErrorPtr	ptrError = xmlGetLastError();
    if( ptrError && ptrError->level > 1 )
    {
      THROW_LIBXML2_EXCEPTION(yat::String::str_format("Error while parsing xml document: %s", ptrError->message), "SAXParsor::Start");
    }
    // Retreive root element
    xmlNode *pRootNode = xmlDocGetRootElement(pDoc);
    // Start parsing giving a ConfigAnalyser as nodes interpretor
    yat::log_info("cfg", "Parsing configuration");

    instance().parse_node(pRootNode, pRootAnalyser);
  }

  // Free the document
  xmlFreeDoc(pDoc);

  if( iRc < 0 )
    // Error occured when applying  xinclude subsitution
    THROW_LIBXML2_EXCEPTION("Error while applying xinclude subsitution", "SAXParsor::Start");
}
Example #12
0
//----------------------------------------------------------------------------
// FileName::rename
//----------------------------------------------------------------------------
void FileName::rename(const String &strNewName) throw( Exception )
{
  if( !m_strFile.empty() )
    if( ::rename(PSZ(m_strFile), PSZ(strNewName)) )
    {
      String strErr = String::str_format(ERR_CANNOT_RENAME_FILE, PSZ(m_strFile));
      ThrowExceptionFromErrno(PSZ(strErr), "FileName::rename");
    }
 
  // Change internal name
  set(strNewName);
}
Example #13
0
BOOL Profile::GetItem ( char *ItemName, void *Item, int Size ) {

   if ( !IsReady() ) 
      return ( FALSE ) ;

   #ifdef __OS2__

      ULONG HowBig ;
      if ( !PrfQueryProfileSize ( Handle, PSZ(Name), PSZ(ItemName), &HowBig ) ) 
         return ( FALSE ) ;

      if ( Size != HowBig ) {
         Log ( "Profile::GetItem: Could not get INI item.  App %s, Item %s.  Wrong size.", Name, ItemName ) ;
         return ( FALSE ) ;
      } /* endif */

      if ( !PrfQueryProfileData ( Handle, PSZ(Name), PSZ(ItemName), Item, &HowBig ) ) {
         char Message [512] ;
         Log ( "Profile::GetItem: Could not get INI item.  App %s, Item %s, size %i.  %s", Name, ItemName, HowBig, InterpretWinError(0,Message) ) ;
         return ( FALSE ) ;
      } /* endif */

   #else // __NT__

      char *Buffer = new char [Size*2+2] ;

      int Returned ( 0 ) ;
      if ( ProfileName[0] ) {
         Returned = GetPrivateProfileString ( Name, ItemName, "", Buffer, Size*2+2, ProfileName ) ; 
      } else {
         Returned = GetProfileString ( Name, ItemName, "", Buffer, Size*2+2 ) ; 
      } /* endif */

      if ( Returned != Size*2 ) {
         delete [] Buffer ;
         Log ( "Profile::GetItem: Could not get INI item.  App %s, Item %s.  Wrong size.", Name, ItemName ) ;
         return ( FALSE ) ;
      } /* endif */

      for ( int i=0; i<Size; i++ ) {
         ((char*)Item)[i] = ( Buffer[i*2+0] > '9' ? Buffer[i*2+0]-'A'+10 : Buffer[i*2+0]-'0' ) << 4 ;
         ((char*)Item)[i] |= ( Buffer[i*2+1] > '9' ? Buffer[i*2+1]-'A'+10 : Buffer[i*2+1]-'0' ) ;
      } /* endfor */

      delete [] Buffer ;

   #endif // __OS2__ vs __NT__

   return ( TRUE ) ;

} /* endmethod */
Example #14
0
//-----------------------------------------------------------------------------
// Group::PrivEnumAttributes
//-----------------------------------------------------------------------------
void Group::PrivEnumAttributes()
{
  CDMA_FUNCTION_TRACE("Group::PrivEnumAttributes");
  try
  {
    // Get handle
    NexusFilePtr ptrNxFile = m_dataset_ptr->getHandle();
    NexusFileAccess auto_open (ptrNxFile);
    
    // Opening path
    ptrNxFile->OpenGroupPath(PSZ(m_path), true);
    
    if( ptrNxFile->AttrCount() > 0 )
    {
      NexusAttrInfo AttrInfo;

      // Iterating on attributes collection
      for( int rc = ptrNxFile->GetFirstAttribute(&AttrInfo); 
           NX_OK == rc; 
           rc = ptrNxFile->GetNextAttribute(&AttrInfo) )
      {
        // Create cdma Attribute
        m_attributes_map[AttrInfo.AttrName()] = IAttributePtr(new Attribute( ptrNxFile, AttrInfo ) );
      }
    }
    m_attributes_loaded = true;
  }
  catch( NexusException &e )
  {
    RE_THROW_EXCEPTION(e);
  }

}
Example #15
0
BOOL Settings :: ReloadResources (PSZ psz)
{
    if (g_hmod)
        DosFreeModule(g_hmod);

    APIRET  rc;

    if ((rc = DosLoadModule(PSZ(NULL), 0, psz, &g_hmod)))
    {
        DisplayError("ERROR", "Could not (re)load Gotcha! resource module "
                     "'%s' (DosLoadModule() return code %d). First make sure the DLL is in the LIBPATH. If this is the case, try to delete "
                     "GOTCHA.INI and start Gotcha! again. If it does not work "
                     "then, contact the author ([email protected]).", psz, rc);
        exit(1);
    }

    ResourceString::Module(g_hmod);

    pszPageTab[0] = RSTR (IDS_PAGESAVE);
    pszPageTab[1] = RSTR (IDS_PAGESNAPSHOT);
    pszPageTab[2] = RSTR (IDS_PAGEMISC);
    pszPageTab[3] = RSTR (IDS_PAGELANGUAGE);

    for( int i = 0; i < BMF_INVALID; i++ ) {
        ifi[ i ].label = RSTR ( IDS_BITMAP12INTERNAL+i ); }

    return TRUE;
}
Example #16
0
//-------------------------------------------------------------------
// FileName::recursive_chmod_dir
//-------------------------------------------------------------------
void FileName::recursive_chmod_dir(mode_t mode) throw( Exception )
{
  if( !path_exist() )
  { // File doesn't exists
    String strErr = String::str_format(ERR_DIR_NOT_FOUND, PSZ(full_name()));
    throw FileNotFoundException(PSZ(strErr), "FileName::recursive_chmod_dir");
  }

  // Recursively change rights on sub-directories
  FileEnum dirEnum(full_name(), FileEnum::ENUM_DIR);
  while( dirEnum.find() )
    dirEnum.recursive_chmod_dir(mode);

  // Change mode to directory itself
  chmod(mode);
}
Example #17
0
//-----------------------------------------------------------------------------
// LogicalGroup::PrivSolveKey
//-----------------------------------------------------------------------------
void LogicalGroup::PrivSolveKey(Context *context_ptr)
{
  CDMA_FUNCTION_TRACE("LogicalGroup::PrivSolveKey");

  KeyPtr key_ptr = context_ptr->getKey();

  if( key_ptr )
  {
    try
    {
      SolverList solvers = m_dictionary_ptr->getSolversList(key_ptr);

      // Iterate on the solvers list
      for( SolverList::iterator it = solvers.begin(); it != solvers.end(); it++ )
      {
        (*it)->solve(*context_ptr);
      }
    }
    catch( cdma::Exception &ex )
    {
      ex.push_error( "KEY_ERROR", PSZ_FMT( "Unable to get data from key '%s'",
                                           PSZ( key_ptr->getName() ) ),
                                           "LogicalGroup::PrivSolveKey" );
      throw ex;
    }
  }
  else
  {
    throw cdma::Exception( "NULL_POINTER",
                           "A valid key is required",
                           "LogicalGroup::PrivSolveKey" );
  }
}
extern char *FormatDate ( time_t Time, char *Format, char *Buffer, int BufferSize ) {

   // Get the local time and date.
   struct tm Tm ;
   memcpy ( &Tm, localtime(&Time), sizeof(Tm) ) ;

   // Process the format string from start to finish.
   char *Source = Format ;
   char *Destination = Buffer ;

   while ( *Source AND ( Destination-Buffer < BufferSize ) ) {
      if ( *Source == Functions[DATEFN_HEADER][0] ) {
         Source ++ ;
         if ( *Source == Functions[DATEFN_YEAR4][0] ) {
            sprintf ( Destination, "%04i", Tm.tm_year+1900 ) ;
         } else if ( *Source == Functions[DATEFN_YEAR2][0] ) {
            sprintf ( Destination, "%02i", Tm.tm_year % 100  ) ;
         } else if ( *Source == Functions[DATEFN_MON][0] ) {
            sprintf ( Destination, "%0.*s", strlen(PCHAR(*Months))/12, PSZ(*Months) + Tm.tm_mon * (strlen(PCHAR(*Months))/12) ) ;
         } else if ( *Source == Functions[DATEFN_MONTH][0] ) {
            sprintf ( Destination, "%i", Tm.tm_mon+1 ) ;
         } else if ( *Source == Functions[DATEFN_MONTHS][0] ) {
            strcpy ( Destination, MonthNames[Tm.tm_mon] ) ;
         } else if ( *Source == Functions[DATEFN_DAY][0] ) {
            sprintf ( Destination, "%i", Tm.tm_mday ) ;
         } else if ( *Source == Functions[DATEFN_WEEKDAY][0] ) {
            strcpy ( Destination, WeekdayNames[Tm.tm_wday] ) ;
         } else if ( *Source == Functions[DATEFN_WKDAY][0] ) {
            sprintf ( Destination, "%0.*s", strlen(PCHAR(*Weekdays))/7, PSZ(*Weekdays) + Tm.tm_wday * (strlen(PCHAR(*Weekdays))/7) ) ;
         } else {
            *Destination++ = Functions[DATEFN_HEADER][0] ;
            *Destination++ = *Source ;
            *Destination = 0 ;
         } /* endif */
         Destination += strlen(Destination) ;
      } else {
         *Destination++ = *Source ;
      } /* endif */
      Source ++ ;
   } /* endwhile */

   // Null terminate the result.
   *Destination = 0 ;

   // Return the address of the formatted date.
   return ( Buffer ) ;
}
Module::Module ( const Module &object ) : Name(0), Handle(0) {
   Name = (char*) malloc ( strlen(object.Name) + 1 ) ;
   strcpy ( Name, object.Name ) ;
   if ( object.Handle ) {
      char Drive[_MAX_DRIVE], Dir[_MAX_DIR], Fname[_MAX_FNAME], Ext[_MAX_EXT] ;
      _splitpath ( Name, Drive, Dir, Fname, Ext ) ;
      char ModuleName [CCHMAXPATH] ;
      strcpy ( ModuleName, Drive ) ;
      strcat ( ModuleName, Dir ) ;
      strcat ( ModuleName, Fname ) ;
      if ( *Drive || *Dir )
         strcat ( ModuleName, Ext ) ;
      strupr ( ModuleName ) ;
      char MissingModule [CCHMAXPATH] ;
      DosLoadModule ( PSZ(MissingModule), sizeof(MissingModule), PSZ(ModuleName), &Handle ) ;
   } /* endif */
} /* endmethod */
Example #20
0
BOOL Profile::GetString ( char *ItemName, char *Item, int MaxSize ) {

   if ( !IsReady() ) 
      return ( FALSE ) ;

   #ifdef __OS2__

      ULONG TrueSize ;
      if ( !PrfQueryProfileSize ( Handle, PSZ(Name), PSZ(ItemName), &TrueSize ) ) 
         return ( FALSE ) ;

      ULONG HowBig = min ( TrueSize+1, MaxSize ) ;
      if ( !PrfQueryProfileData ( Handle, PSZ(Name), PSZ(ItemName), Item, &HowBig ) ) {
         char Message [512] ;
         Log ( "Profile::GetString: Could not get INI item.  App %s, Item %s, TrueSize %i, MaxSize %i.  %s", Name, ItemName, TrueSize, MaxSize, InterpretWinError(0,Message) ) ;
         return ( FALSE ) ;
      } /* endif */

      Item[HowBig] = 0 ;

   #else // __NT__

      char *Buffer = new char [MaxSize+1] ;
      int Returned ( 0 ) ;
      if ( ProfileName[0] ) {
         Returned = GetPrivateProfileString ( Name, ItemName, "", Buffer, MaxSize+1, ProfileName ) ;
      } else {
         Returned = GetProfileString ( Name, ItemName, "", Buffer, MaxSize+1 ) ;
      } /* endif */

      if ( Returned >= MaxSize ) {
         delete [] Buffer ;
         Log ( "Profile::GetString: Could not get INI item.  App %s, Item %s.  Too large.", Name, ItemName ) ;
         return ( FALSE ) ;
      } /* endif */

      strcpy ( Item, Buffer ) ;

      delete [] Buffer ;

   #endif // __OS2__ vs __NT__

   return ( TRUE ) ;

} /* endmethod */
Example #21
0
void Dde_Item::BroadcastUpdate ( ) {

   // Send data complete to all hot links.
   for ( int i=0; i<sizeof(HotLinks)/sizeof(HotLinks[0]); i++ ) {
      if ( HotLinks[i][0] ) {
         PDDESTRUCT Message = MakeDDEObject ( HotLinks[i][1], PSZ(Name), 0, Format, Data, Size ) ;
         WinDdePostMsg ( HotLinks[i][1], HotLinks[i][0], WM_DDE_DATA, Message, DDEPM_RETRY ) ;
      } /* endif */
   } /* endfor */

   // Send advisory to all warm links.
   for ( i=0; i<sizeof(WarmLinks)/sizeof(WarmLinks[0]); i++ ) {
      if ( WarmLinks[i][0] ) {
         PDDESTRUCT Message = MakeDDEObject ( WarmLinks[i][1], PSZ(Name), DDE_FNODATA, Format, 0, 0 ) ;
         WinDdePostMsg ( WarmLinks[i][1], WarmLinks[i][0], WM_DDE_DATA, Message, DDEPM_RETRY ) ;
      } /* endif */
   } /* endfor */
}
Example #22
0
void Dde_Item::Unadvise ( HWND Server, HWND Client ) {

   // Cancel any links on this item for this Server/Client pair.
   Terminate ( Server, Client ) ;

   // Reply with an ACK.
   PDDESTRUCT Response = MakeDDEObject ( Client, PSZ(Name), DDE_FACK, DDEFMT_TEXT, 0, 0 ) ;
   WinDdePostMsg ( Client, Server, WM_DDE_ACK, Response, DDEPM_RETRY ) ;
}
Example #23
0
BOOL Profile::PutItem ( char *ItemName, void *Item, int Size ) {

   if ( !IsReady() ) 
      return ( FALSE ) ;

   #ifdef __OS2__

      if ( !PrfWriteProfileData ( Handle, PSZ(Name), PSZ(ItemName), Item, Size ) ) {
         char Message [512] ;
         Log ( "Profile::PutItem: Could not put INI item.  App %s, Item %s, size %i.  %s", Name, ItemName, Size, InterpretWinError(0,Message) ) ;
         return ( FALSE ) ;
      } /* endif */

   #else // __NT__

      char *Buffer = new char [Size*2+1] ;
      if ( Buffer ) {
         for ( int i=0; i<Size; i++ ) 
            sprintf ( &Buffer[i*2], "%02X", ((unsigned char*)Item)[i] ) ;
         if ( ProfileName[0] ) {
            if ( !WritePrivateProfileString ( Name, ItemName, Buffer, ProfileName ) ) {
               char Message [512] ;
               Log ( "Profile::PutString: Could not put INI item.  App %s, Item %s, Value %s.  %s", Name, ItemName, Buffer, InterpretWinError(0,Message) ) ;
               return ( FALSE ) ;
            } /* endif */
         } else {
            if ( !WriteProfileString ( Name, ItemName, Buffer ) ) {
               char Message [512] ;
               Log ( "Profile::PutString: Could not put INI item.  App %s, Item %s, Value %s.  %s", Name, ItemName, Buffer, InterpretWinError(0,Message) ) ;
               return ( FALSE ) ;
            } /* endif */
         } /* endif */
         delete [] Buffer ;
      } else {
         Log ( "Profile::PutItem: Could not put INI item.  App %s, Item %s, size %i.  Insufficient memory.", Name, ItemName, Size ) ;
         return ( FALSE ) ;
      } /* endif */

   #endif // __OS2__ vs __NT__

   return ( TRUE ) ;

} /* endmethod */
Module::Module ( char *name ) : Handle(0) {
   if ( name && *name ) {
      Name = (char*) malloc ( strlen(name) + 1 ) ;
      strcpy ( Name, name ) ;
      char Drive[_MAX_DRIVE+1], Dir[_MAX_DIR+1], Fname[_MAX_FNAME+1], Ext[_MAX_EXT+1] ;
      _splitpath ( Name, Drive, Dir, Fname, Ext ) ;
      char ModuleName [CCHMAXPATH] ;
      strcpy ( ModuleName, Drive ) ;
      strcat ( ModuleName, Dir ) ;
      strcat ( ModuleName, Fname ) ;
      if ( *Drive || *Dir )
         strcat ( ModuleName, Ext ) ;
      strupr ( ModuleName ) ;
      char MissingModule [CCHMAXPATH] ;
      DosLoadModule ( PSZ(MissingModule), sizeof(MissingModule), PSZ(ModuleName), &Handle ) ;
   } else {
      Name = 0 ;
   } /* endif */
} /* endmethod */
Example #25
0
void CreateControls (ThreadData *ptd, HWND hWnd)
{
   LONG oldproc;

   //
   // Create the edit control label
   //
   ptd->hWndStatic = CreateWindow (TEXT("static"), PSZ(IDS_RUNLABELHOT),
                                   WS_CHILD | WS_VISIBLE,
                                   0,0,0,0, hWnd, (HMENU)IDC_STATIC,
                                   ghInst, NULL);
   //
   // Create the edit control
   //
   ptd->hWndEdit = CreateWindow (TEXT("Edit"), TEXT(""),
                         WS_BORDER | WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL,
                         0,0,0,0, hWnd, (HMENU)IDC_RUNME,
                         ghInst, NULL);

   //
   // set the edit control proc and save the default one
   //
   oldproc = GetWindowLong (ptd->hWndEdit, GWL_WNDPROC);
   SetWindowLong (ptd->hWndEdit, GWL_WNDPROC, (LONG)EditProc);
   SetWindowLong (ptd->hWndEdit, GWL_USERDATA, oldproc);

   //
   // Create the execution button
   //
   ptd->hWndBtn = CreateWindow (TEXT("Button"), PSZ(IDS_BTNLABEL),
                                WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON,
                                0,0,0,0, hWnd, (HMENU)IDC_RUNMEBTN,
                                ghInst, NULL);
   //
   // Create a button for creating new desktops
   //
   ptd->hWndNew = CreateWindow (TEXT("button"), PSZ(IDS_NEWLABELHOT),
                                WS_CHILD | WS_VISIBLE,
                                0,0,0,0, hWnd, (HMENU)IDC_NEWDSKBTN,
                                ghInst, NULL);

}
Example #26
0
Dde_Server::Dde_Server ( HAB Anchor, HMODULE Library, HWND Owner, char *AppName ) :
   Ready(FALSE), Application(AppName) {

   if ( !WinRegisterClass ( Anchor, PSZ(DDESERVER_CLASS),
      Dde_Processor, 0, sizeof(PVOID) ) ) {

      ERRORID Error = WinGetLastError ( Anchor ) ;
      ResourceString Title ( Library, IDS_TITLE ) ;
      ResourceString Format ( Library, IDS_ERROR_WINREGISTERCLASS ) ;
      CHAR Message [200] ;
      sprintf ( Message, PCHAR(Format), DDESERVER_CLASS, Error ) ;
      Log ( "%s", Message ) ;
      WinMessageBox ( HWND_DESKTOP, Owner, PSZ(Message),
         PSZ(Title), 0, MB_ENTER | MB_ICONEXCLAMATION ) ;
      return ;

   } /* endif */

   Ready = TRUE ;
}
Example #27
0
USHORT Settings :: GetLanguages (HWND hwnd)
{
    // find all dlls and add the names to the language list
    HDIR          hdir;
    ULONG         c, fl, ul;
    FILEFINDBUF3  findbuf;
    APIRET        rc;
    PSZ           psz;
    HMODULE       hmod;

    fl   = FILE_NORMAL;
    hdir = HDIR_CREATE;
    c    = 1;
    rc   = DosFindFirst ("*.dll", &hdir, fl, &findbuf,
                         sizeof (findbuf), &c, FIL_STANDARD);
    while (!rc)
    {
        // we don't want the extension
        if ((psz = _getext (findbuf.achName)))
            *psz = '\0';
        // try opening the dll and read the version etc. data
        if ((rc = DosLoadModule(PSZ(NULL), 0, findbuf.achName, &hmod)) == NO_ERROR) {
            PVOID pv;
            if (DosGetResource(hmod, RT_RCDATA, DLL_ID, &pv) == NO_ERROR) {
                if (strcmp(PSZ(pv), "Gotcha!") == 0) {
                    psz = PSZ(pv)+strlen(PSZ(pv))+3;
                    ul = WinInsertLboxItem (hwnd, LIT_END, psz);
                    WinSendMsg(hwnd, LM_SETITEMHANDLE, MPFROMLONG(ul),
                               MPFROMP (strdup(findbuf.achName)));
                }
                DosFreeResource(pv);
            }
            DosFreeModule(hmod);
        }
        c = 1;
        rc = DosFindNext (hdir, &findbuf, sizeof (findbuf), &c);
    }
    DosFindClose (hdir);

    return 1;
}
Example #28
0
Helper :: Helper (HWND hwnd)
{
    HELPINIT   helpInit;

    // if we return because of an error, Help will be disabled
    fHelpEnabled = TRUE;

    // inititalize help init structure
    helpInit.cb                  = sizeof (HELPINIT);
    helpInit.ulReturnCode        = 0L;
    helpInit.pszTutorialName     = PSZ (NULL);
    helpInit.phtHelpTable        = PHELPTABLE (MAKELONG (MAIN_HELP_TABLE,
                                                         0xFFFF));
    helpInit.hmodHelpTableModule = GETMODULE;
    helpInit.hmodAccelActionBarModule = GETMODULE;
    helpInit.idAccelTable        = 0;
    helpInit.idActionBar         = 0;
    helpInit.pszHelpWindowTitle  = PSZ (PSZ_NAMEVERSION);
    helpInit.fShowPanelId        = CMIC_HIDE_PANEL_ID;

    CHAR   ach[_MAX_FNAME+_MAX_EXT];
    sprintf (ach, "%s.hlp", pset->QueryString (SEI_LANGUAGEHELP));
    helpInit.pszHelpLibraryName  = PSZ (ach);

    // create the help instance
    hwndHelpInstance = WinCreateHelpInstance (hab, &helpInit);
    if (!hwndHelpInstance || helpInit.ulReturnCode)
    {
        DisplayError (RSTR (IDS_ERROR_HELPERHEADING),
                      RSTR (IDS_ERROR_COULDNOTINITHELPFILE), ach);
        fHelpEnabled = FALSE;
    }

    // associate help instance with main frame
    if (! WinAssociateHelpInstance (hwndHelpInstance, hwnd))
    {
        DisplayError (RSTR (IDS_ERROR_HELPERHEADING),
                      RSTR (IDS_ERROR_COULDNOTINITHELP));
        fHelpEnabled = FALSE;
    }
}
//----------------------------------------------------------------------------
// SysUtils::exec
//----------------------------------------------------------------------------
bool SysUtils::exec(const char* pszCmdLine, const char *, int bBackground, bool, int *puiReturnCode)
{
  String sCmd = pszCmdLine;
  if( bBackground )
    // Background task
    sCmd += "&";

  // Execute shell command then exit
  *puiReturnCode = ::system(PSZ(sCmd));

  return true;
}
Example #30
0
LONG GetFontHeight (HWND hWnd)
{
   HDC hdc;
   TEXTMETRIC tm;
   SIZE size;
   #define MARGIN 7  // extra space on the button around the text

   hdc = GetDC (hWnd);
   if (!GetTextMetrics (hdc, &tm))
   {
      //
      // Use defaults
      //
      gStaticWidth = STATICWIDTH;
      gBtnWidth    = BTNWIDTH;
      gEditWidth   = EDITWIDTH;
      gNewWidth    = BTNWIDTH + 25;
      return CONTROLHEIGHT;
   }

   //
   // GetTextExtentPoint32 fills in size with the width and height of
   // a string.
   //
   GetTextExtentPoint32 (hdc, PSZ(IDS_RUNLABEL), lstrlen(PSZ(IDS_RUNLABEL)), &size);
   gStaticWidth = size.cx + MARGIN;
   gEditWidth   = EDITWIDTH;
   GetTextExtentPoint32 (hdc, PSZ(IDS_BTNLABEL), lstrlen(PSZ(IDS_BTNLABEL)), &size);
   gBtnWidth = size.cx + MARGIN;
   GetTextExtentPoint32 (hdc, PSZ(IDS_NEWLABEL), lstrlen(PSZ(IDS_NEWLABEL)), &size);
   gNewWidth = size.cx + MARGIN;
   ReleaseDC (hWnd, hdc);
   return tm.tmHeight + 2;

}