Vuo 2.4.4
Loading...
Searching...
No Matches
VuoOsStatus.c
Go to the documentation of this file.
1
10#include "VuoOsStatus.h"
11
12#include <CoreServices/CoreServices.h>
13#include <CoreVideo/CVReturn.h>
14#include <CoreMediaIO/CMIOHardware.h>
15
16#ifdef VUO_COMPILER
18 "title" : "VuoOsStatus",
19 "dependencies" : [
20 "CoreFoundation.framework"
21 ]
22 });
23#endif
24
30char *VuoOsStatus_getText(int32_t error)
31{
32 if (error == noErr)
33 return strdup("(no error)");
34 else if (error == bdNamErr)
35 return strdup("Bad file name");
36 else if (error == fnfErr)
37 return strdup("File not found");
38
39 // LSInfo.h
40 else if (error == kLSAppInTrashErr) return strdup("The app cannot be run when inside a Trash folder");
41 else if (error == kLSExecutableIncorrectFormat) return strdup("No compatible executable was found");
42 else if (error == kLSAttributeNotFoundErr) return strdup("An item attribute value could not be found with the specified name");
43 else if (error == kLSAttributeNotSettableErr) return strdup("The attribute is not settable");
44 else if (error == kLSIncompatibleApplicationVersionErr) return strdup("The app is incompatible with the current OS");
45 else if (error == kLSNoRosettaEnvironmentErr) return strdup("The Rosetta environment was required not available");
46 else if (error == -10666 /*kLSGarbageCollectionUnsupportedErr*/) return strdup("Objective-C garbage collection is no longer supported");
47 else if (error == kLSUnknownErr) return strdup("Unexpected internal error");
48 else if (error == kLSNotAnApplicationErr) return strdup("Item needs to be an application, but is not");
49 else if (error == kLSNotInitializedErr) return strdup("Not initialized");
50 else if (error == kLSDataUnavailableErr) return strdup("Data unavailable (e.g., no kind string)");
51 else if (error == kLSApplicationNotFoundErr) return strdup("Application not found (e.g., no application claims the file)");
52 else if (error == kLSUnknownTypeErr) return strdup("Don't know anything about the type of the item");
53 else if (error == kLSDataTooOldErr) return strdup("Data too old");
54 else if (error == kLSDataErr) return strdup("Data error");
55 else if (error == kLSLaunchInProgressErr) return strdup("Attempted to launch an already launching application");
56 else if (error == kLSNotRegisteredErr) return strdup("Not registered");
57 else if (error == kLSAppDoesNotClaimTypeErr) return strdup("One or more documents are of types (and/or one or more URLs are of schemes) not supported by the target application");
58 else if (error == kLSAppDoesNotSupportSchemeWarning) return strdup("The app does not support this scheme");
59 else if (error == kLSServerCommunicationErr) return strdup("The server process (registration and recent items) is not available");
60 else if (error == kLSCannotSetInfoErr) return strdup("The extension visibility on this item cannot be changed");
61 else if (error == kLSNoRegistrationInfoErr) return strdup("The item contains no registration info");
62 else if (error == kLSIncompatibleSystemVersionErr) return strdup("The app cannot run on the current OS version");
63 else if (error == kLSNoLaunchPermissionErr) return strdup("User doesn't have permission to launch the app (managed networks)");
64 else if (error == kLSNoExecutableErr) return strdup("The executable is missing");
65 else if (error == kLSNoClassicEnvironmentErr) return strdup("The Classic environment was required but is not available");
66 else if (error == kLSMultipleSessionsNotSupportedErr) return strdup("The app cannot run simultaneously in two different sessions");
67
68 // CVReturn.h
69 else if (error == kCVReturnInvalidArgument) return strdup("At least one of the arguments passed in is not valid. Either out of range or the wrong type.");
70 else if (error == kCVReturnAllocationFailed) return strdup("The allocation for a buffer or buffer pool failed. Most likely because of lack of resources.");
71 else if (error == -6663 /*kCVReturnUnsupported*/) return strdup("Unsupported.");
72 else if (error == kCVReturnInvalidDisplay) return strdup("A CVDisplayLink cannot be created for the given DisplayRef.");
73 else if (error == kCVReturnDisplayLinkAlreadyRunning) return strdup("The CVDisplayLink is already started and running.");
74 else if (error == kCVReturnDisplayLinkNotRunning) return strdup("The CVDisplayLink has not been started.");
75 else if (error == kCVReturnDisplayLinkCallbacksNotSet) return strdup("The output callback is not set.");
76 else if (error == kCVReturnInvalidPixelFormat) return strdup("The requested pixelformat is not supported for the CVBuffer type.");
77 else if (error == kCVReturnInvalidSize) return strdup("The requested size (most likely too big) is not supported for the CVBuffer type.");
78 else if (error == kCVReturnInvalidPixelBufferAttributes) return strdup("A CVBuffer cannot be created with the given attributes.");
79 else if (error == kCVReturnPixelBufferNotOpenGLCompatible) return strdup("The Buffer cannot be used with OpenGL as either its size, pixelformat or attributes are not supported by OpenGL.");
80 else if (error == -6684 /*kCVReturnPixelBufferNotMetalCompatible*/) return strdup("The Buffer cannot be used with Metal as either its size, pixelformat or attributes are not supported by Metal.");
81 else if (error == kCVReturnWouldExceedAllocationThreshold) return strdup("The allocation request failed because it would have exceeded a specified allocation threshold (see kCVPixelBufferPoolAllocationThresholdKey).");
82 else if (error == kCVReturnPoolAllocationFailed) return strdup("The allocation for the buffer pool failed. Most likely because of lack of resources. Check if your parameters are in range.");
83 else if (error == kCVReturnInvalidPoolAttributes) return strdup("A CVBufferPool cannot be created with the given attributes.");
84 else if (error == -6692 /*kCVReturnRetry*/) return strdup("A scan hasn't completely traversed the CVBufferPool due to a concurrent operation. The client can retry the scan.");
85
86 // CMIOHardware.h
87 // AudioHardwareBase.h
88 else if (error == kCMIOHardwareNotStoppedError) return strdup("The function call requires that the hardware be stopped but it isn't.");
89 else if (error == kCMIOHardwareNotRunningError) return strdup("The function call requires that the hardware be running but it isn't.");
90 else if (error == kCMIOHardwareUnspecifiedError) return strdup("The function call failed while doing something that doesn't provide any error messages.");
91 else if (error == kCMIOHardwareUnknownPropertyError) return strdup("The object doesn't know about the property at the given address.");
92 else if (error == kCMIOHardwareBadPropertySizeError) return strdup("An improperly sized buffer was provided when accessing the data of a property.");
93 else if (error == kCMIOHardwareIllegalOperationError) return strdup("The requested operation couldn't be completed.");
94 else if (error == kCMIOHardwareBadObjectError) return strdup("The CMIOObjectID passed to the function doesn't map to a valid CMIOObject.");
95 else if (error == kCMIOHardwareBadDeviceError) return strdup("The CMIODeviceID passed to the function doesn't map to a valid CMIODevice.");
96 else if (error == kCMIOHardwareBadStreamError) return strdup("The CMIODeviceID passed to the function doesn't map to a valid CMIOStream.");
97 else if (error == kCMIOHardwareUnsupportedOperationError) return strdup("The device doesn't support the requested operation.");
98 else if (error == kCMIOHardwareSuspendedBySystemError) return strdup("The function call failed because because access been suspended by the system.");
99 else if (error == kCMIODeviceUnsupportedFormatError) return strdup("The CMIOStream doesn't support the requested format.");
100 else if (error == kCMIODevicePermissionsError) return strdup("The requested operation can't be completed because the process doesn't have permission.");
101
102 // AudioCodec.h
103 else if (error == 561214580 /*kAudioCodecStateError*/) return strdup("Codec state error.");
104 else if (error == 560100710 /*kAudioCodecNotEnoughBufferSpaceError*/) return strdup("Not enough buffer space.");
105
106 // CGError.h
107 else if (error == kCGErrorFailure) return strdup("Failure.");
108 else if (error == kCGErrorIllegalArgument) return strdup("Illegal argument.");
109 else if (error == kCGErrorInvalidConnection) return strdup("Invalid connection.");
110 else if (error == kCGErrorInvalidContext) return strdup("Invalid context.");
111 else if (error == kCGErrorCannotComplete) return strdup("Cannot complete.");
112 else if (error == kCGErrorNotImplemented) return strdup("Not implemented.");
113 else if (error == kCGErrorRangeCheck) return strdup("Range check.");
114 else if (error == kCGErrorTypeCheck) return strdup("Type check.");
115 else if (error == kCGErrorInvalidOperation) return strdup("Invalid operation.");
116 else if (error == kCGErrorNoneAvailable) return strdup("None available.");
117
118 // CSCommon.h
119 else if (error == errSecCSUnimplemented) return strdup("unimplemented code signing feature");
120 else if (error == errSecCSInvalidObjectRef) return strdup("invalid API object reference");
121 else if (error == errSecCSInvalidFlags) return strdup("invalid or inappropriate API flag(s) specified");
122 else if (error == errSecCSObjectRequired) return strdup("a required pointer argument was NULL");
123 else if (error == errSecCSStaticCodeNotFound) return strdup("cannot find code object on disk");
124 else if (error == errSecCSUnsupportedGuestAttributes) return strdup("cannot locate guests using this attribute set");
125 else if (error == errSecCSInvalidAttributeValues) return strdup("given attribute values are invalid");
126 else if (error == errSecCSNoSuchCode) return strdup("host has no guest with the requested attributes");
127 else if (error == errSecCSMultipleGuests) return strdup("ambiguous guest specification (host has multiple guests with these attribute values)");
128 else if (error == errSecCSGuestInvalid) return strdup("code identity has been invalidated");
129 else if (error == errSecCSUnsigned) return strdup("code object is not signed at all");
130 else if (error == errSecCSSignatureFailed) return strdup("invalid signature (code or signature have been modified)");
131 else if (error == errSecCSSignatureNotVerifiable) return strdup("the code cannot be read by the verifier (file system permissions etc.)");
132 else if (error == errSecCSSignatureUnsupported) return strdup("unsupported type or version of signature");
133 else if (error == errSecCSBadDictionaryFormat) return strdup("a required plist file or resource is malformed");
134 else if (error == errSecCSResourcesNotSealed) return strdup("resources are present but not sealed by signature");
135 else if (error == errSecCSResourcesNotFound) return strdup("code has no resources but signature indicates they must be present");
136 else if (error == errSecCSResourcesInvalid) return strdup("the sealed resource directory is invalid");
137 else if (error == errSecCSBadResource) return strdup("a sealed resource is missing or invalid");
138 else if (error == errSecCSResourceRulesInvalid) return strdup("invalid resource specification rule(s)");
139 else if (error == errSecCSReqInvalid) return strdup("invalid or corrupted code requirement(s)");
140 else if (error == errSecCSReqUnsupported) return strdup("unsupported type or version of code requirement(s)");
141 else if (error == errSecCSReqFailed) return strdup("code failed to satisfy specified code requirement(s)");
142 else if (error == errSecCSBadObjectFormat) return strdup("object file format unrecognized, invalid, or unsuitable");
143 else if (error == errSecCSInternalError) return strdup("internal error in Code Signing subsystem");
144 else if (error == errSecCSHostReject) return strdup("code rejected its host");
145 else if (error == errSecCSNotAHost) return strdup("attempt to specify guest of code that is not a host");
146 else if (error == errSecCSSignatureInvalid) return strdup("invalid or unsupported format for signature");
147 else if (error == errSecCSHostProtocolRelativePath) return strdup("host protocol violation - absolute guest path required");
148 else if (error == errSecCSHostProtocolContradiction) return strdup("host protocol violation - contradictory hosting modes");
149 else if (error == errSecCSHostProtocolDedicationError) return strdup("host protocol violation - operation not allowed with/for a dedicated guest");
150 else if (error == errSecCSHostProtocolNotProxy) return strdup("host protocol violation - proxy hosting not engaged");
151 else if (error == errSecCSHostProtocolStateError) return strdup("host protocol violation - invalid guest state change request");
152 else if (error == errSecCSHostProtocolUnrelated) return strdup("host protocol violation - the given guest is not a guest of the given host");
153 else if (error == errSecCSNotSupported) return strdup("operation inapplicable or not supported for this type of code");
154 else if (error == errSecCSCMSTooLarge) return strdup("signature too large to embed (size limitation of on-disk representation)");
155 else if (error == errSecCSHostProtocolInvalidHash) return strdup("host protocol violation - invalid guest hash");
156 else if (error == errSecCSStaticCodeChanged) return strdup("the code on disk does not match what is running");
157 else if (error == errSecCSDBDenied) return strdup("permission to use a database denied");
158 else if (error == errSecCSDBAccess) return strdup("cannot access a database");
159 else if (error == errSecCSSigDBDenied) return strdup("SigDB denied");
160 else if (error == errSecCSSigDBAccess) return strdup("SigDB access");
161 else if (error == errSecCSHostProtocolInvalidAttribute) return strdup("host returned invalid or inconsistent guest attributes");
162 else if (error == errSecCSInfoPlistFailed) return strdup("invalid Info.plist (plist or signature have been modified)");
163 else if (error == errSecCSNoMainExecutable) return strdup("the code has no main executable file");
164 else if (error == errSecCSBadBundleFormat) return strdup("bundle format unrecognized, invalid, or unsuitable");
165 else if (error == errSecCSNoMatches) return strdup("no matches for search or update operation");
166 else if (error == errSecCSFileHardQuarantined) return strdup("File created by an AppSandbox, exec/open not allowed");
167 else if (error == errSecCSOutdated) return strdup("presented data is out of date");
168 else if (error == errSecCSDbCorrupt) return strdup("a system database or file is corrupt");
169 else if (error == errSecCSResourceDirectoryFailed) return strdup("invalid resource directory (directory or signature have been modified)");
170 else if (error == errSecCSUnsignedNestedCode) return strdup("nested code is unsigned");
171 else if (error == errSecCSBadNestedCode) return strdup("nested code is modified or invalid");
172 else if (error == errSecCSBadCallbackValue) return strdup("monitor callback returned invalid value");
173 else if (error == errSecCSHelperFailed) return strdup("the codesign_allocate helper tool cannot be found or used");
174 else if (error == errSecCSVetoed) return strdup("vetoed");
175 else if (error == errSecCSBadLVArch) return strdup("library validation flag cannot be used with an i386 binary");
176 else if (error == errSecCSResourceNotSupported) return strdup("unsupported resource found (something not a directory, file or symlink)");
177 else if (error == errSecCSRegularFile) return strdup("the main executable or Info.plist must be a regular file (no symlinks, etc.)");
178 else if (error == errSecCSUnsealedAppRoot) return strdup("unsealed contents present in the bundle root");
179 else if (error == errSecCSWeakResourceRules) return strdup("resource envelope is obsolete (custom omit rules)");
180 else if (error == errSecCSDSStoreSymlink) return strdup(".DS_Store files cannot be a symlink ");
181 else if (error == errSecCSAmbiguousBundleFormat) return strdup("bundle format is ambiguous (could be app or framework)");
182 else if (error == errSecCSBadMainExecutable) return strdup("main executable failed strict validation");
183 else if (error == errSecCSBadFrameworkVersion) return strdup("embedded framework contains modified or invalid version");
184 else if (error == errSecCSUnsealedFrameworkRoot) return strdup("unsealed contents present in the root directory of an embedded framework");
185 else if (error == errSecCSWeakResourceEnvelope) return strdup("resource envelope is obsolete (version 1 signature)");
186 else if (error == errSecCSCancelled) return strdup("operation was terminated by explicit cancellation");
187
188 char *errorString = (char *)calloc(1, 12); // ceil(log10(INT_MAX)) + 1 (optional negative sign) + 1 (null terminator)
189
190 *(UInt32 *)(errorString + 1) = CFSwapInt32HostToBig(error);
191 if (isprint(errorString[1]) && isprint(errorString[2]) && isprint(errorString[3]) && isprint(errorString[4]))
192 {
193 errorString[0] = errorString[5] = '\'';
194 errorString[6] = '\0';
195 }
196 else
197 sprintf(errorString, "%d", (int)error);
198
199 return errorString;
200}