📄 wdesym.c
字号:
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE
* DESCRIBE IT HERE!
*
****************************************************************************/
// the following is a temporary measure to get around the fact
// that winreg.h defines a type called ppvalue
#define _WINREG_
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <win1632.h>
#include <stdlib.h>
#include <string.h>
#include "wdeglbl.h"
#include "wdemem.h"
#include "wderesin.h"
#include "wdetfile.h"
#include "wdegetfn.h"
#include "wdeopts.h"
#include "wdemain.h"
#include "wdegeted.h"
#include "wdestat.h"
#include "wdesdup.h"
#include "wdemsgbx.h"
#include "wdemsgs.gh"
#include "wdefutil.h"
#include "wdewait.h"
#include "wdestken.h"
#include "wdedebug.h"
#include "wde_rc.h"
#include "wdectl3d.h"
#include "wdecurr.h"
#include "wdesym.h"
#include "preproc.h"
/****************************************************************************/
/* macro definitions */
/****************************************************************************/
#define MAX_PP_CHARS 512
#define MAX_SYM_ADDS 128
/****************************************************************************/
/* external variables */
/****************************************************************************/
/****************************************************************************/
/* external function prototypes */
/****************************************************************************/
/****************************************************************************/
/* static function prototypes */
/****************************************************************************/
static Bool WdeResourceViewHash ( WdeResInfo * );
static Bool WdeResourceLoadHash ( WdeResInfo * );
static Bool WdeResourceWriteHash ( WdeResInfo * );
static void WdeAddSymbols ( WdeHashTable * );
static char *WdeLoadSymbols ( WdeHashTable **, char *, Bool );
/****************************************************************************/
/* external variables */
/****************************************************************************/
extern char *WdeSymSaveFilter;
extern char *WdeLoadHeaderTitle;
extern char *WdeWriteHeaderTitle;
/****************************************************************************/
/* static variables */
/****************************************************************************/
static char WdeBusyChars[] = "-\\|/";
static Bool WdeViewSymbols( WdeHashTable **table, HWND parent )
{
WRHashEntryFlags flags;
FARPROC cb;
Bool ok;
cb = NULL;
ok = ( table != NULL );
if( ok ) {
cb = MakeProcInstance( (FARPROC)WdeHelpRoutine, WdeGetAppInstance() );
ok = ( cb != (FARPROC)NULL );
}
if( ok ) {
flags = WR_HASHENTRY_ALL;
ok = WREditSym( parent, table, &flags, cb );
}
if( cb != (FARPROC)NULL ) {
FreeProcInstance( (FARPROC)cb );
}
return( ok );
}
Bool WdeResourceHashTableAction ( WdeResInfo *info, int action )
{
Bool ret;
ret = FALSE;
switch( action ) {
case VIEW_HASH:
ret = WdeResourceViewHash( info );
break;
case LOAD_HASH:
ret = WdeResourceLoadHash( info );
break;
case WRITE_HASH:
ret = WdeResourceWriteHash( info );
break;
}
return( ret );
}
Bool WdeResourceViewHash( WdeResInfo *info )
{
BOOL no_hash;
BOOL ret;
OBJPTR obj;
if( !info->hash_table ) {
InitState( info->forms_win );
no_hash = TRUE;
info->hash_table = WdeInitHashTable();
}
ret = ( WdeViewSymbols( &(info->hash_table), info->edit_win ) );
if( !WdeNumInHashTable( info->hash_table ) ) {
WdeFreeHashTable( info->hash_table );
info->hash_table = NULL;
}
if( ret && ( obj = GetMainObject() ) ) {
WdeTouchHashTable( info->hash_table );
Forward ( obj, RESOLVE_HELPSYMBOL, &ret, NULL ); /* JPK */
Forward ( obj, RESOLVE_SYMBOL, &ret, NULL );
}
if( ret ) {
obj = GetCurrObject();
if( obj ) {
Notify( obj, PRIMARY_OBJECT, NULL );
}
}
return ( ret );
}
Bool WdeResourceLoadHash( WdeResInfo *info )
{
OBJPTR obj;
Bool b;
Bool from_id;
char *include;
include = WdeLoadSymbols( &(info->hash_table), NULL, TRUE );
if( include == NULL ) {
return( FALSE );
}
if( info->sym_name ) {
WdeMemFree( info->sym_name );
}
info->sym_name = include;
if( obj = GetMainObject() ) {
b = TRUE;
from_id = TRUE;
Forward( obj, RESOLVE_HELPSYMBOL, &b, &from_id ); /* JPK */
Forward( obj, RESOLVE_SYMBOL, &b, &from_id );
}
obj = GetCurrObject();
if( obj ) {
Notify( obj, PRIMARY_OBJECT, NULL );
}
WdeSetResModified( info, TRUE );
return ( TRUE );
}
Bool WdeResourceWriteHash( WdeResInfo *info )
{
return( WdeWriteSymbols( info->hash_table, &info->sym_name, TRUE ) );
}
Bool WdeCreateDLGInclude( WdeResInfo *rinfo, char *include )
{
WResID *type;
WResID *res;
WResLangType lang;
char *str;
int len;
Bool ok;
type = NULL;
res = NULL;
str = NULL;
ok= ( rinfo && include );
if( ok ) {
if( rinfo->info->dir == NULL ) {
rinfo->info->dir = WResInitDir();
ok = ( rinfo->info->dir != NULL );
}
}
if( ok ) {
WdeDeleteDLGInclude( rinfo );
type = WResIDFromNum( (uint_16)RT_RCDATA );
ok = ( type != NULL );
}
if( ok ) {
res = WResIDFromStr( "DLGINCLUDE" );
ok = ( res != NULL );
}
if( ok ) {
str = WdeStrDup( include );
ok = ( str != NULL );
}
if( ok ) {
lang.lang = DEF_LANG;
lang.sublang = DEF_SUBLANG;
len = strlen( include ) + 1;
ok = !WResAddResource( type, res, MEMFLAG_DISCARDABLE,
0, len, rinfo->info->dir, &lang, NULL );
}
if( ok ) {
ok = WRFindAndSetData( rinfo->info->dir, type, res, &lang, str );
}
if( type != NULL ) {
WdeMemFree( type );
}
if( res != NULL ) {
WdeMemFree( res );
}
if( !ok ) {
if( str != NULL ) {
WdeMemFree( str );
}
}
return( ok );
}
Bool WdeDeleteDLGInclude( WdeResInfo *rinfo )
{
WResTypeNode *tnode;
WResResNode *rnode;
WResLangNode *lnode;
WResLangType lang;
Bool ok;
ok = ( rinfo != NULL );
if( ok ) {
tnode = WRFindTypeNode( rinfo->info->dir, (uint_16)RT_RCDATA, NULL );
ok = ( tnode != NULL );
}
if( ok ) {
rnode = WRFindResNode( tnode, 0, "DLGINCLUDE" );
ok = ( rnode != NULL );
}
if( ok ) {
lang.lang = DEF_LANG;
lang.sublang = DEF_SUBLANG;
lnode = WRFindLangNodeFromLangType( rnode, &lang );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -