Filewatcher File Search
FTP Search
  
Directory (beta)
  
Content Search (beta)
   
pkg://xab-1.0-1.src.rpm:27326/xab.tar.gz  info  downloads

xab/ 40755    764    764           0  6471571547   7712 5ustar  amitamitxab/StrFnc.c100644    764    764        5505  6155430225  11341 0ustar  amitamit#include <string.h>

#define FOREVER         1

/*definition of blank space characters, have I missed anything ?*/
#define SPACE_BS        ' '
#define BS_BS           '\b'
#define CR_BS           '\r'
#define TAB_BS          '\t'
#define NL_BS           '\n'

/*-----------------------------------------------------------------------
Macro : IsBS (c) returns a non-zero value if the argument is a blank space
character.
-------------------------------------------------------------------------*/
#define IsBS(c) ((c == SPACE_BS) || \
                  (c == CR_BS) || \
                  (c == TAB_BS) || \
                  (c == NL_BS))

/*-------------------------------------------------------------------------
Macro : FHex (c) macro to convert a given number between 0 to 0xF to an
ascii character.
---------------------------------------------------------------------------*/
#define FHex(c) ((c <=9) ? c + '0': c - 10 + 'A')

/*-------------------------------------------------------------------------
Function : StrClean( char *) removes leading, trailing and extra blank spaces
from the argument string. Returns the length of the 'trimmed' string.
---------------------------------------------------------------------------*/
int StrClean (char *str)
{
  int i, j, len;

  len = strlen(str);

  /* 
   Remove the leading blank spaces 
  */
  
  /*count the leading blank spaces*/
  for (i = 0; i < len; i++)
  {
    if (!IsBS(str[i]))  /*not a blank space*/
    {
      break;
    }
  }
  /*at this point, i contains the number of leading blank spaces*/
  len -= i;  /*adjust the length of the string*/
  
  /*remove the leading blank spaces*/
  for (j = 0; j < len + 1; j++)
  {
    str[j] = str[j+1];
  }

  /*
  Remove the trailing blank spaces
  */
  for (i = len - 1; i >= 0; i--)
  {
    if (IsBS(str[i]))
    {
      str[i] = '\0';
      len--;
    }
    else
    {
      break;
    }
  }

  /*
  Remove the extra blank spaces
  */
  for (i = 0; str[i] != '\0'; i++)
  {
    if (IsBS(str[i]) && IsBS(str[i+1]))  /*extra blank space ? */
    {
      for (j = i+1; j < len + 1; j++)
      {
        str[j] = str[j+1];  /*remove the extra space*/
      }
      len --;
      i--;  /*for the 3-blank space case*/
    }
  }
  
  return (len);
}

#if 0

/*--------------------------------------------------------------------
Function : HexDump (unsigned char *dump, int num, char *str)

converts the 'dump' array into a string of digits in hex format.
----------------------------------------------------------------------*/
int HexDump (unsigned char *dump, int num, char *str)
{
  int i;
  unsigned char lnibble, hnibble;
  int len = 0;

  for (i = 0; i < num; i++)
  {
    lnibble = dump[i] & 0xF;
    hnibble = (dump[i] & 0xF0) >> 4;
    str[len++] = FHex(hnibble);
    str[len++] = FHex(lnibble);
    str[len++] = ' ';
  }
  str[len] = '\0';

  return (len);
}

#endif
xab/xab_sys.c100644    764    764       11372  6471571131  11634 0ustar  amitamit#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <dirent.h>

#include "xab_sysdefs.h"
#include "xab_filedefs.h"

extern CardStruct Card;
/******************************Functions***********************************/
char *GetHomeDirectory(length)
     int *length;
{
  char *ret_str = NULL;

  ret_str = getenv("HOME");
  if (length != NULL) *length = strlen(ret_str);

  return ret_str;
}

static void GetPathAndFileName (PathStr, Path, FileName)
     char *PathStr;
     char *Path;
     char *FileName;
{
  char *dptr;

  dptr = strrchr(PathStr, DIRECTORY_DELIMITER);
  if (dptr == NULL) /*not found*/
    {
      Path[0] = '\0';
      strcpy(FileName, PathStr);
    }
  else
    {
      strcpy(FileName, dptr+1);
      *dptr = '\0';
      strcpy(Path, PathStr);
      *dptr = DIRECTORY_DELIMITER;
    }
}

int CleanCurrentXabFile (PathName)
char *PathName;
{
  int status;
  char Path[PATH_NAME_LENGTH];
  char FileName[PATH_NAME_LENGTH];
  char *Fstr;

  GetPathAndFileName(PathName, Path, FileName);
  Fstr = (char *)tempnam(Path, "XABXXXXXXXXX");
  if (Fstr != NULL)
    {
      status = CleanCardFile(Fstr);
      if (status == F_SUCCESS)
	{
	  CloseCardFile();
	  
	  /*Create a Backup File Name*/
	  if (Path[0] != '\0')
	    {
	      strcat(Path, "/");
	    }
	  strcat(Path, FileName);
	  strcat(Path, ".backup");
	  
	  /*rename the file to its backup name*/
	  if (rename (PathName, Path) == 0)
	    {
	      if (rename(Fstr, PathName) == 0)
		{
		  status = OpenCardFile(PathName);
		}
	      else
		{
		  status = H_RENAME_FAILED;
		}
	    }
	  else
	    {
	      status = H_BACKUP_FAILED;
	    }
	  free(Fstr);
	}
    }
  else
    {
      status = H_NO_TMP_NAME;
    }

  return status;
}

int ListDirEntries (dir, dirptr, numdir, filptr, numfil)
char *dir;
char *dirptr[];
int *numdir;
char *filptr[];
int *numfil;
{
  char PathName[PATH_NAME_LENGTH];
  int status = F_SUCCESS;
  DIR *dp;
  struct dirent *ent;
  struct stat sbuf;
  char *buf;

  *numdir = *numfil = 0;

  dp = opendir (dir);
  if (dp != NULL)
    {
      do 
	{
	  ent = readdir(dp);
	  if (ent != NULL)
	    {
	      strcpy(PathName, dir);
	      if (dir[strlen(dir) - 1] != '/') strcat(PathName, "/");
	      strcat(PathName, ent->d_name);
	      if (lstat(PathName, &sbuf) == 0)
		{
		  buf = (char *)malloc(PATH_NAME_LENGTH + 1);
		  if (buf != NULL)
		    {
		      strcpy(buf, ent->d_name);
		      if (S_ISDIR(sbuf.st_mode)) /*directory*/
			{
			  dirptr[*numdir] = buf;
			  (*numdir)++;
			}
		      else
		        {
			  /*display only regular and link files*/
			  if (S_ISREG(sbuf.st_mode) || S_ISLNK(sbuf.st_mode))
			    {
			      filptr[*numfil] = buf;
			      (*numfil)++;
			    }
		        }

		      if ((*numfil >= MAX_FILES_PER_DIR) ||
			 (*numdir >= MAX_FILES_PER_DIR))
			{
			  break;
			}
		    }
		  else
		    {
		      status = H_MALLOC_FAILED;
		      break;
		    }
		}
	      else
		{
		  status = H_LSTAT_ERROR;
		  break;
		}
	    }
	}
      while (ent != NULL);
      closedir(dp);

    }
  else
    {
      status = H_OPENDIR_FAILED;
    }
  return status;
}

void FreeDirStorage (dirptr, numdir, filptr, numfil)
char *dirptr[];
int numdir;
char *filptr[];
int numfil;
{
  int i;

  for (i = 0; i < numdir; i++) free(dirptr[i]);
  for (i = 0; i < numfil; i++) free(filptr[i]);
    
}

void ChangeCurrentDir (DirStr, CurStr)
char *DirStr;
char *CurStr;
{
  char *ptr;

  if (strcmp(CurStr, ".") != 0) /*don't need to do anything if . is selected*/
    {
      if (strcmp(CurStr, "..") == 0) /*go up one level*/
	{
	  DirStr[strlen(DirStr) - 2] = '\0';
	  if ((ptr = strrchr(DirStr, DIRECTORY_DELIMITER)) != NULL)
	    {
	      *ptr = '\0';
	    }
	}
      else
	{
	  strcat(DirStr, CurStr);
	}
      strcat(DirStr, "/");
    }
} 

int SysPrintCard (command)
char *command;
{
  int status = F_SUCCESS;

  char *tmpfil, *strp;
  FILE *tfp;

  /*creats a temporary file*/
  tmpfil = (char *)tempnam(GetHomeDirectory(NULL), "XABXXXXXXXXX");
  if (tmpfil != NULL)
    {
      tfp = fopen(tmpfil, "w");
      if (tfp != NULL)
	{
	  char bcommand[PRINTER_COMMAND_SIZE];

	  fprintf(tfp, "%s\n%s\n\n", &Card.NameOnCard[0], 
		  &Card.Information[0]);
	  fclose(tfp);

	  /*now replace the %s with the temporary file name*/
	  strp = strstr(command, "%s");	  
	  strcpy(bcommand, strp); /*save the back end of the string*/
	  strcpy(strp, tmpfil);
	  strcat(command, bcommand+2);

	  status = system(command);
	  switch(status)
	    {
	    case 127:
	      status = H_EXECVP_FAILED;
	      break;

	    case -1:
	      status = H_SYSTEM_FAILED;
	      break;

	    default:
	      status = F_SUCCESS;
	      break;
	    }

	  unlink(tmpfil);
	  free(tmpfil);
	}
      else
	{
	  status = H_FOPEN_FAILED;
	}
    }
  else
    {
      status = H_NO_TMP_NAME;
    }
  return status;
}



xab/xab_gui_main.c100644    764    764       12774  6471571256  12625 0ustar  amitamit#include <varargs.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>

#include <X11/Intrinsic.h>
#include <X11/StringDefs.h>
#include <X11/Xatom.h>
#include <X11/Shell.h>
#include <X11/Xaw/Dialog.h>
#include <X11/Xaw/Form.h>
#include <X11/Xaw/Label.h>
#include <X11/Xaw/Paned.h>
#include <X11/Xaw/Command.h>
#include <X11/Xaw/AsciiText.h>
#include <X11/Xaw/MenuButton.h>
#include <X11/Xaw/SimpleMenu.h>
#include <X11/Xaw/SmeBSB.h>
#include <X11/Xaw/Viewport.h>
#include <X11/Xaw/AsciiText.h>
#include <X11/Xaw/List.h>

#include "xab_filedefs.h"
#include "xab_sysdefs.h"
#include "xab_guidefs.h"

/*-----------------------------------------------------------------------
                    Global Data Declaration
------------------------------------------------------------------------*/
XtAppContext app_context;
Widget toplevel, pane, MenuForm, BoardForm, BoardVPort;
Widget FileMenu, FolderMenu, CardMenu, HelpMenu; 
Widget FileOption, Fopen, Fmerge, Fclean, Fsearch, FmenuLine1, Fexit;
Widget FolderOption, Fcreate, Fdelete; 
Widget CardOption, Ccreate, Cdelete;
Widget HelpOption, Hversion;
Widget FcreateShell, FcreateDialog, FcreateValue;
Widget CcreateShell, CcreatePane, CcreateButtons, CcreateDialog;
Widget CcreateCopy, CcreatePaste, CcreatePrint; 
Widget CcreateName, CcreateNameLabel;
Widget CcreateInfoLabel, CcreateInfo;
Widget CcreateCancel, CcreateOK, CcreateClear;
Widget CreatFileShell, CreateFileDialog;
Widget MessageShell, MessageDialog, MessageLabel;
Widget ListShell, ListLabel, ListForm, ListVPort, ListList,  ListOK, ListCancel; 
Widget FopenLShell, FopenForm, FdirForm, FfileForm; 
Widget DirlistLabel, DirListVPort, DirList;
Widget FilelistLabel, FileListVPort, FileList;
Widget SelectionLabel, SelectionValue, SelectionOK, SelectionCancel;
Widget PcardShell, PcardDialog;
Widget FsearchShell, FsearchDialog, FsearchValue;
Widget SrchListShell, SrchListForm, SrchListLabel, SrchListVPort, SrchListList;
Widget SrchListView, SrchListClose;

Pixmap FolderPixmap, CardPixmap, FilePixmap, XabPixmap, PrinterPixmap;

int ListSize;
BOARD_LAYOUT CurrentFolder[MAX_NAMES];
int FileOpened = FALSE;
int NumItems;
CardList CurrentList[MAX_NAMES];
char DirName[NAME_LENGTH];
CardStruct Card;
int CardCreate = TRUE;
int ViewIndex;
char DirStr[PATH_NAME_LENGTH];
char NewFileName[PATH_NAME_LENGTH];
char *dirptr[MAX_FILES_PER_DIR], *filptr[MAX_FILES_PER_DIR];
int numdir, numfil;
CardList SearchList[MAX_SRCH];
int NumItemsFound;
char *ListNames[MAX_SRCH] = {"No Files Selected"};

String ListPtr[MAX_NAMES] = {"No Files Selected"}; 
int DeleteType;

AppData app_data;
XtResource app_resources[] = {
{
    XtNfont,
    XtCFont,
    XtRFontStruct,
    sizeof(XFontStruct*),
    XtOffsetOf(AppData, font),
    XtRString,
    XtDefaultFont }
};
int hunit = 8, vunit;

/*******************************************************************
Functions:
******************************************************************/
void GetAppResources (void)
{
  int i;

  XtVaGetApplicationResources (toplevel, 
			       &app_data, app_resources, 
			       XtNumber(app_resources), NULL);

  vunit = app_data.font->ascent + 
	   app_data.font->descent;

  for (i = 0; i < app_data.font->n_properties; i++)
    {
      if (app_data.font->properties[i].name == XA_QUAD_WIDTH)
	{
	  hunit = app_data.font->properties[i].card32 + 1;
	  break;
	}
    }

  /*    printf("vunit = %f, hunit = %f\n", vunit, hunit); */
}


/*----------------------------------------------------------------------
Function : main()

Description: The main function, of course. Initializes the X application,
creates widgets and realizes them.
-----------------------------------------------------------------------*/
int main(argc, argv)
int argc;
String argv[];
{
  int status;

  toplevel = XtVaAppInitialize (&app_context,
				"Card File",
				NULL,0,
				&argc, argv,
				NULL, NULL);

  GetAppResources();


  
  pane = XtVaCreateManagedWidget ("Paned",
				  panedWidgetClass,
				  toplevel,
				  XtNwidth, DEFAULT_WIDTH,
				  XtNheight, DEFAULT_HEIGHT, 
				  NULL);

  InitPixmap();  /*Initialize the pixmap required for folder and files*/

  InitPopups();

  InitMenu();


  BoardVPort = XtVaCreateManagedWidget ("BoardViewPort",
					viewportWidgetClass,
					pane,
					XtNallowVert, True,
					XtNallowHoriz, True,
					XtNforceBars, True,
					XtNuseRight, True,
					XtNuseBottom, True,
					NULL);
 
  BoardForm = XtVaCreateManagedWidget ("DrawingBoard",
				       formWidgetClass,
				       BoardVPort,
				       NULL);

  XtVaSetValues (toplevel, 
		 XtNiconName, "Address Book",
		 XtNtitle, "Address Book: No file selected",
		 XtNiconPixmap, XabPixmap,
		 NULL);

  strcpy (NewFileName, getenv("HOME"));
  strcat (NewFileName, "/.xab");
  status = OpenCardFile(NewFileName);
  if (status == F_SUCCESS)
    {
      char string[MAX_MSG_LEN];
      
      sprintf(string, "Address Book: %s", NewFileName);
      XtVaSetValues (toplevel, 
		     XtNtitle, string,
		     NULL);      
      FileOpened = TRUE;
      status = DisplayCurrentDirectory();
    }
  else
    {
      DestroyFolder();
      CurrentFolder[0].NameType = NAME_DIR;
      strcpy (&CurrentFolder[0].Text[0], "No Files Selected");
      ListSize = 1;
      DrawFolder();

      if (status == F_NO_SUCH_FILE)
	{
	  HandlePopup ((Widget)0, (XtPointer)CreatFileShell, 
		       (XtPointer)0);
	}
      else
	{
	  MessageBox("File could not be opened\nstatus = %d", status);
	}
    }
  
  XtAddCallback (toplevel, XtNdestroyCallback, HandleExit, NULL);

  XtRealizeWidget(toplevel); 

  XtAppMainLoop(app_context);

  return 0;
}









xab/IAFA-PACKAGE100644    764    764        1122  6155430225  11441 0ustar  amitamitTitle : 	X11-based Address Book (xab).
Version:	1.0.
Description:	A program to store and retrieve address, telephone numbers,
		E-mail address or any other information of friends, relatives,
		business contacts or anyone of interest. The address book
		may contain folders and sub-folders so that addresses can be
		categorized. 
Author:		Amit Chatterjee (asav@ix.netcom.com).
Maintained by:	Amit Chatterjee.
Maintained at:  sunsite.unc.edu.
Platforms:	Linux, HP-UX (probably in all other UNIX-based platforms).
Copying-Policy:	Freely Redistributable.  
Keywords:       "X Address Book", "xab".xab/makefile100644    764    764        1747  6471566744  11523 0ustar  amitamitCC = /usr/bin/gcc
LIBDIR = -L /usr/X11/lib
LIBS = -lXaw3d -lXt -lX11
CFLAG = -ansi -Wall  -c ${debug}

OBJS = xab_gui_main.o xab_gui_init.o xab_gui_callbacks.o xab_gui_utils.o xab_file.o xab_sys.o

XBM = bitmaps.xbm

FILE_INCLS = xab_filedefs.h
GUI_INCLS = xab_guidefs.h
SYS_INCLS = xab_sysdefs.h

xab : ${OBJS} 
	  ${CC}  ${OBJS} ${LIBDIR} ${LIBS} -o $@ 

xab_gui_main.o : xab_gui_main.c ${GUI_INCLS} ${FILE_INCLS} $(SYS_INCLS)
	${CC} ${CFLAG} xab_gui_main.c

xab_gui_init.o : xab_gui_init.c ${GUI_INCLS} ${FILE_INCLS} $(SYS_INCLS) ${XBM}
	${CC} ${CFLAG} xab_gui_init.c

xab_gui_callbacks.o : xab_gui_callbacks.c ${GUI_INCLS} ${FILE_INCLS} $(SYS_INCLS)
	${CC} ${CFLAG} xab_gui_callbacks.c

xab_gui_utils.o : xab_gui_utils.c  ${GUI_INCLS} ${FILE_INCLS} $(SYS_INCLS)
	${CC} ${CFLAG} xab_gui_utils.c

xab_sys.o : xab_sys.c ${FILE_INCLS} $(SYS_INCLS)
	${CC} ${CFLAG} xab_sys.c

xab_file.o : xab_file.c ${FILE_INCLS}
	${CC} ${CFLAG} xab_file.c

clean :
	rm *.o; rm xab

install :
	cp xab /usr/local/bin
xab/INSTALL100644    764    764        3337  6155430225  11030 0ustar  amitamitSteps for installing xab.1.0.tar.gz :

(1) Uncompress the distribution using the gzip utility.
    gzip -d xab.1.0.tar.gz

(2) Unpack the distribution.
    tar xvf xab.1.0.tar

(3) Change directory to xab.1.0
    cd xab.1.0
 

If the archive contains the executable (called xab in a.out format), copy it 
into one of the binary directories (/usr/local/bin, for instance). You must 
have the shared library - libXaw3d to run the program. In case, you do not 
have Xaw3d or the executable was not found in distribution, you will have to 
re-build xab from the source.

Edit the makefile and make necessary changes to pathnames (LIBDIR) if it does
not match with that of your system. For HP-UX, you may need to add the string

      -D_INCLUDE_POSIX_SOURCE to the CFLAG.

For some systems, you may need to modify LIBS to add -lXext -lICE. In case,
you don't have Xaw3d, but have Xaw, modify -lXaw3d to -lXaw. 

If you do not have gcc, but have some other C compiler (cc, c89), change the
definition of CC. You may also need to change some of the options in CFLAG.

To build the program, run
       make

This should do it. Copy the executable, xab to an appropriate binary 
directory (/usr/local/bin) and you should be all set.

To run xab, just type xab from an xterm. This program can also be run with
the usual x-toolkit command line parameters (like geometry axb, -font 
fontname, -foreground black, etc). I run it with the following command and
it looks quite preety. Try it out -

  xab -foreground black -background BlancedAlmond &

Hope you like it. Read the document README to find out how to use xab. 
Feel free to send me your opinions and if you notice any bugs (I do not 
guarantee a fix, though).

Amit Chatterjee
(asav@ix.netcom.com) 












xab/xab_gui_utils.c100644    764    764        6774  6471570115  13015 0ustar  amitamit#include <varargs.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>

#include <X11/Intrinsic.h>
#include <X11/StringDefs.h>
#include <X11/Xatom.h>
#include <X11/Shell.h>
#include <X11/Xaw/Dialog.h>
#include <X11/Xaw/Form.h>
#include <X11/Xaw/Label.h>
#include <X11/Xaw/Paned.h>
#include <X11/Xaw/Command.h>
#include <X11/Xaw/AsciiText.h>
#include <X11/Xaw/MenuButton.h>
#include <X11/Xaw/SimpleMenu.h>
#include <X11/Xaw/SmeBSB.h>
#include <X11/Xaw/Viewport.h>
#include <X11/Xaw/AsciiText.h>
#include <X11/Xaw/List.h>

#include "xab_filedefs.h"
#include "xab_sysdefs.h"
#include "xab_guidefs.h"

/**********************************Functions***************************/

void DrawFolder(void)
{
  int i;
  void ItemSelect();  
  Widget widgets[50]; 


  for (i=0; i < ListSize; i++)
    {
      Pixmap pxm;
      Widget vert1W;

      if (CurrentFolder[i].NameType == NAME_DIR)
	{
	  pxm = FolderPixmap;
	}
      else
	{
	  pxm = CardPixmap;
	}

      if (i == 0) vert1W = NULL; 
      else vert1W = CurrentFolder[i-1].widget;
      
      widgets[i] = 
      CurrentFolder[i].widget = XtVaCreateWidget ("Text",
						  commandWidgetClass,
						  BoardForm,
						  XtNlabel, CurrentFolder[i].Text,
						  XtNfromVert, vert1W,
						  XtNleftBitmap, pxm,
						  XtNbottom, XawChainLeft,
						  XtNtop, XawChainLeft,
						  XtNleft, XawChainLeft,
						  XtNright,XawChainLeft,
						  XtNborderWidth, 0,
						  XtNinternalHeight, DEFAULT_INTERNAL_HEIGHT,
						  XtNcursorName, "hand2",
						  NULL);

      XtAddCallback(CurrentFolder[i].widget,
		    XtNcallback, ItemSelect, 
		    (XtPointer)i);
    }

  XtManageChildren ((WidgetList)widgets, (Cardinal)ListSize);
}

void DestroyFolder (void)
{
  int i;

  for (i = 0; i < ListSize; i++)
    {
      XtDestroyWidget(CurrentFolder[i].widget);
    }
}

void MessageBox (format, va_alist)
char *format;
va_dcl
{
  char smsg[MAX_MSG_LEN];
  va_list args;

  va_start(args);
  vsprintf(smsg, format, args);
  va_end (args);

  XtVaSetValues (MessageLabel, 
		 XtNlabel, smsg,
		 XtNwidth, MSG_COLS * hunit,
		 XtNheight, MSG_ROWS * vunit,
		 NULL);

  HandlePopup (0, (XtPointer)MessageShell, 0);
} 

void PokeCardValues (void)
{
  XtVaSetValues (CcreateName,
		 XtNstring, &Card.NameOnCard[0],
		 NULL);

  XtVaSetValues (CcreateInfo,
		 XtNstring, &Card.Information[0],
		 NULL);
  
} 

void RemoveBlankSpaces(string)
char *string;
{
  int i;

  for (i = 0;; i++)
    {
      if ((string[i] == ' ') ||
	  (string[i] == '\n') ||
	  (string[i] == '\r') ||
	  (string[i] == '\t') ||
	  (string[i] == '\0'))
	{
	  string[i] = '\0';
	  break;
	}
    }
}

void RemoveNewLines(string)
char *string;
{
  int i;

  for (i = 0;; i++)
    {
      if ((string[i] == '\n') ||
	  (string[i] == '\r') ||
	  (string[i] == '\0'))
	{
	  string[i] = '\0';
	  break;
	}
    }
}

int DisplayCurrentDirectory (void)
{
  int status, i;
  char UpName[LIST_LENGTH];

  status = ListFoldersandCards(&NumItems, CurrentList, DirName);
  if (status == F_SUCCESS)
    {
      DestroyFolder();
      SortCardAndFolderList (CurrentList, NumItems);
      
      strcpy(UpName, DirName);
      strcat(UpName, " (..)" );
      CurrentFolder[0].NameType = NAME_DIR;
      strcpy( CurrentFolder[0].Text, UpName);

      for (i = 0, ListSize = 1; i < NumItems; i++, ListSize++)
	{
	  CurrentFolder[i+1].NameType = CurrentList[i].NameType;
	  strcpy(&CurrentFolder[i+1].Text[0],
		 &CurrentList[i].CardorFolderName[0]);
	}
      DrawFolder();
    }
  else
    {
      MessageBox("Card listing failed\nstatus = %d", status);
    }
  return status;
}


xab/README100644    764    764       15025  6444236016  10677 0ustar  amitamit                   	XAB Release 1.0
                  	***************

XAB is a X11-based address book. You can use it to store names. addresses, 
telephone numbers, E-mail address (or any other information) of friends,
relatives, co-workers, business contacts, etc. The information can be 
organized into "folders". Each folder may contain a number of "sub-folders" 
and/or "cards". A card is where you store the information mentioned above. In
a way the address book is organized in a manner very similar to the UNIX  
directory structure  where the folders can be compared to directories and 
cards can be compared to files in a directory. You can have sub-folders just 
like you can have sub-directories. For example, you can organize the address 
book as follows:

/(Top Folder) ------- Friends(Folder)                      |- Uncle Sam(Card)
                 |                      |- Uncles(Folder)--|
                 |--- Family(Folder)----|                  |- Uncle Tom(Card)
                 |                      |- Aunts(Folder)
                 |
                 |--- Business Contacts(Folder)

The main XAB window consists of two areas - the top-level menu and the address
book browser. The browser displays the content of the "current folder" 
(sub-folders and cards) in a manner very similar to the way many popular file 
managers display the directory structure. 
You can create (and delete) folders and cards from the top-level menu. 
You can move from one folder to a sub-folder  by clicking on a folder that is 
displayed in the browser area. You can view/edit a card by clicking on a card 
that is displayed in the browser area. It is really very easy.

The folders and cards created by you are saved in a file. When you start XAB,
the browser displays an icon with label "No files selected". You need to go
to the File menu and open the file by clicking on the sub-menu "Open file". If
you want to create a new file (first time), just enter the name of the file you
want to create on the "selection" box. After the file is opened, the browser
area will display the content of the top-level folder (/). To create a folder,
use the folder menu item "create folder". To create a sub-folder, go to the
folder and select "create folder" from the top-level menu. To move to one level
up, click on the folder icon displayed with the name of the parent folder. 
You can delete a card or a folder from by selecting "delete folder"
or "delete card" item from the top-level menu. One word of caution here, the
delete items do not display a warning message like "Are you sure ?", so be 
careful (I will implement all that in the next version). Another word of 
caution, a folder can be deleted even when when it is not empty.

To view a card, click on the card icon displayed on the browser area. A pop-up
window will display the content of the card. You can make necessary changes
to what is displayed and to save the changes, click on the save button. You
can clear the entire content by clicking on the Clear All button. You can
select a portion or all of the Information field by dragging the pointer
over the area you want to select which depressing the right button. If you
want to copy the selected text into a buffer, click on the copy button. You
can paste this buffer anytime you want, on any card, by clicking on the
paste button. To print a card, click on the Print... button. It displays
the default printer command (%s denotes the temporary file name where the
content of the card is copied to). To save it to a file, use the printer
command "cat %s >> filename". 

From the File menu, you can "merge" two files. Now, of what use is this ? Let
me give an example. Suppose you have generated a file with information on your
friends and relatives and your wife has generated a similar file with her
own information. Now you decided to have a joint Unix account. What you can do
is to create a new file and create two sub-folders "Amit's friends" and 
"Vidya's friends". Go to the first folder and use the merge menu item to merge
the file which you created earlier and then go the latter folder and merge the
file created by your wife. Maybe, this is a bad example, a better one (or 
worse) may be a sales manager who decides to create a "master contact file" by
merging all the files generated by the sales reps.

Now, what does the file menu-item "Clean File" do ? When you delete a card or
a folder, it is actually not deleted from the file. Its reference is removed
from its parent's list of children so that the parent does not know of
the deleted folder/card. In theory, it can be undeleted. Don't ask me how. I
will implement it in the next release. Anyway, what the "clean file" does is 
that it when you click on it, it removes the deleted folders/cards from the 
disk, saving you some valuable disk space. Before cleaning up, it saves the
"uncleaned" file by renaming it <filename>.bak where filename is the name of 
the file created by you.

You can use the file menu item "Search..." to search for a pattern. The 
search begins on the current folder and the search is also conducted in all
the sub-folders under the folder. For example, to get a list of people in
the "OFFICE" folder who lives in Durham, search for the word "Durham", and
you will get a list of them. You can select one card from the list and view 
it. The search is case-insensitive.

Thats about it on how to use it. An important limitation that I think you 
should know about - the maximum number of children a folder may have is 100.
If you think that is not sufficient, you can increase that by modifying the
#define MAX_NAMES from 100 to any number you want. Making it too big will
increase the size of each records and thus increasing the size of the file. You
have to re-compile and re-link the program, of course.


Current & Future Releases
-------------------------
I have got lots of plans but don't have a lot of time. I wrote this in the 
evening hours at home while trying to learn X-toolkit programming.
But I will release another version which will be much better not only in terms
of the interface but also I will add in functions like "dialer", 
"undelete", etc. (suggestions are welcome). Please feel free to send me your
feedback and distribute to anyone who wants it. I will try to fix any bugs/
design defects but there is no warranty for this software. And please feel free
to distribute it to anyone who wants it.

Sample File
-----------
I have enclosed a sample file called "sample.card" with the distribution. You
can open it to understand how it works or you may copy it as .xab in your 
home directory.

Amit Chatterjee
(asav@ix.netcom.com)
xab/xab_file.c100644    764    764       56334  6471570704  11751 0ustar  amitamit#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <ctype.h>

#include "xab_filedefs.h"

/*------------------------------------------------
Global Variables
-------------------------------------------------*/
static FILE *fp;
static int pwd;

/*------------------------------------------------
Functions
--------------------------------------------------*/

/*-------------------------------------------------
Function : To Read a Card or a Folder from the Card 
File. 'index' specifies by the entry number for the 
card/folder and 'buffer' is where the read data is 
stored in.

Returns : F_SUCCESS, F_FSEEK_ERROR, F_FREAD_ERROR.

The function has a local scope. 
--------------------------------------------------*/
static int ReadCard (fptr, index, buffer)
FILE *fptr;
int index;
IndexStruct *buffer;
{
  int returnv;

  if (!fseek (fptr, (long)(index * sizeof(IndexStruct)),
              SEEK_SET))
    {
      if (fread((void *)buffer, sizeof(IndexStruct), 1, fptr))
	{
	  returnv = F_SUCCESS;
        }
      else
	{
	  returnv = F_FREAD_ERROR;
	  perror("Buffer could not be read :");
	}       
    }
  else
    {
      returnv = F_FSEEK_ERROR; 
      perror("Seek Failed :");
    }

  return returnv;   
}

/*-------------------------------------------------------
Function : to Create a card file specified by the argument -
'FileName'

Returns : F_SUCCESS, F_FOPEN_ERROR, F_FWRITE_ERROR 
---------------------------------------------------------*/
int CreateCardFile (FileName)
char *FileName;
{
  int returnv = F_SUCCESS;

  fp = fopen(FileName, "w+");
  if (fp == NULL)  /*file could not be opened again*/
    {
      perror("File could not be opened in w+ mode:"); 
      returnv = F_FOPEN_ERROR;
    }
  else
    {
      IndexStruct RootIndex;

      /*write the root record*/
      memset((void *)&RootIndex, 0, sizeof(IndexStruct));
      RootIndex.NameType = NAME_DIR;
      strcpy(&RootIndex.Content.Directory.DirectoryName[0], "/");

      if (!fwrite((void *)&RootIndex, sizeof(IndexStruct),
		  1, fp))
	{
	  perror("Root record could not be created:");
	  fclose(fp);
	  returnv = F_FWRITE_ERROR;
        }
    }
  return returnv;
}
/*---------------------------------------------------------
Function : to Open a card file specified by the argument -
'FileName'.

Returns : F_SUCCESS, F_FOPEN_ERROR
----------------------------------------------------------*/
int OpenCardFile(FileName)
char *FileName;
{  
  int returnv = F_SUCCESS;

  /*Open the Card FIle*/
  fp = fopen(FileName, "r+");
  if (fp == NULL)/*The file could not be opened*/
    {
      if (errno == ENOENT)
	{
	  returnv = F_NO_SUCH_FILE;
	}
      else
	{
	  returnv = F_FOPEN_ERROR;
	}
    }
  else
    {
      /*Initialize other global variables*/
      pwd = 0;  /*we are in the root directory*/
    }
  return returnv;
}

/*----------------------------------------------------------
Function : to Create a Folder specified by the argument 
'FolderName'.

Returns : F_SUCCESS, F_SANCHK_FAIL, etc.
-----------------------------------------------------------*/
int MakeFolder (FolderName, iptr)
char *FolderName;
int *iptr;
{
  int returnv = F_SUCCESS;
  IndexStruct buffer;
  int i;
 
  /*Read the contents of the present directory*/
  if (ReadCard(fp, pwd, &buffer) == F_SUCCESS)
    {
      /*do some sanity check*/
      if (buffer.NameType == NAME_DIR)
	{
	  /*get the first unused slot*/
	  for (i = 0; i < MAX_NAMES; i++)
	    {
	      if (buffer.Content.Directory.List[i] == 0) /*empty slot*/
		{
		  /*go to the end of the file and create the folder*/
		  if (!fseek(fp, 0L, SEEK_END))
		    {
		      long foffset;
		      IndexStruct entry;
		      
		      foffset = ftell(fp); /*calcuate the file offset*/
		      memset((void *)&entry, 0, 
			     sizeof(IndexStruct));
		      entry.NameType = NAME_DIR;
		      strcpy(&entry.Content.Directory.DirectoryName[0],
			     FolderName);
		      entry.Content.Directory.ParentIndex = pwd;
		      if (!fwrite((void *)&entry, 
			          sizeof(IndexStruct), 1, fp))
			{
			  perror("File Write Error:");
			  returnv = F_FWRITE_ERROR;
			}
		      else
			{
			  buffer.Content.Directory.List[i] = foffset / 
			    sizeof(IndexStruct);

			  if (iptr != NULL)
			    {
			      *iptr = foffset / sizeof(IndexStruct);
			    }

			  if (!fseek(fp, 
				    (long)(pwd * sizeof(IndexStruct)),
				SEEK_SET))
			    {
			      if (!fwrite((void *)&buffer,
			             sizeof(IndexStruct), 
                                     1, fp))
				{
				  perror("File Write Error:");
				  returnv = F_FWRITE_ERROR;
				}
			    }
			  else
			    {
			      perror("FSeek Error:");
			      returnv = F_FSEEK_ERROR;
			    }
			}
		    }
		  else
		    {
		      perror("FSeek Failed:");
		      returnv = F_FSEEK_ERROR;
		    }
		  break;
		}
	    }
	  if (i == MAX_NAMES) /*the folder is full*/
	    {
	      fprintf(stderr, "The folder is full\n");
	      returnv = F_FOLDER_FULL;
	    }
	}
      else
	{
	  fprintf(stderr, "Sanity Check Failed, Oops!\n");
	  returnv = F_SANCHK_FAIL;
	}
    }

  return returnv;
}

/*----------------------------------------------------------
Function : to List the contents of the current folder (file 
and sub-folders). Argument 'Number' is a pointer to location 
where the number of items in the folder are stored, 'DirName',
on successful execution, stores the current folder name and
'buffer' is location where the list of cards and sub-folders
are returned.

Returns : F_SUCCESS, etc.
------------------------------------------------------------*/ 
int ListFoldersandCards(Number, buffer, DirName)
int *Number;
CardList *buffer;
char *DirName;
{
  int returnv, i;
  IndexStruct buf1;

  *Number = 0;

  returnv = ReadCard(fp, pwd, &buf1);
  if (returnv == F_SUCCESS)
    {
      /*do some sanity checking to start with*/
      if (buf1.NameType == NAME_DIR)
        {
	  strcpy(DirName, &buf1.Content.Directory.DirectoryName[0]);
	  for (i = 0; (i < MAX_NAMES) && (returnv == F_SUCCESS); i++)
	    {
	      if (buf1.Content.Directory.List[i])/*there is an entry*/
		{
		  IndexStruct buf2;

		  buffer[*Number].index = buf1.Content.Directory.List[i]; 
		      
		  returnv = ReadCard(fp, buf1.Content.Directory.
				     List[i], &buf2);
		  if (returnv == F_SUCCESS)
		    {
		      buffer[*Number].NameType = buf2.NameType;
		      if (buf2.NameType == NAME_CARD)
			{
			  strcpy(&buffer[*Number].CardorFolderName[0],
				 &buf2.Content.Card.NameOnCard[0]);
			}
		      else
			{
			  strcpy(&buffer[*Number].CardorFolderName[0],
				 &buf2.Content.Directory.DirectoryName[0]);
			}

		      (*Number)++;
		    }
		}
	    }
	}
      else
	{
	  fprintf(stderr, "Sanity Check Failed, Oops!\n");
	  returnv = F_SANCHK_FAIL;
	}
    }

  return returnv;
}

/*-----------------------------------------------------------
Function : to move to a sub-folder or move up. 'index' tells
us to which subfolder to move to, index = 0 tells us to move
up.

Returns : F_SUCCESS, etc.
------------------------------------------------------------*/
int ChangeFolder(index)
int index;
{
  int returnv;

  if (index)
    {
      int Number;
      CardList buf[MAX_NAMES];
      char DirName[NAME_LENGTH];
      int i;

      returnv = ListFoldersandCards(&Number, buf, DirName);
      if (returnv == F_SUCCESS)
	{
	  for (i = 0; i < Number; i++)
	    {
	      if (buf[i].index == index) /*found*/
		{
		  if (buf[i].NameType == NAME_DIR)
		    {
		      pwd = buf[i].index;
		      break;
		    }
		  else
		    {
		      fprintf(stderr, "Not a Directory\n");
		      returnv = F_NOT_DIR;
		      break;
		    }
		}
	    }

	  if (i == Number)
	    {
	      returnv = F_DIR_NOT_FOUND;
	      fprintf(stderr, "Directory Could Not be Found\n");
	    }
	}
    }
  else  /*go one level up*/
    {
      IndexStruct buffer;

      returnv = ReadCard(fp, pwd, &buffer);
      if (returnv == F_SUCCESS)
	{
	  /*do some Sanity Check here*/
	  if (buffer.NameType == NAME_DIR)
	    {
	      pwd = buffer.Content.Directory.ParentIndex;
	    }
	  else
	    {
	      returnv = F_SANCHK_FAIL;
	      fprintf(stderr, "Sanity Check Failed, Oops!\n");
	    }
	}
    }
  return returnv;
}

/*----------------------------------------------------------
Function : Creates a card, the contents are specified by
the argument 'Card'.

Returns : F_SUCCESS, etc.
-----------------------------------------------------------*/
int MakeCard (Card)
CardStruct *Card;
{
  int returnv;
  IndexStruct buffer;
  int i;
 
  /*Read the contents of the present directory*/
  returnv = ReadCard(fp, pwd, &buffer);
  if (returnv == F_SUCCESS)
    {
      /*do some sanity check*/
      if (buffer.NameType == NAME_DIR)
	{
	  /*Insert check for duplicate file name here*/

	  /*get the first unused slot*/
	  for (i = 0; i < MAX_NAMES; i++)
	    {
	      if (buffer.Content.Directory.List[i] == 0) /*empty slot*/
		{
		  /*go to the end of the file and create the folder*/
		  if (!fseek(fp, 0L, SEEK_END))
		    {
		      long foffset;
		      IndexStruct entry;
		      
		      foffset = ftell(fp); /*calcuate the file offset*/
		      entry.NameType = NAME_CARD;
		      memcpy((void *)&entry.Content.Card, 
			     (void *)Card,
			     sizeof(CardStruct));

		      if (!fwrite((void *)&entry, 
			          sizeof(IndexStruct), 1, fp))
			{
			  perror("File Write Error:");
			  returnv = F_FWRITE_ERROR;
			}
		      else
			{
			  buffer.Content.Directory.List[i] = 
			    foffset / sizeof(IndexStruct);

			  if (!fseek(fp, 
				    (long)(pwd * sizeof(IndexStruct)),
				SEEK_SET))
			    {
			      if (!fwrite((void *)&buffer,
			             sizeof(IndexStruct), 
                                     1, fp))
				{
				  perror("File Write Error:");
				  returnv = F_FWRITE_ERROR;
				}
			    }
			  else
			    {
			      perror("FSeek Error:");
			      returnv = F_FSEEK_ERROR;
			    }
			}
		    }
		  else
		    {
		      perror("FSeek Failed:");
		      returnv = F_FSEEK_ERROR;
		    }
		  break;
		}
	    }
	  if (i == MAX_NAMES) /*the folder is full*/
	    {
	      fprintf(stderr, "The folder is full\n");
	      returnv = F_FOLDER_FULL;
	    }
	}
      else
	{
	  fprintf(stderr, "Sanity Check Failed, Oops!\n");
	  returnv = F_SANCHK_FAIL;
	}
    }

  return returnv;
}

/*------------------------------------------------------------
Function : to edit and exisiting card specified by the 'index'.
The 'buffer' tells what the new card contents are.

Returns : F_SUCCESS, etc.
------------------------------------------------------------*/
int EditCard (index, buffer)
     int index;
     CardStruct *buffer;
{
  int returnv;
  IndexStruct card;

  returnv = ReadCard(fp, index, &card);
  if (returnv == F_SUCCESS)
    {
      if (card.NameType == NAME_CARD)
	{
	  memcpy((void *)&card.Content.Card,
		 (void *)buffer,
		 sizeof(CardStruct));
	  if (!fseek(fp, 
		     (long)(index * sizeof(IndexStruct)), 
		     SEEK_SET))
	    {
	      if (!fwrite((void *)&card, 
			  sizeof(IndexStruct), 1, fp))
		{
		  returnv = F_FWRITE_ERROR;
		  perror("File Write Error : ");
		}
	    }
	  else
	    {
	      returnv = F_FSEEK_ERROR;
	      perror("Fseek Failed : ");
	    }
	}
      else
	{
	  returnv = F_SANCHK_FAIL;
	  fprintf(stderr, "Sanity Check Failed, Oops!\n");
	}
    }

  return returnv;
}

/*----------------------------------------------------------
Function : to view the content of a card specified by 'index'.
The 'buffer' is where the content of the card is returned.

Return : F_SUCCESS, etc.
------------------------------------------------------------*/
int TypeCard (index, buffer)
int index;
CardStruct *buffer;
{
  int returnv;
  IndexStruct buf;

  returnv = ReadCard (fp, index, &buf);
  if (returnv == F_SUCCESS)
    {
      if (buf.NameType == NAME_CARD)
	{
	  memcpy((void *)buffer,
	     &buf.Content.Card, sizeof(CardStruct));
	}
      else
	{
	  fprintf(stderr, "Not a Card\n");
	  returnv = F_SANCHK_FAIL;
	}
    }

  return returnv;
}
/*-----------------------------------------------------------
Function : to remove a card or a folder specified by 'index'.

Returns : F_SUCCESS, etc.
-------------------------------------------------------------*/
int RemoveCardOrFolder (index)
int index;
{
  int returnv, i;
  IndexStruct buffer;

  returnv = ReadCard(fp, pwd, &buffer);
  if (returnv == F_SUCCESS)
    {
      if (buffer.NameType == NAME_DIR)
	{
	  for (i = 0; i < MAX_NAMES; i++)
	    {
	      if (buffer.Content.Directory.List[i] ==
		  index)
		{
		  buffer.Content.Directory.List[i] = 0;

		  if (!fseek (fp, 
			 (long)(pwd * sizeof(IndexStruct)),
			 SEEK_SET))
		    {
		      if (!fwrite((void *)&buffer, 
			     sizeof(IndexStruct), 1, fp))
			{
			  returnv = F_FWRITE_ERROR;
			  perror("File Write Error : ");
			}
		    }
		  else
		    {
		      perror("Fseek Failed : ");
		      returnv = F_FSEEK_ERROR;
		    }
		  break;
		}
	    }
	  if (i == MAX_NAMES) /*Card or Folder not found*/
	    {
	      returnv = F_DIR_NOT_FOUND;
	      fprintf(stderr, "Card or Folder Not Found\n");
	    }
	}
      else
	{
	  returnv = F_SANCHK_FAIL;
	  fprintf(stderr, "Sanity Check Failed, Oops!\n");
	}
    }

  return returnv;
}

/*-----------------------------------------------------------
Function : to close an opened card file.

Return Value : F_SUCCESS (always).
------------------------------------------------------------*/
int CloseCardFile (void)
{
  fclose(fp);
  return (F_SUCCESS);
}

