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 class UT_StringHolder;
34 
35 // Returns the name of the user's text editor.
36 // (This is determined by the EDITOR environment variable;
37 // a system-appropriate default editor is chosen if EDITOR
38 // is not set.)
39 // Do not free() or delete[] the returned pointer.
40 UT_API extern const char *UTgetTextEditor(bool &is_graphical);
41 
42 UT_API extern void UTinvokeTextEditor(
43  const char *file_to_edit,
44  bool blocking,
45  const char *title);
46 
47 UT_API extern bool UTopenShell(bool blocking, const char *title);
48 
49 UT_API extern bool UTrunTextProgram(
50  const char *command_line,
51  bool blocking,
52  const char *title);
53 
54 UT_API extern bool UTrunGraphicalProgram(
55  const char *command_line,
56  bool blocking,
57  const char *title);
58 
59 // 'in_shell' causes command_line to be executed in csh on NT, instead of the
60 // brain-dead command prompt (which doesn't support I/O redirection & such).
61 // It has no effect on other UNIX based OSes.
62 UT_API extern int UTsystem(const char *command_line, bool in_shell = false);
63 
64 // Starts an external web browser and opens a URL.
65 UT_API extern void UTopenURLInWebBrowser( const char * url );
66 
67 // Starts an external process to open a directory,
68 // optionally with a file selected.
69 UT_API extern void UTopenInFileBrowser(const char *file_path);
70 UT_API extern void UTopenInFileBrowser(const char *directory_path,
71  const char *selected_file);
72 
73 UT_API extern void UTgetProcessor(int &majortype, int &flags);
74 
75 // Gets OS_PROC
76 static inline const char *UTgetOsProc() { return SYSgetOsProc(); }
77 
78 // Sets name to a hardened version of the users name, ie: "jlait".
79 // If alphaonly is set, it will munge the user name to be something
80 // with no spaces by adding _, etc.
81 // Defaults to login name, but can be overridden.
82 UT_API extern void UTgetUserName(UT_String &name, int alphaonly = 1);
83 
84 // Produce an anonymous, but still identifiable name for the user. This is
85 // generated by MD5 hashing the result of UTgetUserMachineName and then
86 // truncating it to 8 characters.
88 
89 // you@machine
90 // The machine defaults to your host name, but can be overridden
91 UT_API extern void UTgetMachineName(UT_String &name, int alphaonly = 1);
92 
93 // machine
94 // The machine defaults to your host name, but can be overridden
95 UT_API extern void UTgetUserMachineName(UT_String &name, int alphaonly = 1);
96 
97 UT_API extern void UTdisplayMessageWindow(const char *message_text,
98  const char *message_title = "Houdini Error");
99 UT_API extern void UTdisplayMessageWindowWithHelpURL(const char *message_text,
100  const char *help_url,
101  const char *message_title = "Houdini Error");
102 UT_API extern bool UTdisplayConfirmationWindow(const char *message_text,
103  const char *message_title = "Houdini");
104 
105 static inline int
106 UTvsnprintf(char *str, size_t size, const char *format, va_list ap)
107 {
108  // Windows prefixes vsnprintf with an underscore for some reason.
109 #ifdef WIN32
110  return _vsnprintf(str, size, format, ap);
111 #else
112  int result;
113  va_list ap_copy;
114 
115  // We need to make a copy of the argument pointer in case we
116  // have to call UTvsnprintf multiple times. It is generally not safe to
117  // re-use the same va_list in multiple calls. Reusing the same va_list
118  // caused a crash on a 64 bit Linux machine compiled with gcc 3.4.
119  // va_copy only became standard with C99 and is currently not supported
120  // on Windows.
121  va_copy(ap_copy, ap);
122  result = vsnprintf(str, size, format, ap_copy);
123  va_end(ap_copy);
124  return result;
125 #endif
126 }
127 
128 UT_API extern std::string
130 
131 #define UTstatic_cast(Type, Data) static_cast<Type>(Data)
132 
133 #endif // __UT_SysSpecific_h__
UT_API const char * UTgetTextEditor(bool &is_graphical)
GLbitfield flags
Definition: glcorearb.h:1596
UT_API bool UTrunTextProgram(const char *command_line, bool blocking, const char *title)
GLsizei const GLchar *const * string
Definition: glcorearb.h:814
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)
UT_API UT_StringHolder UTanonymousUserIdentifier()
#define UT_API
Definition: UT_API.h:14
**But if you need a result
Definition: thread.h:613
UT_API void UTgetUserMachineName(UT_String &name, int alphaonly=1)
UT_API bool UTopenShell(bool blocking, const char *title)
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")
GLint GLint GLsizei GLint GLenum format
Definition: glcorearb.h:108
UT_API void UTopenURLInWebBrowser(const char *url)
SYS_API const char * SYSgetOsProc()
Find the name of the operating system that Houdini was compiled for.
GLuint const GLchar * name
Definition: glcorearb.h:786
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)
GLsizeiptr size
Definition: glcorearb.h:664
UT_API void UTdisplayMessageWindow(const char *message_text, const char *message_title="Houdini Error")
UT_API void UTgetUserName(UT_String &name, int alphaonly=1)