MsgLogO.sgm 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <!-- $XConsortium: MsgLogO.sgm /main/9 1996/10/25 10:36:30 cdedoc $ -->
  2. <!-- (c) Copyright 1996 Digital Equipment Corporation. -->
  3. <!-- (c) Copyright 1996 Hewlett-Packard Company. -->
  4. <!-- (c) Copyright 1996 International Business Machines Corp. -->
  5. <!-- (c) Copyright 1996 Sun Microsystems, Inc. -->
  6. <!-- (c) Copyright 1996 Novell, Inc. -->
  7. <!-- (c) Copyright 1996 FUJITSU LIMITED. -->
  8. <!-- (c) Copyright 1996 Hitachi. -->
  9. <![ %CDE.C.CDE; [<refentry id="CDE.MSG.DtMsgLogOpenFile">]]>
  10. <![ %CDE.C.XO; [<refentry id="XCSA.MSG.DtMsgLogOpenFile">]]>
  11. <refmeta><refentrytitle>
  12. DtMsgLogOpenFile
  13. </refentrytitle><manvolnum>library call</manvolnum></refmeta><refnamediv>
  14. <refname><function>DtMsgLogOpenFile</function></refname><refpurpose>
  15. opens a log file
  16. </refpurpose></refnamediv><refsynopsisdiv>
  17. <funcsynopsis>
  18. <funcsynopsisinfo>#include &lt;Dt/MsgLog.h></funcsynopsisinfo>
  19. <funcdef>FILE* <function>DtMsgLogOpenFile</function></funcdef>
  20. <paramdef>const char* <parameter>type</parameter></paramdef>
  21. <paramdef>char** <parameter>filename_return</parameter></paramdef>
  22. </funcsynopsis>
  23. </refsynopsisdiv><refsect1>
  24. <title>DESCRIPTION</title>
  25. <para>The <function>DtMsgLogOpenFile</function> function
  26. calls <function>fopen</function> to open a log file
  27. with type <literal>open</literal> mode. If <function>fopen</function> opens
  28. a log file successfully and returns a non-NULL
  29. <symbol role="Variable">filename_return</symbol>,
  30. <function>DtMsgLogOpenFile</function> calls
  31. <function>malloc</function> to allocate space for
  32. <symbol role="Variable">filename_return</symbol>.
  33. <function>DtMsgLogOpenFile</function> then copies the
  34. log file name to
  35. <symbol role="Variable">filename_return</symbol>.
  36. </para>
  37. <para>The caller must use the <function>free</function> function to release the
  38. space allocated for <symbol role="Variable">filename_return</symbol>,
  39. if it is not NULL. The caller must also close the file pointer
  40. returned by <function>DtMsgLogOpenFile</function>. Use
  41. caution in doing this because stderr may be returned.
  42. </para>
  43. <para>For a description of the algorithm used to determine the log file to open,
  44. see &cdeman.DtMsgLogMessage;. Note that if a log file cannot
  45. be opened, <symbol role="Variable">filename_return</symbol> will be set to NULL.
  46. </para>
  47. </refsect1><refsect1>
  48. <title>ARGUMENTS</title>
  49. <variablelist>
  50. <varlistentry><term><symbol role="Variable">type</symbol></term>
  51. <listitem>
  52. <para>Specifies the file open flag. See
  53. <function>fopen</function>(3) for more information.
  54. </para>
  55. </listitem>
  56. </varlistentry>
  57. <varlistentry><term><symbol role="Variable">filename_return</symbol></term>
  58. <listitem>
  59. <para>Specifies the variable to receive the returned log file name.
  60. </para>
  61. </listitem>
  62. </varlistentry>
  63. </variablelist>
  64. </refsect1><refsect1>
  65. <title>ENVIRONMENT VARIABLES</title>
  66. <para>None.
  67. </para>
  68. </refsect1><refsect1>
  69. <title>RESOURCES</title>
  70. <para>None.</para>
  71. </refsect1><refsect1>
  72. <title>ACTIONS/MESSAGES</title>
  73. <para>None.
  74. </para>
  75. </refsect1><refsect1>
  76. <title>ERRORS/WARNINGS</title>
  77. <para>None.</para>
  78. </refsect1><refsect1>
  79. <title>EXAMPLES</title>
  80. <para>The following code fragment opens the log file,
  81. logs the log file name, closes the file, and frees
  82. the space allocated for the file name.
  83. </para>
  84. <programlisting>
  85. char * log_file;
  86. FILE * fp = DtMsgLogOpenFile ("a+", &amp;log_file);
  87. if (log_file) {
  88. DtMsgLogMessage (argv[0], DtMsgLogInformation,
  89. "The log file name is: %s", log_file);
  90. free (log_file);
  91. }
  92. if (fp &amp;&amp; fp != stderr)
  93. fclose (fp);
  94. </programlisting>
  95. </refsect1><refsect1>
  96. <title>RETURN VALUE</title>
  97. <para>If <function>DtMsgLogMessage</function> completes
  98. successfully, it returns a pointer to the opened log file.
  99. If it cannot open a log file, it returns stderr.
  100. </para>
  101. </refsect1><refsect1>
  102. <title>FILES</title>
  103. <para>None.
  104. </para>
  105. </refsect1><refsect1>
  106. <title>SEE ALSO</title>
  107. <para>&cdeman.DtMsgLogMessage;,
  108. &cdeman.DtMsgLogSetHandler;</para>
  109. </refsect1></refentry>