/*---------------------------------------------------------
Function : qsort() comparison routine.

Returns : 0 = if equal, 1 if greate, -1 if less.

The function has a local scope.
----------------------------------------------------------*/
static int CardCmp (buf1, buf2)
     const void *buf1, *buf2;
{

  if ((((CardList *)buf1)->NameType == NAME_DIR) && 
  (((CardList *)buf2)->NameType == NAME_CARD))
    return -1;

  if ((((CardList *)buf1)->NameType == NAME_CARD) && 
  (((CardList *)buf2)->NameType == NAME_DIR))
    return 1;

  if ((((CardList *)buf1)->NameType == NAME_DIR) && 
  (((CardList *)buf2)->NameType == NAME_DIR))
    return strcmp(&(((CardList *)buf1)->CardorFolderName[0]),
		  &(((CardList *)buf2)->CardorFolderName[0]));

  if ((((CardList *)buf1)->NameType == NAME_CARD) && 
  (((CardList *)buf2)->NameType == NAME_CARD))
    return strcmp(&(((CardList *)buf1)->CardorFolderName[0]),
		  &(((CardList *)buf2)->CardorFolderName[0]));

  /* Should never happen*/
  return -1;
}

/*-----------------------------------------------------------
Function : to sort the list of carfd and folder. 'buffer'
specifies the list and card and folder that is to be sorted
and 'number' specifies the number of cards/folders under the
current folder.

Returns : void.
------------------------------------------------------------*/
void SortCardAndFolderList(buffer, number)
CardList *buffer;
int number;
{
  qsort ((void *)buffer, 
	 (size_t)number, sizeof(CardList), CardCmp);
}

/*----------------------------------------------------------
Function : 
-----------------------------------------------------------*/
static int CleanFolder (ofp, pres, index, pindex)
FILE *ofp;
int pres;
int *index;
int pindex;
{
  int returnv, i;
  IndexStruct buffer;
  int CurIndex;

  /*read the contents of the current directory*/
  returnv = ReadCard (fp, pres, &buffer);
  if (returnv == F_SUCCESS)
    {
      /*some sanity check*/
      if (buffer.NameType == NAME_DIR)
	{
	  CurIndex = *index; /*save the current context*/
	  buffer.Content.Directory.ParentIndex = pindex;
          (*index)++;

	  /*write the parent record*/
	  if (fwrite((void *)&buffer, sizeof(IndexStruct), 1, ofp))
	    {
	      fflush(ofp);

	      for (i = 0; (returnv == F_SUCCESS) && (i < MAX_NAMES);
		   i++)
		{
		  if (buffer.Content.Directory.List[i]) /*used entry*/
		    {
		      IndexStruct buf2;

		      returnv = ReadCard(fp, buffer.Content.Directory.List[i], 
					 &buf2);
		      if (returnv == F_SUCCESS)
			{
			  if (buf2.NameType == NAME_DIR)
			    {
			      int list;

			      list = buffer.Content.Directory.List[i];
			      buffer.Content.Directory.List[i] = *index;
			      returnv = CleanFolder (ofp, 
						     list, 
						     index,
						     CurIndex);
			    }
			  else /*ordinary file*/
			    {
			      /*copy the record to the output file*/
			      if (fwrite((void *)&buf2,
				  sizeof(IndexStruct), 1, ofp))
			        {
				  buffer.Content.Directory.List[i] = *index;
				  (*index)++;
				}
			      else
				{
				  returnv = F_FWRITE_ERROR;
				  perror("Write to Output File Failed : ");
				}
			    } /*if ordinary file*/
			} /*if read child card succeeded*/
		    } /*if entry used*/
		} /*end for*/

	      /*now let's write the parent record with the updated list*/
	      if (!fseek(ofp, 
                    (long)(CurIndex * sizeof(IndexStruct)),
		    SEEK_SET))
		{
		  if(fwrite((void *)&buffer, sizeof(IndexStruct),
			 1, ofp))
		    {
		      if(fseek(ofp, 0L, SEEK_END))
			{
			  returnv = F_FSEEK_ERROR;
			  perror("Fseek Failed : ");
			}
		    }
		  else
		    {
		      returnv = F_FWRITE_ERROR;
		      perror("File write error : ");
		    }
		}
	      else
		{
		  returnv = F_FSEEK_ERROR;
		  perror("Fseek Failed : ");
		}
	    } /*if fwriting the parent record succeeded*/
	  else
	    {
	      returnv = F_FWRITE_ERROR;
	      perror("Write to Output FIle Failed : ");
	    }
        } /*if sanity check succeeded*/ 
      else
        {
	  returnv = F_SANCHK_FAIL;
	  fprintf(stderr, "Sanity Check Failed, Oops!\n");
	}

    } /*if ReadCard was successful*/

  return returnv;
} 

/*----------------------------------------------------------
Function : to remove file space occupied by already deleted 
entries. 'NewFileName' specifies the file where the cleaned 
card file is to be stored.

Returns : F_SUCCESS, etc.
-----------------------------------------------------------*/
int CleanCardFile (NewFileName)
char *NewFileName;
{
  FILE *ofp;
  int returnv;
  int index = 0;

  ofp = fopen(NewFileName, "w");
  if (ofp == NULL)
    {
      perror("The Output File could not be opened : ");
      returnv = F_FOPEN_ERROR;
    }
  else
    {
      /*Start Cleaning from the top*/
      returnv = CleanFolder(ofp, 0, &index, 0);
      fclose(ofp);
    }

  return returnv;
}

/*--------------------------------------------------------------------
Function: Computes the number of records contained in the card file.
On successfule completion, the area pointed by the input argument NumPtr
conatins the number of records found in the cardfile.

Returns : F_SUCCESS, etc.
---------------------------------------------------------------------*/
int NumRecords(NumPtr)
     int *NumPtr;
{
  int returnv = F_SUCCESS;
  long foffset;

  *NumPtr = 0;

  if (!fseek(fp, 0L, SEEK_END))
    {
      foffset = ftell(fp); /*calcuate the file offset*/
      *NumPtr = foffset / sizeof(IndexStruct);
      returnv = F_SUCCESS;
    }
  else
    {
      returnv = F_FSEEK_ERROR;
    }

  return returnv;
}
/*--------------------------------------------------------------------
--------------------------------------------------------------------*/
static int CopyFolder(FolderIndex, buffer, fptr)
int FolderIndex;
IndexStruct *buffer;
FILE *fptr;
{
  int i, returnv = F_SUCCESS;

  for (i = 0; (returnv == F_SUCCESS) && (i < MAX_NAMES); i++)
    {
      if (buffer->Content.Directory.List[i]) /*it is an used entry*/
	{
	  IndexStruct buf2;

	  returnv = ReadCard(fptr, buffer->Content.Directory.List[i], &buf2);
	  if (returnv == F_SUCCESS)
	    {
	      if (buf2.NameType == NAME_CARD)
		{
		  /*create the card*/
		  returnv = MakeCard (&buf2.Content.Card);
		}
	      else /*NAME_DIR*/
		{
		  int tempwd = pwd;/*save the current working directory*/
		  int Findex;
		  
		  /*create the folder....*/
		  returnv = MakeFolder(
				       &buf2.Content.Directory.DirectoryName[0],
		                       &Findex);
		  if (returnv == F_SUCCESS)
		    {
		      /*move to that folder...*/
		      pwd = Findex;

		      /*and copy everything below that*/
		      returnv = CopyFolder(pwd, &buf2, fptr);
		    }
		  pwd = tempwd; /*restore the original directory*/
		}
	    }
	}
    }

  return returnv;
}
/*---------------------------------------------------------------------
---------------------------------------------------------------------*/
int MergeFile (FileName)
char *FileName;
{
  int returnv = F_SUCCESS;
  FILE *mfp;

  mfp = fopen(FileName, "r"); /*open the file in read-only mode*/
  if (mfp != NULL)
    {
      IndexStruct buffer;

      returnv = ReadCard(mfp, 0, &buffer);
      if (returnv == F_SUCCESS)
	{
	  /*do some sanity testing*/
	  if (buffer.NameType == NAME_DIR)
	    {
	      returnv = CopyFolder(pwd, &buffer, mfp);
	    }
	  else
	    {
	      returnv = F_SANCHK_FAIL;
	    }
	}
      fclose(mfp);
    }
  else
    {
      returnv = F_FOPEN_ERROR;
    }
  return returnv;
}

/*-------------------------------------------------------------

---------------------------------------------------------------*/
static void StrToUpper(str)
char *str;
{
  int i;

  for (i = 0; str[i] != '\0'; i++)
    {
      if (islower(str[i])) str[i] = toupper(str[i]);
    }
}

/*-------------------------------------------------------------

---------------------------------------------------------------*/
static char *SearchStrPattern(bigs, smalls)
char *bigs, *smalls;
{
  char *returnv = NULL;
  char *tbigs, *tsmalls;

  /*allocate memory for the string*/
  tbigs = (char *)malloc(strlen(bigs)+1);
  if (tbigs != NULL)
    {
      strcpy(tbigs, bigs);
      StrToUpper(tbigs);

      tsmalls = (char *)malloc(strlen(smalls)+1);
      if (tsmalls != NULL)
	{
	  strcpy(tsmalls, smalls);
	  StrToUpper(tsmalls);
	  returnv = strstr(tbigs, tsmalls);
	  free(tsmalls);
	}
      free(tbigs);
    }

  return returnv;
}
/*------------------------------------------------------------

-------------------------------------------------------------*/
static int SrchPatternFolder (pattern, index, lptr, numptr)
char *pattern;
int index;
CardList *lptr;
int *numptr;
{
  int returnv;
  int i;
  IndexStruct buf, buf2;

  returnv = ReadCard(fp, index, &buf);
  if (returnv == F_SUCCESS)
    {
      if (buf.NameType == NAME_DIR)
	{
	  for (i = 0; i < MAX_NAMES; i++)
	    {
	      if (buf.Content.Directory.List[i]) /*if it is an used entry*/
		{
		  returnv = ReadCard (fp, 
				      buf.Content.Directory.List[i], 
				      &buf2);
		  if (returnv == F_SUCCESS)
		    {
		      if (buf2.NameType == NAME_DIR)
			{
			  returnv = SrchPatternFolder(pattern,
						      buf.Content.Directory.List[i],
						      lptr, numptr);
			  if (returnv != F_SUCCESS)
			    {
			      break;
			    }
			}
		      else /*card*/
			{
			  int found = TRUE;

			  /*search for the pattern*/
			 if (SearchStrPattern(&buf2.Content.Card.NameOnCard[0],
					  pattern) == NULL) /*not found*/
			   {
			     if (SearchStrPattern(&buf2.Content.Card.Information[0],
					  pattern) == NULL) /*not found*/
			       {
				 found = FALSE;
			       }
			   }

			 if (found)
			   {
			     if (*numptr <= MAX_SRCH)
			       {
				 strcpy(&lptr[*numptr].CardorFolderName[0],
					&buf2.Content.Card.NameOnCard[0]);
				 lptr[*numptr].index = buf.Content.Directory.List[i];
				 (*numptr)++;
			       }
			   }
			}
		    }
		  else
		    {
		      break;
		    }
		}
	    }
	}
      else
	{
	  returnv = F_SANCHK_FAIL;
	}
    }
  return returnv;
}
/*------------------------------------------------------------

-------------------------------------------------------------*/
int SrchPattern (pattern, lptr, numptr)
char *pattern;
CardList *lptr;
int *numptr;
{
  int returnv;

  *numptr = 0;

  returnv = SrchPatternFolder (pattern, pwd, lptr, numptr);

  return returnv;
}









xab/xab_gui_init.c100644    764    764       46267  6471567322  12647 0ustar  amitamit#include <varargs.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>

#include <X11/Intrinsic.h>
#include <X11/StringDefs.h>
#include <X11/Xatom.h>
#include <X11/Shell.h>
#include <X11/Xaw/Dialog.h>
#include <X11/Xaw/Form.h>
#include <X11/Xaw/Label.h>
#include <X11/Xaw/Paned.h>
#include <X11/Xaw/Command.h>
#include <X11/Xaw/AsciiText.h>
#include <X11/Xaw/MenuButton.h>
#include <X11/Xaw/SimpleMenu.h>
#include <X11/Xaw/SmeBSB.h>
#include <X11/Xaw/Viewport.h>
#include <X11/Xaw/AsciiText.h>
#include <X11/Xaw/List.h>
#include <X11/Xaw/SmeLine.h>

#include "bitmaps.xbm"

#include "xab_filedefs.h"
#include "xab_sysdefs.h"
#include "xab_guidefs.h"

/************************Functions***************************************/

static void CreateXabFileDialog (void)
{
  CreatFileShell = XtVaCreatePopupShell ("CreateCardFile",
					 transientShellWidgetClass,
					 toplevel, 
					 NULL);

  CreateFileDialog = XtVaCreateManagedWidget ("OpenCardfileDialog",
					      dialogWidgetClass,
					      CreatFileShell,
					      XtNlabel, 
					      "Card file does not exist, create ?",
					      XtNicon,CardPixmap,
					      NULL);

     
  XawDialogAddButton(CreateFileDialog, "Yes", 
		     YesCreateFile, (XtPointer)CreateFileDialog);
  XawDialogAddButton(CreateFileDialog, "No", 
		     HandleCancel, CreatFileShell);
}

static void CreateMessageBox(void)
{
  MessageShell = XtVaCreatePopupShell ("MessageShell",
				       transientShellWidgetClass,
				       toplevel, NULL);

  MessageDialog = XtVaCreateManagedWidget ("MessageDialog",
					   dialogWidgetClass,
					   MessageShell,
					   XtNlabel,"                    ",
					   NULL);

  MessageLabel = XtNameToWidget (MessageDialog, "label");

  XtVaSetValues(MessageLabel,
		XtNheight, MSG_ROWS * vunit,
		XtNwidth, MSG_COLS * hunit,
		NULL);

  XawDialogAddButton(MessageDialog, "Dismiss", 
		     HandleCancel, (XtPointer)MessageShell);
}

