HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_MBSDUtil.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  * NAME: UT_MBSDUtil.h ( UT Library, C++)
7  *
8  * COMMENTS:
9  *
10  * These functions replace the SGI forms with BSD forms.
11  *
12  */
13 
14 #ifndef __UT_MBSDUtil_h__
15 #define __UT_MBSDUtil_h__
16 
17 #include "UT_API.h"
18 
19 // Everything after this point will only be included if on MacOS.
20 
21 #if defined(MBSD)
22 
23 #include <sched.h>
24 #include <signal.h>
25 #include <fcntl.h>
26 #include <time.h>
27 #include <math.h>
28 #include <errno.h>
29 #include <sys/types.h>
30 #include <sys/socket.h>
31 #include <sys/time.h>
32 #include <SYS/SYS_Types.h>
33 
34 #include "UT_Assert.h"
35 #include "UT_StringMap.h"
36 #include "UT_UniquePtr.h"
37 #include "UT_WorkBuffer.h"
38 
39 //
40 // Defines:
41 //
42 #define PR_SADDR 1
43 #define MP_NPROCS 0
44 #ifndef SO_REUSEPORT
45 #define SO_REUSEPORT SO_REUSEADDR
46 #endif
47 #ifndef SIGCLD
48 #define SIGCLD SIGCHLD
49 #endif
50 
51 
52 #define CONF_INITUSERS 1
53 
54 #define FNONBLK FNONBLOCK
55 
56 #define sigset(a,b) signal(a,b)
57 #define sighold(a)
58 #define sigrelse(a)
59 #define sigignore(a)
60 #define oserror() errno
61 
62 #ifndef CLK_TCK
63 #define CLK_TCK CLOCKS_PER_SEC
64 #endif
65 
66 #define sginap(a) UTnap(a*10)
67 
68 // Forward declares
69 class UT_WorkArgs;
70 class UT_ExtensionList;
71 
72 //
73 // Functions:
74 //
75 UT_API long UTnap(long ms);
76 
77 UT_API void cftime (char *dest, char *fmt, time_t *now);
78 
79 UT_API pid_t sproc (void (*)(void *), unsigned int flags = 0, void *args = 0);
80 
81 UT_API int sysmp (int val, ...);
82 
83 UT_API int usconfig (int flag, int data);
84 
85 UT_API extern void UTclearHostnameCache();
86 UT_API extern int UTgethostname(char *host, int len);
87 
88 UT_API void MBSDregisterThread();
89 
90 UT_API int MBSDLaunchApp(UT_WorkArgs& args);
91 
92 UT_API void MBSDLoadURL(const char* url);
93 
94 UT_API std::string MBSDurlToLocalPathStdString(const std::string &url);
95 
96 UT_API void MBSDAddImageAndMovieExtensions(UT_ExtensionList & extension_list);
97 
98 UT_API UT_AssertResponse MBSDgetAssertResponse(UT_WorkBuffer &info);
99 
100 UT_API void MBSDalert(const char *msg, const char *details);
101 
102 UT_API float MBSDgetBackingScaleFactor(int screen_idx);
103 
104 /// This class works around a bug in OSX Yosemite where duplicate environment
105 /// variable entries can exist in the global `environ`. Duplicate entries cause
106 /// spawned bash/sh subprocesses to inherit the wrong variable values if the
107 /// parent process was launched from launchd. This bug is logged with Apple as
108 /// bug 18724538 and submitted by rvinluan@sidefx.com. When that bug is fixed,
109 /// then we can get rid of UT_MBSDEnvironFix.
110 ///
111 /// This class works around the bug by recreating `environ` without duplicate
112 /// entries.
113 ///
114 /// To use this class, create an instance of it before spawning a process.
115 /// For example:
116 /// {
117 /// #if defined(MBSD)
118 /// UT_MBSDEnvironFix tmp_env;
119 /// #endif
120 /// ::execlp("/bin/bsh", "sh", "-c", command, NULL);
121 /// }
122 class UT_API UT_MBSDEnvironFix
123 {
124 public:
125  UT_MBSDEnvironFix();
126  ~UT_MBSDEnvironFix();
127 private:
128  char **myOrigEnviron;
129  UT_UniquePtr<char*[]> myFixedEnviron;
130  UT_StringMap<UT_String> myEnvironMap;
131 };
132 
133 #ifdef __OBJC__
134 
135 #import <Foundation/Foundation.h>
136 
137 class UT_String;
138 
139 NSString * MBSDconvertString(const UT_String & ut_string);
140 UT_String MBSDconvertString(NSString * string);
141 
142 NSString * UTstackTraceForException(NSException * exception);
143 
144 #endif
145 
146 #endif // MBSD
147 
148 #endif // __UT_MBSDUtil_h__
GLsizei const GLchar *const * string
Definition: glcorearb.h:813
UT_AssertResponse
Definition: UT_Assert.h:183
GLbitfield flags
Definition: glcorearb.h:1595
#define UT_API
Definition: UT_API.h:13
GLboolean * data
Definition: glcorearb.h:130
UT_API int UTgethostname(UT_String &host)
A smart pointer for unique ownership of dynamically allocated objects.
Definition: UT_UniquePtr.h:47
GLuint GLfloat * val
Definition: glcorearb.h:1607
png_infop png_uint_32 flag
Definition: png.h:2242