tttrace_objs.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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 libraries 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. /*%% (c) Copyright 1993, 1994 Hewlett-Packard Company */
  24. /*%% (c) Copyright 1993, 1994 International Business Machines Corp. */
  25. /*%% (c) Copyright 1993, 1994 Sun Microsystems, Inc. */
  26. /*%% (c) Copyright 1993, 1994 Novell, Inc. */
  27. /*%% $XConsortium: tttrace_objs.h /main/3 1995/10/20 17:02:51 rswiston $ */
  28. /*
  29. * @(#)tttrace_objs.h 1.2 93/11/04
  30. *
  31. * Copyright (c) 1993 by Sun Microsystems, Inc.
  32. */
  33. #include "util/tt_string.h"
  34. #define NO_FORM 0
  35. #define NOSCRIPT_FORM 1
  36. #define SCRIPT_FORM 2
  37. #define FORK_COMMAND 0
  38. #define SESSION_TRACE 1
  39. #define MAXARGS 256
  40. #define argstr "0FCao:e:f:S:"
  41. class _Tt_trace_optobj : public _Tt_object {
  42. public:
  43. // If msg_tracing is 0, only do client tracing. If 1, then
  44. // do message and client tracing
  45. int msg_tracing();
  46. // If follow is 1, then trace all children forked
  47. int follow();
  48. // If api_calls is 1, trace client calls into the TT API
  49. int api_calls();
  50. // if all_attrs is 1, use long form
  51. int all_attrs();
  52. // if script returns 1, there is a script specified, and
  53. // the text of the script will be in script_string.
  54. // if script returns 2, the script is a filename
  55. int script(_Tt_string& script_string);
  56. // if outfile returns 1, there is an outfile specified, and
  57. // its value will be in filename
  58. int outfile(_Tt_string& filename);
  59. // if session returns 1, there is a session specified, and
  60. // its value will be in session_string
  61. int session(_Tt_string& session_string);
  62. // if command returns 1, there is a command specified, and
  63. // its value will be in command_string
  64. int command(_Tt_string& command_string);
  65. // argv for command
  66. char** cargv();
  67. // envstr returns a string suitable for putenv(), which is
  68. // used if a command is forked
  69. _Tt_string envstr();
  70. // Name of named pipe returned by tempnam
  71. _Tt_string& pipe_name();
  72. // constructor
  73. _Tt_trace_optobj();
  74. // do command-line processing
  75. int getopts(int argc, char** argv);
  76. // tttrace operates in two rundamental modes:
  77. // - fork command, using specified script or script file,
  78. // or command-line args as the script
  79. // - send session_trace requests, using specified script or script file
  80. int operation_mode();
  81. private:
  82. int _form; // discriminates allowed options
  83. int _msg_tracing;
  84. int _follow;
  85. int _api_calls;
  86. int _all_attrs;
  87. int _has_script_inline;
  88. int _has_script_filename;
  89. _Tt_string _inline_or_filename;
  90. int _has_outfile;
  91. _Tt_string _outfile;
  92. int _has_session;
  93. _Tt_string _session;
  94. int _has_command;
  95. _Tt_string _command;
  96. char* _cargv[MAXARGS];
  97. _Tt_string _envstr;
  98. _Tt_string _pipenm;
  99. int mkenvstr(); // makes string for putenv();
  100. };