static void CreateFileMenu(void)
{
  /*File Menu Widgets*/
  FopenLShell = XtVaCreatePopupShell ("FopenShell",
				      transientShellWidgetClass,
				      toplevel, NULL);

  FopenForm = XtVaCreateManagedWidget ("FopenForm",
				       formWidgetClass,
				       FopenLShell,
				       NULL);

  FdirForm = XtVaCreateManagedWidget ("FdirForm",
				      formWidgetClass,
				      FopenForm,
				      XtNborderWidth, 0,
				      NULL);

  FfileForm = XtVaCreateManagedWidget ("FfileForm",
				       formWidgetClass,
				       FopenForm,
				       XtNborderWidth, 0,
				       XtNfromHoriz, FdirForm,
				       NULL);

  DirlistLabel = XtVaCreateManagedWidget("DirlistLabel",
					 labelWidgetClass,
					 FdirForm,
					 XtNleftBitmap, FolderPixmap,
					 XtNlabel, "Sub-Directories",
					 XtNborderWidth, 0,
					 XtNinternalHeight, DEFAULT_INTERNAL_HEIGHT,
					 NULL);

  DirListVPort = XtVaCreateManagedWidget ("DirListViewPort",
					  viewportWidgetClass,
					  FdirForm,
					  XtNallowVert, True,
					  XtNallowHoriz, True,
					  XtNuseRight, True,
					  XtNuseBottom, True,
					  XtNwidth, 200,
					  XtNheight, 200,
					  XtNfromVert, DirlistLabel,
					  NULL);

  DirList = XtVaCreateManagedWidget ("DirList",
				     listWidgetClass,
				     DirListVPort,
				     XtNforceColumns, True,
				     XtNdefaultColumns, 1,
				     NULL);

  FilelistLabel = XtVaCreateManagedWidget("FilelistLabel",
					  labelWidgetClass,
					  FfileForm,
					  XtNlabel, "Files",
					  XtNleftBitmap, FilePixmap,
					  XtNinternalHeight, DEFAULT_INTERNAL_HEIGHT, 
					  XtNborderWidth, 0,
					  NULL);

  FileListVPort = XtVaCreateManagedWidget ("FileListViewPort",
					   viewportWidgetClass,
					   FfileForm,
					   XtNallowVert, True,
					   XtNallowHoriz, True,
					   XtNwidth, 300,
					   XtNheight, 200,
					   XtNuseRight, True,
					   XtNuseBottom, True,
					   XtNfromVert, FilelistLabel,
					   NULL);

  FileList = XtVaCreateManagedWidget ("FileList",
				      listWidgetClass,
				      FileListVPort,
				      XtNforceColumns, True,
				      XtNdefaultColumns, 1,
				      NULL);

  SelectionLabel = XtVaCreateManagedWidget("SelectionLabel",
					   labelWidgetClass,
					   FopenForm,
					   XtNlabel, "Path",
					   XtNborderWidth, 0,
					   XtNfromVert, FdirForm,
					   NULL);

  SelectionValue = XtVaCreateManagedWidget ("SelectionValue",
					    asciiTextWidgetClass,
					    FopenForm,
					    XtNwidth, 60 * hunit,
					    XtNfromVert, FdirForm,
					    XtNfromHoriz, SelectionLabel,
					    XtNeditType, XawtextEdit,
					    NULL);

  SelectionOK = XtVaCreateManagedWidget ("SelectionOK",
					 commandWidgetClass,
					 FopenForm,
					 XtNlabel, "OK",
					 XtNfromVert, SelectionLabel,
					 NULL);

  SelectionCancel = XtVaCreateManagedWidget ("SelectionCancel",
					     commandWidgetClass,
					     FopenForm,
					     XtNlabel, "Cancel",
					     XtNfromVert, SelectionLabel,
					     XtNfromHoriz, SelectionOK,
					     NULL);

  XtAddCallback (SelectionCancel, XtNcallback, HandleCancel, FopenLShell);
  XtAddCallback (DirList, XtNcallback, DirSelect, NULL);
  XtAddCallback (FileList, XtNcallback, FileSelect, NULL);

  XtAddCallback (FopenLShell, 
		 XtNpopupCallback, UpdateFileSelectionList, NULL); 
}

static void CreateCardShell(void)
{
  CcreateShell = XtVaCreatePopupShell ("CreateCard",
				       transientShellWidgetClass,
				       toplevel, NULL);

  CcreatePane = XtVaCreateManagedWidget ("Paned",
					 panedWidgetClass,
					 CcreateShell,
					 NULL);

  CcreateButtons = XtVaCreateManagedWidget ("CreateCardButons",
					    formWidgetClass,
					    CcreatePane,
					    NULL);

  CcreateClear = XtVaCreateManagedWidget ("ClearCreateCard",
					  commandWidgetClass,
					  CcreateButtons,
					  XtNlabel, "Clear All",
					  XtNbottom, XawChainLeft,
					  XtNtop, XawChainLeft,
					  XtNleft, XawChainLeft,
					  XtNright, XawChainLeft,
					  NULL);

  XtAddCallback (CcreateClear, XtNcallback, HandleClear, NULL);

  CcreateCopy = XtVaCreateManagedWidget ("CreateCardCopy",
					 commandWidgetClass,
					 CcreateButtons,
					 XtNlabel, "Copy",
					 XtNbottom, XawChainLeft,
					 XtNtop, XawChainLeft,
					 XtNleft, XawChainLeft,
					 XtNright, XawChainLeft,
					 XtNfromHoriz, CcreateClear,
					 NULL);

  XtAddCallback (CcreateCopy, XtNcallback, OKCopySelection, NULL);
  
  CcreatePaste = XtVaCreateManagedWidget ("CreateCardPaste",
					  commandWidgetClass,
					  CcreateButtons,
					  XtNlabel, "Paste",
					  XtNbottom, XawChainLeft,
					  XtNtop, XawChainLeft,
					  XtNleft, XawChainLeft,
					  XtNright, XawChainLeft,
					  XtNfromHoriz, CcreateCopy,
					  NULL);

  XtAddCallback (CcreatePaste, XtNcallback, OKPasteSelection, NULL);

  CcreatePrint = XtVaCreateManagedWidget ("CreateCardPrint",
					  commandWidgetClass,
					  CcreateButtons,
					  XtNlabel, "Print...",
					  XtNbottom, XawChainLeft,
					  XtNtop, XawChainLeft,
					  XtNleft, XawChainLeft,
					  XtNright, XawChainLeft,
					  XtNfromHoriz, CcreatePaste,
					  NULL);

  XtAddCallback (CcreatePrint, XtNcallback, PrintCard, NULL);

  
  CcreateDialog = XtVaCreateManagedWidget ("CreateCardDialog",
					   formWidgetClass,
					   CcreatePane,
					   NULL);

  CcreateNameLabel = XtVaCreateManagedWidget("CardNameLabel",
					     labelWidgetClass,
					     CcreateDialog,
					     XtNlabel, "Name",
					     XtNborderWidth, 0,
					     NULL);

  CcreateName = XtVaCreateManagedWidget ("CardName",
					 asciiTextWidgetClass,
					 CcreateDialog,
					 XtNwidth, (NAME_LENGTH - 1) * hunit,
					 XtNeditType, XawtextEdit,
					 XtNuseStringInPlace, True,
					 XtNlength, NAME_LENGTH - 1,
					 XtNstring, &Card.NameOnCard[0],
					 XtNfromHoriz, CcreateNameLabel,
					 NULL);

  CcreateInfoLabel = XtVaCreateManagedWidget("InfoLabel",
					     labelWidgetClass,
					     CcreateDialog,
					     XtNlabel, "Information",
					     XtNborderWidth, 0,
					     XtNfromVert, CcreateNameLabel,
					     NULL);

  CcreateInfo = XtVaCreateManagedWidget ("Information",
					 asciiTextWidgetClass,
					 CcreateDialog,
					 XtNwidth, (INFORMATION_LENGTH / 6) * hunit,
					 XtNheight, 6 * vunit,
					 XtNeditType, XawtextEdit,
					 XtNuseStringInPlace, True,
					 XtNlength, INFORMATION_LENGTH - 1,
					 XtNstring,  &Card.Information[0],
					 XtNwrap, XawtextWrapWord,
					 XtNscrollVertical, XawtextScrollWhenNeeded,
					 XtNfromVert,CcreateName,
					 XtNfromHoriz, CcreateInfoLabel,
					 NULL);

  CcreateOK = XtVaCreateManagedWidget ("OKCreateCard",
				       commandWidgetClass,
				       CcreateDialog,
				       XtNlabel, "Save",
				       XtNfromVert, CcreateInfo,
				       NULL);

  CcreateCancel = XtVaCreateManagedWidget ("CancelCreateCard",
					   commandWidgetClass,
					   CcreateDialog,
					   XtNlabel, "Cancel",
					   XtNfromVert, CcreateInfo,
					   XtNfromHoriz, CcreateOK,
					   NULL);


  XtAddCallback (CcreateOK, XtNcallback, OKCreateCard, NULL);
  XtAddCallback (CcreateCancel, XtNcallback, HandleCancel, CcreateShell);
}

static void CreateListShell(void)
{
  ListShell = XtVaCreatePopupShell ("ListShell",
				    transientShellWidgetClass,
				    toplevel, NULL);

  ListForm = XtVaCreateManagedWidget ("ListForm",
				      formWidgetClass,
				      ListShell,
				      NULL);

  ListLabel = XtVaCreateManagedWidget("ListLabel",
				      labelWidgetClass,
				      ListForm,
				      XtNlabel, "List",
				      XtNleftBitmap, FilePixmap,
				      XtNinternalHeight, DEFAULT_INTERNAL_HEIGHT,
				      XtNwidth, NAME_LENGTH * hunit,
				      XtNborderWidth, 0,
				      NULL);

  ListVPort = XtVaCreateManagedWidget ("ListViewPort",
				       viewportWidgetClass,
				       ListForm,
				       XtNallowVert, True,
				       XtNallowHoriz, True,
				       XtNwidth, 200,
				       XtNheight, 100,
				       XtNfromVert, ListLabel,
				       NULL);

  ListList = XtVaCreateManagedWidget ("ListList",
				      listWidgetClass,
				      ListVPort,
				      XtNforceColumns, True,
				      XtNdefaultColumns, 1,
				      NULL);
  
  ListOK = XtVaCreateManagedWidget ("OKList",
				    commandWidgetClass,
				    ListForm,
				    XtNlabel, "OK",
				    XtNfromVert, ListVPort,
				    NULL);

  ListCancel = XtVaCreateManagedWidget ("CancelList",
					commandWidgetClass,
					ListForm,
					XtNlabel, "Cancel",
					XtNfromVert, ListVPort,
					XtNfromHoriz, ListOK,
					NULL);

  XtAddCallback (ListOK, XtNcallback, DeleteCardOrFolder, ListShell);
  XawListChange (ListList, ListPtr, 1, 0, True); 
  XtAddCallback (ListCancel, XtNcallback, HandleCancel, ListShell);
}

static void CreateCreateFolderShell(void)
{
  FcreateShell = XtVaCreatePopupShell ("CreateFolder",
				       transientShellWidgetClass,
				       toplevel, NULL);

  FcreateDialog = XtVaCreateManagedWidget ("CreateFolderDialog",
					   dialogWidgetClass,
					   FcreateShell,
					   XtNlabel, "Folder Name",
					   XtNvalue, "",
					   XtNicon, FolderPixmap,
					   NULL);

  FcreateValue = XtNameToWidget(FcreateDialog, "value");
  XtVaSetValues(FcreateValue,
		XtNwidth, (NAME_LENGTH - 1) * hunit,
		NULL);
  XtVaSetValues (XtNameToWidget(FcreateDialog, "icon"),
		 XtNforeground, XBlackPixelOfScreen(XtScreen(toplevel)), 
		 XtNbackground, XWhitePixelOfScreen(XtScreen(toplevel)),
		 NULL);
  XawDialogAddButton(FcreateDialog, "OK", OKCreateFolder, 
		     (XtPointer)FcreateDialog);
  XawDialogAddButton(FcreateDialog, "Cancel", HandleCancel, FcreateShell);
}

static void CreatePrintCardShell(void)
{
  PcardShell = XtVaCreatePopupShell ("PrintCardShell",
				     transientShellWidgetClass,
				     toplevel, NULL);

  PcardDialog = XtVaCreateManagedWidget ("PrintCardDialog",
					 dialogWidgetClass,
					 PcardShell,
					 XtNlabel, "Printer Command",
					 XtNvalue, DEFAULT_PRINTER_COMMAND,
					 XtNicon, PrinterPixmap,
					 NULL);

  XtVaSetValues(XtNameToWidget(PcardDialog, "value"),
		XtNwidth, (PRINTER_COMMAND_SIZE/2 - 1) * hunit,
		XtNinsertPosition, strlen(DEFAULT_PRINTER_COMMAND),
		NULL); 

  XawDialogAddButton(PcardDialog, "OK", OKPrintCard, 
		     (XtPointer)PcardDialog);
  XawDialogAddButton(PcardDialog, "Cancel", HandleCancel, PcardShell);
}

static void CreateSearchDialog (void)
{
  FsearchShell = XtVaCreatePopupShell ("SearchShell",
				     transientShellWidgetClass,
				     toplevel, NULL);

  FsearchDialog = XtVaCreateManagedWidget ("SearchDialog",
					   dialogWidgetClass,
					   FsearchShell,
					   XtNlabel, "Search pattern",
					   XtNvalue, "",
					   NULL);

 FsearchValue = XtNameToWidget(FsearchDialog, "value");

  XawDialogAddButton(FsearchDialog, "OK", OKSearch, 
		     (XtPointer)FsearchDialog);
  XawDialogAddButton(FsearchDialog, "Cancel", HandleCancel, FsearchShell);
}

static void CreateSearchListShell(void)
{
  SrchListShell = XtVaCreatePopupShell ("SrchListShell",
					transientShellWidgetClass,
					toplevel, NULL);

  SrchListForm = XtVaCreateManagedWidget ("SrchListForm",
					  formWidgetClass,
					  SrchListShell,
					  NULL);

  SrchListLabel = XtVaCreateManagedWidget("SrchListLabel",
					  labelWidgetClass,
					  SrchListForm,
					  XtNlabel, "Matched list",
					  XtNborderWidth, 0,
					  NULL);

  SrchListVPort = XtVaCreateManagedWidget ("SrchListViewPort",
					   viewportWidgetClass,
					   SrchListForm,
					   XtNallowVert, True,
					   XtNallowHoriz, True,
					   XtNwidth, 200,
					   XtNheight, 100,
					   XtNfromVert, SrchListLabel,
					   NULL);

  SrchListList = XtVaCreateManagedWidget ("SrchListList",
					  listWidgetClass,
					  SrchListVPort,
					  XtNforceColumns, True,
					  XtNdefaultColumns, 1,
					  NULL);
  
  SrchListView = XtVaCreateManagedWidget ("SrchListView",
					  commandWidgetClass,
					  SrchListForm,
					  XtNlabel, "View",
					  XtNfromVert, SrchListVPort,
					  NULL);

  SrchListClose = XtVaCreateManagedWidget ("SrchListClose",
					   commandWidgetClass,
					   SrchListForm,
					   XtNlabel, "Close",
					   XtNfromVert, SrchListVPort,
					   XtNfromHoriz, SrchListView,
					   NULL);

  XtAddCallback (SrchListView, XtNcallback, ViewEditCard, 
		 SrchListShell); 
  XawListChange (SrchListList, ListNames, 1, 0, True); 
  XtAddCallback (SrchListClose, XtNcallback, HandleCancel, SrchListShell);
}

void InitPopups (void)
{
  CreateXabFileDialog();

  CreateMessageBox();

  CreateFileMenu();

  CreateCardShell();

  CreatePrintCardShell();

  CreateListShell();

  CreateCreateFolderShell();

  CreateSearchDialog();

  CreateSearchListShell();

}

void InitPixmap (void)
{
  FolderPixmap = XCreateBitmapFromData(XtDisplay(toplevel),
				       XRootWindowOfScreen(XtScreen(toplevel)),
				       folder_bits,
				       folder_width,
				       folder_height);


  CardPixmap = XCreateBitmapFromData (XtDisplay(toplevel),
				      XRootWindowOfScreen(XtScreen(toplevel)),
				      card_bits,
				      card_width,
				      card_height);

  FilePixmap = XCreateBitmapFromData (XtDisplay(toplevel),
				      XRootWindowOfScreen(XtScreen(toplevel)),
				      file_bits,
				      file_width,
				      file_height);

  XabPixmap = XCreateBitmapFromData (XtDisplay(toplevel),
				     XRootWindowOfScreen(XtScreen(toplevel)),
				     xab_bits,
				     xab_width,
				     xab_height);

  PrinterPixmap = XCreateBitmapFromData (XtDisplay(toplevel),
					 XRootWindowOfScreen(XtScreen(toplevel)),
					 printer_bits,
					 printer_width,
					 printer_height);
}


