Use C++ linker
[oweals/cde.git] / cde / programs / dtcreate / af_aux.c
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these librararies and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /* $TOG: af_aux.c /main/6 1998/04/06 13:14:19 mgreess $ */
24 /******************************************************************************/
25 /*                                                                            */
26 /* af_aux - auxiliary functions for add filetype                              */
27 /*                                                                            */
28 /* Functions to get/set values from/to interface.                             */
29 /* Callback routines for AF interface.                                        */
30 /*                                                                            */
31 /******************************************************************************/
32
33 #include <stdio.h>
34 #include <stdlib.h>
35 #include <sys/signal.h>
36 #include <errno.h>
37 #include <unistd.h>
38 #include <X11/cursorfont.h>
39 #include <X11/Xlib.h>
40 #include <X11/Xatom.h>
41 #include <Xm/Xm.h>
42 #include <Xm/TextF.h>
43 #include <Xm/RowColumnP.h>
44 #include <Xm/MessageB.h>
45 #include <Xm/FileSB.h>
46 #include <sys/stat.h>
47 #if defined(AIXV3)
48 #    include <sys/dir.h>
49 #else
50 #  if defined(__osf__) || defined(linux)
51 #    include <dirent.h>
52 #  else
53 #    include <sys/dirent.h>
54 #  endif
55 #endif
56
57 #include <Dt/Icon.h>
58
59 #include "dtcreate.h"
60 #include "af_aux.h"
61 #include "cmnutils.h"
62 #include "cmnrtns.h"
63
64 /******************************************************************************/
65 /*                                                                            */
66 /*  External Variables                                                        */
67 /*                                                                            */
68 /******************************************************************************/
69
70 /******************************************************************************/
71 /*                                                                            */
72 /*  Variables                                                                 */
73 /*                                                                            */
74 /******************************************************************************/
75
76 /******************************************************************************/
77 /*                                                                            */
78 /*         CALLBACK FUNCTIONS                                                 */
79 /*                                                                            */
80 /******************************************************************************/
81
82 /******************************************************************************/
83 /*                                                                            */
84 /* get_selected_filetype_icon - determines which filetype icon is currently   */
85 /*                              selected.                                     */
86 /*                                                                            */
87 /* INPUT: none                                                                */
88 /* OUTPUT: Widget wid - id of selected icon gadget                            */
89 /*                                                                            */
90 /******************************************************************************/
91 Widget get_selected_filetype_icon (void)
92 {
93   if (!last_filetype_pushed) {
94     last_filetype_pushed = AF_MED_IconGadget;
95   }
96   return (last_filetype_pushed);
97 }
98
99 /******************************************************************************/
100 /*                                                                            */
101 /* activateCB_filetype_icon                                                   */
102 /*                                                                            */
103 /* INPUT: Widget wid - id of icon gadget                                      */
104 /*        XtPointer client_data - not used                                    */
105 /*        XmPushButtonCallbackStruct *cbs - not used                          */
106 /* OUTPUT: none                                                               */
107 /*                                                                            */
108 /******************************************************************************/
109 void activateCB_filetype_icon (Widget wid, XtPointer client_data,
110                                DtIconCallbackStruct *cbs)
111 {
112   Time    lts, mct = 0;
113   static  Time prev_lts = 0;
114
115   if (cbs->reason == XmCR_ACTIVATE) {
116
117 #ifdef DEBUG
118     printf("In activate_filetype_icon callback.\n");
119 #endif
120     if (last_filetype_pushed && (last_filetype_pushed != wid)) {
121        XtVaSetValues(XtParent(last_filetype_pushed), XmNborderWidth, 0, NULL);
122     }
123     XtVaSetValues(XtParent(wid), XmNborderWidth, ICON_BORDER_WIDTH, NULL);
124
125     last_filetype_pushed = wid;
126
127     /********************************************************************/
128     /* This is the support needed to provide double-click functionality */
129     /* to the icon gadgets.  When double-clicked, the icon editor will  */
130     /* be launched.                                                     */
131     /********************************************************************/
132     XtVaSetValues(wid, XmNpushButtonClickTime, 0, NULL);
133
134     lts = XtLastTimestampProcessed(XtDisplay(wid));
135     mct = XtGetMultiClickTime(XtDisplay(wid));
136
137     if ((prev_lts + mct) > lts) {
138        prev_lts = XtLastTimestampProcessed(XtDisplay(wid));
139     } else {
140        prev_lts = XtLastTimestampProcessed(XtDisplay(wid));
141        return;
142     }
143
144 #ifdef DEBUG
145     printf("DblClick icon callback.\n");
146 #endif
147
148     activateCB_edit_icon(wid, CA_FILETYPE_ICONS, cbs);
149
150   }
151
152   return;
153 }
154
155 /******************************************************************************/
156 /*                                                                            */
157 /*   readAFFromGUI -                                                          */
158 /*                                                                            */
159 /*                                                                            */
160 /*                                                                            */
161 /******************************************************************************/
162 void readAFFromGUI (FiletypeData *pFiletypedata)
163 {
164   getAF_FiletypeName(pFiletypedata);
165   getAF_HelpText(pFiletypedata);
166   getAF_OpenCmd(pFiletypedata);
167   getAF_PrintCmd(pFiletypedata);
168   getAF_Icons(pFiletypedata);
169
170   return;
171 }
172
173 /******************************************************************************/
174 /*                                                                            */
175 /* getAF_FiletypeName - get name of filetype family                           */
176 /*                                                                            */
177 /* INPUT: FiletypeData *pFiletypedata - pointer to filetype data structure    */
178 /* OUTPUT: none                                                               */
179 /*                                                                            */
180 /******************************************************************************/
181 void getAF_FiletypeName (FiletypeData *pFiletypedata)
182 {
183   GetWidgetTextString(AF_FileTypeNameTextField, &(pFiletypedata->pszName));
184   return;
185 }
186
187 /******************************************************************************/
188 /*                                                                            */
189 /* getAF_HelpText - retrieve the Help text for the filetype                   */
190 /*                                                                            */
191 /* INPUT: FiletypeData *pFiletypedata - pointer to filetype data structure    */
192 /* OUTPUT: none                                                               */
193 /*                                                                            */
194 /******************************************************************************/
195 void getAF_HelpText (FiletypeData *pFiletypedata)
196 {
197   GetWidgetTextString(AF_FiletypeHelpText, &(pFiletypedata->pszHelp));
198   return;
199 }
200
201 /******************************************************************************/
202 /*                                                                            */
203 /* getAF_Icons - store temporary icon names.                                  */
204 /*                                                                            */
205 /* INPUT: FiletypeData *pFiletypedata - pointer to filetype data structure    */
206 /* OUTPUT: none                                                               */
207 /*                                                                            */
208 /******************************************************************************/
209 void getAF_Icons(FiletypeData *pFiletypedata)
210 {
211   IconData  *pIconData;
212
213   /***************************************************************/
214   /* Medium Pixmap                                               */
215   /***************************************************************/
216   pIconData = GetIconDataFromWid(AF_MED_IconGadget);
217   if ( (pIconData->pmDirtyBit) &&
218        (pIconData->pmFileName) &&
219        (strlen(pIconData->pmFileName)) ) {
220      pFiletypedata->pszMedPmIcon = XtMalloc(strlen(pIconData->pmFileName) + 1);
221      if (pFiletypedata->pszMedPmIcon) {
222         strcpy(pFiletypedata->pszMedPmIcon, pIconData->pmFileName);
223      }
224   }
225   pIconData->pmDirtyBit = False;
226   strcpy(pIconData->pmFileName, "");
227
228   /***************************************************************/
229   /* Medium Bitmap                                               */
230   /***************************************************************/
231   if ( (pIconData->bmDirtyBit) &&
232        (pIconData->bmFileName) &&
233        (strlen(pIconData->bmFileName)) ) {
234      pFiletypedata->pszMedBmIcon = XtMalloc(strlen(pIconData->bmFileName) + 1);
235      if (pFiletypedata->pszMedBmIcon) {
236         strcpy(pFiletypedata->pszMedBmIcon, pIconData->bmFileName);
237      }
238   }
239   pIconData->bmDirtyBit = False;
240   strcpy(pIconData->bmFileName, "");
241
242   /***************************************************************/
243   /* Tiny Pixmap                                                 */
244   /***************************************************************/
245   pIconData = GetIconDataFromWid(AF_TINY_IconGadget);
246   if ( (pIconData->pmDirtyBit) &&
247        (pIconData->pmFileName) &&
248        (strlen(pIconData->pmFileName)) ) {
249      pFiletypedata->pszTinyPmIcon = XtMalloc(strlen(pIconData->pmFileName) + 1);
250      if (pFiletypedata->pszTinyPmIcon) {
251         strcpy(pFiletypedata->pszTinyPmIcon, pIconData->pmFileName);
252      }
253   }
254   pIconData->pmDirtyBit = False;
255   strcpy(pIconData->pmFileName, "");
256
257   /***************************************************************/
258   /* Tiny Bitmap                                                 */
259   /***************************************************************/
260   if ( (pIconData->bmDirtyBit) &&
261        (pIconData->bmFileName) &&
262        (strlen(pIconData->bmFileName)) ) {
263      pFiletypedata->pszTinyBmIcon = XtMalloc(strlen(pIconData->bmFileName) + 1);
264      if (pFiletypedata->pszTinyBmIcon) {
265         strcpy(pFiletypedata->pszTinyBmIcon, pIconData->bmFileName);
266      }
267   }
268   pIconData->bmDirtyBit = False;
269   strcpy(pIconData->bmFileName, "");
270
271
272 #if 0
273   Widget    AF_wids[2];
274   int       i;
275
276
277   AF_wids[0] = AF_MED_IconGadget;
278   AF_wids[1] = AF_TINY_IconGadget;
279
280   for (i=0; i < 2; i++) {
281      /* pixmap */
282      pIconData = GetIconDataFromWid(AF_wids[i]);
283      if ( (pIconData->pmDirtyBit) &&
284           (pIconData->pmFileName) &&
285           (strlen(pIconData->pmFileName)) ) {
286         pFiletypedata->pszMedPmIcon = XtMalloc(strlen(pIconData->pmFileName) + 1);
287         if (pFiletypedata->pszMedPmIcon) {
288            strcpy(pFiletypedata->pszMedPmIcon, pIconData->pmFileName);
289         }
290      }
291      pIconData->pmDirtyBit = False;
292      strcpy(pIconData->pmFileName, "");
293
294      /* bitmap */
295      if ( (pIconData->bmDirtyBit) &&
296           (pIconData->bmFileName) &&
297           (strlen(pIconData->bmFileName)) ) {
298         pFiletypedata->pszMedBmIcon = XtMalloc(strlen(pIconData->bmFileName) + 1);
299         if (pFiletypedata->pszMedBmIcon) {
300            strcpy(pFiletypedata->pszMedBmIcon, pIconData->bmFileName);
301         }
302      }
303      pIconData->bmDirtyBit = False;
304      strcpy(pIconData->bmFileName, "");
305   }
306 #endif
307
308
309 }
310
311 /******************************************************************************/
312 /*                                                                            */
313 /* getAF_OpenCmd - retrieve the Open command string                           */
314 /*                                                                            */
315 /* INPUT: FiletypeData *pFiletypedata - pointer to filetype data structure    */
316 /* OUTPUT: none                                                               */
317 /*                                                                            */
318 /******************************************************************************/
319 void getAF_OpenCmd (FiletypeData *pFiletypedata)
320 {
321   GetWidgetTextString(AF_OpenCmdText, &(pFiletypedata->pszOpenCmd));
322   return;
323 }
324
325 /******************************************************************************/
326 /*                                                                            */
327 /* getAF_PrintCmd - retrieve Print command string                             */
328 /*                                                                            */
329 /* INPUT: FiletypeData *pFiletypedata - pointer to filetype data structure    */
330 /* OUTPUT: none                                                               */
331 /*                                                                            */
332 /******************************************************************************/
333 void getAF_PrintCmd (FiletypeData *pFiletypedata)
334 {
335   GetWidgetTextString(AF_FiletypePrintCmdTextField, &(pFiletypedata->pszPrintCmd));
336   return;
337 }
338
339 /******************************************************************************/
340 /*                                                                            */
341 /* init_AddFiletype_dialog_fields                                             */
342 /*                                                                            */
343 /* INPUT:  FiletypeData * - pointer to FiletypeData structure                 */
344 /* OUTPUT: none                                                               */
345 /*                                                                            */
346 /******************************************************************************/
347 void init_AddFiletype_dialog_fields(FiletypeData *pFtD)
348 {
349   char *pszIconFileName = (char *)NULL;
350   char *pszTmpFile;
351
352   if (pFtD->pszName) {
353      PutWidgetTextString(AF_FileTypeNameTextField, pFtD->pszName);
354   }
355
356   ParseAndUpdateID(pFtD);
357
358   if (pFtD->pszHelp) {
359      PutWidgetTextString(AF_FiletypeHelpText, pFtD->pszHelp);
360   }
361
362   if (pFtD->pszIcon) {
363
364      if (bShowPixmaps) {
365
366         /*************************/
367         /* Medium Pixmap         */
368         /*************************/
369         if (pFtD->pszMedPmIcon) {
370            SET_ICONGADGET_ICON(AF_MED_IconGadget, pFtD->pszMedPmIcon);
371         } else {
372            pszIconFileName = (char *)NULL;
373            FIND_ICONGADGET_ICON(pFtD->pszIcon, pszIconFileName, DtMEDIUM);
374            pszTmpFile = GetCorrectIconType(pszIconFileName);
375            SET_ICONGADGET_ICON(AF_MED_IconGadget, pszTmpFile);
376            if (pszIconFileName) XtFree(pszIconFileName);
377            if (pszTmpFile) XtFree(pszTmpFile);
378         }
379
380         /*************************/
381         /* Tiny Pixmap           */
382         /*************************/
383         if (pFtD->pszTinyPmIcon) {
384            SET_ICONGADGET_ICON(AF_TINY_IconGadget, pFtD->pszTinyPmIcon);
385         } else {
386            pszIconFileName = (char *)NULL;
387            FIND_ICONGADGET_ICON(pFtD->pszIcon, pszIconFileName, DtTINY);
388            pszTmpFile = GetCorrectIconType(pszIconFileName);
389            SET_ICONGADGET_ICON(AF_TINY_IconGadget, pszTmpFile);
390            if (pszIconFileName) XtFree(pszIconFileName);
391            if (pszTmpFile) XtFree(pszTmpFile);
392         }
393      } else {
394         /*************************/
395         /* Medium Pixmap         */
396         /*************************/
397         if (pFtD->pszMedBmIcon) {
398            SET_ICONGADGET_ICON(AF_MED_IconGadget, pFtD->pszMedBmIcon);
399         } else {
400            pszIconFileName = (char *)NULL;
401            FIND_ICONGADGET_ICON(pFtD->pszIcon, pszIconFileName, DtMEDIUM);
402            pszTmpFile = GetCorrectIconType(pszIconFileName);
403            SET_ICONGADGET_ICON(AF_MED_IconGadget, pszTmpFile);
404            if (pszIconFileName) XtFree(pszIconFileName);
405            if (pszTmpFile) XtFree(pszTmpFile);
406         }
407
408         /*************************/
409         /* Tiny Pixmap           */
410         /*************************/
411         if (pFtD->pszTinyBmIcon) {
412            SET_ICONGADGET_ICON(AF_TINY_IconGadget, pFtD->pszTinyBmIcon);
413         } else {
414            pszIconFileName = (char *)NULL;
415            FIND_ICONGADGET_ICON(pFtD->pszIcon, pszIconFileName, DtTINY);
416            pszTmpFile = GetCorrectIconType(pszIconFileName);
417            SET_ICONGADGET_ICON(AF_TINY_IconGadget, pszTmpFile);
418            if (pszIconFileName) XtFree(pszIconFileName);
419            if (pszTmpFile) XtFree(pszTmpFile);
420         }
421      }
422
423
424 #if 0
425         /*************************/
426         /* Tiny Pixmap           */
427         /*************************/
428         pszIconFileName = (char *)NULL;
429         if (pFtD->pszTinyPmIcon) {
430            pszTmpFile = pFtD->pszTinyPmIcon;
431         } else {
432            FIND_ICONGADGET_ICON(pFtD->pszIcon, pszIconFileName, DtTINY);
433            pszTmpFile = pszIconFileName;
434         }
435         SET_ICONGADGET_ICON(AF_TINY_IconGadget, pszTmpFile);
436         if (pszIconFileName) XtFree(pszIconFileName);
437
438      } else {
439
440         /*************************/
441         /* Medium Bitmap         */
442         /*************************/
443         pszIconFileName = (char *)NULL;
444         if (pFtD->pszMedBmIcon) {
445            pszTmpFile = pFtD->pszMedBmIcon;
446         } else {
447            FIND_ICONGADGET_ICON(pFtD->pszIcon, pszIconFileName, DtMEDIUM);
448            pszTmpFile = pszIconFileName;
449         }
450         SET_ICONGADGET_ICON(AF_MED_IconGadget, pszTmpFile);
451         if (pszIconFileName) XtFree(pszIconFileName);
452
453         /*************************/
454         /* Tiny Bitmap           */
455         /*************************/
456         pszIconFileName = (char *)NULL;
457         if (pFtD->pszTinyBmIcon) {
458            pszTmpFile = pFtD->pszTinyBmIcon;
459         } else {
460            FIND_ICONGADGET_ICON(pFtD->pszIcon, pszIconFileName, DtTINY);
461            pszTmpFile = pszIconFileName;
462         }
463         SET_ICONGADGET_ICON(AF_TINY_IconGadget, pszTmpFile);
464         if (pszIconFileName) XtFree(pszIconFileName);
465      }
466 #endif
467
468   }
469
470   if (pFtD->pszOpenCmd) {
471      PutWidgetTextString(AF_OpenCmdText, pFtD->pszOpenCmd);
472   }
473   if (pFtD->pszPrintCmd) {
474      PutWidgetTextString(AF_FiletypePrintCmdTextField, pFtD->pszPrintCmd);
475   }
476
477   return;
478 }
479
480 /******************************************************************************/
481 /*                                                                            */
482 /* clear_AddFiletype_dialog_fields                                            */
483 /*                                                                            */
484 /* INPUT:  FiletypeData * - pointer to FiletypeData structure                 */
485 /* OUTPUT: none                                                               */
486 /*                                                                            */
487 /******************************************************************************/
488 void clear_AddFiletype_dialog_fields(void)
489 {
490   /*char pszFile[MAXBUFSIZE];*/
491
492   clear_text(AF_FileTypeNameTextField);
493   clear_text(AF_IdCharacteristicsText);
494   clear_text(AF_FiletypeHelpText);
495   createCB_IconGadget(AF_MED_IconGadget, FALSE, Medium_Icon);
496   createCB_IconGadget(AF_TINY_IconGadget, FALSE, Tiny_Icon);
497   /*
498   SET_ICONGADGET_ICON_AND_EXT(AF_MED_IconGadget, af_med_icon_default, pszFile);
499   SET_ICONGADGET_ICON_AND_EXT(AF_TINY_IconGadget, af_tiny_icon_default, pszFile);
500   */
501   clear_text(AF_OpenCmdText);
502   clear_text(AF_FiletypePrintCmdTextField);
503
504   return;
505 }
506
507 /******************************************************************************/
508 /*                                                                            */
509 /* free_Filetypedata                                                          */
510 /*                                                                            */
511 /* INPUT:  FiletypeData * - pointer to FiletypeData structure                 */
512 /* OUTPUT: none                                                               */
513 /*                                                                            */
514 /******************************************************************************/
515 void free_Filetypedata(FiletypeData *pFtD)
516 {
517   char buffer[MAXFILENAME];
518
519 #ifdef DEBUG
520   printf("Free FiletypeData structure\n"); /* debug */
521 #endif
522
523   if (pFtD->pszName) XtFree(pFtD->pszName);
524 #if DEBUG
525   printf("Freed Name\n");
526 #endif
527
528   if (pFtD->pszIcon) XtFree(pFtD->pszIcon);
529   if (pFtD->pszMedPmIcon) {
530 #if DEBUG
531      printf("free_Filetypedata: unlink '%s'\n", pFtD->pszMedPmIcon);  /* debug */
532 #endif
533      unlink(pFtD->pszMedPmIcon);
534      XtFree(pFtD->pszMedPmIcon);
535   }
536   if (pFtD->pszMedBmIcon) {
537 #if DEBUG
538      printf("free_Filetypedata: unlink '%s'\n", pFtD->pszMedBmIcon);  /* debug */
539 #endif
540      unlink(pFtD->pszMedBmIcon);
541      /**** remove the mask if it exists ****/
542      sprintf(buffer, "%s_m", pFtD->pszMedBmIcon);
543      unlink(buffer);
544      XtFree(pFtD->pszMedBmIcon);
545   }
546   if (pFtD->pszTinyPmIcon) {
547 #if DEBUG
548      printf("free_Filetypedata: unlink '%s'\n", pFtD->pszTinyPmIcon);  /* debug */
549 #endif
550      unlink(pFtD->pszTinyPmIcon);
551      XtFree(pFtD->pszTinyPmIcon);
552   }
553   if (pFtD->pszTinyBmIcon) {
554 #if DEBUG
555      printf("free_Filetypedata: unlink '%s'\n", pFtD->pszTinyBmIcon);  /* debug */
556 #endif
557      unlink(pFtD->pszTinyBmIcon);
558      /**** remove the mask if it exists ****/
559      sprintf(buffer, "%s_m", pFtD->pszTinyBmIcon);
560      unlink(buffer);
561      XtFree(pFtD->pszTinyBmIcon);
562   }
563
564   if (pFtD->pszHelp) XtFree(pFtD->pszHelp);
565   if (pFtD->pszOpenCmd) XtFree(pFtD->pszOpenCmd);
566   if (pFtD->pszPrintCmd) XtFree(pFtD->pszPrintCmd);
567   if (pFtD->pszPattern) XtFree(pFtD->pszPattern);
568   if (pFtD->pszPermissions) XtFree(pFtD->pszPermissions);
569   if (pFtD->pszContents) XtFree(pFtD->pszContents);
570   XtFree((char *) pFtD);
571   return;
572 }
573
574 /******************************************************************************/
575 /*                                                                            */
576 /* AddFiletypeToList                                                          */
577 /*                                                                            */
578 /* INPUT:  none                                                               */
579 /* OUTPUT: none                                                               */
580 /*                                                                            */
581 /******************************************************************************/
582 void AddFiletypeToList(void)
583 {
584   if (!XmListItemExists(CA_FiletypesList, XmStringCreateSimple(XmTextFieldGetString(AF_FileTypeNameTextField)))) {
585     XmListAddItem(CA_FiletypesList, XmStringCreateSimple(XmTextFieldGetString(AF_FileTypeNameTextField)), 0);
586   }
587 }
588
589 /******************************************************************************/
590 /*                                                                            */
591 /* UpdateFiletypeDataArray                                                    */
592 /*                                                                            */
593 /* INPUT:  none                                                               */
594 /* OUTPUT: none                                                               */
595 /*                                                                            */
596 /******************************************************************************/
597 void UpdateFiletypeDataArray(FiletypeData *pFtD)
598 {
599   FiletypeData  **papArray;
600   int           i;
601
602   /**************************************************************************/
603   /* Add this structure to the filetype array in the ActionData structure.  */
604   /**************************************************************************/
605   papArray = (FiletypeData **) XtMalloc(sizeof(FiletypeData *) * (AD.cFiletypes + 1));
606   for (i=0; i < AD.cFiletypes; i++) {
607      papArray[i] = AD.papFiletypes[i];
608   }
609   papArray[AD.cFiletypes] = pFtD;
610   if (AD.papFiletypes) {
611     XtFree((char *) AD.papFiletypes);
612   }
613   AD.papFiletypes = papArray;
614   AD.cFiletypes++;
615 }
616
617 /******************************************************************************/
618 /*                                                                            */
619 /* AddFiletypeCheckFields                                                     */
620 /*                                                                            */
621 /* INPUT:  none                                                               */
622 /* OUTPUT: FALSE  - no errors found                                           */
623 /*         TRUE   - found errors                                              */
624 /*                                                                            */
625 /******************************************************************************/
626 Boolean AddFiletypeCheckFields(void)
627 {
628
629   char    *ptr = (char *)NULL;
630   Boolean bError = FALSE;
631   char    *msgPtr, *errPtr;
632
633   /**************************************************************************/
634   /* Check if filetype name is present.                                     */
635   /**************************************************************************/
636   if (!bError) {
637      ptr = (char *)NULL;
638      GetWidgetTextString(AF_FileTypeNameTextField, &ptr);
639 #ifdef DEBUG
640      printf("Filetype Family Name = '%s'\n", ptr);
641 #endif
642      if (!ptr) {
643         msgPtr = GETMESSAGE(8, 10, "The Datatype Family Name is missing.\n\
644 Enter a name in the 'Name of Datatype Family' field.");
645         errPtr = XtNewString(msgPtr);
646         display_error_message(AddFiletype, errPtr);
647         XtFree(errPtr);
648         XmProcessTraversal(AF_FileTypeNameTextField, XmTRAVERSE_CURRENT);
649         bError = TRUE;
650      } else {
651         XtFree(ptr);
652      }
653   }
654
655   /**************************************************************************/
656   /* Check if identifying characteristics are present.                      */
657   /**************************************************************************/
658   if (!bError) {
659      ptr = (char *)NULL;
660      GetWidgetTextString(AF_IdCharacteristicsText, &ptr);
661 #ifdef DEBUG
662      printf("Identifying Chars = '%s'\n", ptr);
663 #endif
664      if (!ptr) {
665         msgPtr = GETMESSAGE(8, 15,
666              "The Identifying Characteristics are missing.\n\
667 You must specify the characteristics before the datatype\n\
668 can be created. Select the Edit button next to the\n\
669 Identifying Characteristics list to specify the characteristics.");
670         errPtr = XtNewString(msgPtr);
671         display_error_message(AddFiletype, errPtr);
672         XtFree(errPtr);
673         XmProcessTraversal(AF_IdCharacteristicsEdit, XmTRAVERSE_CURRENT);
674         bError = TRUE;
675      } else {
676         XtFree(ptr);
677      }
678   }
679
680   return(bError);
681 }
682