home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / xfe / XfeWidgets / Xfe / Debug.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  3.9 KB  |  177 lines

  1. /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18. /*-----------------------------------------*/
  19. /*                                                                        */
  20. /* Name:        <Xfe/Debug.c>                                            */
  21. /* Description:    Xfe widgets functions for debugging.                    */
  22. /* Author:        Ramiro Estrugo <ramiro@netscape.com>                    */
  23. /*                                                                        */
  24. /*----------------------------------------------------------------------*/
  25.  
  26.  
  27. #ifdef DEBUG                                    /* ifdef DEBUG            */
  28.  
  29. #include <stdlib.h>
  30. #include <ctype.h>
  31.  
  32. #include <Xfe/XfeP.h>
  33. #include <Xm/RepType.h>
  34.  
  35. /*----------------------------------------------------------------------*/
  36. /* extern */ String
  37. XfeDebugXmStringToStaticPSZ(XmString xmstring)
  38. {
  39.     static char buf[2048];
  40.     String        psz_string;
  41.  
  42.     buf[0] = '\0';
  43.  
  44.     if (xmstring)
  45.     {
  46.         psz_string = XfeXmStringGetPSZ(xmstring,XmFONTLIST_DEFAULT_TAG);
  47.  
  48.         if (psz_string)
  49.         {
  50.             strcpy(buf,psz_string);
  51.  
  52.             XtFree(psz_string);
  53.         }
  54.     }
  55.  
  56.     return buf;
  57. }
  58. /*----------------------------------------------------------------------*/
  59. /* extern */ void
  60. XfeDebugPrintArgVector(FILE *        fp,
  61.                        String        prefix,
  62.                        String        suffix,
  63.                        ArgList        av,
  64.                        Cardinal        ac)
  65. {
  66.     Cardinal i;
  67.  
  68.     for(i = 0; i < ac; i++)
  69.     {
  70.         fprintf(fp,"%s: av[%d] = '%s'%s",
  71.                 prefix,
  72.                 i,
  73.                 av[i].name,
  74.                 suffix);
  75.     }
  76. }
  77. /*----------------------------------------------------------------------*/
  78. /* extern */ String
  79. XfeDebugRepTypeValueToName(String rep_type,unsigned char value)
  80. {
  81.     char * result = NULL;
  82.  
  83.     if (rep_type)
  84.     {
  85.         XmRepTypeId id = XmRepTypeGetId(rep_type);
  86.  
  87.         if (id != XmREP_TYPE_INVALID)
  88.         {
  89.             XmRepTypeEntry entry = XmRepTypeGetRecord(id);
  90.  
  91.             if (entry)
  92.             {
  93.                 Cardinal i = 0;
  94.  
  95.                 while ((i < entry->num_values) && !result)
  96.                 {
  97.                     if (entry->values[i] == value)
  98.                     {
  99.                         result = XtNewString(entry->value_names[i]);
  100.                     }
  101.  
  102.                     i++;
  103.                 }
  104.  
  105.                  XtFree((char *) entry);
  106.             }
  107.         }
  108.     }
  109.     
  110.     return result;
  111. }
  112. /*----------------------------------------------------------------------*/
  113. /* extern */ unsigned char
  114. XfeDebugRepTypeNameToValue(String rep_type,String name)
  115. {
  116.     unsigned char result = 99;
  117.     Boolean found = False;
  118.  
  119.     if (rep_type)
  120.     {
  121.         XmRepTypeId id = XmRepTypeGetId(rep_type);
  122.  
  123.         if (id != XmREP_TYPE_INVALID)
  124.         {
  125.             XmRepTypeEntry entry = XmRepTypeGetRecord(id);
  126.  
  127.             if (entry)
  128.             {
  129.                 Cardinal i = 0;
  130.  
  131.                 while ((i < entry->num_values) && !found)
  132.                 {
  133.                     if (strcmp(entry->value_names[i],name) == 0)
  134.                     {
  135.                         result = entry->values[i];
  136.                         found = True;
  137.                     }
  138.  
  139.                     i++;
  140.                 }
  141.  
  142.                  XtFree((char *) entry);
  143.             }
  144.         }
  145.     }
  146.     
  147.     return result;
  148. }
  149. /*----------------------------------------------------------------------*/
  150. /* extern */ unsigned char
  151. XfeDebugRepTypeIndexToValue(String rep_type,Cardinal i)
  152. {
  153.     unsigned char result = 99;
  154.  
  155.     if (rep_type)
  156.     {
  157.         XmRepTypeId id = XmRepTypeGetId(rep_type);
  158.  
  159.         if (id != XmREP_TYPE_INVALID)
  160.         {
  161.             XmRepTypeEntry entry = XmRepTypeGetRecord(id);
  162.  
  163.             if (entry)
  164.             {
  165.                 result = entry->values[i];
  166.  
  167.                  XtFree((char *) entry);
  168.             }
  169.         }
  170.     }
  171.     
  172.     return result;
  173. }
  174. /*----------------------------------------------------------------------*/
  175.  
  176. #endif                                            /* endif DEBUG            */
  177.