void InitMenu(void)
{
 /*Top Level Menu Items*/
  MenuForm = XtVaCreateManagedWidget ("TopLevelMenu",
				      formWidgetClass,
				      pane,
				      NULL);

  /*Top-level menu "File"*/
  FileMenu = XtVaCreateManagedWidget  ("File",
				       menuButtonWidgetClass,
				       MenuForm,
				       XtNmenuName, "FileMenu",
				       XtNbottom, XawChainLeft,
				       XtNtop, XawChainLeft,
				       XtNleft, XawChainLeft,
				       XtNright, XawChainLeft,
				       NULL);

  FileOption = XtCreatePopupShell ("FileMenu",
				   simpleMenuWidgetClass,
				   toplevel,
				   NULL, 0);

  /*File menu item "Open File" */
  Fopen = XtVaCreateManagedWidget("Open File ...",
				  smeBSBObjectClass,
				  FileOption,
				  NULL);

  XtAddCallback (Fopen, XtNcallback, OpenFile, FopenLShell); 
		
  /*File menu item "Clean File"*/
  Fclean = XtVaCreateManagedWidget("Clean File",
				  smeBSBObjectClass,
				  FileOption,
				  NULL);
  XtAddCallback (Fclean, XtNcallback, HandleCleanXab, NULL);

  /*File menu item "Merge File"*/
  Fmerge = XtVaCreateManagedWidget ("Merge File ...",
				    smeBSBObjectClass,
				    FileOption,
				    NULL);
  XtAddCallback (Fmerge, XtNcallback, MergeFiles, NULL);

  /*File menu item "Search..." */
  Fsearch = XtVaCreateManagedWidget ("Search ...",
				     smeBSBObjectClass,
				     FileOption,
				     NULL);

  XtAddCallback(Fsearch, XtNcallback, SearchPattern, FsearchShell);

  /*File menu line*/
  FmenuLine1 = XtVaCreateManagedWidget ("Line 1",
					smeLineObjectClass,
					FileOption,
					NULL);
  /*File menu item "Exit"*/
  Fexit = XtVaCreateManagedWidget("Exit",
				  smeBSBObjectClass,
				  FileOption,
				  NULL);


  XtAddCallback (Fexit, XtNcallback, HandleExit, NULL);

  /*Toplevel menu item "Folder"*/
  FolderMenu = XtVaCreateManagedWidget ("Folder",
					menuButtonWidgetClass,
					MenuForm,
					XtNmenuName, "FolderMenu",
					XtNfromHoriz, FileMenu,
					XtNbottom, XawChainLeft,
					XtNtop, XawChainLeft,
					XtNleft, XawChainLeft,
					XtNright, XawChainLeft,
					NULL);

  FolderOption = XtCreatePopupShell ("FolderMenu",
				     simpleMenuWidgetClass, 
				     toplevel,
				     NULL, 0);

  /*Folder menu item "Create Folder*/
  Fcreate = XtVaCreateManagedWidget("Create Folder ...",
				    smeBSBObjectClass,
				    FolderOption,
				    NULL);

  XtAddCallback (Fcreate, XtNcallback, CreateFolder, FcreateShell);
 
  /*Folder menu item "Delete Folder"*/
  Fdelete = XtVaCreateManagedWidget("Delete Folder ...",
				    smeBSBObjectClass,
				    FolderOption,
				    NULL);

  XtAddCallback (Fdelete, XtNcallback, DeleteFolder, ListShell);

  /*Toplevel menu item "Card"*/
  CardMenu = XtVaCreateManagedWidget ("Card",
				       menuButtonWidgetClass,
				       MenuForm,
				       XtNmenuName, "CardMenu",
				       XtNfromHoriz, FolderMenu,
				       XtNbottom, XawChainLeft,
				       XtNtop, XawChainLeft,
				       XtNleft, XawChainLeft,
				       XtNright, XawChainLeft,
				       NULL);

  CardOption = XtCreatePopupShell ("CardMenu",
				   simpleMenuWidgetClass, 
				   toplevel,
				   NULL, 0);

  /*Card menu item "Create Card"*/
  Ccreate = XtVaCreateManagedWidget("Create Card ...",
				    smeBSBObjectClass,
				    CardOption,
				    NULL);

  XtAddCallback (Ccreate, XtNcallback, CreateCard, CcreateShell);

  /*Card menu item "Delete Card"*/
  Cdelete = XtVaCreateManagedWidget("Delete Card ...",
				    smeBSBObjectClass,
				    CardOption,
				    NULL);

  XtAddCallback (Cdelete, XtNcallback, DeleteCard, ListShell);

  /*Top-level menu "Help"*/
  HelpMenu = XtVaCreateManagedWidget  ("Help",
				       menuButtonWidgetClass,
				       MenuForm,
				       XtNmenuName, "HelpMenu",
				       XtNbottom, XawChainTop,
				       XtNtop, XawChainTop,
				       XtNleft, XawChainRight,
				       XtNright, XawChainRight,
				       NULL);

  HelpOption = XtCreatePopupShell ("HelpMenu",
				   simpleMenuWidgetClass, 
				   toplevel,
				   NULL, 0);

  /*Help menu item "Version Number"*/
  Hversion = XtVaCreateManagedWidget("Version Number",
				     smeBSBObjectClass,
				     HelpOption,
				     NULL);

  XtAddCallback (Hversion, XtNcallback, HelpVersion, NULL);

}








xab/bitmaps.xbm100644    764    764       13363  6270731370  12171 0ustar  amitamit#define card_width 32
#define card_height 32
static unsigned char card_bits[] = {
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0x7f, 0x02, 0x00, 0x00, 0x40,
   0x02, 0xfe, 0x7f, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40,
   0x3a, 0xdf, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x7a, 0xdf, 0x0f, 0x40,
   0x02, 0x00, 0x00, 0x40, 0xba, 0xf7, 0xdf, 0x41, 0x02, 0x00, 0x00, 0x40,
   0x7a, 0x0f, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40,
   0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0xfa, 0x1f, 0xe0, 0x41,
   0x02, 0x00, 0x00, 0x5e, 0xba, 0x03, 0x00, 0x40, 0x02, 0x1c, 0x00, 0x40,
   0x02, 0x00, 0xc0, 0x4f, 0xfa, 0x03, 0x00, 0x40, 0x0a, 0x00, 0x00, 0x40,
   0xfe, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};

#define folder_width 32
#define folder_height 32
static char folder_bits[] = {
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x01, 0x00, 0x00, 0x02, 0x02,
   0x00, 0x00, 0x01, 0x04, 0xfe, 0xff, 0xff, 0x1f, 0x01, 0x00, 0x00, 0x20,
   0x01, 0x00, 0x00, 0x60, 0x01, 0x00, 0x00, 0x60, 0x01, 0x00, 0x00, 0x60,
   0x01, 0x00, 0x00, 0x60, 0x01, 0x00, 0x00, 0x60, 0x01, 0x00, 0x00, 0x60,
   0x01, 0x00, 0x00, 0x60, 0x01, 0x00, 0x00, 0x60, 0x01, 0x00, 0x00, 0x60,
   0x01, 0x00, 0x00, 0x60, 0x01, 0x00, 0x00, 0x60, 0x01, 0x00, 0x00, 0x60,
   0x01, 0x00, 0x00, 0x60, 0x01, 0x00, 0x00, 0x60, 0x01, 0x00, 0x00, 0x60,
   0x01, 0x00, 0x00, 0x60, 0x01, 0x00, 0x00, 0x60, 0x01, 0x00, 0x00, 0x60,
   0x01, 0x00, 0x00, 0x60, 0xff, 0xff, 0xff, 0x7f, 0xfe, 0xff, 0xff, 0x7f,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};

#define xab_width 46
#define xab_height 32
#define xab_x_hot 0
#define xab_y_hot 0
static char xab_bits[] = {
   0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f,
   0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xff, 0x01, 0x00, 0x00, 0x00, 0x30,
   0xff, 0xfd, 0xff, 0xff, 0xff, 0x37, 0x7f, 0x04, 0xc0, 0x07, 0x00, 0x36,
   0x7f, 0xfd, 0xff, 0xff, 0xff, 0x37, 0x1f, 0xfd, 0xff, 0xff, 0xff, 0x37,
   0x5f, 0x05, 0x00, 0xfe, 0xff, 0x37, 0x5f, 0xfd, 0xff, 0xff, 0xff, 0x37,
   0x43, 0x05, 0x80, 0x01, 0xfe, 0x37, 0x5b, 0xfd, 0xff, 0xff, 0xff, 0x37,
   0x5b, 0x05, 0xc0, 0x01, 0xf8, 0x37, 0x5b, 0xfd, 0xff, 0xff, 0xff, 0x37,
   0x5b, 0x05, 0x00, 0xfc, 0xff, 0x37, 0x5b, 0xfd, 0xff, 0xff, 0xff, 0x37,
   0x5b, 0xfd, 0xff, 0xff, 0xff, 0x37, 0x5b, 0xfd, 0xff, 0xff, 0xff, 0x37,
   0x5b, 0xfd, 0xff, 0xff, 0xff, 0x37, 0x5b, 0x05, 0xc0, 0xff, 0xff, 0x37,
   0x5b, 0xfd, 0xff, 0xff, 0xff, 0x37, 0x5b, 0x05, 0xc0, 0xff, 0xff, 0x37,
   0x5b, 0xfd, 0xff, 0xff, 0xff, 0x37, 0x5b, 0x01, 0x00, 0x00, 0x00, 0x30,
   0x5b, 0xff, 0xff, 0xff, 0xff, 0x3d, 0x5b, 0x00, 0x00, 0x00, 0x00, 0x3c,
   0xdb, 0xff, 0xff, 0xff, 0x7f, 0x3f, 0x1b, 0x00, 0x00, 0x00, 0x00, 0x3f,
   0xfb, 0xff, 0xff, 0xff, 0xef, 0x3f, 0xfb, 0xff, 0xff, 0xff, 0xef, 0x3f,
   0x03, 0x00, 0x00, 0x00, 0xe0, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f};
                              
#define file_width 32
#define file_height 32
static char file_bits[] = {
   0xf0, 0xff, 0x3f, 0x00, 0x10, 0x00, 0x60, 0x00, 0x10, 0x00, 0xa0, 0x00,
   0x10, 0x00, 0x20, 0x01, 0x10, 0x00, 0x20, 0x02, 0x10, 0x00, 0x20, 0x04,
   0x10, 0x00, 0x20, 0x08, 0x10, 0x00, 0xe0, 0x1f, 0x10, 0x00, 0x00, 0x18,
   0x10, 0x00, 0x00, 0x18, 0x10, 0x00, 0x00, 0x18, 0x10, 0x00, 0x00, 0x18,
   0x10, 0x00, 0x00, 0x18, 0x10, 0x00, 0x00, 0x18, 0x10, 0x00, 0x00, 0x18,
   0x10, 0x00, 0x00, 0x18, 0x10, 0x00, 0x00, 0x18, 0x10, 0x00, 0x00, 0x18,
   0x10, 0x00, 0x00, 0x18, 0x10, 0x00, 0x00, 0x18, 0x10, 0x00, 0x00, 0x18,
   0x10, 0x00, 0x00, 0x18, 0x10, 0x00, 0x00, 0x18, 0x10, 0x00, 0x00, 0x18,
   0x10, 0x00, 0x00, 0x18, 0x10, 0x00, 0x00, 0x18, 0x10, 0x00, 0x00, 0x18,
   0x10, 0x00, 0x00, 0x18, 0x10, 0x00, 0x00, 0x18, 0x10, 0x00, 0x00, 0x18,
   0xf0, 0xff, 0xff, 0x1f, 0xe0, 0xff, 0xff, 0x1f};

#define printer_width 48
#define printer_height 48
static char printer_bits[] = {
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0xff,
   0x00, 0x04, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x02, 0x00, 0x00, 0x00, 0xa0,
   0x00, 0xf1, 0xff, 0xff, 0xff, 0x90, 0x80, 0xb8, 0xaa, 0xaa, 0x6a, 0x88,
   0x40, 0xfc, 0xff, 0xff, 0x3f, 0x84, 0x20, 0x0e, 0x00, 0x00, 0x10, 0x82,
   0x10, 0x03, 0x00, 0x00, 0x08, 0x81, 0x88, 0xff, 0xff, 0xff, 0x87, 0x80,
   0x04, 0x00, 0x00, 0x00, 0x40, 0x80, 0x02, 0x00, 0x00, 0x00, 0x20, 0x80,
   0xff, 0xff, 0xff, 0xff, 0x1f, 0x80, 0x01, 0x00, 0x00, 0x00, 0x10, 0x80,
   0xfd, 0x00, 0x00, 0xf8, 0x17, 0x80, 0x01, 0x00, 0x00, 0x08, 0x14, 0x80,
   0x01, 0x00, 0x00, 0x08, 0x14, 0x80, 0x01, 0x00, 0x00, 0x08, 0x14, 0x80,
   0x01, 0x00, 0x00, 0xf8, 0x17, 0x80, 0x01, 0x00, 0x00, 0x00, 0x10, 0x80,
   0x01, 0x00, 0x00, 0x00, 0x10, 0x40, 0x01, 0x00, 0x00, 0x00, 0x10, 0x20,
   0x01, 0x00, 0x00, 0x00, 0x10, 0x10, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x08,
   0xaa, 0xaa, 0xaa, 0xaa, 0x6b, 0x04, 0x14, 0x00, 0x00, 0x80, 0xd6, 0x02,
   0x08, 0x00, 0x00, 0x40, 0xff, 0x01, 0xfc, 0xff, 0xff, 0xbf, 0x00, 0x00,
   0x04, 0x00, 0x00, 0x60, 0x00, 0x00, 0xfc, 0xff, 0xff, 0x3f, 0x00, 0x00};







xab/xab_guidefs.h100644    764    764       11042  6471567655  12463 0ustar  amitamit#ifndef XAB_GUIDEFS_H
#define XAB_GUIDEFS_H

#define XAB_VERSION                   1.0

#define MAX_MSG_LEN                   255
#define LIST_LENGTH                   NAME_LENGTH + 25
#define DEFAULT_WIDTH                 500
#define DEFAULT_HEIGHT                304
/*
#define HOR_PIXELS_PER_CHAR           8
#define PIXELS_PER_ROW                16
*/
#define MSG_ROWS                      3
#define MSG_COLS                      60
#define DEFAULT_INTERNAL_HEIGHT       14

typedef struct
{
  int NameType;
  char Text[LIST_LENGTH];
  Widget widget;
} BOARD_LAYOUT;

typedef struct { XFontStruct *font; } AppData;

extern XtAppContext app_context;
extern Widget toplevel, pane, MenuForm, BoardForm, BoardVPort;
extern Widget FileMenu, FolderMenu, CardMenu, HelpMenu; 
extern Widget FileOption, Fopen, Fclean, Fmerge, Fsearch, FmenuLine1, Fexit;
extern Widget FolderOption, Fcreate, Fdelete; 
extern Widget CardOption, Ccreate, Cdelete;
extern Widget HelpOption, Hversion;
extern Widget FcreateShell, FcreateDialog, FcreateValue;
extern Widget CcreateShell, CcreatePane, CcreateButtons, CcreateDialog;
extern Widget CcreateCopy, CcreatePaste, CcreatePrint; 
extern Widget CcreateName, CcreateNameLabel;
extern Widget CcreateInfoLabel, CcreateInfo;
extern Widget CcreateCancel, CcreateOK, CcreateClear;
extern Widget CreatFileShell, CreateFileDialog;
extern Widget MessageShell, MessageDialog, MessageLabel;
extern Widget ListShell, ListLabel, ListForm, ListVPort, ListList,  ListOK, ListCancel; 
extern Widget FopenLShell, FopenForm, FdirForm, FfileForm; 
extern Widget DirlistLabel, DirListVPort, DirList;
extern Widget FilelistLabel, FileListVPort, FileList;
extern Widget SelectionLabel, SelectionValue, SelectionOK, SelectionCancel;
extern Widget PcardShell, PcardDialog;
extern Widget FsearchShell, FsearchDialog, FsearchValue;
extern Widget SrchListShell, SrchListForm, SrchListLabel, SrchListVPort, SrchListList;
extern Widget SrchListView, SrchListClose;

