home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright 1993, 1994, Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
- * the contents of this file may not be disclosed to third parties, copied or
- * duplicated in any form, in whole or in part, without the prior written
- * permission of Silicon Graphics, Inc.
- *
- * RESTRICTED RIGHTS LEGEND:
- * Use, duplication or disclosure by the Government is subject to restrictions
- * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
- * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
- * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
- * rights reserved under the Copyright Laws of the United States.
- */
- #include <stdio.h>
- #include "exinterfmotif.h"
- #include <string.h>
- #include "exglobals.h"
- #include "exinterf.h"
- #include "exbookglo.h"
-
- extern struct indexlist *find_keyword();
- int buttonwidth = 65;
- int buttonhalf = 32;
-
- /************************************************************
- *
- * Clears the buffer of a text thingy.
- *
- ************************************************************/
- bufclear(struct Tstruct *T)
- {
- int i;
- T->bufpos = 0;
- for (i = 0; i < 300; i++)
- T->buf[i] = '\0';
- }
-
- /************************************************************
- *
- * Free storage used by the buttons in the add group window.
- *
- ************************************************************/
- void freegpform()
- {
- struct charlist *charptr, *prevcharptr;
-
- charptr = HeadGrpChar;
- while (charptr != NULL)
- {
- prevcharptr = charptr->next;
- if (charptr->indexflag == 0)
- free(charptr->str);
- free(charptr);
- charptr = prevcharptr;
- }
- HeadGrpChar = NULL;
- TailGrpChar = NULL;
- }
-
- void initExistKWList()
- {
- long cumlength, limit;
- static short nblocks = 1;
- struct indexlist *ndxptr;
- int count;
-
- ndxptr = Index;
- count = 0;
- ExistKeywordString[0] = '\0';
- strcpy(ExistKeywordString, "");
- cumlength = 0;
- limit = (1024 * nblocks)-2;
- while (ndxptr != NULL)
- {
- count++;
- cumlength+=(strlen(ndxptr->string)+1);
- if (cumlength > limit)
- {
- nblocks++;
- ExistKeywordString = (char *)realloc((void *)ExistKeywordString, 1024*(nblocks));
- limit = (1024 * nblocks)-2;
- }
- strcat(ExistKeywordString, (ndxptr->string));
- strcat(ExistKeywordString, ",");
- ndxptr = ndxptr->next;
- }
- ExistKeywordCount = count;
- }
-
- /************************************************************
- *
- * Initialize the buttons in the add group window.
- *
- ************************************************************/
- long initgpform()
- {
- AGKey.bufpos = 0;
- bufclear(&AGKey);
- AGName.bufpos = 0;
- bufclear(&AGName);
- AGHfile.bufpos = 0;
- bufclear(&AGHfile);
- GroupKeywordCount = 0;
- GroupKeywordString[0] = '\0';
-
- initExistKWList();
- }
-
- /************************************************************
- *
- * Initialize the buttons for the window where the user adds
- * demos to the book.
- *
- ************************************************************/
- long initadwin()
- {
- struct indexlist *ndxptr;
- short count;
- struct icntmpltstruct *iconptr;
- struct wordlist *wrdptr;
- struct charlist *curchar;
- struct filelist *tmpfptr;
- long cl_demo, cl_files, lim_demo, lim_files;
- static short nb_demo = 1;
- static short nb_files = 1;
-
-
- initExistKWList();
-
- DemoKeywordCount = 0;
- ExeFileCount = 0;
- DemoKeywordString[0] = '\0';
- ExeFileString[0] = '\0';
-
- ADName.bufpos = 0;
- bufclear(&ADName);
- ADCommand.bufpos = 0;
- bufclear(&ADCommand);
- ADAltCommand.bufpos = 0;
- bufclear(&ADAltCommand);
- ADHfile.bufpos = 0;
- bufclear(&ADHfile);
- ADIfile.bufpos = 0;
- bufclear(&ADIfile);
- ADIfile2.bufpos = 0;
- bufclear(&ADIfile2);
- ADKey.bufpos = 0;
- bufclear(&ADKey);
-
- HeadChar = NULL;
- TailChar = NULL;
- Head_FL = NULL;
- Tail_FL = NULL;
- if (EditDemoFlag == 1)
- {
- if (selected >= 0)
- {
- KW_change = FALSE;
- iconptr = seliconptr->iconptr;
- curicon = iconptr;
- ADName.bufpos = strlen(iconptr->nameptr->string);
- strcpy(ADName.buf, iconptr->nameptr->string);
- ADCommand.bufpos = strlen(iconptr->startstring);
- strcpy(ADCommand.buf, iconptr->startstring);
- if (iconptr->alt_command != NULL)
- {
- ADAltCommand.bufpos = strlen(iconptr->alt_command);
- strcpy(ADAltCommand.buf, iconptr->alt_command);
- }
- if (iconptr->helpfile != NULL)
- {
- ADHfile.bufpos = strlen(iconptr->helpfile->name);
- strcpy(ADHfile.buf, iconptr->helpfile->name);
- }
- if (iconptr->geofile != NULL)
- {
- ADIfile.bufpos = strlen(iconptr->geofile->name);
- strcpy(ADIfile.buf, iconptr->geofile->name);
- }
- if (iconptr->imgfile != NULL)
- {
- ADIfile2.bufpos = strlen(iconptr->imgfile->name);
- strcpy(ADIfile2.buf, iconptr->imgfile->name);
- }
- count = 0;
- DemoKeywordString[0] = '\0';
- strcpy(DemoKeywordString, "");
- cl_demo = 0;
- lim_demo = (512 * nb_demo)-2;
- wrdptr = iconptr->keywords;
- while (wrdptr != NULL)
- {
- curchar = (struct charlist *) malloc(sizeof(struct charlist) );
- curchar->str = NULL;
- curchar->next = NULL;
- if (HeadChar == NULL)
- HeadChar = curchar;
- else
- TailChar->next = curchar;
- TailChar = curchar;
- TailChar->indexflag = 1;
- TailChar->str = wrdptr->indexptr->string;
- cl_demo+=strlen(wrdptr->indexptr->string)+1;
- if (cl_demo > lim_demo)
- {
- nb_demo++;
- DemoKeywordString = (char *)realloc( (void *)DemoKeywordString,
- 512*nb_demo);
- lim_demo = (512 * nb_demo)-2;
- }
- strcat(DemoKeywordString, (wrdptr->indexptr->string));
- strcat(DemoKeywordString, ",");
- count++;
- wrdptr = wrdptr->next;
- }
- DemoKeywordCount = count;
- if (iconptr->addtlfiles != NULL)
- {
- count = 0;
- ExeFileString[0] = '\0';
- strcpy(ExeFileString, "");
- tmpfptr = iconptr->addtlfiles;
- cl_files = 0;
- lim_files = (512*nb_files) -2;
- while (tmpfptr != NULL)
- {
- curchar = (struct charlist *)malloc( sizeof(struct charlist) );
- curchar->str = NULL;
- curchar->next = NULL;
- if (Head_FL == NULL)
- Head_FL = curchar;
- else
- Tail_FL->next = curchar;
- Tail_FL = curchar;
- Tail_FL->indexflag = 1; /* 1 means that this string was
- already in the icons list of
- additional files. 0 will mean
- that this is a new file */
- Tail_FL->str = tmpfptr->file->name;
- if (cl_files > lim_files)
- {
- nb_files++;
- ExeFileString = (char *)realloc( (void *)ExeFileString,
- 512*nb_files);
- lim_files = (512*nb_files) -2;
- }
- strcat(ExeFileString, (tmpfptr->file->name));
- strcat(ExeFileString, ",");
- count++;
- tmpfptr = tmpfptr->next;
- }
- ExeFileCount = count;
- }
- }
- }
- return(99);
- }
-
-