Exemplo n.º 1
0
        static CTStringAttributeKey()
        {
            var handle = Dlfcn.dlopen(Constants.CoreTextLibrary, 0);

            if (handle == IntPtr.Zero)
            {
                return;
            }
            try {
                Font = Dlfcn.GetStringConstant(handle, "kCTFontAttributeName");
                ForegroundColorFromContext = Dlfcn.GetStringConstant(handle, "kCTForegroundColorFromContextAttributeName");
                KerningAdjustment          = Dlfcn.GetStringConstant(handle, "kCTKernAttributeName");
                LigatureFormation          = Dlfcn.GetStringConstant(handle, "kCTLigatureAttributeName");
                ForegroundColor            = Dlfcn.GetStringConstant(handle, "kCTForegroundColorAttributeName");
                ParagraphStyle             = Dlfcn.GetStringConstant(handle, "kCTParagraphStyleAttributeName");
                StrokeWidth    = Dlfcn.GetStringConstant(handle, "kCTStrokeWidthAttributeName");
                StrokeColor    = Dlfcn.GetStringConstant(handle, "kCTStrokeColorAttributeName");
                UnderlineStyle = Dlfcn.GetStringConstant(handle, "kCTUnderlineStyleAttributeName");
                Superscript    = Dlfcn.GetStringConstant(handle, "kCTSuperscriptAttributeName");
                UnderlineColor = Dlfcn.GetStringConstant(handle, "kCTUnderlineColorAttributeName");
                VerticalForms  = Dlfcn.GetStringConstant(handle, "kCTVerticalFormsAttributeName");
                GlyphInfo      = Dlfcn.GetStringConstant(handle, "kCTGlyphInfoAttributeName");
                CharacterShape = Dlfcn.GetStringConstant(handle, "kCTCharacterShapeAttributeName");
                RunDelegate    = Dlfcn.GetStringConstant(handle, "kCTRunDelegateAttributeName");
            }
            finally {
                Dlfcn.dlclose(handle);
            }
        }
Exemplo n.º 2
0
		static CTFontDescriptorAttributeKey ()
		{
			var handle = Dlfcn.dlopen (Constants.CoreTextLibrary, 0);
			if (handle == IntPtr.Zero)
				return;
			try {
				Url                 = Dlfcn.GetStringConstant (handle, "kCTFontURLAttribute");
				Name                = Dlfcn.GetStringConstant (handle, "kCTFontNameAttribute");
				DisplayName         = Dlfcn.GetStringConstant (handle, "kCTFontDisplayNameAttribute");
				FamilyName          = Dlfcn.GetStringConstant (handle, "kCTFontFamilyNameAttribute");
				StyleName           = Dlfcn.GetStringConstant (handle, "kCTFontStyleNameAttribute");
				Traits              = Dlfcn.GetStringConstant (handle, "kCTFontTraitsAttribute");
				Variation           = Dlfcn.GetStringConstant (handle, "kCTFontVariationAttribute");
				Size                = Dlfcn.GetStringConstant (handle, "kCTFontSizeAttribute");
				Matrix              = Dlfcn.GetStringConstant (handle, "kCTFontMatrixAttribute");
				CascadeList         = Dlfcn.GetStringConstant (handle, "kCTFontCascadeListAttribute");
				CharacterSet        = Dlfcn.GetStringConstant (handle, "kCTFontCharacterSetAttribute");
				Languages           = Dlfcn.GetStringConstant (handle, "kCTFontLanguagesAttribute");
				BaselineAdjust      = Dlfcn.GetStringConstant (handle, "kCTFontBaselineAdjustAttribute");
				MacintoshEncodings  = Dlfcn.GetStringConstant (handle, "kCTFontMacintoshEncodingsAttribute");
				Features            = Dlfcn.GetStringConstant (handle, "kCTFontFeaturesAttribute");
				FeatureSettings     = Dlfcn.GetStringConstant (handle, "kCTFontFeatureSettingsAttribute");
				FixedAdvance        = Dlfcn.GetStringConstant (handle, "kCTFontFixedAdvanceAttribute");
				FontOrientation     = Dlfcn.GetStringConstant (handle, "kCTFontOrientationAttribute");
				FontFormat          = Dlfcn.GetStringConstant (handle, "kCTFontFormatAttribute");
				RegistrationScope   = Dlfcn.GetStringConstant (handle, "kCTFontRegistrationScopeAttribute");
				Priority            = Dlfcn.GetStringConstant (handle, "kCTFontPriorityAttribute");
				Enabled             = Dlfcn.GetStringConstant (handle, "kCTFontEnabledAttribute");
			}
			finally {
				Dlfcn.dlclose (handle);
			}
		}
Exemplo n.º 3
0
        internal static void Init()
        {
            var handle = Dlfcn.dlopen(Constants.AddressBookLibrary, 0);

            if (handle == IntPtr.Zero)
            {
                return;
            }
            try {
                Assistant = Dlfcn.GetStringConstant(handle, "kABPersonAssistantLabel");
                Brother   = Dlfcn.GetStringConstant(handle, "kABPersonBrotherLabel");
                Child     = Dlfcn.GetStringConstant(handle, "kABPersonChildLabel");
                Father    = Dlfcn.GetStringConstant(handle, "kABPersonFatherLabel");
                Friend    = Dlfcn.GetStringConstant(handle, "kABPersonFriendLabel");
                Manager   = Dlfcn.GetStringConstant(handle, "kABPersonManagerLabel");
                Mother    = Dlfcn.GetStringConstant(handle, "kABPersonMotherLabel");
                Parent    = Dlfcn.GetStringConstant(handle, "kABPersonParentLabel");
                Partner   = Dlfcn.GetStringConstant(handle, "kABPersonPartnerLabel");
                Sister    = Dlfcn.GetStringConstant(handle, "kABPersonSisterLabel");
                Spouse    = Dlfcn.GetStringConstant(handle, "kABPersonSpouseLabel");
            }
            finally {
                Dlfcn.dlclose(handle);
            }
        }