extern Pixmap FolderPixmap, CardPixmap, FilePixmap, XabPixmap, PrinterPixmap;

extern int ListSize;
extern BOARD_LAYOUT CurrentFolder[];
extern int FileOpened;
extern int NumItems;
extern CardList CurrentList[];
extern char DirName[];
extern CardStruct Card;
extern int CardCreate;
extern int ViewIndex;
extern char DirStr[];
extern char NewFileName[];
extern char *dirptr[], *filptr[];
extern int numdir, numfil;
extern String ListPtr[]; 
extern int DeleteType;
extern AppData app_data;
extern XtResource app_resources[];
extern int hunit, vunit;
extern CardList SearchList[];
extern int NumItemsFound;
extern char *ListNames[];
extern void InitPopups (void);
extern void InitPixmap(void);
extern void InitMenu(void);
extern void GetAppResources(void);

extern void HandlePopup (Widget, XtPointer, XtPointer);
extern void HandleExit (Widget, XtPointer, XtPointer);
extern void HandleCleanXab( Widget , XtPointer, XtPointer);
extern void ItemSelect (Widget, XtPointer, XtPointer);
extern void CreateCard (Widget, XtPointer, XtPointer);
extern void OKCreateCard (Widget, XtPointer, XtPointer);
extern void OKOpenFile (Widget, XtPointer, XtPointer);
extern void OpenFile (Widget, XtPointer, XtPointer);
extern void YesCreateFile (Widget, XtPointer, XtPointer);
extern void CreateFolder (Widget, XtPointer, XtPointer);
extern void OKCreateFolder (Widget, XtPointer, XtPointer);
extern void DeleteFolder (Widget, XtPointer, XtPointer);
extern void DeleteCard (Widget, XtPointer, XtPointer);
extern void DeleteCardOrFolder (Widget, XtPointer, XtPointer);
extern void HandleCancel(Widget, XtPointer, XtPointer);
extern void HandleClear (Widget, XtPointer, XtPointer);
extern void DirSelect (Widget, XtPointer, XtPointer);
extern void FileSelect (Widget, XtPointer, XtPointer);
extern void MergeFiles (Widget, XtPointer, XtPointer);
extern void OKMergeFile (Widget, XtPointer, XtPointer);
extern void HelpVersion (Widget, XtPointer, XtPointer);
extern void OKCopySelection (Widget, XtPointer, XtPointer);
extern void OKPasteSelection (Widget, XtPointer, XtPointer);
extern void PrintCard (Widget, XtPointer, XtPointer);
extern void OKPrintCard (Widget, XtPointer, XtPointer);
extern void UpdateFileSelectionList(Widget, XtPointer, XtPointer); /*FIX001*/
extern void SearchPattern(Widget, XtPointer, XtPointer);
extern void OKSearch (Widget, XtPointer, XtPointer);
extern void ViewEditCard (Widget, XtPointer, XtPointer);
extern void PokeCardValues (void);

extern void MessageBox ();
extern void DrawFolder(void);
extern void DestroyFolder(void);
extern int DisplayCurrentDirectory(void);
extern void RemoveNewLines(char *);
extern void RemoveBlankSpaces (char *);
#endif









xab/sample.card100644    764    764       14614  6444233511  12133 0ustar  amitamit/
Friends
FamilyCo-Workers	UnclesAuntsUncle Sam500 1st Avenue, Apt. 24,
Cedar Falls,
Iowa.

(319) 555 2345 (home)
(319) 555 7890 (work)
uncle.sam@local.net (E-mail)
(319) 555 7689 (Fax)h
hsXۍ+`(a`
h-72`Aunt MaryRaleigh, NC

(919) 555 1212y8xHu+1`y8yxyxUncle SamWashington, DC

uncle_sam@gov.usay8xHu+1`y8yxyxJim HarrisDept - 3K90
BNR, PPK

x4642y8xHu+1`y8yxyxGeorge BakerAlbuquerque, NM

