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 UT_API extern void UTgetProcessor(int &majortype, int &flags);
67 
68 // Gets OS_PROC
69 static inline const char *UTgetOsProc() { return SYSgetOsProc(); }
70 
71 // Sets name to a hardened version of the users name, ie: "jlait".
72 // If alphaonly is set, it will munge the user name to be something
73 // with no spaces by adding _, etc.
74 // Defaults to login name, but can be overridden.
75 UT_API extern void UTgetUserName(UT_String &name, int alphaonly = 1);
76 
77 // you@machine
78 // The machine defaults to your host name, but can be overridden
79 UT_API extern void UTgetMachineName(UT_String &name, int alphaonly = 1);
80 
81 // machine
82 // The machine defaults to your host name, but can be overridden
83 UT_API extern void UTgetUserMachineName(UT_String &name, int alphaonly = 1);
84 
85 UT_API extern void UTdisplayMessageWindow(const char *message_text,
86  const char *message_title = "Houdini Error");
87 UT_API extern void UTdisplayMessageWindowWithHelpURL(const char *message_text,
88  const char *help_url,
89  const char *message_title = "Houdini Error");
90 UT_API extern bool UTdisplayConfirmationWindow(const char *message_text,
91  const char *message_title = "Houdini");
92 
93 static inline int
94 UTvsnprintf(char *str, size_t size, const char *format, va_list ap)
95 {
96  // Windows prefixes vsnprintf with an underscore for some reason.
97 #ifdef WIN32
98  return _vsnprintf(str, size, format, ap);
99 #else
100  int result;
101  va_list ap_copy;
102 
103  // We need to make a copy of the argument pointer in case we
104  // have to call UTvsnprintf multiple times. It is generally not safe to
105  // re-use the same va_list in multiple calls. Reusing the same va_list
106  // caused a crash on a 64 bit Linux machine compiled with gcc 3.4.
107  // va_copy only became standard with C99 and is currently not supported
108  // on Windows.
109  va_copy(ap_copy, ap);
110  result = vsnprintf(str, size, format, ap_copy);
111  va_end(ap_copy);
112  return result;
113 #endif
114 }
115 
116 UT_API extern std::string
118 
119 #define UTstatic_cast(Type, Data) static_cast<Type>(Data)
120 
121 #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)
GLsizeiptr size
Definition: glew.h:1681
GLuint const GLchar * name
Definition: glew.h:1814
UT_API void UTgetMachineName(UT_String &name, int alphaonly=1)
UT_API int UTsystem(const char *command_line, bool in_shell=false)
GLenum GLsizei GLsizei GLsizei GLsizei GLbitfield flags
Definition: glew.h:2864
UT_API void UTgetProcessor(int &majortype, int &flags)
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: glew.h:1254
#define UT_API
Definition: UT_API.h:13
UT_API void UTgetUserMachineName(UT_String &name, int alphaonly=1)
UT_API bool UTopenShell(bool blocking, const char *title)
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")
UT_API void UTopenURLInWebBrowser(const char *url)
SYS_API const char * SYSgetOsProc()
Find the name of the operating system that Houdini was compiled for.
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)
GLsizei const GLchar *const * string
Definition: glew.h:1844
UT_API void UTdisplayMessageWindow(const char *message_text, const char *message_title="Houdini Error")
GLuint64EXT * result
Definition: glew.h:14007
UT_API void UTgetUserName(UT_String &name, int alphaonly=1)