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