pkg://xab-1.0-1.src.rpm:27326/xab.tar.gz
info downloads
xab/ 40755 764 764 0 6471571547 7712 5 ustar amit amit xab/StrFnc.c 100644 764 764 5505 6155430225 11341 0 ustar amit amit #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.c 100644 764 764 11372 6471571131 11634 0 ustar amit amit #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.c 100644 764 764 12774 6471571256 12625 0 ustar amit amit #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-PACKAGE 100644 764 764 1122 6155430225 11441 0 ustar amit amit Title : 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/makefile 100644 764 764 1747 6471566744 11523 0 ustar amit amit CC = /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/INSTALL 100644 764 764 3337 6155430225 11030 0 ustar amit amit Steps 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.c 100644 764 764 6774 6471570115 13015 0 ustar amit amit #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/README 100644 764 764 15025 6444236016 10677 0 ustar amit amit 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.c 100644 764 764 56334 6471570704 11751 0 ustar amit amit #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.c 100644 764 764 46267 6471567322 12647 0 ustar amit amit #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.xbm 100644 764 764 13363 6270731370 12171 0 ustar amit amit #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.h 100644 764 764 11042 6471567655 12463 0 ustar amit amit #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.card 100644 764 764 14614 6444233511 12133 0 ustar amit amit /
Friends
Family Co-Workers Uncles Aunts Uncle Sam 500 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
h sXۍ+` ( a `
h -72` Aunt Mary Raleigh, NC
(919) 555 1212 y 8 x Hu+1`y 8 y x y x Uncle Sam Washington, DC
uncle_sam@gov.usa