home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 January
/
usenetsourcesnewsgroupsinfomagicjanuary1994.iso
/
sources
/
x
/
volume4
/
xgen
/
part03
/
hash_shell_address.c
< prev
next >
Wrap
C/C++ Source or Header
|
1989-06-29
|
2KB
|
97 lines
#define MAX_NUM_SHELLS 50
#include <stdio.h>
#include <X11/IntrinsicP.h>
#include <X11/Intrinsic.h>
#include <X11/CompositeP.h>
#include <X11/CommandP.h>
#include <X11/LabelP.h>
#include <X11/Box.h>
#include <X11/StringDefs.h>
#include <X11/Shell.h>
#include <X11/Viewport.h>
#include <X11/Form.h>
#include <X11/Core.h>
#include <X11/VPaned.h>
#include "application.h"
static struct _shell_address shell_address[MAX_NUM_SHELLS];
enter_shell_address( widget_ptr, name)
Widget widget_ptr;
char *name;
{
static int i = 0;
int key;
if( i == 0 )
{
for ( i=0 ; i<MAX_NUM_SHELLS ; i++ )
{
shell_address[i].name = NULL;
}
}
key = ((*name) * *(name+1))%MAX_NUM_SHELLS;
while( shell_address[key].name != NULL &&
*(shell_address[key].name) != '!')
key = ++key%MAX_NUM_SHELLS;
shell_address[key].widget_ptr = widget_ptr;
shell_address[key].name = (char *)malloc(
(strlen(name)+1) * sizeof( char ));
strcpy( shell_address[key].name, name);
}
Widget get_shell_address(name)
char *name;
{
int key;
key = ((*name) * *(name+1))%MAX_NUM_SHELLS;
while( shell_address[key].widget_ptr != NULL
&& strcmp(shell_address[key].name, name) != 0)
key++;
return(shell_address[key].widget_ptr);
}
remove_shell_address(name)
char *name;
{
int key;
key = ((*name * *(name+1)))%MAX_NUM_SHELLS;
while( shell_address[key].widget_ptr != NULL &&
strcmp(shell_address[key].name, name) != 0)
key++;
if(shell_address[key].widget_ptr == NULL)
{
fprintf(stderr," Shell %s not found: Not removed\n",
name);
return(0);
}
*(shell_address[key].name) = '!';
return(1);
}