(505) 555 1212
gbaker@aol.comy8xHu+1`y8yxyxBusiness ContactsPersonal ContactsImportant NumbersPersonal InformationE-mail address : xyz@junkmail.com

Pager Number : 1234567ث@,R@,R@xȭUU4L@ȭ6@@ȭثLyS@xxab/xab_filedefs.h100644    764    764        4314  6471570037  12566 0ustar  amitamit#ifndef XAB_FileDefs_h
#define XAB_FileDefs_h

/*--------------------------------------------------------
Defines
----------------------------------------------------------*/
#define TRUE              1
#define FALSE             0

#define NAME_LENGTH       25
#define INFORMATION_LENGTH 300

#define NAME_CARD         0
#define NAME_DIR          1

#define MAX_NAMES         100
#define MAX_SRCH          100

/*
Define Return Codes
*/
#define F_SUCCESS         0

#define F_FREAD_ERROR     -1
#define F_FSEEK_ERROR     -2
#define F_FOPEN_ERROR     -3
#define F_FWRITE_ERROR    -4
#define F_FOLDER_FULL     -5 
#define F_SANCHK_FAIL     -6 
#define F_NOT_DIR         -7
#define F_DIR_NOT_FOUND   -8
#define F_NO_SUCH_FILE    -9

/*------------------------------------------------------
Structure Definitions
-------------------------------------------------------*/
typedef struct
{
  char NameOnCard[NAME_LENGTH];
  char Information[INFORMATION_LENGTH];
}CardStruct;


typedef struct
{
  char DirectoryName[NAME_LENGTH];   /*Name of the directory*/
  int List[MAX_NAMES]; /*list of cards (or sub-directory in the directory*/
  int ParentIndex; /*Index of the Parent Directory*/
}DirectoryStruct;

typedef struct
{
  int NameType;   /*NAME_CARD or NAME_DIR*/
  union 
    {
      DirectoryStruct Directory;
      CardStruct Card;
    }Content;
}IndexStruct;

typedef struct
{
  int NameType;
  char CardorFolderName[NAME_LENGTH];
  int index;
}CardList;

/*----------------------------------------------------------
Function Prototype Declaration
----------------------------------------------------------*/
extern int CreateCardFile (char *);
extern int OpenCardFile (char *);
extern int MakeFolder (char *, int *);
extern int ListFoldersandCards (int *, CardList *, char *);
extern int ChangeFolder (int);
extern int MakeCard (CardStruct *);
extern int EditCard (int, CardStruct *);
extern int TypeCard (int, CardStruct *);
extern int RemoveCardorFolder (int);
extern int CloseCardFile (void);
extern void SortCardAndFolderList(CardList *, int);
extern int CleanCardFile (char *);
extern int NumRecords (int *);
extern int MergeFile (char *);
extern int SrchPattern (char *, CardList *, int *);
extern int RemoveCardOrFolder (int);

#endif









xab/xab_sysdefs.h100644    764    764        1446  6155430225  12461 0ustar  amitamit#ifndef XAB_SysDefs_h
#define XAB_SysDefs_h

#define PATH_NAME_LENGTH       255
#define MAX_FILES_PER_DIR      500
#define PRINTER_COMMAND_SIZE   100

#define DIRECTORY_DELIMITER '/'
#define DEFAULT_PRINTER_COMMAND "lpr %s"

/*Error Codes*/
#define H_NO_TMP_NAME    -50
#define H_BACKUP_FAILED  -51
#define H_RENAME_FAILED  -52
#define H_MALLOC_FAILED  -53
#define H_LSTAT_ERROR    -54
#define H_OPENDIR_FAILED -55
#define H_FOPEN_FAILED   -56
#define H_EXECVP_FAILED  -57
#define H_SYSTEM_FAILED  -58

extern char *GetHomeDirectory (int *);
extern int CleanCurrentXabFile (char *);
extern int ListDirEntries(char *, char *[], int *, char *[], int *);
extern void FreeDirStorage(char *[], int, char *[], int);
extern void ChangeCurrentDir (char *, char *);
extern int SysPrintCard (char *);
#endif








xab/xab_gui_callbacks.c100644    764    764       44320  6443534706  13606 0ustar  amitamit#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>

#include <X11/Intrinsic.h>
#include <X11/StringDefs.h>
#include <X11/Xatom.h>
#include <X11/Shell.h>
#include <X11/Xaw/Dialog.h>
#include <X11/Xaw/Form.h>
#include <X11/Xaw/Label.h>
#include <X11/Xaw/Paned.h>
#include <X11/Xaw/Command.h>
#include <X11/Xaw/AsciiText.h>
#include <X11/Xaw/MenuButton.h>
#include <X11/Xaw/SimpleMenu.h>
#include <X11/Xaw/SmeBSB.h>
#include <X11/Xaw/Viewport.h>
#include <X11/Xaw/AsciiText.h>
#include <X11/Xaw/List.h>

#include "xab_filedefs.h"
#include "xab_sysdefs.h"
#include "xab_guidefs.h"

/*------------------------------------------------------------------------
Functions : HandlePopup ()

Description: This callback function is called when a shell has to be 
popped up. The client_data parameter points to the shell widget. It is
also called from within other callback procedures to pop up a transient
shell.
------------------------------------------------------------------------*/
void HandlePopup(w, client_data, call_data)
Widget w;
XtPointer client_data, call_data;
{
  Position x, y;
  Widget shell = (Widget)client_data;
  int twidth = 0, theight = 0;
  int swidth = 0, sheight = 0;

  XtVaGetValues(toplevel, XtNx, &x, XtNy, &y, 
		XtNwidth, &twidth, 
		XtNheight, &theight,
		NULL);

  XtVaGetValues (shell, XtNwidth, &swidth, XtNheight, &sheight, NULL);

  if ((swidth == 0) || (sheight == 0)) /*first time pop-up*/
    {
      XtVaSetValues(shell, XtNx, x+100, XtNy, y+120, NULL);
    }
  else
    {
      XtVaSetValues (shell, 
		     XtNx, x + (twidth - swidth)/2,
		     XtNy, y + (theight - sheight)/2,
		     NULL);
    }
  XtPopup(shell, XtGrabExclusive);
}

/*-------------------------------------------------------------------------
Function : HandleExit()

Description: This callback function is called when the "exit" menu item
is clicked. It is also called when the toplevel window is destroyed. The
opened file is closed.
--------------------------------------------------------------------------*/
void HandleExit(w, client_data, call_data)
Widget w;
XtPointer client_data, call_data; 
{
  if (FileOpened)
    {
      CloseCardFile();
    }
  exit(0);
}

/*-------------------------------------------------------------------------
Function : HandleCleanXab()

Description: This callback procedure is called when the "clean file" menu item
is clicked.
--------------------------------------------------------------------------*/
void HandleCleanXab(w, client_data, call_data)
Widget w;
XtPointer client_data, call_data;  
{
  int status;
  int olds, news;

  if (FileOpened)
    {
      NumRecords(&olds);
      status = CleanCurrentXabFile (NewFileName);
      if (status == F_SUCCESS)
	{
	  NumRecords(&news);
	  status = DisplayCurrentDirectory();
	  MessageBox("File %s Cleaned\n%d records purged", 
		     NewFileName, olds - news);
	}
      else
	{
	  MessageBox("Cleanup failure\nstatus = %d", status);
	}
    }
  else
    {
      MessageBox ("File not open");
    }
}

/*------------------------------------------------------------------------
Function : ItemSelect()

Description: This callback procedure is called when the an item on the 
browser is clicked. If the selected item is a folder, the procedure changes
to that folder and displays the content of the sub-folder. If the selected
item is a card, the content of the card is popped up.
--------------------------------------------------------------------------*/
void ItemSelect( w, client_data, call_data)
Widget w;
XtPointer client_data, call_data; 
{
  int index = (int)client_data;
  int status;
  

  if (FileOpened)
    {
      if (index == 0)  /*go up one level*/ 
	{
	  status = ChangeFolder(0);
	  if (status == F_SUCCESS)
	    {
	      status = DisplayCurrentDirectory();
	    }
	  else
	    {
	      MessageBox("Could not change folder\nstatus = %d", status);
	    }
	}
      else
	{
	  if (CurrentList[index-1].NameType == NAME_DIR)
	    {
	      status = ChangeFolder(CurrentList[index-1].index);
	      if (status == F_SUCCESS)
		{
		  status = DisplayCurrentDirectory();
		}
	      else
		{
		  MessageBox ("Could not change folder\nstatus = %d", status);
		}
	    }
	  else
	    {
	      status = TypeCard (CurrentList[index - 1].index,
				 &Card);
	      if (status == F_SUCCESS)
		{
		  CardCreate = FALSE;
		  ViewIndex = CurrentList[index - 1].index;
		  PokeCardValues();
		  HandlePopup ((Widget)0, (XtPointer)CcreateShell, 
			       (XtPointer)0);
		}
	      else
		{
		  MessageBox("Could not open card");
		}
	    }
	}
    }
  else
    {
      MessageBox ("File not open");
    }
}

/*-----------------------------------------------------------------------
Function : CreateCard ()
------------------------------------------------------------------------*/
void CreateCard (w, client_data, call_data)
Widget w;
XtPointer client_data, call_data; 
{ 
  if (FileOpened)
    {
      CardCreate = TRUE;

      memset(&Card, 0, sizeof(CardStruct));
      PokeCardValues();
      HandlePopup(w, client_data, call_data);
    }
  else
    {
      MessageBox("File not open");
    }
}

void OKCreateCard(w, client_data, call_data)
Widget w;
XtPointer client_data, call_data;  
{
  int status;

  XtPopdown (CcreateShell);

  if (CardCreate)
    {
      RemoveNewLines (&Card.NameOnCard[0]);
      status = MakeCard(&Card);
    }
  else
    {
      status = EditCard(ViewIndex, &Card);
    }
  if (status == F_SUCCESS)
    {
      status = DisplayCurrentDirectory();
    }
  else
    {
      MessageBox ("Card could not be created/edited\nstatus = %d", status);
    }
}

void OKOpenFile(w, client_data, call_data)
Widget w;
XtPointer client_data, call_data;  
{
  String PathName;
  int status;

  XtPopdown(FopenLShell);

  XtVaGetValues(SelectionValue, XtNstring, &PathName, NULL);
  strncpy(NewFileName, PathName, PATH_NAME_LENGTH - 1);
  NewFileName[PATH_NAME_LENGTH - 1] = '\0';
  RemoveBlankSpaces(NewFileName);

  if (FileOpened)
    {
      CloseCardFile();
      FileOpened = FALSE;
      XtVaSetValues (toplevel, 
		     XtNtitle, "Address Book: No file selected",
		     NULL);
    }

  status = OpenCardFile(NewFileName);
  if (status == F_SUCCESS)
    {
      char string[MAX_MSG_LEN];

      sprintf(string, "Address Book: %s", NewFileName);
      XtVaSetValues (toplevel, 
		     XtNtitle, string,
		     NULL);      
      FileOpened = TRUE;
      status = DisplayCurrentDirectory();
    }
  else
    {
      DestroyFolder();
      CurrentFolder[0].NameType = NAME_DIR;
      strcpy (&CurrentFolder[0].Text[0], "No Files Selected");
      ListSize = 1;
      DrawFolder();

      if (status == F_NO_SUCH_FILE)
	{
	  HandlePopup ((Widget)0, (XtPointer)CreatFileShell, 
		       (XtPointer)0);
	}
      else
	{
	  MessageBox("File could not be opened\nstatus = %d", status);
	}
    }
}

void OpenFile (w, client_data, call_data)
Widget w;
XtPointer client_data, call_data; 
{
  XtRemoveAllCallbacks(SelectionOK, XtNcallback);
  XtAddCallback(SelectionOK, XtNcallback, OKOpenFile, FopenLShell);
  HandlePopup(w, (XtPointer)FopenLShell, NULL);
}

void YesCreateFile(w, client_data, call_data)
Widget w;
XtPointer client_data, call_data;  
{
  int status;

  XtPopdown(CreatFileShell);

  status = CreateCardFile(NewFileName);
  if (status == F_SUCCESS)
    {
      char string[MAX_MSG_LEN];

      sprintf(string, "Address Book: %s", NewFileName);
      XtVaSetValues (toplevel, 
		     XtNtitle, string,
		     NULL);   
      FileOpened = TRUE;
      status = DisplayCurrentDirectory();
    }
  else
    {
      MessageBox ("Could not create card file\nstatus = %d", status);
    }
}

void CreateFolder (w, client_data, call_data)
Widget w;
XtPointer client_data, call_data; 
{
  if (FileOpened)
    {
      XtVaSetValues(FcreateValue,
		    XtNstring, "",
		    NULL);
      HandlePopup(w, client_data, call_data);
    }
  else
    {
      MessageBox ("File not opened");
    }
}

void OKCreateFolder(w, client_data, call_data)
Widget w;
XtPointer client_data, call_data;  
{ 
  char FolderName[NAME_LENGTH];
  Widget FcreatDlg = (Widget)client_data;
  int status;

  XtPopdown(FcreateShell);
  strncpy(FolderName, XawDialogGetValueString(FcreatDlg), NAME_LENGTH - 1);
  FolderName[NAME_LENGTH - 1] = '\0';
  RemoveNewLines(FolderName);
  
  status = MakeFolder(FolderName, NULL);
  if (status == F_SUCCESS)
    {
      status = DisplayCurrentDirectory();
    }
  else
    {
      MessageBox ("Could not create folder\nstatus = %d", status);
    }
}

void DeleteFolder (w, client_data, call_data)
Widget w;
XtPointer client_data, call_data; 
{
  int i;

  if (FileOpened)
    {
      XtVaSetValues (ListLabel, 
		     XtNlabel, DirName,
		     XtNleftBitmap, FolderPixmap,
		     XtNwidth, NAME_LENGTH * hunit,
		     NULL);
      for (i = 0; i < NumItems; i++)
	{
	  if (CurrentList[i].NameType == NAME_DIR)
	    {
	      ListPtr[i] = &CurrentList[i].CardorFolderName[0];
	    }
	  else  /*it is assumed that the list is sorted*/
	    {
	      break;
	    }
	}

      if (i == 0) /*no sub-folders in the folder*/
	{
	  MessageBox ("No folder found");
	}
      else
	{
	  DeleteType = NAME_DIR;
	  XawListChange(ListList, ListPtr, i, 0, True);
	  HandlePopup(w, client_data, call_data);
	}
    }
  else
    {
      MessageBox ("File not open");
    }
}

void DeleteCard (w, client_data, call_data)
Widget w;
XtPointer client_data, call_data; 
{
  int i;
  int NumCards = 0;

  if (FileOpened)
    {
      XtVaSetValues (ListLabel, 
		     XtNlabel, DirName,
		     XtNleftBitmap, CardPixmap,
		     XtNwidth, NAME_LENGTH * hunit,
		     NULL);
      
      for (i = 0; i < NumItems; i++)
	{
	  if (CurrentList[i].NameType == NAME_CARD)
	    {
	      ListPtr[NumCards] = &CurrentList[i].CardorFolderName[0];
	      NumCards++;
	    }
	}

      if (NumCards == 0) /*no sub-folders in the folder*/
	{
	  MessageBox ("No cards found in the folder");
	}
      else
	{
	  DeleteType = NAME_CARD;
	  XawListChange(ListList, ListPtr, NumCards, 0, True);
	  HandlePopup(w, client_data, call_data);
	}
    }
  else
    {
      MessageBox ("File not open");
    }
}

void DeleteCardOrFolder (w, client_data, call_data)
Widget w;
XtPointer client_data, call_data; 
{
  int i, status;
  XawListReturnStruct *list;

  list = XawListShowCurrent(ListList);

  if (list->list_index != XAW_LIST_NONE)
    {
      XtPopdown(ListShell);
      if (DeleteType == NAME_DIR) /*Request to delete a folder*/
	{
	   status = RemoveCardOrFolder(CurrentList[list->list_index].index);
	   if (status == F_SUCCESS)
	     {
	       status = DisplayCurrentDirectory();
	     }
	   else
	     {
	       MessageBox("Folder could not be deleted\nstatus = %d", 
			  status);
	     }
	}
      else
	{
	  for (i = 0; i < NumItems; i++)/*skip the folder entries*/
	    {
	      if (CurrentList[i].NameType == NAME_CARD)
		{
		  break;
		}
	    }
	  status =  RemoveCardOrFolder(CurrentList[i + list->list_index].index);
	  if (status == F_SUCCESS)
	    {
	      status = DisplayCurrentDirectory();
	    }
	  else
	    {
	      MessageBox("File could not be deleted\nstatus = %d", 
			 status);
	    }
	}
    }
  else
    {
      MessageBox("No selection active");
    }
}

void HandleCancel(w, client_data, call_data)
Widget w;
XtPointer client_data, call_data;  
{
  Widget widget = (Widget)client_data;

  XtPopdown(widget);
}

void HandleClear (w, client_data, call_data)
Widget w;
XtPointer client_data, call_data; 
{
  Card.Information[0] = '\0';
  PokeCardValues();
}

void DirSelect (w, client_data, call_data)
Widget w;
XtPointer client_data, call_data; 
{
  int status;
  XawListReturnStruct *lp = (XawListReturnStruct *)call_data;

  ChangeCurrentDir (DirStr, lp->string);
  FreeDirStorage(dirptr, numdir, filptr, numfil); 
  if ((status = ListDirEntries(DirStr,
		     dirptr, &numdir, filptr, &numfil)) == F_SUCCESS)
    {
      if (numfil == 0)
	{
	  char *buf;
	  
	  buf = (char *)malloc(10);
	  if (buf != NULL)
	    {
	      buf[0] = '\0';
	      filptr[0] = buf;
	      numfil++;
	    }
	  /*else, too bad, not much can be done*/
	}
      XawListChange(DirList, dirptr, numdir, 0, True);
      XawListChange(FileList, filptr, numfil, 0, True);

      XtVaSetValues(SelectionValue,
		    XtNwidth, 50 * hunit,
		    XtNstring, DirStr,
		    NULL);
      XtVaSetValues(SelectionValue, 
		    XtNinsertPosition, strlen(DirStr) - 1,
		    NULL);
    }
}

void FileSelect (w, client_data, call_data)
Widget w;
XtPointer client_data, call_data; 
{
  XawListReturnStruct *lp = (XawListReturnStruct *)call_data;

  strcpy(NewFileName, DirStr);
  strcat(NewFileName, lp->string);

  XtVaSetValues(SelectionValue,
		XtNwidth, 50 * hunit,
		XtNstring, NewFileName,
		NULL);
  XtVaSetValues(SelectionValue, XtNinsertPosition, strlen(NewFileName), 
		NULL);
  
}

void OKMergeFile(w, client_data, call_data)
Widget w;
XtPointer client_data, call_data;  
{
  String PathName;
  int status;
  char MFile[PATH_NAME_LENGTH];

  XtPopdown(FopenLShell);

  XtVaGetValues(SelectionValue, XtNstring, &PathName, NULL);
  strncpy(MFile, PathName, PATH_NAME_LENGTH - 1);
  MFile[PATH_NAME_LENGTH - 1] = '\0';
  RemoveBlankSpaces(MFile);

  status = MergeFile(MFile);
  if (status == F_SUCCESS)
    {
      status = DisplayCurrentDirectory();
    }
  else
    {
      MessageBox("File merging failed\nstatus = %d", status);
    }
}

void MergeFiles (w, client_data, call_data)
Widget w;
XtPointer client_data, call_data; 
{
  if (FileOpened)
    {
      XtRemoveAllCallbacks(SelectionOK, XtNcallback);
      XtAddCallback(SelectionOK, XtNcallback, OKMergeFile, FopenLShell);
      HandlePopup(w, (XtPointer)FopenLShell, NULL);
    }
  else
    {
      MessageBox("File not open");
    }
}

void HelpVersion (w, client_data, call_data)
Widget w;
XtPointer client_data, call_data;
{
  MessageBox ("X - Address Book, \nVersion : %3.1f",
              XAB_VERSION);
}

void OKCopySelection (w, client_data, call_data)
Widget w;
XtPointer client_data, call_data;
{
  XawTextPosition st, en;

  XawTextGetSelectionPos(CcreateInfo, &st, &en);
  if (st == en)
    {
      MessageBox("No text selected");
    }
  else
    {
      XStoreBuffer (XtDisplay(toplevel),
		    &Card.Information[st],
		    en - st,
		    0);
	
      XawTextUnsetSelection(CcreateInfo);
    }
 
  
}

void OKPasteSelection (w, client_data, call_data)
Widget w;
XtPointer client_data, call_data;
{
  char *pbuffer;
  int length;
  int inspos;
  char newinfo[INFORMATION_LENGTH] = {'\0'};

  pbuffer = XFetchBuffer (XtDisplay(toplevel),
			  &length,
			  0);
  if (length > 0)
    {
      inspos = XawTextGetInsertionPoint (CcreateInfo);

      if (inspos > 0) strncpy(newinfo, &Card.Information[0], inspos + 1);

      strncat(newinfo, pbuffer, INFORMATION_LENGTH - 1 - strlen(newinfo));
      strncat(newinfo, &Card.Information[inspos], 
	      INFORMATION_LENGTH - 1 - strlen(newinfo));
      strncpy(&Card.Information[0], newinfo, INFORMATION_LENGTH - 1);
      Card.Information[INFORMATION_LENGTH - 1] = '\0';
      XtVaSetValues(CcreateInfo, 
		    XtNlength, INFORMATION_LENGTH - 1,
		    XtNstring, &Card.Information[0],
		    NULL);
      XawTextSetInsertionPoint(CcreateInfo, inspos + length);
    }
  else
    {
      MessageBox("No buffer selected");
    }
}

void PrintCard (w, client_data, call_data)
Widget w;
XtPointer client_data, call_data;
{
  HandlePopup(w, (XtPointer)PcardShell, (XtPointer)0);
}

void OKPrintCard (w, client_data, call_data)
Widget w;
XtPointer client_data, call_data;
{
  int status;
  char PrintC[PRINTER_COMMAND_SIZE]; 

  XtPopdown(PcardShell);

  strncpy(PrintC, XawDialogGetValueString(PcardDialog), 
	  PRINTER_COMMAND_SIZE - 1);
  PrintC[PRINTER_COMMAND_SIZE - 1] = '\0';
  RemoveNewLines(PrintC);

  status = SysPrintCard(PrintC);
  if (status != F_SUCCESS)
    {
      MessageBox("Printer command failed\nstatus = %d\n", status);
    }
}

/*FIX001++*/
void UpdateFileSelectionList (w, client_data, call_data)
Widget w;
XtPointer client_data, call_data;
{
  int status, length;

  strncpy(DirStr, GetHomeDirectory(&length), PATH_NAME_LENGTH - 1);
  DirStr[PATH_NAME_LENGTH - 1] = '\0';

  if (DirStr[strlen(DirStr) - 1] != '/')
    {
      length++;
      strcat(DirStr, "/");
    }
  if ((status = ListDirEntries(DirStr,
		     dirptr, &numdir, filptr, &numfil)) == F_SUCCESS)
    {
      XawListChange(DirList, dirptr, numdir, 0, True);
      XawListChange(FileList, filptr, numfil, 0, True);

      XtVaSetValues(SelectionValue,
		    XtNwidth, 60 * hunit,
		    XtNstring, DirStr,
		    NULL);
      XtVaSetValues(SelectionValue, XtNinsertPosition, length, NULL);
    }
  else
    {
      fprintf(stderr, "FATAL Error retrieving the directory structure, status = %d\n", status);
      exit(-1);
    }
}
/*FIX001--*/

void SearchPattern (w, client_data, call_data)
Widget w;
XtPointer client_data, call_data;
{
  if (FileOpened)
    {
      XtVaSetValues(FsearchValue, XtNstring, "", NULL);
      HandlePopup ((Widget) 0, client_data, NULL);
    }
  else
    {
      MessageBox ("No files opened");
    }
}

void OKSearch (w, client_data, call_data)
Widget w;
XtPointer client_data, call_data;
{
  int status;
  String pattern;

  XtPopdown (FsearchShell);

  pattern = XawDialogGetValueString (FsearchDialog);
  if (strlen(pattern) > 0)
    {
      /*start the search*/
      status = SrchPattern (pattern, SearchList, &NumItemsFound);
      if (status == F_SUCCESS)
	{
	  if (NumItemsFound > 0)
	    {
	      int i;
	      
	      /*copy the list to the list widget*/
	      for (i = 0; i < NumItemsFound; i++)
		{
		  ListNames[i] = &SearchList[i].CardorFolderName[0];
		}
	      XawListChange (SrchListList, ListNames, NumItemsFound, 
			     0, True);
	      
	      HandlePopup((Widget)0, SrchListShell, NULL);
	    }
	  else
	    {
	      MessageBox ("Match not found");
	    }
	}
      else
	{
	  MessageBox("Pattern search failed\nstatus = %d", status);
	}
    }
  else
    {
      MessageBox("No pattern specified");
    }
}

void ViewEditCard (w, client_data, call_data)
Widget w;
XtPointer client_data, call_data;
{
  int status;
  XawListReturnStruct *list;

  list = XawListShowCurrent(SrchListList);

  if (list->list_index != XAW_LIST_NONE)
    {
      XtPopdown(SrchListShell);

      status = TypeCard (SearchList[list->list_index].index,
			 &Card);
      if (status == F_SUCCESS)
	{
	  CardCreate = FALSE;
	  ViewIndex = SearchList[list->list_index].index;
	  PokeCardValues();
	  HandlePopup ((Widget)0, (XtPointer)CcreateShell, 
		       (XtPointer)0);
	}
      else
	{
	  MessageBox("Could not open card,\nstatus=%d", status);
	}
    }
  else
    {
      MessageBox("Selection not active");
    }
}





xab/.gdb_history100664    764    764         446  6252015120  12264 0ustar  amitamitfile /home/amit/sw/card/xab
break InitMenu();
info line 'InitMenu()'
break  InitMenu()
break 
break 169
run
info line xab_gui_main.c:169
kill
break xab_gui_utils.c:87
run
cont
quit
file /home/amit/sw/card/xab
break 169
stepi
run
stepi
step
info line 'i'
list i
examine i
quit
finish
kill
quit