HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_SysSpecific.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * Authored by:
7  * Chris Thompson
8  * Side Effects Software Inc.
9  *
10  * NAME: UT_SysSpecific.h (Utility Library, C++)
11  *
12  * COMMENTS: Functions related to operating-system specific
13  * preferences, defaults, helper applications, etc.
14  * The difference between this file and UT_SysClone
15  * is that that one simply replaces SGI system calls with
16  * custom calls of the same name, while SysSpecific is a true
17  * wrapper that hides even the system call name under a "UT"-
18  * prefixed name.
19  *
20  */
21 
22 #ifndef __UT_SysSpecific_h__
23 #define __UT_SysSpecific_h__
24 
25 #include "UT_API.h"
26 #include <SYS/SYS_Platform.h>
27 #include <stdlib.h>
28 #include <stdarg.h>
29 #include <stdio.h>
30 #include <string>
31 
32 class UT_String;
33 
34 // Returns the name of the user's text editor.
35 // (This is determined by the EDITOR environment variable;
36 // a system-appropriate default editor is chosen if EDITOR
37 // is not set.)
38 // Do not free() or delete[] the returned pointer.
39 UT_API extern const char *UTgetTextEditor(bool &is_graphical);
40 
41 UT_API extern void UTinvokeTextEditor(
42  const char *file_to_edit,
43  bool blocking,
44  const char *title);
45 
46 UT_API extern bool UTopenShell(bool blocking, const char *title);
47 
48 UT_API extern bool UTrunTextProgram(
49  const char *command_line,
50  bool blocking,
51  const char *title);
52 
53 UT_API extern bool UTrunGraphicalProgram(
54  const char *command_line,
55  bool blocking,
56  const char *title);
57 
58 // 'in_shell' causes command_line to be executed in csh on NT, instead of the
59 // brain-dead command prompt (which doesn't support I/O redirection & such).
60 // It has no effect on other UNIX based OSes.
61 UT_API extern int UTsystem(const char *command_line, bool in_shell = false);
62 
63 // Starts an external web browser and opens a URL.
64 UT_API extern void UTopenURLInWebBrowser( const char * url );
65 
66 // Starts an external process to open a directory,
67 // optionally with a file selected.
68 UT_API extern void UTopenInFileBrowser(const char *file_path);
69 UT_API extern void UTopenInFileBrowser(const char *directory_path,
70  const char *selected_file);
71 
72 UT_API extern void UTgetProcessor(int &majortype, int &flags);
73 
74 // Gets OS_PROC
75 static inline const char *UTgetOsProc() { return SYSgetOsProc(); }
76 
77 // Sets name to a hardened version of the users name, ie: "jlait".
78 // If alphaonly is set, it will munge the user name to be something
79 // with no spaces by adding _, etc.
80 // Defaults to login name, but can be overridden.
81 UT_API extern void UTgetUserName(UT_String &name, int alphaonly = 1);
82 
83 // you@machine
84 // The machine defaults to your host name, but can be overridden
85 UT_API extern void UTgetMachineName(UT_String &name, int alphaonly = 1);
86 
87 // machine
88 // The machine defaults to your host name, but can be overridden
89 UT_API extern void UTgetUserMachineName(UT_String &name, int alphaonly = 1);
90 
91 UT_API extern void UTdisplayMessageWindow(const char *message_text,
92  const char *message_title = "Houdini Error");
93 UT_API extern void UTdisplayMessageWindowWithHelpURL(const char *message_text,
94  const char *help_url,
95  const char *message_title = "Houdini Error");
96 UT_API extern bool UTdisplayConfirmationWindow(const char *message_text,
97  const char *message_title = "Houdini");
98 
99 static inline int
100 UTvsnprintf(char *str, size_t size, const char *format, va_list ap)
101 {
102  // Windows prefixes vsnprintf with an underscore for some reason.
103 #ifdef WIN32
104  return _vsnprintf(str, size, format, ap);
105 #else
106  int result;
107  va_list ap_copy;
108 
109  // We need to make a copy of the argument pointer in case we
110  // have to call UTvsnprintf multiple times. It is generally not safe to
111  // re-use the same va_list in multiple calls. Reusing the same va_list
112  // caused a crash on a 64 bit Linux machine compiled with gcc 3.4.
113  // va_copy only became standard with C99 and is currently not supported
114  // on Windows.
115  va_copy(ap_copy, ap);
116  result = vsnprintf(str, size, format, ap_copy);
117  va_end(ap_copy);
118  return result;
119 #endif
120 }
121 
122 UT_API extern std::string
124 
125 #define UTstatic_cast(Type, Data) static_cast<Type>(Data)
126 
127 #endif // __UT_SysSpecific_h__
UT_API const char * UTgetTextEditor(bool &is_graphical)
UT_API bool UTrunTextProgram(const char *command_line, bool blocking, const char *title)
UT_API void UTgetMachineName(UT_String &name, int alphaonly=1)
UT_API int UTsystem(const char *command_line, bool in_shell=false)
UT_API void UTgetProcessor(int &majortype, int &flags)
#define UT_API
Definition: UT_API.h:14
GLuint const GLchar * name
Definition: glcorearb.h:786
UT_API void UTgetUserMachineName(UT_String &name, int alphaonly=1)
UT_API bool UTopenShell(bool blocking, const char *title)
GLsizeiptr size
Definition: glcorearb.h:664
UT_API void UTopenInFileBrowser(const char *file_path)
UT_API std::string UTunmangleClassNameFromTypeIdName(const std::string &name)
UT_API bool UTdisplayConfirmationWindow(const char *message_text, const char *message_title="Houdini")
UT_API void UTdisplayMessageWindowWithHelpURL(const char *message_text, const char *help_url, const char *message_title="Houdini Error")
GLsizei const GLchar *const * string
Definition: glcorearb.h:814
UT_API void UTopenURLInWebBrowser(const char *url)
SYS_API const char * SYSgetOsProc()
Find the name of the operating system that Houdini was compiled for.
GLbitfield flags
Definition: glcorearb.h:1596
UT_API void UTinvokeTextEditor(const char *file_to_edit, bool blocking, const char *title)
UT_API bool UTrunGraphicalProgram(const char *command_line, bool blocking, const char *title)
GLint GLint GLsizei GLint GLenum format
Definition: glcorearb.h:108
UT_API void UTdisplayMessageWindow(const char *message_text, const char *message_title="Houdini Error")
UT_API void UTgetUserName(UT_String &name, int alphaonly=1)