home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-03-06 | 30.2 KB | 1,154 lines |
- Newsgroups: comp.sources.x
- Path: uunet!think.com!mips!msi!dcmartin
- From: jeff@rd1.interlan.com (Jeff Bailey)
- Subject: v16i137: pan - Post A Note (for Open Windows), Part01/06
- Message-ID: <csx-16i137-pan@uunet.UU.NET>
- Originator: dcmartin@fascet
- Sender: dcmartin@msi.com (David C. Martin - Moderator)
- Organization: Molecular Simulations, Inc.
- Date: Fri, 6 Mar 1992 20:03:09 GMT
- Approved: dcmartin@msi.com
-
- Submitted-by: jeff@rd1.interlan.com (Jeff Bailey)
- Posting-number: Volume 16, Issue 137
- Archive-name: pan/part01
-
-
-
- ---- Cut Here and feed the following to sh ----
- #!/bin/sh
- # This is a shell archive (produced by shar 3.49)
- # To extract the files from this archive, save it to a file, remove
- # everything above the "!/bin/sh" line above, and type "sh file_name".
- #
- # made 02/25/1992 22:06 UTC by jeff@tasslehoff
- # Source directory /users/jeff/c/pan/new
- #
- # existing files will NOT be overwritten unless -c is specified
- #
- # This shar contains:
- # length mode name
- # ------ ---------- ------------------------------------------
- # 822 -rw-r--r-- COPYRIGHT
- # 2102 -rw-r--r-- README
- # 168 -rw-r--r-- MANIFEST
- # 428 -rw-r--r-- Makefile
- # 7160 -rw-r--r-- event.c
- # 6605 -rw-r--r-- hidexp.c
- # 8172 -rw-r--r-- llm.c
- # 12600 -rw-r--r-- menu.c
- # 1777 -rw-r--r-- misc.c
- # 14223 -rw-r--r-- move.c
- # 16239 -rw-r--r-- note.c
- # 15901 -rw-r--r-- pan.c
- # 6718 -rw-r--r-- pan.h
- # 1997 -rw-r--r-- pan.icon
- # 10032 -rw-r--r-- pan.man
- # 8055 -rw-r--r-- parser.c
- # 8786 -rw-r--r-- rmfolder.c
- # 2035 -rw-r--r-- rmnote.c
- # 9860 -rw-r--r-- search.c
- # 3574 -rw-r--r-- update.c
- # 1960 -rw-r--r-- win.c
- #
- # ============= COPYRIGHT ==============
- if test -f 'COPYRIGHT' -a X"$1" != X"-c"; then
- echo 'x - skipping COPYRIGHT (File already exists)'
- else
- echo 'x - extracting COPYRIGHT (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'COPYRIGHT' &&
- Post A Note V2.4
- Copyright (c) 1992, Jeffrey W. Bailey
- All rights reserved.
- X
- Permission is granted to distribute this program in exact, complete
- source form, which includes this copyright notice, as long as no fee
- other than media and distribution cost is charged.
- X
- This program may not be used in whole, or in part, in any other manner
- without prior written permission from the author.
- X
- This program may not be distributed in modified form without prior
- written permission from the author. In other words, patches may be
- distributed, but modified source may not be distributed.
- X
- If there are any questions, comments or suggestions, the author may be
- contacted at:
- X
- X jeff@rd1.interlan.com
- X
- X or
- X
- X Jeffrey Bailey
- X Racal-Datacom, Inc.
- X Mail Stop E-110
- X 1601 N. Harrison Parkway
- X Sunrise, FL 33323-2899
- SHAR_EOF
- chmod 0644 COPYRIGHT ||
- echo 'restore of COPYRIGHT failed'
- Wc_c="`wc -c < 'COPYRIGHT'`"
- test 822 -eq "$Wc_c" ||
- echo 'COPYRIGHT: original size 822, current size' "$Wc_c"
- fi
- # ============= README ==============
- if test -f 'README' -a X"$1" != X"-c"; then
- echo 'x - skipping README (File already exists)'
- else
- echo 'x - extracting README (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'README' &&
- History:
- X
- I wrote this program after seeing a couple of X based post-it style programs
- and deciding that none of them did what I wanted. It has gone through several
- in-house revisions. Some of the available options were requested by individual
- users of the program. Because of this, they may not seem generally useful.
- X
- Version 2.4 is the first version that I have publicly distributed. This is
- due mostly to apathy. Recently, some people have prodded me to distribute
- pan to the net. So here it is. I hope someone finds it useful.
- X
- If you find bugs, or mis-features, or want enhancements, feel free to send
- me e-mail. Note, however, that I promise nothing. I may or may not do
- what you request. It depends upon my available free time, current work
- load, and whether I want to or not.
- X
- Caveats:
- X
- A lot of people have been using this program for quite a while, and I haven't
- gotten a single complaint about a lost note due to program error (or
- due to any other reason). However, as we all know, there is always a first.
- In other words, I think pan is pretty trustworthy, but I wouldn't bet my
- life on it!
- X
- I've only ever built this under Open Windows (v2 & v3) on a sun4 platform.
- I don't know whether it will build and run under any other configuration.
- If you have a different configuration, let me know how things work out (good
- or bad).
- X
- Sorry about the lack of an Imakefile, but I've never needed to use one, so
- I haven't learned the syntax. Basically, pan needs the xview library, the
- olgx library, and the X11 library. It also needs the X and xview include
- files.
- X
- Building pan:
- X
- To build pan, make sure OPENWINHOME is set in the environment and
- then run make. If this doesn't work, take a look at the Makefile and
- see if you can modify it for your configuration. The included Makefile
- is pathetically simple.
- X
- Note that if you use a more strict (or ANSI) compiler, you might get lots
- of warnings. I haven't gone through and made sure that I always cast the
- return value from xv_get() everywhere and I might have been sloppy elsewhere
- too. I apologize if this causes any grief.
- SHAR_EOF
- chmod 0644 README ||
- echo 'restore of README failed'
- Wc_c="`wc -c < 'README'`"
- test 2102 -eq "$Wc_c" ||
- echo 'README: original size 2102, current size' "$Wc_c"
- fi
- # ============= MANIFEST ==============
- if test -f 'MANIFEST' -a X"$1" != X"-c"; then
- echo 'x - skipping MANIFEST (File already exists)'
- else
- echo 'x - extracting MANIFEST (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'MANIFEST' &&
- COPYRIGHT
- README
- MANIFEST
- Makefile
- event.c
- hidexp.c
- llm.c
- menu.c
- misc.c
- move.c
- note.c
- pan.c
- pan.h
- pan.icon
- pan.man
- parser.c
- rmfolder.c
- rmnote.c
- search.c
- update.c
- win.c
- SHAR_EOF
- chmod 0644 MANIFEST ||
- echo 'restore of MANIFEST failed'
- Wc_c="`wc -c < 'MANIFEST'`"
- test 168 -eq "$Wc_c" ||
- echo 'MANIFEST: original size 168, current size' "$Wc_c"
- fi
- # ============= Makefile ==============
- if test -f 'Makefile' -a X"$1" != X"-c"; then
- echo 'x - skipping Makefile (File already exists)'
- else
- echo 'x - extracting Makefile (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'Makefile' &&
- CFLAGS=-I$(OPENWINHOME)/include -O
- SRCS=pan.c event.c hidexp.c llm.c menu.c misc.c move.c note.c parser.c \
- X rmfolder.c rmnote.c search.c update.c win.c
- OBJS=pan.o event.o hidexp.o llm.o menu.o misc.o move.o note.o parser.o \
- X rmfolder.o rmnote.o search.o update.o win.o
- LIBS=-L$(OPENWINHOME)/lib -lxview -lolgx -lX11
- X
- pan : $(OBJS)
- X cc -o pan $(OBJS) $(LIBS)
- X
- pan.o : pan.c pan.icon
- X
- $(OBJS) : pan.h
- X
- clean:
- X rm -f pan $(OBJS)
- SHAR_EOF
- chmod 0644 Makefile ||
- echo 'restore of Makefile failed'
- Wc_c="`wc -c < 'Makefile'`"
- test 428 -eq "$Wc_c" ||
- echo 'Makefile: original size 428, current size' "$Wc_c"
- fi
- # ============= event.c ==============
- if test -f 'event.c' -a X"$1" != X"-c"; then
- echo 'x - skipping event.c (File already exists)'
- else
- echo 'x - extracting event.c (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'event.c' &&
- /*
- Post A Note V2.4
- Copyright (c) 1992, Jeffrey W. Bailey
- All rights reserved.
- X
- Permission is granted to distribute this program in exact, complete
- source form, which includes this copyright notice, as long as no fee
- other than media and distribution cost is charged.
- X
- This program may not be used in whole, or in part, in any other manner
- without prior written permission from the author.
- X
- This program may not be distributed in modified form without prior
- written permission from the author. In other words, patches may be
- distributed, but modified source may not be distributed.
- X
- If there are any questions, comments or suggestions, the author may be
- contacted at:
- X
- X jeff@rd1.interlan.com
- X
- X or
- X
- X Jeffrey Bailey
- X Racal-Datacom, Inc.
- X Mail Stop E-110
- X 1601 N. Harrison Parkway
- X Sunrise, FL 33323-2899
- */
- X
- #include "pan.h"
- X
- extern char *malloc();
- extern char *getenv();
- X
- extern int errno;
- extern char *sys_errlist[];
- X
- /*
- X Handle the window exit event of the mouse pointer. Used to do auto-saves.
- X This trick on a frame is not specifically documented, but seems to work.
- X I hope it doesn't break in the future.
- */
- frameexit(frame, event, arg)
- X Frame frame;
- X Event *event;
- X Notify_arg arg;
- X {
- X int found = 0;
- X struct SubDir *sp;
- X struct Note *np;
- X
- X if(event_id(event) != LOC_WINEXIT) return;
- X if(debug_on) fprintf(stderr, "Got LOC_WINEXIT\n");
- X
- X sp = (struct SubDir *) LLM_first(&subdir_rt);
- X while(sp != NULL && !found)
- X {
- X np = (struct Note *) LLM_first(&sp->note_rt);
- X while(np != NULL && !found)
- X {
- X if(np->frame == frame && np->mapped)
- X {
- X update(np);
- X updateinfo(np, NOFORCE);
- X found = 1;
- X }
- X np = (struct Note *) LLM_next(&sp->note_rt);
- X }
- X sp = (struct SubDir *) LLM_next(&subdir_rt);
- X }
- X
- X }
- X
- /*
- X Handles a drag & drop event from the file manager into a note, retrieving
- X the path & file name and inserting it into the note text.
- */
- dragdrop(window, event, arg)
- X Xv_Window window;
- X Event *event;
- X Notify_arg arg;
- X {
- X int found = 0;
- X struct SubDir *sp;
- X struct Note *np;
- X Xv_Window twin;
- X int n;
- X int amount;
- X char buf[SELN_BUFSIZE];
- X
- X if(debug_on)
- X {
- X if(event_action(event) == ACTION_DRAG_MOVE)
- X fprintf(stderr, "Got ACTION_DRAG_MOVE event\n");
- X if(event_action(event) == ACTION_DRAG_LOAD)
- X fprintf(stderr, "Got ACTION_DRAG_LOAD event\n");
- X if(event_action(event) == ACTION_DRAG_COPY)
- X fprintf(stderr, "Got ACTION_DRAG_COPY event\n");
- X }
- X if(event_action(event) == ACTION_DRAG_LOAD)
- X {
- X sp = (struct SubDir *)LLM_first(&subdir_rt);
- X while(sp != NULL && !found)
- X {
- X np = (struct Note *) LLM_first(&sp->note_rt);
- X while(np != NULL && !found)
- X {
- X if(np->mapped)
- X {
- X twin = (Xv_Window) xv_get(np->textsw, OPENWIN_NTH_VIEW, 0);
- X if(twin == window)
- X {
- X found = 1;
- X n = xv_decode_drop(event, buf, sizeof(buf));
- X buf[sizeof(buf) - 1] = 0;
- X if(debug_on) fprintf(stderr, "buf {%s}\n", buf);
- X if(n > 0)
- X textsw_insert(np->textsw, buf, strlen(buf));
- X }
- X }
- X np = (struct Note *) LLM_next(&sp->note_rt);
- X }
- X sp = (struct SubDir *)LLM_next(&subdir_rt);
- X }
- X }
- X if((event_action(event) == ACTION_GO_PAGE_FORWARD ||
- X event_action(event) == ACTION_GO_PAGE_BACKWARD) && event_is_down(event))
- X {
- X if(debug_on) fprintf(stderr, "Got PAGE event\n");
- X sp = (struct SubDir *)LLM_first(&subdir_rt);
- X while(sp != NULL && !found)
- X {
- X np = (struct Note *) LLM_first(&sp->note_rt);
- X while(np != NULL && !found)
- X {
- X if(np->mapped)
- X {
- X twin = (Xv_Window) xv_get(np->textsw, OPENWIN_NTH_VIEW, 0);
- X if(twin == window)
- X {
- X Textsw_index t_ndx;
- X int top, bottom;
- X int len;
- X
- X found = 1;
- X textsw_file_lines_visible(np->textsw, &top, &bottom);
- X len = xv_get(np->textsw, TEXTSW_LENGTH);
- X if(debug_on)
- X fprintf(stderr, "len %d\n", len);
- X amount = bottom - top + 1;
- X if(event_action(event) == ACTION_GO_PAGE_BACKWARD)
- X amount = -(amount);
- X if(debug_on)
- X fprintf(stderr, "top %d, bot %d\n", top, bottom);
- X top += amount;
- X if(top < 0) top = 0;
- X t_ndx = textsw_index_for_file_line(np->textsw, top);
- X if(debug_on)
- X fprintf(stderr, "t_ndx %d\n",
- X t_ndx);
- X if(t_ndx >= 0)
- X {
- X xv_set(np->textsw,
- X TEXTSW_INSERTION_POINT, t_ndx,
- X TEXTSW_UPPER_CONTEXT, 0,
- X NULL);
- X textsw_normalize_view(np->textsw, t_ndx);
- X }
- X }
- X }
- X np = (struct Note *) LLM_next(&sp->note_rt);
- X }
- X sp = (struct SubDir *)LLM_next(&subdir_rt);
- X }
- X }
- X if(event_id(event) == KBD_DONE)
- X {
- X if(debug_on) fprintf(stderr, "Got KBD_DONE event\n");
- X sp = (struct SubDir *)LLM_first(&subdir_rt);
- X while(sp != NULL && !found)
- X {
- X np = (struct Note *) LLM_first(&sp->note_rt);
- X while(np != NULL && !found)
- X {
- X if(np->mapped)
- X {
- X twin = (Xv_Window) xv_get(np->textsw, OPENWIN_NTH_VIEW, 0);
- X if(twin == window)
- X {
- X found = 1;
- X update(np);
- X updateinfo(np, NOFORCE);
- X }
- X }
- X np = (struct Note *) LLM_next(&sp->note_rt);
- X }
- X sp = (struct SubDir *)LLM_next(&subdir_rt);
- X }
- X }
- X }
- X
- /*
- X Handles child process death notification. Used with the print note
- X action.
- */
- Notify_value child_death(me, pid, status, rusage)
- X Notify_client me;
- X int pid;
- X union wait *status;
- X struct rusage *rusage;
- X {
- X if(WIFEXITED(*status))
- X {
- X if(debug_on) fprintf(stderr, "Got child death\n");
- X return(NOTIFY_DONE);
- X }
- X return(NOTIFY_IGNORED);
- X }
- SHAR_EOF
- chmod 0644 event.c ||
- echo 'restore of event.c failed'
- Wc_c="`wc -c < 'event.c'`"
- test 7160 -eq "$Wc_c" ||
- echo 'event.c: original size 7160, current size' "$Wc_c"
- fi
- # ============= hidexp.c ==============
- if test -f 'hidexp.c' -a X"$1" != X"-c"; then
- echo 'x - skipping hidexp.c (File already exists)'
- else
- echo 'x - extracting hidexp.c (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'hidexp.c' &&
- /*
- Post A Note V2.4
- Copyright (c) 1992, Jeffrey W. Bailey
- All rights reserved.
- X
- Permission is granted to distribute this program in exact, complete
- source form, which includes this copyright notice, as long as no fee
- other than media and distribution cost is charged.
- X
- This program may not be used in whole, or in part, in any other manner
- without prior written permission from the author.
- X
- This program may not be distributed in modified form without prior
- written permission from the author. In other words, patches may be
- distributed, but modified source may not be distributed.
- X
- If there are any questions, comments or suggestions, the author may be
- contacted at:
- X
- X jeff@rd1.interlan.com
- X
- X or
- X
- X Jeffrey Bailey
- X Racal-Datacom, Inc.
- X Mail Stop E-110
- X 1601 N. Harrison Parkway
- X Sunrise, FL 33323-2899
- */
- X
- #include "pan.h"
- X
- extern char *malloc();
- extern char *getenv();
- X
- extern int errno;
- extern char *sys_errlist[];
- X
- /*
- X Routine called when hide notes button is selected. Hides ALL notes.
- */
- hideall()
- X {
- X struct SubDir *sp;
- X struct Note *np;
- X
- X sp = (struct SubDir *) LLM_first(&subdir_rt);
- X while(sp != NULL)
- X {
- X np = (struct Note *) LLM_first(&sp->note_rt);
- X while(np != NULL)
- X {
- X if(np->mapped && np->state != Hidden)
- X {
- X np->state = Hidden;
- X update(np);
- X updateinfo(np, FORCE);
- X textsw_reset(np->textsw, 0, 0);
- X put_win(np);
- X np->mapped = 0;
- X }
- X np = (struct Note *) LLM_next(&sp->note_rt);
- X }
- X sp = (struct SubDir *) LLM_next(&subdir_rt);
- X }
- X refresh_popups();
- X }
- X
- /*
- X Routine called when expose notes button menu selection All is selected.
- X Exposes ALL notes.
- */
- exposeall()
- X {
- X struct SubDir *sp;
- X struct Note *np;
- X
- X sp = (struct SubDir *) LLM_first(&subdir_rt);
- X while(sp != NULL)
- X {
- X np = (struct Note *) LLM_first(&sp->note_rt);
- X while(np != NULL)
- X {
- X if(np->state != Visible)
- X {
- X if(!np->mapped)
- X {
- X buildnote(np);
- X xv_set(np->title, PANEL_VALUE, np->ntitle, NULL);
- X xv_set(np->frame, XV_LABEL, np->ntitle, NULL);
- X reseticon(np);
- X np->state = Visible;
- X update(np);
- X updateinfo(np, FORCE);
- X }
- X }
- X np = (struct Note *) LLM_next(&sp->note_rt);
- X }
- X sp = (struct SubDir *) LLM_next(&subdir_rt);
- X }
- X refresh_popups();
- X }
- X
- /*
- X Routine called when expose notes button menu selection All is selected
- X from within a folder. Exposes ALL notes in the folder.
- */
- exposefolder(sp)
- X struct SubDir *sp;
- X {
- X struct Note *np;
- X
- X np = (struct Note *) LLM_first(&sp->note_rt);
- X while(np != NULL)
- X {
- X if(np->state != Visible)
- X {
- X if(!np->mapped)
- X {
- X buildnote(np);
- X xv_set(np->title, PANEL_VALUE, np->ntitle, NULL);
- X xv_set(np->frame, XV_LABEL, np->ntitle, NULL);
- X reseticon(np);
- X np->state = Visible;
- X update(np);
- X updateinfo(np, FORCE);
- X }
- X }
- X np = (struct Note *) LLM_next(&sp->note_rt);
- X }
- X refresh_popups();
- X }
- X
- /*
- X Routine called when the hide button on a note is selected. Hides the
- X selected note.
- */
- hidenote(item, event)
- X Panel_item item;
- X Event *event;
- X {
- X struct Note *np;
- X
- X np = (struct Note *) xv_get(item, PANEL_CLIENT_DATA);
- X
- X np->state = Hidden;
- X update(np);
- X updateinfo(np, FORCE);
- X textsw_reset(np->textsw, 0, 0);
- X put_win(np);
- X
- X np->mapped = 0;
- X refresh_popups();
- X }
- X
- /*
- X Called when the window border menu Quit item is selected on a note.
- X Veils the note.
- */
- dismissed(frame)
- X Frame frame;
- X {
- X int found = 0;
- X struct SubDir *sp;
- X struct Note *np;
- X
- X sp = (struct SubDir *) LLM_first(&subdir_rt);
- X while(sp != NULL && !found)
- X {
- X np = (struct Note *) LLM_first(&sp->note_rt);
- X while(np != NULL && !found)
- X {
- X if(np->mapped && np->frame == frame)
- X {
- X np->state = Veiled;
- X updateinfo(np, NOFORCE);
- X update(np);
- X textsw_reset(np->textsw, 0, 0);
- X put_win(np);
- X np->mapped = 0;
- X found = 1;
- X }
- X np = (struct Note *) LLM_next(&sp->note_rt);
- X }
- X sp = (struct SubDir *) LLM_next(&subdir_rt);
- X }
- X refresh_popups();
- X }
- X
- /*
- X Called when an expose menu item is chosen. Figures out which note
- X to expose, then does it.
- */
- exposemenu(menu, mitem)
- X Menu menu;
- X Menu_item mitem;
- X {
- X struct SubDir *sp;
- X struct Note *np;
- X char *ptext;
- X Menu_item pullright;
- X
- X np = (struct Note *)xv_get(mitem, MENU_CLIENT_DATA);
- X if(np == NULL &&
- X strcmp((char *)xv_get(mitem, MENU_STRING), CHOICE_ALL) == 0)
- X {
- X exposeall();
- X }
- X else if((long) np == 0xFFFFFFFF &&
- X strcmp((char *)xv_get(mitem, MENU_STRING), CHOICE_ALL) == 0)
- X {
- X pullright = (Menu_item) xv_get(menu, MENU_PARENT);
- X ptext = (char *)xv_get(pullright, MENU_STRING);
- X sp = (struct SubDir *) LLM_first(&subdir_rt);
- X while(sp != NULL)
- X {
- X if(strcmp(sp->subdir, ptext) == 0)
- X exposefolder(sp);
- X sp = (struct SubDir *) LLM_next(&subdir_rt);
- X }
- X }
- X else
- X {
- X if(np == NULL)
- X {
- X notice_prompt(main_frame, NULL,
- X NOTICE_MESSAGE_STRINGS,
- X "No notes to expose",
- X NULL,
- X NOTICE_BUTTON_YES, "Acknowledge",
- X NOTICE_NO_BEEPING, noticenobeep,
- X NULL);
- X return;
- X }
- X if(!np->mapped)
- X {
- X buildnote(np);
- X xv_set(np->title, PANEL_VALUE, np->ntitle, NULL);
- X xv_set(np->frame, XV_LABEL, np->ntitle, NULL);
- X reseticon(np);
- X np->state = Visible;
- X update(np);
- X updateinfo(np, FORCE);
- X }
- X refresh_popups();
- X }
- X }
- X
- /* refresh any pop up windows as necessary */
- refresh_popups()
- X {
- X refresh_move();
- X refresh_destroy();
- X refresh_search();
- X }
- SHAR_EOF
- chmod 0644 hidexp.c ||
- echo 'restore of hidexp.c failed'
- Wc_c="`wc -c < 'hidexp.c'`"
- test 6605 -eq "$Wc_c" ||
- echo 'hidexp.c: original size 6605, current size' "$Wc_c"
- fi
- # ============= llm.c ==============
- if test -f 'llm.c' -a X"$1" != X"-c"; then
- echo 'x - skipping llm.c (File already exists)'
- else
- echo 'x - extracting llm.c (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'llm.c' &&
- /*
- Post A Note V2.4
- Copyright (c) 1992, Jeffrey W. Bailey
- All rights reserved.
- X
- Permission is granted to distribute this program in exact, complete
- source form, which includes this copyright notice, as long as no fee
- other than media and distribution cost is charged.
- X
- This program may not be used in whole, or in part, in any other manner
- without prior written permission from the author.
- X
- This program may not be distributed in modified form without prior
- written permission from the author. In other words, patches may be
- distributed, but modified source may not be distributed.
- X
- If there are any questions, comments or suggestions, the author may be
- contacted at:
- X
- X jeff@rd1.interlan.com
- X
- X or
- X
- X Jeffrey Bailey
- X Racal-Datacom, Inc.
- X Mail Stop E-110
- X 1601 N. Harrison Parkway
- X Sunrise, FL 33323-2899
- */
- X
- #include <stdio.h>
- #include "pan.h"
- X
- extern char *malloc();
- X
- LLM_init(root, size)
- X struct LLM_root *root;
- X int size;
- X {
- X if(root == NULL)
- X {
- X return(NULL);
- X }
- X root->First = NULL;
- X root->Last = NULL;
- X root->Current = NULL;
- X root->Size = size + sizeof(struct LLM_node);
- X root->Init = 1;
- X return(1);
- X }
- X
- char *LLM_add(root)
- X struct LLM_root *root;
- X {
- X struct LLM_node *hold, *temp;
- X
- X if(root == NULL)
- X {
- X return(NULL);
- X }
- X if(root->Init != 1)
- X {
- X return(NULL);
- X }
- X hold = (struct LLM_node *) malloc(root->Size);
- X if(hold == NULL)
- X {
- X return(NULL);
- X }
- X if(root->First == NULL)
- X {
- X root->First = hold;
- X root->Last = hold;
- X root->Current = hold;
- X hold->Next = NULL;
- X hold->Prev = NULL;
- X }
- X else
- X {
- X temp = root->Last;
- X temp->Next = hold;
- X hold->Next = NULL;
- X hold->Prev = temp;
- X root->Last = hold;
- X }
- X return( (char *) (hold + 1));
- X }
- X
- char *LLM_first(root)
- X struct LLM_root *root;
- X {
- X if(root == NULL)
- X {
- X return(NULL);
- X }
- X if(root->Init != 1)
- X {
- X return(NULL);
- X }
- X if(root->First == NULL)
- X {
- X return(NULL);
- X }
- X root->Current = root->First;
- X return((char *) (root->Current + 1));
- X }
- X
- char *LLM_last(root)
- X struct LLM_root *root;
- X {
- X if(root == NULL)
- X {
- X return(NULL);
- X }
- X if(root->Init != 1)
- X {
- X return(NULL);
- X }
- X if(root->Last == NULL)
- X {
- X return(NULL);
- X }
- X root->Current = root->Last;
- X return((char *) (root->Current + 1));
- X }
- X
- char *LLM_next(root)
- X struct LLM_root *root;
- X {
- X if(root == NULL)
- X {
- X return(NULL);
- X }
- X if(root->Init != 1)
- X {
- X return(NULL);
- X }
- X if(root->First == NULL)
- X {
- X return(NULL);
- X }
- X if(root->Current == NULL)
- X {
- X return(NULL);
- X }
- X if(root->Current == root->Last)
- X {
- X return(NULL);
- X }
- X root->Current = root->Current->Next;
- X return((char *) (root->Current + 1));
- X }
- X
- char *LLM_previous(root)
- X struct LLM_root *root;
- X {
- X if(root == NULL)
- X {
- X return(NULL);
- X }
- X if(root->Init != 1)
- X {
- X return(NULL);
- X }
- X if(root->First == NULL)
- X {
- X return(NULL);
- X }
- X if(root->Current == NULL)
- X {
- X return(NULL);
- X }
- X if(root->Current == root->First)
- X {
- X return(NULL);
- X }
- X root->Current = root->Current->Prev;
- X return((char *) (root->Current + 1));
- X }
- X
- LLM_free(root)
- X struct LLM_root *root;
- X {
- X struct LLM_node *temp, *hold;
- X
- X if(root == NULL)
- X {
- X return(NULL);
- X }
- X if(root->Init != 1)
- X {
- X return(NULL);
- X }
- X temp = root->First;
- X while(temp != NULL) /* Loop until we're at the end. */
- X {
- X hold = temp;
- X temp = temp->Next;
- X (void)free((char *)hold); /* Free up our current node. */
- X }
- X root->First = NULL;
- X root->Last = NULL;
- X root->Current = NULL;
- X return(1);
- X }
- X
- LLM_delete(root, node)
- X struct LLM_root *root;
- X char *node;
- X {
- X struct LLM_node *temp;
- X
- X if(root == NULL)
- X {
- X return(NULL);
- X }
- X if(root->Init != 1)
- X {
- X return(NULL);
- X }
- X if(node == NULL)
- X {
- X return(NULL);
- X }
- X temp = (struct LLM_node *) node;
- X temp--;
- X
- X if(temp->Prev != NULL)
- X temp->Prev->Next = temp->Next;
- X else
- X root->First = temp->Next;
- X
- X if(temp->Next != NULL)
- X temp->Next->Prev = temp->Prev;
- X else
- X root->Last = temp->Prev;
- X
- X if(temp == root->Current) root->Current = root->First;
- X
- X (void)free((char *)temp);
- X return(1);
- X }
- X
- char *LLM_insert(root, node)
- X struct LLM_root *root;
- X char *node;
- X {
- X struct LLM_node *temp, *hold;
- X
- X if(root == NULL)
- X {
- X return(NULL);
- X }
- X if(root->Init != 1)
- X {
- X return(NULL);
- X }
- X if(node == NULL)
- X {
- X return(NULL);
- X }
- X temp = (struct LLM_node *) node;
- X temp--;
- X hold = (struct LLM_node *) malloc(root->Size);
- X if(hold == NULL)
- X {
- X return(NULL);
- X }
- X if(temp == root->First)
- X {
- X hold->Next = root->First;
- X hold->Next->Prev = hold;
- X root->First = hold;
- X hold->Prev = NULL;
- X return( (char *) (hold + 1));
- X }
- X hold->Next = temp;
- X hold->Prev = temp->Prev;
- X temp->Prev = hold;
- X hold->Prev->Next = hold;
- X
- X return( (char *) (hold + 1));
- X }
- X
- LLM_position(root, node)
- X struct LLM_root *root;
- X char *node;
- X {
- X struct LLM_node *temp;
- X
- X if(root == NULL)
- X {
- X return(NULL);
- X }
- X if(node == NULL)
- X {
- X return(NULL);
- X }
- X if(root->Init != 1)
- X {
- X return(NULL);
- X }
- X temp = (struct LLM_node *) node;
- X temp--;
- X root->Current = temp;
- X return(1);
- X }
- X
- char *LLM_current(root)
- X struct LLM_root *root;
- X {
- X if(root == NULL)
- X {
- X return(NULL);
- X }
- X if(root->Init != 1)
- X {
- X return(NULL);
- X }
- X if(root->Current == NULL)
- X {
- X return(NULL);
- X }
- X return((char *) (root->Current + 1));
- X }
- X
- LLM_unlink(root, node)
- X struct LLM_root *root;
- X char *node;
- X {
- X struct LLM_node *temp;
- X
- X if(root == NULL)
- X {
- X return(NULL);
- X }
- X if(root->Init != 1)
- X {
- X return(NULL);
- X }
- X if(node == NULL)
- X {
- X return(NULL);
- X }
- X temp = (struct LLM_node *) node;
- X temp--;
- X
- X if(temp->Prev != NULL)
- X temp->Prev->Next = temp->Next;
- X else
- X root->First = temp->Next;
- X
- X if(temp->Next != NULL)
- X temp->Next->Prev = temp->Prev;
- X else
- X root->Last = temp->Prev;
- X
- X if(temp == root->Current) root->Current = root->First;
- X
- X return(1);
- X }
- X
- LLM_link(root, node, newnode)
- X struct LLM_root *root;
- X char *node;
- X char *newnode;
- X {
- X struct LLM_node *temp, *hold;
- X
- X if(root == NULL)
- X {
- X return(NULL);
- X }
- X if(root->Init != 1)
- X {
- X return(NULL);
- X }
- X if(newnode == NULL)
- X {
- X return(NULL);
- X }
- X hold = (struct LLM_node *) newnode;
- X hold--;
- X if(node == NULL && root->First != NULL) /* link at end */
- X {
- X temp = root->Last;
- X temp->Next = hold;
- X hold->Next = NULL;
- X hold->Prev = temp;
- X root->Last = hold;
- X return(1);
- X }
- X if(node == NULL && root->First == NULL) /* first node */
- X {
- X root->First = hold;
- X root->Last = hold;
- X root->Current = hold;
- X hold->Next = NULL;
- X hold->Prev = NULL;
- X return(1);
- X }
- X temp = (struct LLM_node *) node;
- X temp--;
- X if(temp == root->First)
- X {
- X hold->Next = root->First;
- X hold->Next->Prev = hold;
- X root->First = hold;
- X hold->Prev = NULL;
- X return(1);
- X }
- X hold->Next = temp;
- X hold->Prev = temp->Prev;
- X temp->Prev = hold;
- X hold->Prev->Next = hold;
- X
- X return(1);
- X }
- SHAR_EOF
- chmod 0644 llm.c ||
- echo 'restore of llm.c failed'
- Wc_c="`wc -c < 'llm.c'`"
- test 8172 -eq "$Wc_c" ||
- echo 'llm.c: original size 8172, current size' "$Wc_c"
- fi
- true || echo 'restore of menu.c failed'
- echo End of part 1, continue with part 2
- exit 0
- --
- --
- Molecular Simulations, Inc. mail: dcmartin@msi.com
- 796 N. Pastoria Avenue uucp: uunet!dcmartin
- Sunnyvale, California 94086 at&t: 408/522-9236
-