Exemplo n.º 4
0
        static NSHttpCookie()
        {
            var handle = Dlfcn.dlopen(Constants.FoundationLibrary, 0);

            if (handle == IntPtr.Zero)
            {
                return;
            }

            try {
                KeyName       = Dlfcn.GetStringConstant(handle, "NSHTTPCookieName");
                KeyValue      = Dlfcn.GetStringConstant(handle, "NSHTTPCookieValue");
                KeyOriginURL  = Dlfcn.GetStringConstant(handle, "NSHTTPCookieOriginURL");
                KeyVersion    = Dlfcn.GetStringConstant(handle, "NSHTTPCookieVersion");
                KeyDomain     = Dlfcn.GetStringConstant(handle, "NSHTTPCookieDomain");
                KeyPath       = Dlfcn.GetStringConstant(handle, "NSHTTPCookiePath");
                KeySecure     = Dlfcn.GetStringConstant(handle, "NSHTTPCookieSecure");
                KeyExpires    = Dlfcn.GetStringConstant(handle, "NSHTTPCookieExpires");
                KeyComment    = Dlfcn.GetStringConstant(handle, "NSHTTPCookieComment");
                KeyCommentURL = Dlfcn.GetStringConstant(handle, "NSHTTPCookieCommentURL");
                KeyDiscard    = Dlfcn.GetStringConstant(handle, "NSHTTPCookieDiscard");
                KeyMaximumAge = Dlfcn.GetStringConstant(handle, "NSHTTPCookieMaximumAge");
                KeyPort       = Dlfcn.GetStringConstant(handle, "NSHTTPCookiePort");
            } finally {
                Dlfcn.dlclose(handle);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Initializes static members of the <see cref="KSec"/> class.
        /// </summary>
        static KSec()
        {
            IntPtr handle = Dlfcn.dlopen(Constants.SecurityLibrary, 0);

            Assumes.False(handle == IntPtr.Zero);

            try
            {
                AttrApplicationTag = Dlfcn.GetStringConstant(handle, "kSecAttrApplicationTag");
                AttrKeyType        = Dlfcn.GetStringConstant(handle, "kSecAttrKeyType");
                AttrKeySizeInBits  = Dlfcn.GetStringConstant(handle, "kSecAttrKeySizeInBits");
                AttrKeyTypeRSA     = Dlfcn.GetStringConstant(handle, "kSecAttrKeyTypeRSA");
                AttrIsPermanent    = Dlfcn.GetStringConstant(handle, "kSecAttrIsPermanent");
                PublicKeyAttrs     = Dlfcn.GetStringConstant(handle, "kSecPublicKeyAttrs");
                PrivateKeyAttrs    = Dlfcn.GetStringConstant(handle, "kSecPrivateKeyAttrs");
                ClassKey           = Dlfcn.GetStringConstant(handle, "kSecClassKey");
                Class                      = Dlfcn.GetStringConstant(handle, "kSecClass");
                AttrKeyClass               = Dlfcn.GetStringConstant(handle, "kSecAttrKeyClass");
                AttrKeyClassPublic         = Dlfcn.GetStringConstant(handle, "kSecAttrKeyClassPublic");
                AttrKeyClassPrivate        = Dlfcn.GetStringConstant(handle, "kSecAttrKeyClassPrivate");
                ReturnData                 = Dlfcn.GetStringConstant(handle, "kSecReturnData");
                ReturnPersistentRef        = Dlfcn.GetStringConstant(handle, "kSecReturnPersistentRef");
                AttrAccessibleWhenUnlocked = Dlfcn.GetStringConstant(handle, "kSecAttrAccessibleWhenUnlocked");
                AttrAccessible             = Dlfcn.GetStringConstant(handle, "kSecAttrAccessible");
                ReturnRef                  = Dlfcn.GetStringConstant(handle, "kSecReturnRef");
                ValueData                  = Dlfcn.GetStringConstant(handle, "kSecValueData");
            }
            finally
            {
                Dlfcn.dlclose(handle);
            }
        }
Exemplo n.º 6
0
        public void FieldExists()
        {
            var failed_fields = new List <string> ();

            Errors = 0;
            int n = 0;

            foreach (var p in AllProperties())
            {
                var f = p.GetCustomAttribute <FieldAttribute> ();
                if (f == null)
                {
                    continue;
                }

                string name = f.SymbolName;
                if (Skip(name))
                {
                    continue;
                }

                string path = FindLibrary(f.LibraryName);
                IntPtr lib  = Dlfcn.dlopen(path, 0);
                if (Dlfcn.GetIndirect(lib, name) == IntPtr.Zero)
                {
                    ReportError("Could not find the field '{0}' in {1}", name, path);
                    failed_fields.Add(name);
                }
                Dlfcn.dlclose(lib);
                n++;
            }
            Assert.AreEqual(0, Errors, "{0} errors found in {1} fields validated: {2}", Errors, n, string.Join(", ", failed_fields));
        }
Exemplo n.º 7
0
        static CFAllocator()
        {
            var handle = Dlfcn.dlopen(Constants.CoreFoundationLibrary, 0);

            null_ptr = Dlfcn.GetIntPtr(handle, "kCFAllocatorNull");
            Dlfcn.dlclose(handle);
        }
Exemplo n.º 8
0
        public void Exif43Fields()
        {
            // documented as new in iOS 4.3 - https://developer.apple.com/library/ios/#documentation/GraphicsImaging/Reference/CGImageProperties_Reference/Reference/reference.html
            IntPtr lib = Dlfcn.dlopen(Constants.ImageIOLibrary, 0);

            try {
                if (TestRuntime.CheckSystemAndSDKVersion(6, 0))
                {
                    // symbols are available in iOS 6.0 beta 1
                    Assert.That(Dlfcn.dlsym(lib, "kCGImagePropertyExifCameraOwnerName"), Is.Not.EqualTo(IntPtr.Zero), "kCGImagePropertyExifCameraOwnerName");
                    Assert.That(Dlfcn.dlsym(lib, "kCGImagePropertyExifBodySerialNumber"), Is.Not.EqualTo(IntPtr.Zero), "kCGImagePropertyExifBodySerialNumber");
                    Assert.That(Dlfcn.dlsym(lib, "kCGImagePropertyExifLensSpecification"), Is.Not.EqualTo(IntPtr.Zero), "kCGImagePropertyExifLensSpecification");
                    Assert.That(Dlfcn.dlsym(lib, "kCGImagePropertyExifLensMake"), Is.Not.EqualTo(IntPtr.Zero), "kCGImagePropertyExifLensMake");
                    Assert.That(Dlfcn.dlsym(lib, "kCGImagePropertyExifLensModel"), Is.Not.EqualTo(IntPtr.Zero), "kCGImagePropertyExifLensModel");
                    Assert.That(Dlfcn.dlsym(lib, "kCGImagePropertyExifLensSerialNumber"), Is.Not.EqualTo(IntPtr.Zero), "kCGImagePropertyExifLensSerialNumber");
                }
                else
                {
                    // but symbols are not available in iOS 5.1.1
                    Assert.That(Dlfcn.dlsym(lib, "kCGImagePropertyExifCameraOwnerName"), Is.EqualTo(IntPtr.Zero), "kCGImagePropertyExifCameraOwnerName");
                    Assert.That(Dlfcn.dlsym(lib, "kCGImagePropertyExifBodySerialNumber"), Is.EqualTo(IntPtr.Zero), "kCGImagePropertyExifBodySerialNumber");
                    Assert.That(Dlfcn.dlsym(lib, "kCGImagePropertyExifLensSpecification"), Is.EqualTo(IntPtr.Zero), "kCGImagePropertyExifLensSpecification");
                    Assert.That(Dlfcn.dlsym(lib, "kCGImagePropertyExifLensMake"), Is.EqualTo(IntPtr.Zero), "kCGImagePropertyExifLensMake");
                    Assert.That(Dlfcn.dlsym(lib, "kCGImagePropertyExifLensModel"), Is.EqualTo(IntPtr.Zero), "kCGImagePropertyExifLensModel");
                    Assert.That(Dlfcn.dlsym(lib, "kCGImagePropertyExifLensSerialNumber"), Is.EqualTo(IntPtr.Zero), "kCGImagePropertyExifLensSerialNumber");
                }
            }
            finally {
                Dlfcn.dlclose(lib);
            }
        }
Exemplo n.º 9
0
        public void CameraMaker()
        {
            // since only Canon and Nikon have dictionary key values I assume the others are "placeholder" at the moment !?!
            Assert.NotNull(CGImageProperties.MakerCanonDictionary, "MakerCanonDictionary");
            Assert.NotNull(CGImageProperties.MakerNikonDictionary, "MakerNikonDictionary");

            // iOS 8.3 finally fixed them :)
            if (TestRuntime.CheckiOSSystemVersion(8, 3))
            {
                Assert.NotNull(CGImageProperties.MakerMinoltaDictionary, "MakerMinoltaDictionary");
                Assert.NotNull(CGImageProperties.MakerFujiDictionary, "MakerFujiDictionary");
                Assert.NotNull(CGImageProperties.MakerOlympusDictionary, "MakerOlympusDictionary");
                Assert.NotNull(CGImageProperties.MakerPentaxDictionary, "MakerPentaxDictionary");
                return;
            }

            // documented as new in iOS 4.0 - https://developer.apple.com/library/ios/#documentation/GraphicsImaging/Reference/CGImageProperties_Reference/Reference/reference.html
            // but symbols are not available in iOS 5.1.1
            // this test will fail if Apple decide to include them in the future
            IntPtr lib = Dlfcn.dlopen(Constants.ImageIOLibrary, 0);

            try {
                Assert.That(Dlfcn.dlsym(lib, "kCGImagePropertyMakerMinoltaDictionary"), Is.EqualTo(IntPtr.Zero), "kCGImagePropertyMakerMinoltaDictionary");
                Assert.That(Dlfcn.dlsym(lib, "kCGImagePropertyMakerFujiDictionary"), Is.EqualTo(IntPtr.Zero), "kCGImagePropertyMakerFujiDictionary");
                Assert.That(Dlfcn.dlsym(lib, "kCGImagePropertyMakerOlympusDictionary"), Is.EqualTo(IntPtr.Zero), "kCGImagePropertyMakerOlympusDictionary");
                Assert.That(Dlfcn.dlsym(lib, "kCGImagePropertyMakerPentaxDictionary"), Is.EqualTo(IntPtr.Zero), "kCGImagePropertyMakerPentaxDictionary");
            }
            finally {
                Dlfcn.dlclose(lib);
            }
        }
        static CVImageBuffer()
        {
            var handle = Dlfcn.dlopen(Constants.CoreVideoLibrary, 0);

            if (handle == IntPtr.Zero)
            {
                return;
            }
            try
            {
                CGColorSpaceKey                      = Dlfcn.GetStringConstant(handle, "kCVImageBufferCGColorSpaceKey");
                GammaLevelKey                        = Dlfcn.GetStringConstant(handle, "kCVImageBufferGammaLevelKey");
                CleanApertureKey                     = Dlfcn.GetStringConstant(handle, "kCVImageBufferCleanApertureKey");
                PreferredCleanApertureKey            = Dlfcn.GetStringConstant(handle, "kCVImageBufferPreferredCleanApertureKey");
                CleanApertureWidthKey                = Dlfcn.GetStringConstant(handle, "kCVImageBufferCleanApertureWidthKey");
                CleanApertureHeightKey               = Dlfcn.GetStringConstant(handle, "kCVImageBufferCleanApertureHeightKey");
                CleanApertureHorizontalOffsetKey     = Dlfcn.GetStringConstant(handle, "kCVImageBufferCleanApertureHorizontalOffsetKey");
                CleanApertureVerticalOffsetKey       = Dlfcn.GetStringConstant(handle, "kCVImageBufferCleanApertureVerticalOffsetKey");
                FieldCountKey                        = Dlfcn.GetStringConstant(handle, "kCVImageBufferFieldCountKey");
                FieldDetailKey                       = Dlfcn.GetStringConstant(handle, "kCVImageBufferFieldDetailKey");
                FieldDetailTemporalTopFirst          = Dlfcn.GetStringConstant(handle, "kCVImageBufferFieldDetailTemporalTopFirst");
                FieldDetailTemporalBottomFirst       = Dlfcn.GetStringConstant(handle, "kCVImageBufferFieldDetailTemporalBottomFirst");
                FieldDetailSpatialFirstLineEarly     = Dlfcn.GetStringConstant(handle, "kCVImageBufferFieldDetailSpatialFirstLineEarly");
                FieldDetailSpatialFirstLineLate      = Dlfcn.GetStringConstant(handle, "kCVImageBufferFieldDetailSpatialFirstLineLate");
                PixelAspectRatioKey                  = Dlfcn.GetStringConstant(handle, "kCVImageBufferPixelAspectRatioKey");
                PixelAspectRatioHorizontalSpacingKey = Dlfcn.GetStringConstant(handle, "kCVImageBufferPixelAspectRatioHorizontalSpacingKey");
                PixelAspectRatioVerticalSpacingKey   = Dlfcn.GetStringConstant(handle, "kCVImageBufferPixelAspectRatioVerticalSpacingKey");
                DisplayDimensionsKey                 = Dlfcn.GetStringConstant(handle, "kCVImageBufferDisplayDimensionsKey");
                DisplayWidthKey                      = Dlfcn.GetStringConstant(handle, "kCVImageBufferDisplayWidthKey");
                DisplayHeightKey                     = Dlfcn.GetStringConstant(handle, "kCVImageBufferDisplayHeightKey");
                YCbCrMatrixKey                       = Dlfcn.GetStringConstant(handle, "kCVImageBufferYCbCrMatrixKey");
                YCbCrMatrix_ITU_R_709_2              = Dlfcn.GetStringConstant(handle, "kCVImageBufferYCbCrMatrix_ITU_R_709_2");
                YCbCrMatrix_ITU_R_601_4              = Dlfcn.GetStringConstant(handle, "kCVImageBufferYCbCrMatrix_ITU_R_601_4");
                YCbCrMatrix_SMPTE_240M_1995          = Dlfcn.GetStringConstant(handle, "kCVImageBufferYCbCrMatrix_SMPTE_240M_1995");

                ChromaSubsamplingKey  = Dlfcn.GetStringConstant(handle, "kCVImageBufferChromaSubsamplingKey");
                ChromaSubsampling_420 = Dlfcn.GetStringConstant(handle, "kCVImageBufferChromaSubsampling_420");
                ChromaSubsampling_422 = Dlfcn.GetStringConstant(handle, "kCVImageBufferChromaSubsampling_422");
                ChromaSubsampling_411 = Dlfcn.GetStringConstant(handle, "kCVImageBufferChromaSubsampling_411");

                TransferFunctionKey              = Dlfcn.GetStringConstant(handle, "kCVImageBufferTransferFunctionKey");
                TransferFunction_ITU_R_709_2     = Dlfcn.GetStringConstant(handle, "kCVImageBufferTransferFunction_ITU_R_709_2");
                TransferFunction_SMPTE_240M_1995 = Dlfcn.GetStringConstant(handle, "kCVImageBufferTransferFunction_SMPTE_240M_1995");
                TransferFunction_UseGamma        = Dlfcn.GetStringConstant(handle, "kCVImageBufferTransferFunction_UseGamma");

                ChromaLocationTopFieldKey    = Dlfcn.GetStringConstant(handle, "kCVImageBufferChromaLocationTopFieldKey");
                ChromaLocationBottomFieldKey = Dlfcn.GetStringConstant(handle, "kCVImageBufferChromaLocationBottomFieldKey");
                ChromaLocation_Left          = Dlfcn.GetStringConstant(handle, "kCVImageBufferChromaLocation_Left");
                ChromaLocation_Center        = Dlfcn.GetStringConstant(handle, "kCVImageBufferChromaLocation_Center");
                ChromaLocation_TopLeft       = Dlfcn.GetStringConstant(handle, "kCVImageBufferChromaLocation_TopLeft");
                ChromaLocation_Top           = Dlfcn.GetStringConstant(handle, "kCVImageBufferChromaLocation_Top");
                ChromaLocation_BottomLeft    = Dlfcn.GetStringConstant(handle, "kCVImageBufferChromaLocation_BottomLeft");
                ChromaLocation_Bottom        = Dlfcn.GetStringConstant(handle, "kCVImageBufferChromaLocation_Bottom");
                ChromaLocation_DV420         = Dlfcn.GetStringConstant(handle, "kCVImageBufferChromaLocation_DV420");
            }
            finally
            {
                Dlfcn.dlclose(handle);
            }
        }
Exemplo n.º 11
0
        static CGPDFInfo()
        {
            IntPtr h = Dlfcn.dlopen(Constants.CoreGraphicsLibrary, 0);

            try {
                kCGPDFContextTitle               = Dlfcn.GetIndirect(h, "kCGPDFContextTitle");
                kCGPDFContextAuthor              = Dlfcn.GetIndirect(h, "kCGPDFContextAuthor");
                kCGPDFContextSubject             = Dlfcn.GetIndirect(h, "kCGPDFContextSubject");
                kCGPDFContextKeywords            = Dlfcn.GetIndirect(h, "kCGPDFContextKeywords");
                kCGPDFContextCreator             = Dlfcn.GetIndirect(h, "kCGPDFContextCreator");
                kCGPDFContextOwnerPassword       = Dlfcn.GetIndirect(h, "kCGPDFContextOwnerPassword");
                kCGPDFContextUserPassword        = Dlfcn.GetIndirect(h, "kCGPDFContextUserPassword");
                kCGPDFContextEncryptionKeyLength = Dlfcn.GetIndirect(h, "kCGPDFContextEncryptionKeyLength");
                kCGPDFContextAllowsPrinting      = Dlfcn.GetIndirect(h, "kCGPDFContextAllowsPrinting");
                kCGPDFContextAllowsCopying       = Dlfcn.GetIndirect(h, "kCGPDFContextAllowsCopying");
#if false
                kCGPDFContextOutputIntent        = Dlfcn.GetIndirect(h, "kCGPDFContextOutputIntent");
                kCGPDFXOutputIntentSubtype       = Dlfcn.GetIndirect(h, "kCGPDFXOutputIntentSubtype");
                kCGPDFXOutputConditionIdentifier = Dlfcn.GetIndirect(h, "kCGPDFXOutputConditionIdentifier");
                kCGPDFXOutputCondition           = Dlfcn.GetIndirect(h, "kCGPDFXOutputCondition");
                kCGPDFXRegistryName             = Dlfcn.GetIndirect(h, "kCGPDFXRegistryName");
                kCGPDFXInfo                     = Dlfcn.GetIndirect(h, "kCGPDFXInfo");
                kCGPDFXDestinationOutputProfile = Dlfcn.GetIndirect(h, "kCGPDFXDestinationOutputProfile");
                kCGPDFContextOutputIntents      = Dlfcn.GetIndirect(h, "kCGPDFContextOutputIntents");
#endif
            } finally {
                Dlfcn.dlclose(h);
            }
        }
        static ABPersonSocialProfile()
        {
            var handle = Dlfcn.dlopen(Constants.AddressBookLibrary, 0);

            if (handle == IntPtr.Zero)
            {
                return;
            }
            try
            {
                URLKey            = Dlfcn.GetStringConstant(handle, "kABPersonSocialProfileURLKey");
                ServiceKey        = Dlfcn.GetStringConstant(handle, "kABPersonSocialProfileServiceKey");
                UsernameKey       = Dlfcn.GetStringConstant(handle, "kABPersonSocialProfileUsernameKey");
                UserIdentifierKey = Dlfcn.GetStringConstant(handle, "kABPersonSocialProfileUserIdentifierKey");
                ServiceTwitter    = Dlfcn.GetStringConstant(handle, "kABPersonSocialProfileServiceTwitter");
                ServiceGameCenter = Dlfcn.GetStringConstant(handle, "kABPersonSocialProfileServiceGameCenter");
                ServiceFacebook   = Dlfcn.GetStringConstant(handle, "kABPersonSocialProfileServiceFacebook");
                ServiceMyspace    = Dlfcn.GetStringConstant(handle, "kABPersonSocialProfileServiceMyspace");
                ServiceLinkedIn   = Dlfcn.GetStringConstant(handle, "kABPersonSocialProfileServiceLinkedIn");
                ServiceFlickr     = Dlfcn.GetStringConstant(handle, "kABPersonSocialProfileServiceFlickr");
            }
            finally
            {
                Dlfcn.dlclose(handle);
            }
        }
Exemplo n.º 13
0
        private PlatformPerformance()
        {
            var handle = Dlfcn.dlopen("/usr/lib/libSystem.dylib", 0);

            self = Dlfcn.GetIntPtr(handle, "mach_task_self_");
            Dlfcn.dlclose(handle);
        }
Exemplo n.º 14
0
        static CFHTTPMessage()
        {
            var handle = Dlfcn.dlopen(Constants.CFNetworkLibrary, 0);

            if (handle == IntPtr.Zero)
            {
                throw new InvalidOperationException();
            }

            try {
                _HTTPVersion1_0 = GetStringConstant(handle, "kCFHTTPVersion1_0");
                _HTTPVersion1_1 = GetStringConstant(handle, "kCFHTTPVersion1_1");

                _AuthenticationSchemeBasic = GetStringConstant(
                    handle, "kCFHTTPAuthenticationSchemeBasic");
                _AuthenticationSchemeNegotiate = GetStringConstant(
                    handle, "kCFHTTPAuthenticationSchemeNegotiate");
                _AuthenticationSchemeNTLM = GetStringConstant(
                    handle, "kCFHTTPAuthenticationSchemeNTLM");
                _AuthenticationSchemeDigest = GetStringConstant(
                    handle, "kCFHTTPAuthenticationSchemeDigest");

                _AuthenticationUsername = GetStringConstant(
                    handle, "kCFHTTPAuthenticationUsername");
                _AuthenticationPassword = GetStringConstant(
                    handle, "kCFHTTPAuthenticationPassword");
                _AuthenticationAccountDomain = GetStringConstant(
                    handle, "kCFHTTPAuthenticationAccountDomain");
            } finally {
                Dlfcn.dlclose(handle);
            }
        }
Exemplo n.º 15
0
        public void Sqlite3()
        {
            var lib = Dlfcn.dlopen("/usr/lib/libsqlite3.dylib", 0);

            Assert.That(lib, Is.Not.EqualTo(IntPtr.Zero), "/usr/lib/libsqlite3.dylib");
            try {
                Assert.That(Dlfcn.dlsym(lib, "sqlite3_bind_int"), Is.Not.EqualTo(IntPtr.Zero), "sqlite3_bind_int");
                // iOS does not have some symbols defined - if that change/fail in the future we'll need to update Mono.Data.Sqlite
                // note: Apple devices (at least iOS and AppleTV) running 10.x have a more recent version of libsqlite which includes _key and _rekey
                var version = TestRuntime.CheckXcodeVersion(8, 0);
                if (version && (Runtime.Arch == Arch.DEVICE))
                {
                    Assert.That(Dlfcn.dlsym(lib, "sqlite3_key"), Is.Not.EqualTo(IntPtr.Zero), "sqlite3_key");
                    Assert.That(Dlfcn.dlsym(lib, "sqlite3_rekey"), Is.Not.EqualTo(IntPtr.Zero), "sqlite3_rekey");
                }
                else
                {
                    Assert.That(Dlfcn.dlsym(lib, "sqlite3_key"), Is.EqualTo(IntPtr.Zero), "sqlite3_key");
                    Assert.That(Dlfcn.dlsym(lib, "sqlite3_rekey"), Is.EqualTo(IntPtr.Zero), "sqlite3_rekey");
                }
                Assert.That(Dlfcn.dlsym(lib, "sqlite3_column_database_name"), Is.EqualTo(IntPtr.Zero), "sqlite3_column_database_name");
                Assert.That(Dlfcn.dlsym(lib, "sqlite3_column_database_name16"), Is.EqualTo(IntPtr.Zero), "sqlite3_column_database_name16");
                Assert.That(Dlfcn.dlsym(lib, "sqlite3_column_origin_name"), Is.EqualTo(IntPtr.Zero), "sqlite3_column_origin_name");
                Assert.That(Dlfcn.dlsym(lib, "sqlite3_column_origin_name16"), Is.EqualTo(IntPtr.Zero), "sqlite3_column_origin_name16");
                Assert.That(Dlfcn.dlsym(lib, "sqlite3_column_table_name"), Is.EqualTo(IntPtr.Zero), "sqlite3_column_table_name");
                Assert.That(Dlfcn.dlsym(lib, "sqlite3_column_table_name16"), Is.EqualTo(IntPtr.Zero), "sqlite3_column_table_name16");
            }
            finally {
                Dlfcn.dlclose(lib);
            }
        }
Exemplo n.º 16
0
        public void CopyProperties()
        {
            // what we had to answer with 5.2 for http://stackoverflow.com/q/10753108/220643
            IntPtr lib = Dlfcn.dlopen(Constants.ImageIOLibrary, 0);

            try {
                NSString kCGImageSourceShouldCache   = Dlfcn.GetStringConstant(lib, "kCGImageSourceShouldCache");
                NSString kCGImagePropertyPixelWidth  = Dlfcn.GetStringConstant(lib, "kCGImagePropertyPixelWidth");
                NSString kCGImagePropertyPixelHeight = Dlfcn.GetStringConstant(lib, "kCGImagePropertyPixelHeight");

#if MONOMAC
                using (var imageSource = CGImageSource.FromUrl(fileUrl)) {
#else
                using (var imageSource = CGImageSource.FromUrl(NSUrl.FromFilename(filename))) {
#endif
                    using (var dict = new NSMutableDictionary()) {
                        dict [kCGImageSourceShouldCache] = NSNumber.FromBoolean(false);
                        using (var props = imageSource.CopyProperties(dict)) {
                            Assert.Null(props.ValueForKey(kCGImagePropertyPixelWidth), "kCGImagePropertyPixelWidth");
                            Assert.Null(props.ValueForKey(kCGImagePropertyPixelHeight), "kCGImagePropertyPixelHeight");
                            NSNumber n = (NSNumber)props ["FileSize"];
                            // image is "optimized" for devices (and a lot bigger at 10351 bytes ;-)
                            Assert.That((int)n, Is.AtLeast(7318), "FileSize");
                        }
                    }
                }
            }
            finally {
                Dlfcn.dlclose(lib);
            }
        }
        static CVPixelBuffer()
        {
            var handle = Dlfcn.dlopen(Constants.CoreVideoLibrary, 0);

            if (handle == IntPtr.Zero)
            {
                return;
            }
            try
            {
                PixelFormatTypeKey              = Dlfcn.GetStringConstant(handle, "kCVPixelBufferPixelFormatTypeKey");
                MemoryAllocatorKey              = Dlfcn.GetStringConstant(handle, "kCVPixelBufferMemoryAllocatorKey");
                WidthKey                        = Dlfcn.GetStringConstant(handle, "kCVPixelBufferWidthKey");
                HeightKey                       = Dlfcn.GetStringConstant(handle, "kCVPixelBufferHeightKey");
                ExtendedPixelsLeftKey           = Dlfcn.GetStringConstant(handle, "kCVPixelBufferExtendedPixelsLeftKey");
                ExtendedPixelsTopKey            = Dlfcn.GetStringConstant(handle, "kCVPixelBufferExtendedPixelsTopKey");
                ExtendedPixelsRightKey          = Dlfcn.GetStringConstant(handle, "kCVPixelBufferExtendedPixelsRightKey");
                ExtendedPixelsBottomKey         = Dlfcn.GetStringConstant(handle, "kCVPixelBufferExtendedPixelsBottomKey");
                BytesPerRowAlignmentKey         = Dlfcn.GetStringConstant(handle, "kCVPixelBufferBytesPerRowAlignmentKey");
                CGBitmapContextCompatibilityKey = Dlfcn.GetStringConstant(handle, "kCVPixelBufferCGBitmapContextCompatibilityKey");
                CGImageCompatibilityKey         = Dlfcn.GetStringConstant(handle, "kCVPixelBufferCGImageCompatibilityKey");
                OpenGLCompatibilityKey          = Dlfcn.GetStringConstant(handle, "kCVPixelBufferOpenGLCompatibilityKey");
                IOSurfacePropertiesKey          = Dlfcn.GetStringConstant(handle, "kCVPixelBufferIOSurfacePropertiesKey");
                PlaneAlignmentKey               = Dlfcn.GetStringConstant(handle, "kCVPixelBufferPlaneAlignmentKey");
                CVImageBufferType               = CVPixelBufferGetTypeID();
            }
            finally
            {
                Dlfcn.dlclose(handle);
            }
        }
Exemplo n.º 18
0
        static CMTimeRange()
        {
            var lib = Dlfcn.dlopen(Constants.CoreMediaLibrary, 0);

            if (lib != IntPtr.Zero)
            {
                try {
                    var retZero = Dlfcn.dlsym(lib, "kCMTimeRangeZero");
                    Zero = (CMTimeRange)Marshal.PtrToStructure(retZero, typeof(CMTimeRange));

                    var retInvalid = Dlfcn.dlsym(lib, "kCMTimeRangeInvalid");
#if !XAMCORE_3_0
                    Invalid = (CMTimeRange)Marshal.PtrToStructure(retInvalid, typeof(CMTimeRange));
#endif
                    InvalidRange = (CMTimeRange)Marshal.PtrToStructure(retInvalid, typeof(CMTimeRange));

                    var retMappingInvalid = Dlfcn.dlsym(lib, "kCMTimeMappingInvalid");
                    if (retMappingInvalid != IntPtr.Zero)
                    {
                        InvalidMapping = (CMTimeRange)Marshal.PtrToStructure(retMappingInvalid, typeof(CMTimeRange));
                    }

                    TimeMappingSourceKey = Dlfcn.GetStringConstant(lib, "kCMTimeMappingSourceKey");
                    TimeMappingTargetKey = Dlfcn.GetStringConstant(lib, "kCMTimeMappingTargetKey");
                } finally {
                    Dlfcn.dlclose(lib);
                }
            }
        }
Exemplo n.º 19
0
        static CTFontNameKeyId()
        {
            var handle = Dlfcn.dlopen(Constants.CoreTextLibrary, 0);

            if (handle == IntPtr.Zero)
            {
                return;
            }
            try {
                Copyright     = Dlfcn.GetStringConstant(handle, "kCTFontCopyrightNameKey");
                Family        = Dlfcn.GetStringConstant(handle, "kCTFontFamilyNameKey");
                SubFamily     = Dlfcn.GetStringConstant(handle, "kCTFontSubFamilyNameKey");
                Style         = Dlfcn.GetStringConstant(handle, "kCTFontStyleNameKey");
                Unique        = Dlfcn.GetStringConstant(handle, "kCTFontUniqueNameKey");
                Full          = Dlfcn.GetStringConstant(handle, "kCTFontFullNameKey");
                Version       = Dlfcn.GetStringConstant(handle, "kCTFontVersionNameKey");
                PostScript    = Dlfcn.GetStringConstant(handle, "kCTFontPostScriptNameKey");
                Trademark     = Dlfcn.GetStringConstant(handle, "kCTFontTrademarkNameKey");
                Manufacturer  = Dlfcn.GetStringConstant(handle, "kCTFontManufacturerNameKey");
                Designer      = Dlfcn.GetStringConstant(handle, "kCTFontDesignerNameKey");
                Description   = Dlfcn.GetStringConstant(handle, "kCTFontDescriptionNameKey");
                VendorUrl     = Dlfcn.GetStringConstant(handle, "kCTFontVendorURLNameKey");
                DesignerUrl   = Dlfcn.GetStringConstant(handle, "kCTFontDesignerURLNameKey");
                License       = Dlfcn.GetStringConstant(handle, "kCTFontLicenseNameKey");
                LicenseUrl    = Dlfcn.GetStringConstant(handle, "kCTFontLicenseURLNameKey");
                SampleText    = Dlfcn.GetStringConstant(handle, "kCTFontSampleTextNameKey");
                PostscriptCid = Dlfcn.GetStringConstant(handle, "kCTFontPostScriptCIDNameKey");
            }
            finally {
                Dlfcn.dlclose(handle);
            }
        }
Exemplo n.º 20
0
        static CFHTTPStream()
        {
            var handle = Dlfcn.dlopen(Constants.CFNetworkLibrary, 0);

            if (handle == IntPtr.Zero)
            {
                throw new InvalidOperationException();
            }

            try {
                _AttemptPersistentConnection = GetStringConstant(
                    handle, "kCFStreamPropertyHTTPAttemptPersistentConnection");
                _FinalURL = GetStringConstant(
                    handle, "kCFStreamPropertyHTTPFinalURL");
                _FinalRequest = GetStringConstant(
                    handle, "kCFStreamPropertyHTTPFinalRequest");
                _Proxy = GetStringConstant(
                    handle, "kCFStreamPropertyHTTPProxy");
                _RequestBytesWrittenCount = GetStringConstant(
                    handle, "kCFStreamPropertyHTTPRequestBytesWrittenCount");
                _ResponseHeader = GetStringConstant(
                    handle, "kCFStreamPropertyHTTPResponseHeader");
                _ShouldAutoredirect = GetStringConstant(
                    handle, "kCFStreamPropertyHTTPShouldAutoredirect");
            } finally {
                Dlfcn.dlclose(handle);
            }
        }
Exemplo n.º 21
0
        static void Main(string[] args)
        {
            IntPtr h = Dlfcn.dlopen(Constants.CoreGraphicsLibrary, 0);

            NSApplication.Init();
            NSApplication.Main(args);
            Dlfcn.dlclose(h);
        }
Exemplo n.º 22
0
		static AudioSessionRouteChangeEventArgs ()
		{
			var lib = Dlfcn.dlopen (Constants.AudioToolboxLibrary, 0);
			route_change_key = Dlfcn.GetIntPtr (lib, "kAudioSession_RouteChangeKey_Reason");
			previous_route_key = Dlfcn.GetIntPtr (lib, "kAudioSession_AudioRouteChangeKey_PreviousRouteDescription");
			current_route_key = Dlfcn.GetIntPtr (lib, "kAudioSession_AudioRouteChangeKey_CurrentRouteDescription");

			Dlfcn.dlclose (lib);
		}
Exemplo n.º 23
0
        public void FieldExists()
        {
            var failed_fields = new List <string> ();

            Errors = 0;
            int c = 0, n = 0;

            foreach (Type t in Assembly.GetTypes())
            {
                if (Skip(t) || SkipDueToAttribute(t))
                {
                    continue;
                }

                if (LogProgress)
                {
                    Console.WriteLine("{0}. {1}", c++, t.FullName);
                }

                foreach (var p in t.GetProperties(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic))
                {
                    // looking for properties with getters only
                    if (p.CanWrite || !p.CanRead)
                    {
                        continue;
                    }

                    if (SkipDueToAttribute(p))
                    {
                        continue;
                    }

                    var f = p.GetCustomAttribute <FieldAttribute> ();
                    if (f == null)
                    {
                        continue;
                    }

                    string name = f.SymbolName;
                    if (Skip(name))
                    {
                        continue;
                    }

                    string path = FindLibrary(f.LibraryName);
                    IntPtr lib  = Dlfcn.dlopen(path, 0);
                    if (Dlfcn.GetIndirect(lib, name) == IntPtr.Zero)
                    {
                        ReportError("Could not find the field '{0}' in {1}", name, path);
                        failed_fields.Add(name);
                    }
                    Dlfcn.dlclose(lib);
                    n++;
                }
            }
            Assert.AreEqual(0, Errors, "{0} errors found in {1} fields validated: {2}", Errors, n, string.Join(", ", failed_fields));
        }
Exemplo n.º 24
0
        static double GetConstant(string constantName)
        {
            var handle = Dlfcn.dlopen(Constants.CoreLocationLibrary, 0);

            try {
                return(Dlfcn.GetDouble(handle, constantName));
            } finally {
                Dlfcn.dlclose(handle);
            }
        }
Exemplo n.º 25
0
        static CMMemoryPool()
        {
            var handle = Dlfcn.dlopen(Constants.CoreMediaLibrary, 0);

            try {
                AgeOutPeriodSelector = Dlfcn.GetIntPtr(handle, "kCMMemoryPoolOption_AgeOutPeriod");
            } finally {
                Dlfcn.dlclose(handle);
            }
        }
Exemplo n.º 26
0
        static CFDictionary()
        {
            var lib = Dlfcn.dlopen(Constants.CoreFoundationLibrary, 0);

            try {
                KeyCallbacks   = Dlfcn.GetIndirect(lib, "kCFTypeDictionaryKeyCallBacks");
                ValueCallbacks = Dlfcn.GetIndirect(lib, "kCFTypeDictionaryValueCallBacks");
            } finally {
                Dlfcn.dlclose(lib);
            }
        }
        public void TerminateForInvalidReceipt()
        {
            TestRuntime.AssertSystemVersion(PlatformName.iOS, 7, 1, throwIfOtherPlatform: false);
            // not yet documented - seems to kill the app on purpose ?!? on both sim and devices
            //SKReceiptRefreshRequest.TerminateForInvalidReceipt ();

            IntPtr sk = Dlfcn.dlopen("/System/Library/Frameworks/StoreKit.framework/StoreKit", 1);
            IntPtr fp = Dlfcn.dlsym(sk, "SKTerminateForInvalidReceipt");

            Assert.That(fp, Is.Not.EqualTo(IntPtr.Zero), "pointer");
            Dlfcn.dlclose(sk);
        }
Exemplo n.º 28
0
        // we just want to confirm the symbol exists so `dlsym` can be disabled
        protected void Check(Assembly a)
        {
            Errors = 0;
            ErrorData.Clear();
            int n = 0;

            foreach (var t in a.GetTypes())
            {
                foreach (var m in t.GetMethods(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static))
                {
                    if ((m.Attributes & MethodAttributes.PinvokeImpl) == 0)
                    {
                        continue;
                    }

                    var dllimport = m.GetCustomAttribute <DllImportAttribute> ();

                    string name = dllimport.EntryPoint ?? m.Name;
                    switch (name)
                    {
                    // known not to be present in ARM64
                    case "objc_msgSend_stret":
                    case "objc_msgSendSuper_stret":
                        // the linker normally removes them (IntPtr.Size optimization)
                        continue;
                    }

                    string path = dllimport.Value;
                    switch (path)
                    {
                    case "__Internal":
                        // load from executable
                        path = null;
                        break;

                    case "libc":
                        // we still have some rogue/not-fully-qualified DllImport
                        path = "/usr/lib/libSystem.dylib";
                        break;
                    }

                    var lib = Dlfcn.dlopen(path, 0);
                    var h   = Dlfcn.dlsym(lib, name);
                    if (h == IntPtr.Zero)
                    {
                        ReportError("Could not find the symbol '{0}' in {1}", name, path);
                    }
                    Dlfcn.dlclose(lib);
                    n++;
                }
            }
            Assert.AreEqual(0, Errors, "{0} errors found in {1} symbol lookups{2}", Errors, n, Errors == 0 ? string.Empty : ":\n" + ErrorData.ToString() + "\n");
        }
Exemplo n.º 29
0
        static CFSet()
        {
            var handle = Dlfcn.dlopen(Constants.CoreFoundationLibrary, 0);

            try {
                var kCFTypeSetCallBacksPtr = Dlfcn.GetIndirect(handle, "kCFTypeSetCallBacks");
                kCFTypeSetCallBacks = (CFSetCallBacks)Marshal.PtrToStructure(kCFTypeSetCallBacksPtr, typeof(CFSetCallBacks));
                var kCFCopyStringSetCallBacksPtr = Dlfcn.GetIndirect(handle, "kCFCopyStringSetCallBacks");
                kCFCopyStringSetCallBacks = (CFSetCallBacks)Marshal.PtrToStructure(kCFCopyStringSetCallBacksPtr, typeof(CFSetCallBacks));
            } finally {
                Dlfcn.dlclose(handle);
            }
        }
        static void Init()
        {
            if (kLossyCompressionQuality != IntPtr.Zero)
            {
                return;
            }

            IntPtr lib = Dlfcn.dlopen(Constants.ImageIOLibrary, 0);

            kLossyCompressionQuality = Dlfcn.GetIntPtr(lib, "kCGImageDestinationLossyCompressionQuality");
            kBackgroundColor         = Dlfcn.GetIntPtr(lib, "kCGImageDestinationBackgroundColor");
            Dlfcn.dlclose(lib);
        }