{- | Copyright : Will Thompson, Iñaki García Etxebarria and Jonas Platte License : LGPL-2.1 Maintainer : Iñaki García Etxebarria (inaki@blueleaf.cc) -} #define ENABLE_OVERLOADING (MIN_VERSION_haskell_gi_overloading(1,0,0) \ && !defined(__HADDOCK_VERSION__)) module GI.GLib.Functions ( -- * Methods -- ** access #method:access# access , -- ** asciiDigitValue #method:asciiDigitValue# asciiDigitValue , -- ** asciiDtostr #method:asciiDtostr# asciiDtostr , -- ** asciiFormatd #method:asciiFormatd# asciiFormatd , -- ** asciiStrcasecmp #method:asciiStrcasecmp# asciiStrcasecmp , -- ** asciiStrdown #method:asciiStrdown# asciiStrdown , -- ** asciiStringToSigned #method:asciiStringToSigned# asciiStringToSigned , -- ** asciiStringToUnsigned #method:asciiStringToUnsigned# asciiStringToUnsigned , -- ** asciiStrncasecmp #method:asciiStrncasecmp# asciiStrncasecmp , -- ** asciiStrtod #method:asciiStrtod# asciiStrtod , -- ** asciiStrtoll #method:asciiStrtoll# asciiStrtoll , -- ** asciiStrtoull #method:asciiStrtoull# asciiStrtoull , -- ** asciiStrup #method:asciiStrup# asciiStrup , -- ** asciiTolower #method:asciiTolower# asciiTolower , -- ** asciiToupper #method:asciiToupper# asciiToupper , -- ** asciiXdigitValue #method:asciiXdigitValue# asciiXdigitValue , -- ** assertWarning #method:assertWarning# assertWarning , -- ** assertionMessage #method:assertionMessage# assertionMessage , -- ** assertionMessageCmpstr #method:assertionMessageCmpstr# assertionMessageCmpstr , -- ** assertionMessageError #method:assertionMessageError# assertionMessageError , -- ** atexit #method:atexit# atexit , -- ** atomicIntAdd #method:atomicIntAdd# atomicIntAdd , -- ** atomicIntAnd #method:atomicIntAnd# atomicIntAnd , -- ** atomicIntCompareAndExchange #method:atomicIntCompareAndExchange# atomicIntCompareAndExchange , -- ** atomicIntDecAndTest #method:atomicIntDecAndTest# atomicIntDecAndTest , -- ** atomicIntExchangeAndAdd #method:atomicIntExchangeAndAdd# atomicIntExchangeAndAdd , -- ** atomicIntGet #method:atomicIntGet# atomicIntGet , -- ** atomicIntInc #method:atomicIntInc# atomicIntInc , -- ** atomicIntOr #method:atomicIntOr# atomicIntOr , -- ** atomicIntSet #method:atomicIntSet# atomicIntSet , -- ** atomicIntXor #method:atomicIntXor# atomicIntXor , -- ** atomicPointerAdd #method:atomicPointerAdd# atomicPointerAdd , -- ** atomicPointerAnd #method:atomicPointerAnd# atomicPointerAnd , -- ** atomicPointerCompareAndExchange #method:atomicPointerCompareAndExchange# atomicPointerCompareAndExchange , -- ** atomicPointerGet #method:atomicPointerGet# atomicPointerGet , -- ** atomicPointerOr #method:atomicPointerOr# atomicPointerOr , -- ** atomicPointerSet #method:atomicPointerSet# atomicPointerSet , -- ** atomicPointerXor #method:atomicPointerXor# atomicPointerXor , -- ** atomicRcBoxAcquire #method:atomicRcBoxAcquire# atomicRcBoxAcquire , -- ** atomicRcBoxAlloc #method:atomicRcBoxAlloc# atomicRcBoxAlloc , -- ** atomicRcBoxAlloc0 #method:atomicRcBoxAlloc0# atomicRcBoxAlloc0 , -- ** atomicRcBoxDup #method:atomicRcBoxDup# atomicRcBoxDup , -- ** atomicRcBoxGetSize #method:atomicRcBoxGetSize# atomicRcBoxGetSize , -- ** atomicRcBoxRelease #method:atomicRcBoxRelease# atomicRcBoxRelease , -- ** atomicRcBoxReleaseFull #method:atomicRcBoxReleaseFull# atomicRcBoxReleaseFull , -- ** atomicRefCountCompare #method:atomicRefCountCompare# atomicRefCountCompare , -- ** atomicRefCountDec #method:atomicRefCountDec# atomicRefCountDec , -- ** atomicRefCountInc #method:atomicRefCountInc# atomicRefCountInc , -- ** atomicRefCountInit #method:atomicRefCountInit# atomicRefCountInit , -- ** base64Decode #method:base64Decode# base64Decode , -- ** base64DecodeInplace #method:base64DecodeInplace# base64DecodeInplace , -- ** base64Encode #method:base64Encode# base64Encode , -- ** basename #method:basename# basename , -- ** bitLock #method:bitLock# bitLock , -- ** bitNthLsf #method:bitNthLsf# bitNthLsf , -- ** bitNthMsf #method:bitNthMsf# bitNthMsf , -- ** bitStorage #method:bitStorage# bitStorage , -- ** bitTrylock #method:bitTrylock# bitTrylock , -- ** bitUnlock #method:bitUnlock# bitUnlock , -- ** buildFilenamev #method:buildFilenamev# buildFilenamev , -- ** buildPathv #method:buildPathv# buildPathv , -- ** canonicalizeFilename #method:canonicalizeFilename# canonicalizeFilename , -- ** chdir #method:chdir# chdir , -- ** checkVersion #method:checkVersion# checkVersion , -- ** childWatchAdd #method:childWatchAdd# childWatchAdd , -- ** childWatchSourceNew #method:childWatchSourceNew# childWatchSourceNew , -- ** clearError #method:clearError# clearError , -- ** close #method:close# close , -- ** computeChecksumForBytes #method:computeChecksumForBytes# computeChecksumForBytes , -- ** computeChecksumForData #method:computeChecksumForData# computeChecksumForData , -- ** computeChecksumForString #method:computeChecksumForString# computeChecksumForString , -- ** computeHmacForBytes #method:computeHmacForBytes# computeHmacForBytes , -- ** computeHmacForData #method:computeHmacForData# computeHmacForData , -- ** computeHmacForString #method:computeHmacForString# computeHmacForString , -- ** convert #method:convert# convert , -- ** convertErrorQuark #method:convertErrorQuark# convertErrorQuark , -- ** convertWithFallback #method:convertWithFallback# convertWithFallback , -- ** datalistForeach #method:datalistForeach# datalistForeach , -- ** datalistGetData #method:datalistGetData# datalistGetData , -- ** datalistGetFlags #method:datalistGetFlags# datalistGetFlags , -- ** datalistIdGetData #method:datalistIdGetData# datalistIdGetData , -- ** datalistSetFlags #method:datalistSetFlags# datalistSetFlags , -- ** datalistUnsetFlags #method:datalistUnsetFlags# datalistUnsetFlags , -- ** datasetDestroy #method:datasetDestroy# datasetDestroy , -- ** datasetForeach #method:datasetForeach# datasetForeach , -- ** datasetIdGetData #method:datasetIdGetData# datasetIdGetData , -- ** dcgettext #method:dcgettext# dcgettext , -- ** dgettext #method:dgettext# dgettext , -- ** directEqual #method:directEqual# directEqual , -- ** directHash #method:directHash# directHash , -- ** dngettext #method:dngettext# dngettext , -- ** doubleEqual #method:doubleEqual# doubleEqual , -- ** doubleHash #method:doubleHash# doubleHash , -- ** dpgettext #method:dpgettext# dpgettext , -- ** dpgettext2 #method:dpgettext2# dpgettext2 , -- ** environGetenv #method:environGetenv# environGetenv , -- ** environSetenv #method:environSetenv# environSetenv , -- ** environUnsetenv #method:environUnsetenv# environUnsetenv , -- ** fileErrorFromErrno #method:fileErrorFromErrno# fileErrorFromErrno , -- ** fileErrorQuark #method:fileErrorQuark# fileErrorQuark , -- ** fileGetContents #method:fileGetContents# fileGetContents , -- ** fileOpenTmp #method:fileOpenTmp# fileOpenTmp , -- ** fileReadLink #method:fileReadLink# fileReadLink , -- ** fileSetContents #method:fileSetContents# fileSetContents , -- ** fileTest #method:fileTest# fileTest , -- ** filenameDisplayBasename #method:filenameDisplayBasename# filenameDisplayBasename , -- ** filenameDisplayName #method:filenameDisplayName# filenameDisplayName , -- ** filenameFromUri #method:filenameFromUri# filenameFromUri , -- ** filenameFromUtf8 #method:filenameFromUtf8# filenameFromUtf8 , -- ** filenameToUri #method:filenameToUri# filenameToUri , -- ** filenameToUtf8 #method:filenameToUtf8# filenameToUtf8 , -- ** findProgramInPath #method:findProgramInPath# findProgramInPath , -- ** formatSize #method:formatSize# formatSize , -- ** formatSizeForDisplay #method:formatSizeForDisplay# formatSizeForDisplay , -- ** formatSizeFull #method:formatSizeFull# formatSizeFull , -- ** free #method:free# free , -- ** getApplicationName #method:getApplicationName# getApplicationName , -- ** getCharset #method:getCharset# getCharset , -- ** getCodeset #method:getCodeset# getCodeset , -- ** getCurrentDir #method:getCurrentDir# getCurrentDir , -- ** getCurrentTime #method:getCurrentTime# getCurrentTime , -- ** getEnviron #method:getEnviron# getEnviron , -- ** getFilenameCharsets #method:getFilenameCharsets# getFilenameCharsets , -- ** getHomeDir #method:getHomeDir# getHomeDir , -- ** getHostName #method:getHostName# getHostName , -- ** getLanguageNames #method:getLanguageNames# getLanguageNames , -- ** getLanguageNamesWithCategory #method:getLanguageNamesWithCategory# getLanguageNamesWithCategory , -- ** getLocaleVariants #method:getLocaleVariants# getLocaleVariants , -- ** getMonotonicTime #method:getMonotonicTime# getMonotonicTime , -- ** getNumProcessors #method:getNumProcessors# getNumProcessors , -- ** getPrgname #method:getPrgname# getPrgname , -- ** getRealName #method:getRealName# getRealName , -- ** getRealTime #method:getRealTime# getRealTime , -- ** getSystemConfigDirs #method:getSystemConfigDirs# getSystemConfigDirs , -- ** getSystemDataDirs #method:getSystemDataDirs# getSystemDataDirs , -- ** getTmpDir #method:getTmpDir# getTmpDir , -- ** getUserCacheDir #method:getUserCacheDir# getUserCacheDir , -- ** getUserConfigDir #method:getUserConfigDir# getUserConfigDir , -- ** getUserDataDir #method:getUserDataDir# getUserDataDir , -- ** getUserName #method:getUserName# getUserName , -- ** getUserRuntimeDir #method:getUserRuntimeDir# getUserRuntimeDir , -- ** getUserSpecialDir #method:getUserSpecialDir# getUserSpecialDir , -- ** getenv #method:getenv# getenv , -- ** hostnameIsAsciiEncoded #method:hostnameIsAsciiEncoded# hostnameIsAsciiEncoded , -- ** hostnameIsIpAddress #method:hostnameIsIpAddress# hostnameIsIpAddress , -- ** hostnameIsNonAscii #method:hostnameIsNonAscii# hostnameIsNonAscii , -- ** hostnameToAscii #method:hostnameToAscii# hostnameToAscii , -- ** hostnameToUnicode #method:hostnameToUnicode# hostnameToUnicode , -- ** idleAdd #method:idleAdd# idleAdd , -- ** idleRemoveByData #method:idleRemoveByData# idleRemoveByData , -- ** idleSourceNew #method:idleSourceNew# idleSourceNew , -- ** int64Equal #method:int64Equal# int64Equal , -- ** int64Hash #method:int64Hash# int64Hash , -- ** intEqual #method:intEqual# intEqual , -- ** intHash #method:intHash# intHash , -- ** internStaticString #method:internStaticString# internStaticString , -- ** internString #method:internString# internString , -- ** ioAddWatch #method:ioAddWatch# ioAddWatch , -- ** ioCreateWatch #method:ioCreateWatch# ioCreateWatch , -- ** listenv #method:listenv# listenv , -- ** localeFromUtf8 #method:localeFromUtf8# localeFromUtf8 , -- ** localeToUtf8 #method:localeToUtf8# localeToUtf8 , -- ** logDefaultHandler #method:logDefaultHandler# logDefaultHandler , -- ** logRemoveHandler #method:logRemoveHandler# logRemoveHandler , -- ** logSetAlwaysFatal #method:logSetAlwaysFatal# logSetAlwaysFatal , -- ** logSetFatalMask #method:logSetFatalMask# logSetFatalMask , -- ** logSetHandler #method:logSetHandler# logSetHandler , -- ** logStructuredArray #method:logStructuredArray# logStructuredArray , -- ** logVariant #method:logVariant# logVariant , -- ** logWriterDefault #method:logWriterDefault# logWriterDefault , -- ** logWriterFormatFields #method:logWriterFormatFields# logWriterFormatFields , -- ** logWriterIsJournald #method:logWriterIsJournald# logWriterIsJournald , -- ** logWriterJournald #method:logWriterJournald# logWriterJournald , -- ** logWriterStandardStreams #method:logWriterStandardStreams# logWriterStandardStreams , -- ** logWriterSupportsColor #method:logWriterSupportsColor# logWriterSupportsColor , -- ** mainCurrentSource #method:mainCurrentSource# mainCurrentSource , -- ** mainDepth #method:mainDepth# mainDepth , -- ** malloc #method:malloc# malloc , -- ** malloc0 #method:malloc0# malloc0 , -- ** malloc0N #method:malloc0N# malloc0N , -- ** mallocN #method:mallocN# mallocN , -- ** markupErrorQuark #method:markupErrorQuark# markupErrorQuark , -- ** markupEscapeText #method:markupEscapeText# markupEscapeText , -- ** memIsSystemMalloc #method:memIsSystemMalloc# memIsSystemMalloc , -- ** memProfile #method:memProfile# memProfile , -- ** memSetVtable #method:memSetVtable# memSetVtable , -- ** memdup #method:memdup# memdup , -- ** mkdirWithParents #method:mkdirWithParents# mkdirWithParents , -- ** nullifyPointer #method:nullifyPointer# nullifyPointer , -- ** numberParserErrorQuark #method:numberParserErrorQuark# numberParserErrorQuark , -- ** onErrorQuery #method:onErrorQuery# onErrorQuery , -- ** onErrorStackTrace #method:onErrorStackTrace# onErrorStackTrace , -- ** optionErrorQuark #method:optionErrorQuark# optionErrorQuark , -- ** parseDebugString #method:parseDebugString# parseDebugString , -- ** pathGetBasename #method:pathGetBasename# pathGetBasename , -- ** pathGetDirname #method:pathGetDirname# pathGetDirname , -- ** pathIsAbsolute #method:pathIsAbsolute# pathIsAbsolute , -- ** pathSkipRoot #method:pathSkipRoot# pathSkipRoot , -- ** patternMatch #method:patternMatch# patternMatch , -- ** patternMatchSimple #method:patternMatchSimple# patternMatchSimple , -- ** patternMatchString #method:patternMatchString# patternMatchString , -- ** pointerBitLock #method:pointerBitLock# pointerBitLock , -- ** pointerBitTrylock #method:pointerBitTrylock# pointerBitTrylock , -- ** pointerBitUnlock #method:pointerBitUnlock# pointerBitUnlock , -- ** poll #method:poll# poll , -- ** propagateError #method:propagateError# propagateError , -- ** quarkFromStaticString #method:quarkFromStaticString# quarkFromStaticString , -- ** quarkFromString #method:quarkFromString# quarkFromString , -- ** quarkToString #method:quarkToString# quarkToString , -- ** quarkTryString #method:quarkTryString# quarkTryString , -- ** randomDouble #method:randomDouble# randomDouble , -- ** randomDoubleRange #method:randomDoubleRange# randomDoubleRange , -- ** randomInt #method:randomInt# randomInt , -- ** randomIntRange #method:randomIntRange# randomIntRange , -- ** randomSetSeed #method:randomSetSeed# randomSetSeed , -- ** rcBoxAcquire #method:rcBoxAcquire# rcBoxAcquire , -- ** rcBoxAlloc #method:rcBoxAlloc# rcBoxAlloc , -- ** rcBoxAlloc0 #method:rcBoxAlloc0# rcBoxAlloc0 , -- ** rcBoxDup #method:rcBoxDup# rcBoxDup , -- ** rcBoxGetSize #method:rcBoxGetSize# rcBoxGetSize , -- ** rcBoxRelease #method:rcBoxRelease# rcBoxRelease , -- ** rcBoxReleaseFull #method:rcBoxReleaseFull# rcBoxReleaseFull , -- ** realloc #method:realloc# realloc , -- ** reallocN #method:reallocN# reallocN , -- ** refCountCompare #method:refCountCompare# refCountCompare , -- ** refCountDec #method:refCountDec# refCountDec , -- ** refCountInc #method:refCountInc# refCountInc , -- ** refCountInit #method:refCountInit# refCountInit , -- ** refStringAcquire #method:refStringAcquire# refStringAcquire , -- ** refStringLength #method:refStringLength# refStringLength , -- ** refStringNew #method:refStringNew# refStringNew , -- ** refStringNewIntern #method:refStringNewIntern# refStringNewIntern , -- ** refStringNewLen #method:refStringNewLen# refStringNewLen , -- ** refStringRelease #method:refStringRelease# refStringRelease , -- ** reloadUserSpecialDirsCache #method:reloadUserSpecialDirsCache# reloadUserSpecialDirsCache , -- ** rmdir #method:rmdir# rmdir , -- ** setApplicationName #method:setApplicationName# setApplicationName , -- ** setErrorLiteral #method:setErrorLiteral# setErrorLiteral , -- ** setPrgname #method:setPrgname# setPrgname , -- ** setenv #method:setenv# setenv , -- ** shellErrorQuark #method:shellErrorQuark# shellErrorQuark , -- ** shellParseArgv #method:shellParseArgv# shellParseArgv , -- ** shellQuote #method:shellQuote# shellQuote , -- ** shellUnquote #method:shellUnquote# shellUnquote , -- ** sliceAlloc #method:sliceAlloc# sliceAlloc , -- ** sliceAlloc0 #method:sliceAlloc0# sliceAlloc0 , -- ** sliceCopy #method:sliceCopy# sliceCopy , -- ** sliceFree1 #method:sliceFree1# sliceFree1 , -- ** sliceFreeChainWithOffset #method:sliceFreeChainWithOffset# sliceFreeChainWithOffset , -- ** sliceGetConfig #method:sliceGetConfig# sliceGetConfig , -- ** sliceGetConfigState #method:sliceGetConfigState# sliceGetConfigState , -- ** sliceSetConfig #method:sliceSetConfig# sliceSetConfig , -- ** spacedPrimesClosest #method:spacedPrimesClosest# spacedPrimesClosest , -- ** spawnAsync #method:spawnAsync# spawnAsync , -- ** spawnAsyncWithFds #method:spawnAsyncWithFds# spawnAsyncWithFds , -- ** spawnAsyncWithPipes #method:spawnAsyncWithPipes# spawnAsyncWithPipes , -- ** spawnCheckExitStatus #method:spawnCheckExitStatus# spawnCheckExitStatus , -- ** spawnClosePid #method:spawnClosePid# spawnClosePid , -- ** spawnCommandLineAsync #method:spawnCommandLineAsync# spawnCommandLineAsync , -- ** spawnCommandLineSync #method:spawnCommandLineSync# spawnCommandLineSync , -- ** spawnErrorQuark #method:spawnErrorQuark# spawnErrorQuark , -- ** spawnExitErrorQuark #method:spawnExitErrorQuark# spawnExitErrorQuark , -- ** spawnSync #method:spawnSync# spawnSync , -- ** stpcpy #method:stpcpy# stpcpy , -- ** strEqual #method:strEqual# strEqual , -- ** strHasPrefix #method:strHasPrefix# strHasPrefix , -- ** strHasSuffix #method:strHasSuffix# strHasSuffix , -- ** strHash #method:strHash# strHash , -- ** strIsAscii #method:strIsAscii# strIsAscii , -- ** strMatchString #method:strMatchString# strMatchString , -- ** strToAscii #method:strToAscii# strToAscii , -- ** strTokenizeAndFold #method:strTokenizeAndFold# strTokenizeAndFold , -- ** strcanon #method:strcanon# strcanon , -- ** strcasecmp #method:strcasecmp# strcasecmp , -- ** strchomp #method:strchomp# strchomp , -- ** strchug #method:strchug# strchug , -- ** strcmp0 #method:strcmp0# strcmp0 , -- ** strcompress #method:strcompress# strcompress , -- ** strdelimit #method:strdelimit# strdelimit , -- ** strdown #method:strdown# strdown , -- ** strdup #method:strdup# strdup , -- ** strerror #method:strerror# strerror , -- ** strescape #method:strescape# strescape , -- ** strfreev #method:strfreev# strfreev , -- ** stringNew #method:stringNew# stringNew , -- ** stringNewLen #method:stringNewLen# stringNewLen , -- ** stringSizedNew #method:stringSizedNew# stringSizedNew , -- ** stripContext #method:stripContext# stripContext , -- ** strjoinv #method:strjoinv# strjoinv , -- ** strlcat #method:strlcat# strlcat , -- ** strlcpy #method:strlcpy# strlcpy , -- ** strncasecmp #method:strncasecmp# strncasecmp , -- ** strndup #method:strndup# strndup , -- ** strnfill #method:strnfill# strnfill , -- ** strreverse #method:strreverse# strreverse , -- ** strrstr #method:strrstr# strrstr , -- ** strrstrLen #method:strrstrLen# strrstrLen , -- ** strsignal #method:strsignal# strsignal , -- ** strstrLen #method:strstrLen# strstrLen , -- ** strtod #method:strtod# strtod , -- ** strup #method:strup# strup , -- ** strvContains #method:strvContains# strvContains , -- ** strvEqual #method:strvEqual# strvEqual , -- ** strvGetType #method:strvGetType# strvGetType , -- ** strvLength #method:strvLength# strvLength , -- ** testAddDataFunc #method:testAddDataFunc# testAddDataFunc , -- ** testAddFunc #method:testAddFunc# testAddFunc , -- ** testAssertExpectedMessagesInternal #method:testAssertExpectedMessagesInternal# testAssertExpectedMessagesInternal , -- ** testBug #method:testBug# testBug , -- ** testBugBase #method:testBugBase# testBugBase , -- ** testExpectMessage #method:testExpectMessage# testExpectMessage , -- ** testFail #method:testFail# testFail , -- ** testFailed #method:testFailed# testFailed , -- ** testGetDir #method:testGetDir# testGetDir , -- ** testIncomplete #method:testIncomplete# testIncomplete , -- ** testLogTypeName #method:testLogTypeName# testLogTypeName , -- ** testQueueDestroy #method:testQueueDestroy# testQueueDestroy , -- ** testQueueFree #method:testQueueFree# testQueueFree , -- ** testRandDouble #method:testRandDouble# testRandDouble , -- ** testRandDoubleRange #method:testRandDoubleRange# testRandDoubleRange , -- ** testRandInt #method:testRandInt# testRandInt , -- ** testRandIntRange #method:testRandIntRange# testRandIntRange , -- ** testRun #method:testRun# testRun , -- ** testRunSuite #method:testRunSuite# testRunSuite , -- ** testSetNonfatalAssertions #method:testSetNonfatalAssertions# testSetNonfatalAssertions , -- ** testSkip #method:testSkip# testSkip , -- ** testSubprocess #method:testSubprocess# testSubprocess , -- ** testTimerElapsed #method:testTimerElapsed# testTimerElapsed , -- ** testTimerLast #method:testTimerLast# testTimerLast , -- ** testTimerStart #method:testTimerStart# testTimerStart , -- ** testTrapAssertions #method:testTrapAssertions# testTrapAssertions , -- ** testTrapFork #method:testTrapFork# testTrapFork , -- ** testTrapHasPassed #method:testTrapHasPassed# testTrapHasPassed , -- ** testTrapReachedTimeout #method:testTrapReachedTimeout# testTrapReachedTimeout , -- ** testTrapSubprocess #method:testTrapSubprocess# testTrapSubprocess , -- ** timeoutAdd #method:timeoutAdd# timeoutAdd , -- ** timeoutAddSeconds #method:timeoutAddSeconds# timeoutAddSeconds , -- ** timeoutSourceNew #method:timeoutSourceNew# timeoutSourceNew , -- ** timeoutSourceNewSeconds #method:timeoutSourceNewSeconds# timeoutSourceNewSeconds , -- ** tryMalloc #method:tryMalloc# tryMalloc , -- ** tryMalloc0 #method:tryMalloc0# tryMalloc0 , -- ** tryMalloc0N #method:tryMalloc0N# tryMalloc0N , -- ** tryMallocN #method:tryMallocN# tryMallocN , -- ** tryRealloc #method:tryRealloc# tryRealloc , -- ** tryReallocN #method:tryReallocN# tryReallocN , -- ** unicharBreakType #method:unicharBreakType# unicharBreakType , -- ** unicharCombiningClass #method:unicharCombiningClass# unicharCombiningClass , -- ** unicharCompose #method:unicharCompose# unicharCompose , -- ** unicharDecompose #method:unicharDecompose# unicharDecompose , -- ** unicharDigitValue #method:unicharDigitValue# unicharDigitValue , -- ** unicharGetMirrorChar #method:unicharGetMirrorChar# unicharGetMirrorChar , -- ** unicharGetScript #method:unicharGetScript# unicharGetScript , -- ** unicharIsalnum #method:unicharIsalnum# unicharIsalnum , -- ** unicharIsalpha #method:unicharIsalpha# unicharIsalpha , -- ** unicharIscntrl #method:unicharIscntrl# unicharIscntrl , -- ** unicharIsdefined #method:unicharIsdefined# unicharIsdefined , -- ** unicharIsdigit #method:unicharIsdigit# unicharIsdigit , -- ** unicharIsgraph #method:unicharIsgraph# unicharIsgraph , -- ** unicharIslower #method:unicharIslower# unicharIslower , -- ** unicharIsmark #method:unicharIsmark# unicharIsmark , -- ** unicharIsprint #method:unicharIsprint# unicharIsprint , -- ** unicharIspunct #method:unicharIspunct# unicharIspunct , -- ** unicharIsspace #method:unicharIsspace# unicharIsspace , -- ** unicharIstitle #method:unicharIstitle# unicharIstitle , -- ** unicharIsupper #method:unicharIsupper# unicharIsupper , -- ** unicharIswide #method:unicharIswide# unicharIswide , -- ** unicharIswideCjk #method:unicharIswideCjk# unicharIswideCjk , -- ** unicharIsxdigit #method:unicharIsxdigit# unicharIsxdigit , -- ** unicharIszerowidth #method:unicharIszerowidth# unicharIszerowidth , -- ** unicharTolower #method:unicharTolower# unicharTolower , -- ** unicharTotitle #method:unicharTotitle# unicharTotitle , -- ** unicharToupper #method:unicharToupper# unicharToupper , -- ** unicharType #method:unicharType# unicharType , -- ** unicharValidate #method:unicharValidate# unicharValidate , -- ** unicharXdigitValue #method:unicharXdigitValue# unicharXdigitValue , -- ** unicodeCanonicalDecomposition #method:unicodeCanonicalDecomposition# unicodeCanonicalDecomposition , -- ** unicodeCanonicalOrdering #method:unicodeCanonicalOrdering# unicodeCanonicalOrdering , -- ** unicodeScriptFromIso15924 #method:unicodeScriptFromIso15924# unicodeScriptFromIso15924 , -- ** unicodeScriptToIso15924 #method:unicodeScriptToIso15924# unicodeScriptToIso15924 , -- ** unixErrorQuark #method:unixErrorQuark# unixErrorQuark , -- ** unixFdAddFull #method:unixFdAddFull# unixFdAddFull , -- ** unixFdSourceNew #method:unixFdSourceNew# unixFdSourceNew , -- ** unixOpenPipe #method:unixOpenPipe# unixOpenPipe , -- ** unixSetFdNonblocking #method:unixSetFdNonblocking# unixSetFdNonblocking , -- ** unixSignalAdd #method:unixSignalAdd# unixSignalAdd , -- ** unixSignalSourceNew #method:unixSignalSourceNew# unixSignalSourceNew , -- ** unlink #method:unlink# unlink , -- ** unsetenv #method:unsetenv# unsetenv , -- ** uriEscapeString #method:uriEscapeString# uriEscapeString , -- ** uriListExtractUris #method:uriListExtractUris# uriListExtractUris , -- ** uriParseScheme #method:uriParseScheme# uriParseScheme , -- ** uriUnescapeSegment #method:uriUnescapeSegment# uriUnescapeSegment , -- ** uriUnescapeString #method:uriUnescapeString# uriUnescapeString , -- ** usleep #method:usleep# usleep , -- ** utf8Casefold #method:utf8Casefold# utf8Casefold , -- ** utf8Collate #method:utf8Collate# utf8Collate , -- ** utf8CollateKey #method:utf8CollateKey# utf8CollateKey , -- ** utf8CollateKeyForFilename #method:utf8CollateKeyForFilename# utf8CollateKeyForFilename , -- ** utf8FindNextChar #method:utf8FindNextChar# utf8FindNextChar , -- ** utf8FindPrevChar #method:utf8FindPrevChar# utf8FindPrevChar , -- ** utf8GetChar #method:utf8GetChar# utf8GetChar , -- ** utf8GetCharValidated #method:utf8GetCharValidated# utf8GetCharValidated , -- ** utf8MakeValid #method:utf8MakeValid# utf8MakeValid , -- ** utf8Normalize #method:utf8Normalize# utf8Normalize , -- ** utf8OffsetToPointer #method:utf8OffsetToPointer# utf8OffsetToPointer , -- ** utf8PointerToOffset #method:utf8PointerToOffset# utf8PointerToOffset , -- ** utf8PrevChar #method:utf8PrevChar# utf8PrevChar , -- ** utf8Strchr #method:utf8Strchr# utf8Strchr , -- ** utf8Strdown #method:utf8Strdown# utf8Strdown , -- ** utf8Strlen #method:utf8Strlen# utf8Strlen , -- ** utf8Strncpy #method:utf8Strncpy# utf8Strncpy , -- ** utf8Strrchr #method:utf8Strrchr# utf8Strrchr , -- ** utf8Strreverse #method:utf8Strreverse# utf8Strreverse , -- ** utf8Strup #method:utf8Strup# utf8Strup , -- ** utf8Substring #method:utf8Substring# utf8Substring , -- ** utf8Validate #method:utf8Validate# utf8Validate , -- ** utf8ValidateLen #method:utf8ValidateLen# utf8ValidateLen , -- ** uuidStringIsValid #method:uuidStringIsValid# uuidStringIsValid , -- ** uuidStringRandom #method:uuidStringRandom# uuidStringRandom , -- ** variantGetGtype #method:variantGetGtype# variantGetGtype , ) where import Data.GI.Base.ShortPrelude import qualified Data.GI.Base.ShortPrelude as SP import qualified Data.GI.Base.Overloading as O import qualified Prelude as P import qualified Data.GI.Base.Attributes as GI.Attributes import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr import qualified Data.GI.Base.GClosure as B.GClosure import qualified Data.GI.Base.GError as B.GError import qualified Data.GI.Base.GVariant as B.GVariant import qualified Data.GI.Base.GValue as B.GValue import qualified Data.GI.Base.GParamSpec as B.GParamSpec import qualified Data.GI.Base.CallStack as B.CallStack import qualified Data.GI.Base.Properties as B.Properties import qualified Data.Text as T import qualified Data.ByteString.Char8 as B import qualified Data.Map as Map import qualified Foreign.Ptr as FP import qualified GHC.OverloadedLabels as OL import qualified GI.GLib.Callbacks as GLib.Callbacks import {-# SOURCE #-} qualified GI.GLib.Enums as GLib.Enums import {-# SOURCE #-} qualified GI.GLib.Flags as GLib.Flags import {-# SOURCE #-} qualified GI.GLib.Structs.Bytes as GLib.Bytes import {-# SOURCE #-} qualified GI.GLib.Structs.Data as GLib.Data import {-# SOURCE #-} qualified GI.GLib.Structs.DebugKey as GLib.DebugKey import {-# SOURCE #-} qualified GI.GLib.Structs.IOChannel as GLib.IOChannel import {-# SOURCE #-} qualified GI.GLib.Structs.LogField as GLib.LogField import {-# SOURCE #-} qualified GI.GLib.Structs.MemVTable as GLib.MemVTable import {-# SOURCE #-} qualified GI.GLib.Structs.PatternSpec as GLib.PatternSpec import {-# SOURCE #-} qualified GI.GLib.Structs.PollFD as GLib.PollFD import {-# SOURCE #-} qualified GI.GLib.Structs.Source as GLib.Source import {-# SOURCE #-} qualified GI.GLib.Structs.String as GLib.String import {-# SOURCE #-} qualified GI.GLib.Structs.TestSuite as GLib.TestSuite import {-# SOURCE #-} qualified GI.GLib.Structs.TimeVal as GLib.TimeVal -- function g_variant_get_gtype -- Args : [] -- Lengths : [] -- returnType : Just (TBasicType TGType) -- throws : False -- Skip return : False foreign import ccall "g_variant_get_gtype" g_variant_get_gtype :: IO CGType {- | /No description available in the introspection data./ -} variantGetGtype :: (B.CallStack.HasCallStack, MonadIO m) => m GType variantGetGtype = liftIO $ do result <- g_variant_get_gtype let result' = GType result return result' -- function g_uuid_string_random -- Args : [] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_uuid_string_random" g_uuid_string_random :: IO CString {- | Generates a random UUID (RFC 4122 version 4) as a string. /Since: 2.52/ -} uuidStringRandom :: (B.CallStack.HasCallStack, MonadIO m) => m T.Text {- ^ __Returns:__ A string that should be freed with 'GI.GLib.Functions.free'. -} uuidStringRandom = liftIO $ do result <- g_uuid_string_random checkUnexpectedReturnNULL "uuidStringRandom" result result' <- cstringToText result freeMem result return result' -- function g_uuid_string_is_valid -- Args : [Arg {argCName = "str", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a string representing a UUID", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "g_uuid_string_is_valid" g_uuid_string_is_valid :: CString -> -- str : TBasicType TUTF8 IO CInt {- | Parses the string /@str@/ and verify if it is a UUID. The function accepts the following syntax: * simple forms (e.g. @f81d4fae-7dec-11d0-a765-00a0c91e6bf6@) Note that hyphens are required within the UUID string itself, as per the aforementioned RFC. /Since: 2.52/ -} uuidStringIsValid :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@str@/: a string representing a UUID -} -> m Bool {- ^ __Returns:__ 'True' if /@str@/ is a valid UUID, 'False' otherwise. -} uuidStringIsValid str = liftIO $ do str' <- textToCString str result <- g_uuid_string_is_valid str' let result' = (/= 0) result freeMem str' return result' -- function g_utf8_validate_len -- Args : [Arg {argCName = "str", argType = TCArray False (-1) 1 (TBasicType TUInt8), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a pointer to character data", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "max_len", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "max bytes to validate", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "end", argType = TBasicType TUTF8, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "return location for end of valid data", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [Arg {argCName = "max_len", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "max bytes to validate", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "g_utf8_validate_len" g_utf8_validate_len :: Ptr Word8 -> -- str : TCArray False (-1) 1 (TBasicType TUInt8) Word64 -> -- max_len : TBasicType TUInt64 Ptr CString -> -- end : TBasicType TUTF8 IO CInt {- | Validates UTF-8 encoded text. As with 'GI.GLib.Functions.utf8Validate', but /@maxLen@/ must be set, and hence this function will always return 'False' if any of the bytes of /@str@/ are nul. /Since: 2.60/ -} utf8ValidateLen :: (B.CallStack.HasCallStack, MonadIO m) => ByteString {- ^ /@str@/: a pointer to character data -} -> m ((Bool, T.Text)) {- ^ __Returns:__ 'True' if the text was valid UTF-8 -} utf8ValidateLen str = liftIO $ do let maxLen = fromIntegral $ B.length str str' <- packByteString str end <- allocMem :: IO (Ptr CString) result <- g_utf8_validate_len str' maxLen end let result' = (/= 0) result end' <- peek end end'' <- cstringToText end' freeMem str' freeMem end return (result', end'') -- function g_utf8_validate -- Args : [Arg {argCName = "str", argType = TCArray False (-1) 1 (TBasicType TUInt8), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a pointer to character data", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "max_len", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "max bytes to validate, or -1 to go until NUL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "end", argType = TBasicType TUTF8, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "return location for end of valid data", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [Arg {argCName = "max_len", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "max bytes to validate, or -1 to go until NUL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "g_utf8_validate" g_utf8_validate :: Ptr Word8 -> -- str : TCArray False (-1) 1 (TBasicType TUInt8) Int64 -> -- max_len : TBasicType TInt64 Ptr CString -> -- end : TBasicType TUTF8 IO CInt {- | Validates UTF-8 encoded text. /@str@/ is the text to validate; if /@str@/ is nul-terminated, then /@maxLen@/ can be -1, otherwise /@maxLen@/ should be the number of bytes to validate. If /@end@/ is non-'Nothing', then the end of the valid range will be stored there (i.e. the start of the first invalid character if some bytes were invalid, or the end of the text being validated otherwise). Note that 'GI.GLib.Functions.utf8Validate' returns 'False' if /@maxLen@/ is positive and any of the /@maxLen@/ bytes are nul. Returns 'True' if all of /@str@/ was valid. Many GLib and GTK+ routines require valid UTF-8 as input; so data read from a file or the network should be checked with 'GI.GLib.Functions.utf8Validate' before doing anything else with it. -} utf8Validate :: (B.CallStack.HasCallStack, MonadIO m) => ByteString {- ^ /@str@/: a pointer to character data -} -> m ((Bool, T.Text)) {- ^ __Returns:__ 'True' if the text was valid UTF-8 -} utf8Validate str = liftIO $ do let maxLen = fromIntegral $ B.length str str' <- packByteString str end <- allocMem :: IO (Ptr CString) result <- g_utf8_validate str' maxLen end let result' = (/= 0) result end' <- peek end end'' <- cstringToText end' freeMem str' freeMem end return (result', end'') -- function g_utf8_substring -- Args : [Arg {argCName = "str", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a UTF-8 encoded string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "start_pos", argType = TBasicType TLong, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a character offset within @str", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "end_pos", argType = TBasicType TLong, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "another character offset within @str", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_utf8_substring" g_utf8_substring :: CString -> -- str : TBasicType TUTF8 CLong -> -- start_pos : TBasicType TLong CLong -> -- end_pos : TBasicType TLong IO CString {- | Copies a substring out of a UTF-8 encoded string. The substring will contain /@endPos@/ - /@startPos@/ characters. /Since: 2.30/ -} utf8Substring :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@str@/: a UTF-8 encoded string -} -> CLong {- ^ /@startPos@/: a character offset within /@str@/ -} -> CLong {- ^ /@endPos@/: another character offset within /@str@/ -} -> m T.Text {- ^ __Returns:__ a newly allocated copy of the requested substring. Free with 'GI.GLib.Functions.free' when no longer needed. -} utf8Substring str startPos endPos = liftIO $ do str' <- textToCString str result <- g_utf8_substring str' startPos endPos checkUnexpectedReturnNULL "utf8Substring" result result' <- cstringToText result freeMem result freeMem str' return result' -- function g_utf8_strup -- Args : [Arg {argCName = "str", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a UTF-8 encoded string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "len", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "length of @str, in bytes, or -1 if @str is nul-terminated.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_utf8_strup" g_utf8_strup :: CString -> -- str : TBasicType TUTF8 Int64 -> -- len : TBasicType TInt64 IO CString {- | Converts all Unicode characters in the string that have a case to uppercase. The exact manner that this is done depends on the current locale, and may result in the number of characters in the string increasing. (For instance, the German ess-zet will be changed to SS.) -} utf8Strup :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@str@/: a UTF-8 encoded string -} -> Int64 {- ^ /@len@/: length of /@str@/, in bytes, or -1 if /@str@/ is nul-terminated. -} -> m T.Text {- ^ __Returns:__ a newly allocated string, with all characters converted to uppercase. -} utf8Strup str len = liftIO $ do str' <- textToCString str result <- g_utf8_strup str' len checkUnexpectedReturnNULL "utf8Strup" result result' <- cstringToText result freeMem result freeMem str' return result' -- function g_utf8_strreverse -- Args : [Arg {argCName = "str", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a UTF-8 encoded string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "len", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the maximum length of @str to use, in bytes. If @len < 0,\n then the string is nul-terminated.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_utf8_strreverse" g_utf8_strreverse :: CString -> -- str : TBasicType TUTF8 Int64 -> -- len : TBasicType TInt64 IO CString {- | Reverses a UTF-8 string. /@str@/ must be valid UTF-8 encoded text. (Use 'GI.GLib.Functions.utf8Validate' on all text before trying to use UTF-8 utility functions with it.) This function is intended for programmatic uses of reversed strings. It pays no attention to decomposed characters, combining marks, byte order marks, directional indicators (LRM, LRO, etc) and similar characters which might need special handling when reversing a string for display purposes. Note that unlike 'GI.GLib.Functions.strreverse', this function returns newly-allocated memory, which should be freed with 'GI.GLib.Functions.free' when no longer needed. /Since: 2.2/ -} utf8Strreverse :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@str@/: a UTF-8 encoded string -} -> Int64 {- ^ /@len@/: the maximum length of /@str@/ to use, in bytes. If /@len@/ \< 0, then the string is nul-terminated. -} -> m T.Text {- ^ __Returns:__ a newly-allocated string which is the reverse of /@str@/ -} utf8Strreverse str len = liftIO $ do str' <- textToCString str result <- g_utf8_strreverse str' len checkUnexpectedReturnNULL "utf8Strreverse" result result' <- cstringToText result freeMem result freeMem str' return result' -- function g_utf8_strrchr -- Args : [Arg {argCName = "p", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a nul-terminated UTF-8 encoded string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "len", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the maximum length of @p", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "c", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_utf8_strrchr" g_utf8_strrchr :: CString -> -- p : TBasicType TUTF8 Int64 -> -- len : TBasicType TInt64 CInt -> -- c : TBasicType TUniChar IO CString {- | Find the rightmost occurrence of the given Unicode character in a UTF-8 encoded string, while limiting the search to /@len@/ bytes. If /@len@/ is -1, allow unbounded search. -} utf8Strrchr :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@p@/: a nul-terminated UTF-8 encoded string -} -> Int64 {- ^ /@len@/: the maximum length of /@p@/ -} -> Char {- ^ /@c@/: a Unicode character -} -> m T.Text {- ^ __Returns:__ 'Nothing' if the string does not contain the character, otherwise, a pointer to the start of the rightmost occurrence of the character in the string. -} utf8Strrchr p len c = liftIO $ do p' <- textToCString p let c' = (fromIntegral . ord) c result <- g_utf8_strrchr p' len c' checkUnexpectedReturnNULL "utf8Strrchr" result result' <- cstringToText result freeMem result freeMem p' return result' -- function g_utf8_strncpy -- Args : [Arg {argCName = "dest", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "buffer to fill with characters from @src", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "src", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "UTF-8 encoded string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "n", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "character count", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_utf8_strncpy" g_utf8_strncpy :: CString -> -- dest : TBasicType TUTF8 CString -> -- src : TBasicType TUTF8 Word64 -> -- n : TBasicType TUInt64 IO CString {- | Like the standard C @/strncpy()/@ function, but copies a given number of characters instead of a given number of bytes. The /@src@/ string must be valid UTF-8 encoded text. (Use 'GI.GLib.Functions.utf8Validate' on all text before trying to use UTF-8 utility functions with it.) Note you must ensure /@dest@/ is at least 4 * /@n@/ to fit the largest possible UTF-8 characters -} utf8Strncpy :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@dest@/: buffer to fill with characters from /@src@/ -} -> T.Text {- ^ /@src@/: UTF-8 encoded string -} -> Word64 {- ^ /@n@/: character count -} -> m T.Text {- ^ __Returns:__ /@dest@/ -} utf8Strncpy dest src n = liftIO $ do dest' <- textToCString dest src' <- textToCString src result <- g_utf8_strncpy dest' src' n checkUnexpectedReturnNULL "utf8Strncpy" result result' <- cstringToText result freeMem result freeMem dest' freeMem src' return result' -- function g_utf8_strlen -- Args : [Arg {argCName = "p", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "pointer to the start of a UTF-8 encoded string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "max", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the maximum number of bytes to examine. If @max\n is less than 0, then the string is assumed to be\n nul-terminated. If @max is 0, @p will not be examined and\n may be %NULL. If @max is greater than 0, up to @max\n bytes are examined", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TLong) -- throws : False -- Skip return : False foreign import ccall "g_utf8_strlen" g_utf8_strlen :: CString -> -- p : TBasicType TUTF8 Int64 -> -- max : TBasicType TInt64 IO CLong {- | Computes the length of the string in characters, not including the terminating nul character. If the /@max@/\'th byte falls in the middle of a character, the last (partial) character is not counted. -} utf8Strlen :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@p@/: pointer to the start of a UTF-8 encoded string -} -> Int64 {- ^ /@max@/: the maximum number of bytes to examine. If /@max@/ is less than 0, then the string is assumed to be nul-terminated. If /@max@/ is 0, /@p@/ will not be examined and may be 'Nothing'. If /@max@/ is greater than 0, up to /@max@/ bytes are examined -} -> m CLong {- ^ __Returns:__ the length of the string in characters -} utf8Strlen p max = liftIO $ do p' <- textToCString p result <- g_utf8_strlen p' max freeMem p' return result -- function g_utf8_strdown -- Args : [Arg {argCName = "str", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a UTF-8 encoded string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "len", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "length of @str, in bytes, or -1 if @str is nul-terminated.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_utf8_strdown" g_utf8_strdown :: CString -> -- str : TBasicType TUTF8 Int64 -> -- len : TBasicType TInt64 IO CString {- | Converts all Unicode characters in the string that have a case to lowercase. The exact manner that this is done depends on the current locale, and may result in the number of characters in the string changing. -} utf8Strdown :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@str@/: a UTF-8 encoded string -} -> Int64 {- ^ /@len@/: length of /@str@/, in bytes, or -1 if /@str@/ is nul-terminated. -} -> m T.Text {- ^ __Returns:__ a newly allocated string, with all characters converted to lowercase. -} utf8Strdown str len = liftIO $ do str' <- textToCString str result <- g_utf8_strdown str' len checkUnexpectedReturnNULL "utf8Strdown" result result' <- cstringToText result freeMem result freeMem str' return result' -- function g_utf8_strchr -- Args : [Arg {argCName = "p", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a nul-terminated UTF-8 encoded string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "len", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the maximum length of @p", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "c", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_utf8_strchr" g_utf8_strchr :: CString -> -- p : TBasicType TUTF8 Int64 -> -- len : TBasicType TInt64 CInt -> -- c : TBasicType TUniChar IO CString {- | Finds the leftmost occurrence of the given Unicode character in a UTF-8 encoded string, while limiting the search to /@len@/ bytes. If /@len@/ is -1, allow unbounded search. -} utf8Strchr :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@p@/: a nul-terminated UTF-8 encoded string -} -> Int64 {- ^ /@len@/: the maximum length of /@p@/ -} -> Char {- ^ /@c@/: a Unicode character -} -> m T.Text {- ^ __Returns:__ 'Nothing' if the string does not contain the character, otherwise, a pointer to the start of the leftmost occurrence of the character in the string. -} utf8Strchr p len c = liftIO $ do p' <- textToCString p let c' = (fromIntegral . ord) c result <- g_utf8_strchr p' len c' checkUnexpectedReturnNULL "utf8Strchr" result result' <- cstringToText result freeMem result freeMem p' return result' -- function g_utf8_prev_char -- Args : [Arg {argCName = "p", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a pointer to a position within a UTF-8 encoded string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_utf8_prev_char" g_utf8_prev_char :: CString -> -- p : TBasicType TUTF8 IO CString {- | Finds the previous UTF-8 character in the string before /@p@/. /@p@/ does not have to be at the beginning of a UTF-8 character. No check is made to see if the character found is actually valid other than it starts with an appropriate byte. If /@p@/ might be the first character of the string, you must use 'GI.GLib.Functions.utf8FindPrevChar' instead. -} utf8PrevChar :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@p@/: a pointer to a position within a UTF-8 encoded string -} -> m T.Text {- ^ __Returns:__ a pointer to the found character -} utf8PrevChar p = liftIO $ do p' <- textToCString p result <- g_utf8_prev_char p' checkUnexpectedReturnNULL "utf8PrevChar" result result' <- cstringToText result freeMem result freeMem p' return result' -- function g_utf8_pointer_to_offset -- Args : [Arg {argCName = "str", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a UTF-8 encoded string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "pos", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a pointer to a position within @str", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TLong) -- throws : False -- Skip return : False foreign import ccall "g_utf8_pointer_to_offset" g_utf8_pointer_to_offset :: CString -> -- str : TBasicType TUTF8 CString -> -- pos : TBasicType TUTF8 IO CLong {- | Converts from a pointer to position within a string to a integer character offset. Since 2.10, this function allows /@pos@/ to be before /@str@/, and returns a negative offset in this case. -} utf8PointerToOffset :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@str@/: a UTF-8 encoded string -} -> T.Text {- ^ /@pos@/: a pointer to a position within /@str@/ -} -> m CLong {- ^ __Returns:__ the resulting character offset -} utf8PointerToOffset str pos = liftIO $ do str' <- textToCString str pos' <- textToCString pos result <- g_utf8_pointer_to_offset str' pos' freeMem str' freeMem pos' return result -- function g_utf8_offset_to_pointer -- Args : [Arg {argCName = "str", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a UTF-8 encoded string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "offset", argType = TBasicType TLong, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a character offset within @str", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_utf8_offset_to_pointer" g_utf8_offset_to_pointer :: CString -> -- str : TBasicType TUTF8 CLong -> -- offset : TBasicType TLong IO CString {- | Converts from an integer character offset to a pointer to a position within the string. Since 2.10, this function allows to pass a negative /@offset@/ to step backwards. It is usually worth stepping backwards from the end instead of forwards if /@offset@/ is in the last fourth of the string, since moving forward is about 3 times faster than moving backward. Note that this function doesn\'t abort when reaching the end of /@str@/. Therefore you should be sure that /@offset@/ is within string boundaries before calling that function. Call 'GI.GLib.Functions.utf8Strlen' when unsure. This limitation exists as this function is called frequently during text rendering and therefore has to be as fast as possible. -} utf8OffsetToPointer :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@str@/: a UTF-8 encoded string -} -> CLong {- ^ /@offset@/: a character offset within /@str@/ -} -> m T.Text {- ^ __Returns:__ the resulting pointer -} utf8OffsetToPointer str offset = liftIO $ do str' <- textToCString str result <- g_utf8_offset_to_pointer str' offset checkUnexpectedReturnNULL "utf8OffsetToPointer" result result' <- cstringToText result freeMem result freeMem str' return result' -- function g_utf8_normalize -- Args : [Arg {argCName = "str", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a UTF-8 encoded string.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "len", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "length of @str, in bytes, or -1 if @str is nul-terminated.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "mode", argType = TInterface (Name {namespace = "GLib", name = "NormalizeMode"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the type of normalization to perform.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_utf8_normalize" g_utf8_normalize :: CString -> -- str : TBasicType TUTF8 Int64 -> -- len : TBasicType TInt64 CUInt -> -- mode : TInterface (Name {namespace = "GLib", name = "NormalizeMode"}) IO CString {- | Converts a string into canonical form, standardizing such issues as whether a character with an accent is represented as a base character and combining accent or as a single precomposed character. The string has to be valid UTF-8, otherwise 'Nothing' is returned. You should generally call 'GI.GLib.Functions.utf8Normalize' before comparing two Unicode strings. The normalization mode 'GI.GLib.Enums.NormalizeModeDefault' only standardizes differences that do not affect the text content, such as the above-mentioned accent representation. 'GI.GLib.Enums.NormalizeModeAll' also standardizes the \"compatibility\" characters in Unicode, such as SUPERSCRIPT THREE to the standard forms (in this case DIGIT THREE). Formatting information may be lost but for most text operations such characters should be considered the same. 'GI.GLib.Enums.NormalizeModeDefaultCompose' and 'GI.GLib.Enums.NormalizeModeAllCompose' are like 'GI.GLib.Enums.NormalizeModeDefault' and 'GI.GLib.Enums.NormalizeModeAll', but returned a result with composed forms rather than a maximally decomposed form. This is often useful if you intend to convert the string to a legacy encoding or pass it to a system with less capable Unicode handling. -} utf8Normalize :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@str@/: a UTF-8 encoded string. -} -> Int64 {- ^ /@len@/: length of /@str@/, in bytes, or -1 if /@str@/ is nul-terminated. -} -> GLib.Enums.NormalizeMode {- ^ /@mode@/: the type of normalization to perform. -} -> m T.Text {- ^ __Returns:__ a newly allocated string, that is the normalized form of /@str@/, or 'Nothing' if /@str@/ is not valid UTF-8. -} utf8Normalize str len mode = liftIO $ do str' <- textToCString str let mode' = (fromIntegral . fromEnum) mode result <- g_utf8_normalize str' len mode' checkUnexpectedReturnNULL "utf8Normalize" result result' <- cstringToText result freeMem result freeMem str' return result' -- function g_utf8_make_valid -- Args : [Arg {argCName = "str", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "string to coerce into UTF-8", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "len", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the maximum length of @str to use, in bytes. If @len < 0,\n then the string is nul-terminated.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_utf8_make_valid" g_utf8_make_valid :: CString -> -- str : TBasicType TUTF8 Int64 -> -- len : TBasicType TInt64 IO CString {- | If the provided string is valid UTF-8, return a copy of it. If not, return a copy in which bytes that could not be interpreted as valid Unicode are replaced with the Unicode replacement character (U+FFFD). For example, this is an appropriate function to use if you have received a string that was incorrectly declared to be UTF-8, and you need a valid UTF-8 version of it that can be logged or displayed to the user, with the assumption that it is close enough to ASCII or UTF-8 to be mostly readable as-is. /Since: 2.52/ -} utf8MakeValid :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@str@/: string to coerce into UTF-8 -} -> Int64 {- ^ /@len@/: the maximum length of /@str@/ to use, in bytes. If /@len@/ \< 0, then the string is nul-terminated. -} -> m T.Text {- ^ __Returns:__ a valid UTF-8 string whose content resembles /@str@/ -} utf8MakeValid str len = liftIO $ do str' <- textToCString str result <- g_utf8_make_valid str' len checkUnexpectedReturnNULL "utf8MakeValid" result result' <- cstringToText result freeMem result freeMem str' return result' -- function g_utf8_get_char_validated -- Args : [Arg {argCName = "p", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a pointer to Unicode character encoded as UTF-8", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "max_len", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the maximum number of bytes to read, or -1 if @p is nul-terminated", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUniChar) -- throws : False -- Skip return : False foreign import ccall "g_utf8_get_char_validated" g_utf8_get_char_validated :: CString -> -- p : TBasicType TUTF8 Int64 -> -- max_len : TBasicType TInt64 IO CInt {- | Convert a sequence of bytes encoded as UTF-8 to a Unicode character. This function checks for incomplete characters, for invalid characters such as characters that are out of the range of Unicode, and for overlong encodings of valid characters. Note that 'GI.GLib.Functions.utf8GetCharValidated' returns (gunichar)-2 if /@maxLen@/ is positive and any of the bytes in the first UTF-8 character sequence are nul. -} utf8GetCharValidated :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@p@/: a pointer to Unicode character encoded as UTF-8 -} -> Int64 {- ^ /@maxLen@/: the maximum number of bytes to read, or -1 if /@p@/ is nul-terminated -} -> m Char {- ^ __Returns:__ the resulting character. If /@p@/ points to a partial sequence at the end of a string that could begin a valid character (or if /@maxLen@/ is zero), returns (gunichar)-2; otherwise, if /@p@/ does not point to a valid UTF-8 encoded Unicode character, returns (gunichar)-1. -} utf8GetCharValidated p maxLen = liftIO $ do p' <- textToCString p result <- g_utf8_get_char_validated p' maxLen let result' = (chr . fromIntegral) result freeMem p' return result' -- function g_utf8_get_char -- Args : [Arg {argCName = "p", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a pointer to Unicode character encoded as UTF-8", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUniChar) -- throws : False -- Skip return : False foreign import ccall "g_utf8_get_char" g_utf8_get_char :: CString -> -- p : TBasicType TUTF8 IO CInt {- | Converts a sequence of bytes encoded as UTF-8 to a Unicode character. If /@p@/ does not point to a valid UTF-8 encoded character, results are undefined. If you are not sure that the bytes are complete valid Unicode characters, you should use 'GI.GLib.Functions.utf8GetCharValidated' instead. -} utf8GetChar :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@p@/: a pointer to Unicode character encoded as UTF-8 -} -> m Char {- ^ __Returns:__ the resulting character -} utf8GetChar p = liftIO $ do p' <- textToCString p result <- g_utf8_get_char p' let result' = (chr . fromIntegral) result freeMem p' return result' -- function g_utf8_find_prev_char -- Args : [Arg {argCName = "str", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "pointer to the beginning of a UTF-8 encoded string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "p", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "pointer to some position within @str", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_utf8_find_prev_char" g_utf8_find_prev_char :: CString -> -- str : TBasicType TUTF8 CString -> -- p : TBasicType TUTF8 IO CString {- | Given a position /@p@/ with a UTF-8 encoded string /@str@/, find the start of the previous UTF-8 character starting before /@p@/. Returns 'Nothing' if no UTF-8 characters are present in /@str@/ before /@p@/. /@p@/ does not have to be at the beginning of a UTF-8 character. No check is made to see if the character found is actually valid other than it starts with an appropriate byte. -} utf8FindPrevChar :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@str@/: pointer to the beginning of a UTF-8 encoded string -} -> T.Text {- ^ /@p@/: pointer to some position within /@str@/ -} -> m T.Text {- ^ __Returns:__ a pointer to the found character or 'Nothing'. -} utf8FindPrevChar str p = liftIO $ do str' <- textToCString str p' <- textToCString p result <- g_utf8_find_prev_char str' p' checkUnexpectedReturnNULL "utf8FindPrevChar" result result' <- cstringToText result freeMem result freeMem str' freeMem p' return result' -- function g_utf8_find_next_char -- Args : [Arg {argCName = "p", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a pointer to a position within a UTF-8 encoded string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "end", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a pointer to the byte following the end of the string,\n or %NULL to indicate that the string is nul-terminated", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_utf8_find_next_char" g_utf8_find_next_char :: CString -> -- p : TBasicType TUTF8 CString -> -- end : TBasicType TUTF8 IO CString {- | Finds the start of the next UTF-8 character in the string after /@p@/. /@p@/ does not have to be at the beginning of a UTF-8 character. No check is made to see if the character found is actually valid other than it starts with an appropriate byte. If /@end@/ is 'Nothing', the return value will never be 'Nothing': if the end of the string is reached, a pointer to the terminating nul byte is returned. If /@end@/ is non-'Nothing', the return value will be 'Nothing' if the end of the string is reached. -} utf8FindNextChar :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@p@/: a pointer to a position within a UTF-8 encoded string -} -> Maybe (T.Text) {- ^ /@end@/: a pointer to the byte following the end of the string, or 'Nothing' to indicate that the string is nul-terminated -} -> m (Maybe T.Text) {- ^ __Returns:__ a pointer to the found character or 'Nothing' if /@end@/ is set and is reached -} utf8FindNextChar p end = liftIO $ do p' <- textToCString p maybeEnd <- case end of Nothing -> return nullPtr Just jEnd -> do jEnd' <- textToCString jEnd return jEnd' result <- g_utf8_find_next_char p' maybeEnd maybeResult <- convertIfNonNull result $ \result' -> do result'' <- cstringToText result' freeMem result' return result'' freeMem p' freeMem maybeEnd return maybeResult -- function g_utf8_collate_key_for_filename -- Args : [Arg {argCName = "str", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a UTF-8 encoded string.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "len", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "length of @str, in bytes, or -1 if @str is nul-terminated.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_utf8_collate_key_for_filename" g_utf8_collate_key_for_filename :: CString -> -- str : TBasicType TUTF8 Int64 -> -- len : TBasicType TInt64 IO CString {- | Converts a string into a collation key that can be compared with other collation keys produced by the same function using @/strcmp()/@. In order to sort filenames correctly, this function treats the dot \'.\' as a special case. Most dictionary orderings seem to consider it insignificant, thus producing the ordering \"event.c\" \"eventgenerator.c\" \"event.h\" instead of \"event.c\" \"event.h\" \"eventgenerator.c\". Also, we would like to treat numbers intelligently so that \"file1\" \"file10\" \"file5\" is sorted as \"file1\" \"file5\" \"file10\". Note that this function depends on the [current locale][setlocale]. /Since: 2.8/ -} utf8CollateKeyForFilename :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@str@/: a UTF-8 encoded string. -} -> Int64 {- ^ /@len@/: length of /@str@/, in bytes, or -1 if /@str@/ is nul-terminated. -} -> m T.Text {- ^ __Returns:__ a newly allocated string. This string should be freed with 'GI.GLib.Functions.free' when you are done with it. -} utf8CollateKeyForFilename str len = liftIO $ do str' <- textToCString str result <- g_utf8_collate_key_for_filename str' len checkUnexpectedReturnNULL "utf8CollateKeyForFilename" result result' <- cstringToText result freeMem result freeMem str' return result' -- function g_utf8_collate_key -- Args : [Arg {argCName = "str", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a UTF-8 encoded string.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "len", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "length of @str, in bytes, or -1 if @str is nul-terminated.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_utf8_collate_key" g_utf8_collate_key :: CString -> -- str : TBasicType TUTF8 Int64 -> -- len : TBasicType TInt64 IO CString {- | Converts a string into a collation key that can be compared with other collation keys produced by the same function using @/strcmp()/@. The results of comparing the collation keys of two strings with @/strcmp()/@ will always be the same as comparing the two original keys with 'GI.GLib.Functions.utf8Collate'. Note that this function depends on the [current locale][setlocale]. -} utf8CollateKey :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@str@/: a UTF-8 encoded string. -} -> Int64 {- ^ /@len@/: length of /@str@/, in bytes, or -1 if /@str@/ is nul-terminated. -} -> m T.Text {- ^ __Returns:__ a newly allocated string. This string should be freed with 'GI.GLib.Functions.free' when you are done with it. -} utf8CollateKey str len = liftIO $ do str' <- textToCString str result <- g_utf8_collate_key str' len checkUnexpectedReturnNULL "utf8CollateKey" result result' <- cstringToText result freeMem result freeMem str' return result' -- function g_utf8_collate -- Args : [Arg {argCName = "str1", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a UTF-8 encoded string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "str2", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a UTF-8 encoded string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TInt) -- throws : False -- Skip return : False foreign import ccall "g_utf8_collate" g_utf8_collate :: CString -> -- str1 : TBasicType TUTF8 CString -> -- str2 : TBasicType TUTF8 IO Int32 {- | Compares two strings for ordering using the linguistically correct rules for the [current locale][setlocale]. When sorting a large number of strings, it will be significantly faster to obtain collation keys with 'GI.GLib.Functions.utf8CollateKey' and compare the keys with @/strcmp()/@ when sorting instead of sorting the original strings. -} utf8Collate :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@str1@/: a UTF-8 encoded string -} -> T.Text {- ^ /@str2@/: a UTF-8 encoded string -} -> m Int32 {- ^ __Returns:__ \< 0 if /@str1@/ compares before /@str2@/, 0 if they compare equal, > 0 if /@str1@/ compares after /@str2@/. -} utf8Collate str1 str2 = liftIO $ do str1' <- textToCString str1 str2' <- textToCString str2 result <- g_utf8_collate str1' str2' freeMem str1' freeMem str2' return result -- function g_utf8_casefold -- Args : [Arg {argCName = "str", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a UTF-8 encoded string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "len", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "length of @str, in bytes, or -1 if @str is nul-terminated.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_utf8_casefold" g_utf8_casefold :: CString -> -- str : TBasicType TUTF8 Int64 -> -- len : TBasicType TInt64 IO CString {- | Converts a string into a form that is independent of case. The result will not correspond to any particular case, but can be compared for equality or ordered with the results of calling 'GI.GLib.Functions.utf8Casefold' on other strings. Note that calling 'GI.GLib.Functions.utf8Casefold' followed by 'GI.GLib.Functions.utf8Collate' is only an approximation to the correct linguistic case insensitive ordering, though it is a fairly good one. Getting this exactly right would require a more sophisticated collation function that takes case sensitivity into account. GLib does not currently provide such a function. -} utf8Casefold :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@str@/: a UTF-8 encoded string -} -> Int64 {- ^ /@len@/: length of /@str@/, in bytes, or -1 if /@str@/ is nul-terminated. -} -> m T.Text {- ^ __Returns:__ a newly allocated string, that is a case independent form of /@str@/. -} utf8Casefold str len = liftIO $ do str' <- textToCString str result <- g_utf8_casefold str' len checkUnexpectedReturnNULL "utf8Casefold" result result' <- cstringToText result freeMem result freeMem str' return result' -- function g_usleep -- Args : [Arg {argCName = "microseconds", argType = TBasicType TULong, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "number of microseconds to pause", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_usleep" g_usleep :: CULong -> -- microseconds : TBasicType TULong IO () {- | Pauses the current thread for the given number of microseconds. There are 1 million microseconds per second (represented by the 'GI.GLib.Constants.USEC_PER_SEC' macro). 'GI.GLib.Functions.usleep' may have limited precision, depending on hardware and operating system; don\'t rely on the exact length of the sleep. -} usleep :: (B.CallStack.HasCallStack, MonadIO m) => CULong {- ^ /@microseconds@/: number of microseconds to pause -} -> m () usleep microseconds = liftIO $ do g_usleep microseconds return () -- function g_uri_unescape_string -- Args : [Arg {argCName = "escaped_string", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an escaped string to be unescaped.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "illegal_characters", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a string of illegal characters not to be\n allowed, or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_uri_unescape_string" g_uri_unescape_string :: CString -> -- escaped_string : TBasicType TUTF8 CString -> -- illegal_characters : TBasicType TUTF8 IO CString {- | Unescapes a whole escaped string. If any of the characters in /@illegalCharacters@/ or the character zero appears as an escaped character in /@escapedString@/ then that is an error and 'Nothing' will be returned. This is useful it you want to avoid for instance having a slash being expanded in an escaped path element, which might confuse pathname handling. /Since: 2.16/ -} uriUnescapeString :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@escapedString@/: an escaped string to be unescaped. -} -> Maybe (T.Text) {- ^ /@illegalCharacters@/: a string of illegal characters not to be allowed, or 'Nothing'. -} -> m T.Text {- ^ __Returns:__ an unescaped version of /@escapedString@/. The returned string should be freed when no longer needed. -} uriUnescapeString escapedString illegalCharacters = liftIO $ do escapedString' <- textToCString escapedString maybeIllegalCharacters <- case illegalCharacters of Nothing -> return nullPtr Just jIllegalCharacters -> do jIllegalCharacters' <- textToCString jIllegalCharacters return jIllegalCharacters' result <- g_uri_unescape_string escapedString' maybeIllegalCharacters checkUnexpectedReturnNULL "uriUnescapeString" result result' <- cstringToText result freeMem result freeMem escapedString' freeMem maybeIllegalCharacters return result' -- function g_uri_unescape_segment -- Args : [Arg {argCName = "escaped_string", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "A string, may be %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "escaped_string_end", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Pointer to end of @escaped_string, may be %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "illegal_characters", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "An optional string of illegal characters not to be allowed, may be %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_uri_unescape_segment" g_uri_unescape_segment :: CString -> -- escaped_string : TBasicType TUTF8 CString -> -- escaped_string_end : TBasicType TUTF8 CString -> -- illegal_characters : TBasicType TUTF8 IO CString {- | Unescapes a segment of an escaped string. If any of the characters in /@illegalCharacters@/ or the character zero appears as an escaped character in /@escapedString@/ then that is an error and 'Nothing' will be returned. This is useful it you want to avoid for instance having a slash being expanded in an escaped path element, which might confuse pathname handling. /Since: 2.16/ -} uriUnescapeSegment :: (B.CallStack.HasCallStack, MonadIO m) => Maybe (T.Text) {- ^ /@escapedString@/: A string, may be 'Nothing' -} -> Maybe (T.Text) {- ^ /@escapedStringEnd@/: Pointer to end of /@escapedString@/, may be 'Nothing' -} -> Maybe (T.Text) {- ^ /@illegalCharacters@/: An optional string of illegal characters not to be allowed, may be 'Nothing' -} -> m T.Text {- ^ __Returns:__ an unescaped version of /@escapedString@/ or 'Nothing' on error. The returned string should be freed when no longer needed. As a special case if 'Nothing' is given for /@escapedString@/, this function will return 'Nothing'. -} uriUnescapeSegment escapedString escapedStringEnd illegalCharacters = liftIO $ do maybeEscapedString <- case escapedString of Nothing -> return nullPtr Just jEscapedString -> do jEscapedString' <- textToCString jEscapedString return jEscapedString' maybeEscapedStringEnd <- case escapedStringEnd of Nothing -> return nullPtr Just jEscapedStringEnd -> do jEscapedStringEnd' <- textToCString jEscapedStringEnd return jEscapedStringEnd' maybeIllegalCharacters <- case illegalCharacters of Nothing -> return nullPtr Just jIllegalCharacters -> do jIllegalCharacters' <- textToCString jIllegalCharacters return jIllegalCharacters' result <- g_uri_unescape_segment maybeEscapedString maybeEscapedStringEnd maybeIllegalCharacters checkUnexpectedReturnNULL "uriUnescapeSegment" result result' <- cstringToText result freeMem result freeMem maybeEscapedString freeMem maybeEscapedStringEnd freeMem maybeIllegalCharacters return result' -- function g_uri_parse_scheme -- Args : [Arg {argCName = "uri", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a valid URI.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_uri_parse_scheme" g_uri_parse_scheme :: CString -> -- uri : TBasicType TUTF8 IO CString {- | Gets the scheme portion of a URI string. RFC 3986 decodes the scheme as: > >URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ] Common schemes include \"file\", \"http\", \"svn+ssh\", etc. /Since: 2.16/ -} uriParseScheme :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@uri@/: a valid URI. -} -> m T.Text {- ^ __Returns:__ The \"Scheme\" component of the URI, or 'Nothing' on error. The returned string should be freed when no longer needed. -} uriParseScheme uri = liftIO $ do uri' <- textToCString uri result <- g_uri_parse_scheme uri' checkUnexpectedReturnNULL "uriParseScheme" result result' <- cstringToText result freeMem result freeMem uri' return result' -- function g_uri_list_extract_uris -- Args : [Arg {argCName = "uri_list", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an URI list", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TCArray True (-1) (-1) (TBasicType TUTF8)) -- throws : False -- Skip return : False foreign import ccall "g_uri_list_extract_uris" g_uri_list_extract_uris :: CString -> -- uri_list : TBasicType TUTF8 IO (Ptr CString) {- | Splits an URI list conforming to the text\/uri-list mime type defined in RFC 2483 into individual URIs, discarding any comments. The URIs are not validated. /Since: 2.6/ -} uriListExtractUris :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@uriList@/: an URI list -} -> m [T.Text] {- ^ __Returns:__ a newly allocated 'Nothing'-terminated list of strings holding the individual URIs. The array should be freed with 'GI.GLib.Functions.strfreev'. -} uriListExtractUris uriList = liftIO $ do uriList' <- textToCString uriList result <- g_uri_list_extract_uris uriList' checkUnexpectedReturnNULL "uriListExtractUris" result result' <- unpackZeroTerminatedUTF8CArray result mapZeroTerminatedCArray freeMem result freeMem result freeMem uriList' return result' -- function g_uri_escape_string -- Args : [Arg {argCName = "unescaped", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the unescaped input string.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "reserved_chars_allowed", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a string of reserved characters that\n are allowed to be used, or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "allow_utf8", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "%TRUE if the result can include UTF-8 characters.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_uri_escape_string" g_uri_escape_string :: CString -> -- unescaped : TBasicType TUTF8 CString -> -- reserved_chars_allowed : TBasicType TUTF8 CInt -> -- allow_utf8 : TBasicType TBoolean IO CString {- | Escapes a string for use in a URI. Normally all characters that are not \"unreserved\" (i.e. ASCII alphanumerical characters plus dash, dot, underscore and tilde) are escaped. But if you specify characters in /@reservedCharsAllowed@/ they are not escaped. This is useful for the \"reserved\" characters in the URI specification, since those are allowed unescaped in some portions of a URI. /Since: 2.16/ -} uriEscapeString :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@unescaped@/: the unescaped input string. -} -> Maybe (T.Text) {- ^ /@reservedCharsAllowed@/: a string of reserved characters that are allowed to be used, or 'Nothing'. -} -> Bool {- ^ /@allowUtf8@/: 'True' if the result can include UTF-8 characters. -} -> m T.Text {- ^ __Returns:__ an escaped version of /@unescaped@/. The returned string should be freed when no longer needed. -} uriEscapeString unescaped reservedCharsAllowed allowUtf8 = liftIO $ do unescaped' <- textToCString unescaped maybeReservedCharsAllowed <- case reservedCharsAllowed of Nothing -> return nullPtr Just jReservedCharsAllowed -> do jReservedCharsAllowed' <- textToCString jReservedCharsAllowed return jReservedCharsAllowed' let allowUtf8' = (fromIntegral . fromEnum) allowUtf8 result <- g_uri_escape_string unescaped' maybeReservedCharsAllowed allowUtf8' checkUnexpectedReturnNULL "uriEscapeString" result result' <- cstringToText result freeMem result freeMem unescaped' freeMem maybeReservedCharsAllowed return result' -- function g_unsetenv -- Args : [Arg {argCName = "variable", argType = TBasicType TFileName, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the environment variable to remove, must\n not contain '='", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_unsetenv" g_unsetenv :: CString -> -- variable : TBasicType TFileName IO () {- | Removes an environment variable from the environment. Note that on some systems, when variables are overwritten, the memory used for the previous variables and its value isn\'t reclaimed. You should be mindful of the fact that environment variable handling in UNIX is not thread-safe, and your program may crash if one thread calls 'GI.GLib.Functions.unsetenv' while another thread is calling @/getenv()/@. (And note that many functions, such as @/gettext()/@, call @/getenv()/@ internally.) This function is only safe to use at the very start of your program, before creating any other threads (or creating objects that create worker threads of their own). If you need to set up the environment for a child process, you can use 'GI.GLib.Functions.getEnviron' to get an environment array, modify that with 'GI.GLib.Functions.environSetenv' and 'GI.GLib.Functions.environUnsetenv', and then pass that array directly to @/execvpe()/@, 'GI.GLib.Functions.spawnAsync', or the like. /Since: 2.4/ -} unsetenv :: (B.CallStack.HasCallStack, MonadIO m) => [Char] {- ^ /@variable@/: the environment variable to remove, must not contain \'=\' -} -> m () unsetenv variable = liftIO $ do variable' <- stringToCString variable g_unsetenv variable' freeMem variable' return () -- function g_unlink -- Args : [Arg {argCName = "filename", argType = TBasicType TFileName, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a pathname in the GLib file name encoding\n (UTF-8 on Windows)", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TInt) -- throws : False -- Skip return : False foreign import ccall "g_unlink" g_unlink :: CString -> -- filename : TBasicType TFileName IO Int32 {- | A wrapper for the POSIX @/unlink()/@ function. The @/unlink()/@ function deletes a name from the filesystem. If this was the last link to the file and no processes have it opened, the diskspace occupied by the file is freed. See your C library manual for more details about @/unlink()/@. Note that on Windows, it is in general not possible to delete files that are open to some process, or mapped into memory. /Since: 2.6/ -} unlink :: (B.CallStack.HasCallStack, MonadIO m) => [Char] {- ^ /@filename@/: a pathname in the GLib file name encoding (UTF-8 on Windows) -} -> m Int32 {- ^ __Returns:__ 0 if the name was successfully deleted, -1 if an error occurred -} unlink filename = liftIO $ do filename' <- stringToCString filename result <- g_unlink filename' freeMem filename' return result -- function g_unix_signal_source_new -- Args : [Arg {argCName = "signum", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A signal number", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TInterface (Name {namespace = "GLib", name = "Source"})) -- throws : False -- Skip return : False foreign import ccall "g_unix_signal_source_new" g_unix_signal_source_new :: Int32 -> -- signum : TBasicType TInt IO (Ptr GLib.Source.Source) {- | Create a 'GI.GLib.Structs.Source.Source' that will be dispatched upon delivery of the UNIX signal /@signum@/. In GLib versions before 2.36, only @SIGHUP@, @SIGINT@, @SIGTERM@ can be monitored. In GLib 2.36, @SIGUSR1@ and @SIGUSR2@ were added. In GLib 2.54, @SIGWINCH@ was added. Note that unlike the UNIX default, all sources which have created a watch will be dispatched, regardless of which underlying thread invoked 'GI.GLib.Functions.unixSignalSourceNew'. For example, an effective use of this function is to handle @SIGTERM@ cleanly; flushing any outstanding files, and then calling g_main_loop_quit (). It is not safe to do any of this a regular UNIX signal handler; your handler may be invoked while @/malloc()/@ or another library function is running, causing reentrancy if you attempt to use it from the handler. None of the GLib\/GObject API is safe against this kind of reentrancy. The interaction of this source when combined with native UNIX functions like @/sigprocmask()/@ is not defined. The source will not initially be associated with any 'GI.GLib.Structs.MainContext.MainContext' and must be added to one with 'GI.GLib.Structs.Source.sourceAttach' before it will be executed. /Since: 2.30/ -} unixSignalSourceNew :: (B.CallStack.HasCallStack, MonadIO m) => Int32 {- ^ /@signum@/: A signal number -} -> m GLib.Source.Source {- ^ __Returns:__ A newly created 'GI.GLib.Structs.Source.Source' -} unixSignalSourceNew signum = liftIO $ do result <- g_unix_signal_source_new signum checkUnexpectedReturnNULL "unixSignalSourceNew" result result' <- (wrapBoxed GLib.Source.Source) result return result' -- function g_unix_signal_add_full -- Args : [Arg {argCName = "priority", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the priority of the signal source. Typically this will be in\n the range between #G_PRIORITY_DEFAULT and #G_PRIORITY_HIGH.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "signum", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Signal number", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "handler", argType = TInterface (Name {namespace = "GLib", name = "SourceFunc"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Callback", sinceVersion = Nothing}, argScope = ScopeTypeNotified, argClosure = 3, argDestroy = 4, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Data for @handler", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "notify", argType = TInterface (Name {namespace = "GLib", name = "DestroyNotify"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "#GDestroyNotify for @handler", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUInt) -- throws : False -- Skip return : False foreign import ccall "g_unix_signal_add_full" g_unix_signal_add_full :: Int32 -> -- priority : TBasicType TInt Int32 -> -- signum : TBasicType TInt FunPtr GLib.Callbacks.C_SourceFunc -> -- handler : TInterface (Name {namespace = "GLib", name = "SourceFunc"}) Ptr () -> -- user_data : TBasicType TPtr FunPtr GLib.Callbacks.C_DestroyNotify -> -- notify : TInterface (Name {namespace = "GLib", name = "DestroyNotify"}) IO Word32 {- | A convenience function for 'GI.GLib.Functions.unixSignalSourceNew', which attaches to the default 'GI.GLib.Structs.MainContext.MainContext'. You can remove the watch using 'GI.GLib.Functions.sourceRemove'. /Since: 2.30/ -} unixSignalAdd :: (B.CallStack.HasCallStack, MonadIO m) => Int32 {- ^ /@priority@/: the priority of the signal source. Typically this will be in the range between 'GI.GLib.Constants.PRIORITY_DEFAULT' and 'GI.GLib.Constants.PRIORITY_HIGH'. -} -> Int32 {- ^ /@signum@/: Signal number -} -> GLib.Callbacks.SourceFunc {- ^ /@handler@/: Callback -} -> m Word32 {- ^ __Returns:__ An ID (greater than 0) for the event source -} unixSignalAdd priority signum handler = liftIO $ do handler' <- GLib.Callbacks.mk_SourceFunc (GLib.Callbacks.wrap_SourceFunc Nothing (GLib.Callbacks.drop_closures_SourceFunc handler)) let userData = castFunPtrToPtr handler' let notify = safeFreeFunPtrPtr result <- g_unix_signal_add_full priority signum handler' userData notify return result -- function g_unix_set_fd_nonblocking -- Args : [Arg {argCName = "fd", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A file descriptor", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "nonblock", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "If %TRUE, set the descriptor to be non-blocking", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : True -- Skip return : False foreign import ccall "g_unix_set_fd_nonblocking" g_unix_set_fd_nonblocking :: Int32 -> -- fd : TBasicType TInt CInt -> -- nonblock : TBasicType TBoolean Ptr (Ptr GError) -> -- error IO CInt {- | Control the non-blocking state of the given file descriptor, according to /@nonblock@/. On most systems this uses @/O_NONBLOCK/@, but on some older ones may use @/O_NDELAY/@. /Since: 2.30/ -} unixSetFdNonblocking :: (B.CallStack.HasCallStack, MonadIO m) => Int32 {- ^ /@fd@/: A file descriptor -} -> Bool {- ^ /@nonblock@/: If 'True', set the descriptor to be non-blocking -} -> m () {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -} unixSetFdNonblocking fd nonblock = liftIO $ do let nonblock' = (fromIntegral . fromEnum) nonblock onException (do _ <- propagateGError $ g_unix_set_fd_nonblocking fd nonblock' return () ) (do return () ) -- function g_unix_open_pipe -- Args : [Arg {argCName = "fds", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Array of two integers", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Bitfield of file descriptor flags, as for fcntl()", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : True -- Skip return : False foreign import ccall "g_unix_open_pipe" g_unix_open_pipe :: Int32 -> -- fds : TBasicType TInt Int32 -> -- flags : TBasicType TInt Ptr (Ptr GError) -> -- error IO CInt {- | Similar to the UNIX @/pipe()/@ call, but on modern systems like Linux uses the @/pipe2()/@ system call, which atomically creates a pipe with the configured flags. The only supported flag currently is @/FD_CLOEXEC/@. If for example you want to configure @/O_NONBLOCK/@, that must still be done separately with @/fcntl()/@. This function does not take @/O_CLOEXEC/@, it takes @/FD_CLOEXEC/@ as if for @/fcntl()/@; these are different on Linux\/glibc. /Since: 2.30/ -} unixOpenPipe :: (B.CallStack.HasCallStack, MonadIO m) => Int32 {- ^ /@fds@/: Array of two integers -} -> Int32 {- ^ /@flags@/: Bitfield of file descriptor flags, as for @/fcntl()/@ -} -> m () {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -} unixOpenPipe fds flags = liftIO $ do onException (do _ <- propagateGError $ g_unix_open_pipe fds flags return () ) (do return () ) -- function g_unix_fd_source_new -- Args : [Arg {argCName = "fd", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a file descriptor", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "condition", argType = TInterface (Name {namespace = "GLib", name = "IOCondition"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "IO conditions to watch for on @fd", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TInterface (Name {namespace = "GLib", name = "Source"})) -- throws : False -- Skip return : False foreign import ccall "g_unix_fd_source_new" g_unix_fd_source_new :: Int32 -> -- fd : TBasicType TInt CUInt -> -- condition : TInterface (Name {namespace = "GLib", name = "IOCondition"}) IO (Ptr GLib.Source.Source) {- | Creates a 'GI.GLib.Structs.Source.Source' to watch for a particular IO condition on a file descriptor. The source will never close the fd -- you must do it yourself. /Since: 2.36/ -} unixFdSourceNew :: (B.CallStack.HasCallStack, MonadIO m) => Int32 {- ^ /@fd@/: a file descriptor -} -> [GLib.Flags.IOCondition] {- ^ /@condition@/: IO conditions to watch for on /@fd@/ -} -> m GLib.Source.Source {- ^ __Returns:__ the newly created 'GI.GLib.Structs.Source.Source' -} unixFdSourceNew fd condition = liftIO $ do let condition' = gflagsToWord condition result <- g_unix_fd_source_new fd condition' checkUnexpectedReturnNULL "unixFdSourceNew" result result' <- (wrapBoxed GLib.Source.Source) result return result' -- function g_unix_fd_add_full -- Args : [Arg {argCName = "priority", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the priority of the source", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "fd", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a file descriptor", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "condition", argType = TInterface (Name {namespace = "GLib", name = "IOCondition"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "IO conditions to watch for on @fd", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "function", argType = TInterface (Name {namespace = "GLib", name = "UnixFDSourceFunc"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GUnixFDSourceFunc", sinceVersion = Nothing}, argScope = ScopeTypeNotified, argClosure = 4, argDestroy = 5, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "data to pass to @function", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "notify", argType = TInterface (Name {namespace = "GLib", name = "DestroyNotify"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "function to call when the idle is removed, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUInt) -- throws : False -- Skip return : False foreign import ccall "g_unix_fd_add_full" g_unix_fd_add_full :: Int32 -> -- priority : TBasicType TInt Int32 -> -- fd : TBasicType TInt CUInt -> -- condition : TInterface (Name {namespace = "GLib", name = "IOCondition"}) FunPtr GLib.Callbacks.C_UnixFDSourceFunc -> -- function : TInterface (Name {namespace = "GLib", name = "UnixFDSourceFunc"}) Ptr () -> -- user_data : TBasicType TPtr FunPtr GLib.Callbacks.C_DestroyNotify -> -- notify : TInterface (Name {namespace = "GLib", name = "DestroyNotify"}) IO Word32 {- | Sets a function to be called when the IO condition, as specified by /@condition@/ becomes true for /@fd@/. This is the same as @/g_unix_fd_add()/@, except that it allows you to specify a non-default priority and a provide a 'GI.GLib.Callbacks.DestroyNotify' for /@userData@/. /Since: 2.36/ -} unixFdAddFull :: (B.CallStack.HasCallStack, MonadIO m) => Int32 {- ^ /@priority@/: the priority of the source -} -> Int32 {- ^ /@fd@/: a file descriptor -} -> [GLib.Flags.IOCondition] {- ^ /@condition@/: IO conditions to watch for on /@fd@/ -} -> GLib.Callbacks.UnixFDSourceFunc {- ^ /@function@/: a 'GI.GLib.Callbacks.UnixFDSourceFunc' -} -> m Word32 {- ^ __Returns:__ the ID (greater than 0) of the event source -} unixFdAddFull priority fd condition function = liftIO $ do let condition' = gflagsToWord condition function' <- GLib.Callbacks.mk_UnixFDSourceFunc (GLib.Callbacks.wrap_UnixFDSourceFunc Nothing (GLib.Callbacks.drop_closures_UnixFDSourceFunc function)) let userData = castFunPtrToPtr function' let notify = safeFreeFunPtrPtr result <- g_unix_fd_add_full priority fd condition' function' userData notify return result -- function g_unix_error_quark -- Args : [] -- Lengths : [] -- returnType : Just (TBasicType TUInt32) -- throws : False -- Skip return : False foreign import ccall "g_unix_error_quark" g_unix_error_quark :: IO Word32 {- | /No description available in the introspection data./ -} unixErrorQuark :: (B.CallStack.HasCallStack, MonadIO m) => m Word32 unixErrorQuark = liftIO $ do result <- g_unix_error_quark return result -- function g_unicode_script_to_iso15924 -- Args : [Arg {argCName = "script", argType = TInterface (Name {namespace = "GLib", name = "UnicodeScript"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode script", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUInt32) -- throws : False -- Skip return : False foreign import ccall "g_unicode_script_to_iso15924" g_unicode_script_to_iso15924 :: CInt -> -- script : TInterface (Name {namespace = "GLib", name = "UnicodeScript"}) IO Word32 {- | Looks up the ISO 15924 code for /@script@/. ISO 15924 assigns four-letter codes to scripts. For example, the code for Arabic is \'Arab\'. The four letter codes are encoded as a /@guint32@/ by this function in a big-endian fashion. That is, the code returned for Arabic is 0x41726162 (0x41 is ASCII code for \'A\', 0x72 is ASCII code for \'r\', etc). See <http://unicode.org/iso15924/codelists.html Codes for the representation of names of scripts> for details. /Since: 2.30/ -} unicodeScriptToIso15924 :: (B.CallStack.HasCallStack, MonadIO m) => GLib.Enums.UnicodeScript {- ^ /@script@/: a Unicode script -} -> m Word32 {- ^ __Returns:__ the ISO 15924 code for /@script@/, encoded as an integer, of zero if /@script@/ is 'GI.GLib.Enums.UnicodeScriptInvalidCode' or ISO 15924 code \'Zzzz\' (script code for UNKNOWN) if /@script@/ is not understood. -} unicodeScriptToIso15924 script = liftIO $ do let script' = (fromIntegral . fromEnum) script result <- g_unicode_script_to_iso15924 script' return result -- function g_unicode_script_from_iso15924 -- Args : [Arg {argCName = "iso15924", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode script", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TInterface (Name {namespace = "GLib", name = "UnicodeScript"})) -- throws : False -- Skip return : False foreign import ccall "g_unicode_script_from_iso15924" g_unicode_script_from_iso15924 :: Word32 -> -- iso15924 : TBasicType TUInt32 IO CInt {- | Looks up the Unicode script for /@iso15924@/. ISO 15924 assigns four-letter codes to scripts. For example, the code for Arabic is \'Arab\'. This function accepts four letter codes encoded as a /@guint32@/ in a big-endian fashion. That is, the code expected for Arabic is 0x41726162 (0x41 is ASCII code for \'A\', 0x72 is ASCII code for \'r\', etc). See <http://unicode.org/iso15924/codelists.html Codes for the representation of names of scripts> for details. /Since: 2.30/ -} unicodeScriptFromIso15924 :: (B.CallStack.HasCallStack, MonadIO m) => Word32 {- ^ /@iso15924@/: a Unicode script -} -> m GLib.Enums.UnicodeScript {- ^ __Returns:__ the Unicode script for /@iso15924@/, or of 'GI.GLib.Enums.UnicodeScriptInvalidCode' if /@iso15924@/ is zero and 'GI.GLib.Enums.UnicodeScriptUnknown' if /@iso15924@/ is unknown. -} unicodeScriptFromIso15924 iso15924 = liftIO $ do result <- g_unicode_script_from_iso15924 iso15924 let result' = (toEnum . fromIntegral) result return result' -- function g_unicode_canonical_ordering -- Args : [Arg {argCName = "string", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a UCS-4 encoded string.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "len", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the maximum length of @string to use.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_unicode_canonical_ordering" g_unicode_canonical_ordering :: CInt -> -- string : TBasicType TUniChar Word64 -> -- len : TBasicType TUInt64 IO () {- | Computes the canonical ordering of a string in-place. This rearranges decomposed characters in the string according to their combining classes. See the Unicode manual for more information. -} unicodeCanonicalOrdering :: (B.CallStack.HasCallStack, MonadIO m) => Char {- ^ /@string@/: a UCS-4 encoded string. -} -> Word64 {- ^ /@len@/: the maximum length of /@string@/ to use. -} -> m () unicodeCanonicalOrdering string len = liftIO $ do let string' = (fromIntegral . ord) string g_unicode_canonical_ordering string' len return () -- function g_unicode_canonical_decomposition -- Args : [Arg {argCName = "ch", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode character.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "result_len", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "location to store the length of the return value.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUniChar) -- throws : False -- Skip return : False foreign import ccall "g_unicode_canonical_decomposition" g_unicode_canonical_decomposition :: CInt -> -- ch : TBasicType TUniChar Word64 -> -- result_len : TBasicType TUInt64 IO CInt {-# DEPRECATED unicodeCanonicalDecomposition ["(Since version 2.30)","Use the more flexible @/g_unichar_fully_decompose()/@"," instead."] #-} {- | Computes the canonical decomposition of a Unicode character. -} unicodeCanonicalDecomposition :: (B.CallStack.HasCallStack, MonadIO m) => Char {- ^ /@ch@/: a Unicode character. -} -> Word64 {- ^ /@resultLen@/: location to store the length of the return value. -} -> m Char {- ^ __Returns:__ a newly allocated string of Unicode characters. /@resultLen@/ is set to the resulting length of the string. -} unicodeCanonicalDecomposition ch resultLen = liftIO $ do let ch' = (fromIntegral . ord) ch result <- g_unicode_canonical_decomposition ch' resultLen let result' = (chr . fromIntegral) result return result' -- function g_unichar_xdigit_value -- Args : [Arg {argCName = "c", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TInt) -- throws : False -- Skip return : False foreign import ccall "g_unichar_xdigit_value" g_unichar_xdigit_value :: CInt -> -- c : TBasicType TUniChar IO Int32 {- | Determines the numeric value of a character as a hexidecimal digit. -} unicharXdigitValue :: (B.CallStack.HasCallStack, MonadIO m) => Char {- ^ /@c@/: a Unicode character -} -> m Int32 {- ^ __Returns:__ If /@c@/ is a hex digit (according to 'GI.GLib.Functions.unicharIsxdigit'), its numeric value. Otherwise, -1. -} unicharXdigitValue c = liftIO $ do let c' = (fromIntegral . ord) c result <- g_unichar_xdigit_value c' return result -- function g_unichar_validate -- Args : [Arg {argCName = "ch", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "g_unichar_validate" g_unichar_validate :: CInt -> -- ch : TBasicType TUniChar IO CInt {- | Checks whether /@ch@/ is a valid Unicode character. Some possible integer values of /@ch@/ will not be valid. 0 is considered a valid character, though it\'s normally a string terminator. -} unicharValidate :: (B.CallStack.HasCallStack, MonadIO m) => Char {- ^ /@ch@/: a Unicode character -} -> m Bool {- ^ __Returns:__ 'True' if /@ch@/ is a valid Unicode character -} unicharValidate ch = liftIO $ do let ch' = (fromIntegral . ord) ch result <- g_unichar_validate ch' let result' = (/= 0) result return result' -- function g_unichar_type -- Args : [Arg {argCName = "c", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TInterface (Name {namespace = "GLib", name = "UnicodeType"})) -- throws : False -- Skip return : False foreign import ccall "g_unichar_type" g_unichar_type :: CInt -> -- c : TBasicType TUniChar IO CUInt {- | Classifies a Unicode character by type. -} unicharType :: (B.CallStack.HasCallStack, MonadIO m) => Char {- ^ /@c@/: a Unicode character -} -> m GLib.Enums.UnicodeType {- ^ __Returns:__ the type of the character. -} unicharType c = liftIO $ do let c' = (fromIntegral . ord) c result <- g_unichar_type c' let result' = (toEnum . fromIntegral) result return result' -- function g_unichar_toupper -- Args : [Arg {argCName = "c", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUniChar) -- throws : False -- Skip return : False foreign import ccall "g_unichar_toupper" g_unichar_toupper :: CInt -> -- c : TBasicType TUniChar IO CInt {- | Converts a character to uppercase. -} unicharToupper :: (B.CallStack.HasCallStack, MonadIO m) => Char {- ^ /@c@/: a Unicode character -} -> m Char {- ^ __Returns:__ the result of converting /@c@/ to uppercase. If /@c@/ is not an lowercase or titlecase character, or has no upper case equivalent /@c@/ is returned unchanged. -} unicharToupper c = liftIO $ do let c' = (fromIntegral . ord) c result <- g_unichar_toupper c' let result' = (chr . fromIntegral) result return result' -- function g_unichar_totitle -- Args : [Arg {argCName = "c", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUniChar) -- throws : False -- Skip return : False foreign import ccall "g_unichar_totitle" g_unichar_totitle :: CInt -> -- c : TBasicType TUniChar IO CInt {- | Converts a character to the titlecase. -} unicharTotitle :: (B.CallStack.HasCallStack, MonadIO m) => Char {- ^ /@c@/: a Unicode character -} -> m Char {- ^ __Returns:__ the result of converting /@c@/ to titlecase. If /@c@/ is not an uppercase or lowercase character, /@c@/ is returned unchanged. -} unicharTotitle c = liftIO $ do let c' = (fromIntegral . ord) c result <- g_unichar_totitle c' let result' = (chr . fromIntegral) result return result' -- function g_unichar_tolower -- Args : [Arg {argCName = "c", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode character.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUniChar) -- throws : False -- Skip return : False foreign import ccall "g_unichar_tolower" g_unichar_tolower :: CInt -> -- c : TBasicType TUniChar IO CInt {- | Converts a character to lower case. -} unicharTolower :: (B.CallStack.HasCallStack, MonadIO m) => Char {- ^ /@c@/: a Unicode character. -} -> m Char {- ^ __Returns:__ the result of converting /@c@/ to lower case. If /@c@/ is not an upperlower or titlecase character, or has no lowercase equivalent /@c@/ is returned unchanged. -} unicharTolower c = liftIO $ do let c' = (fromIntegral . ord) c result <- g_unichar_tolower c' let result' = (chr . fromIntegral) result return result' -- function g_unichar_to_utf8 -- XXX Could not generate function g_unichar_to_utf8 -- Error was : Not implemented: "Don't know how to allocate \"outbuf\" of type TBasicType TUTF8" -- function g_unichar_iszerowidth -- Args : [Arg {argCName = "c", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "g_unichar_iszerowidth" g_unichar_iszerowidth :: CInt -> -- c : TBasicType TUniChar IO CInt {- | Determines if a given character typically takes zero width when rendered. The return value is 'True' for all non-spacing and enclosing marks (e.g., combining accents), format characters, zero-width space, but not U+00AD SOFT HYPHEN. A typical use of this function is with one of 'GI.GLib.Functions.unicharIswide' or 'GI.GLib.Functions.unicharIswideCjk' to determine the number of cells a string occupies when displayed on a grid display (terminals). However, note that not all terminals support zero-width rendering of zero-width marks. /Since: 2.14/ -} unicharIszerowidth :: (B.CallStack.HasCallStack, MonadIO m) => Char {- ^ /@c@/: a Unicode character -} -> m Bool {- ^ __Returns:__ 'True' if the character has zero width -} unicharIszerowidth c = liftIO $ do let c' = (fromIntegral . ord) c result <- g_unichar_iszerowidth c' let result' = (/= 0) result return result' -- function g_unichar_isxdigit -- Args : [Arg {argCName = "c", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode character.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "g_unichar_isxdigit" g_unichar_isxdigit :: CInt -> -- c : TBasicType TUniChar IO CInt {- | Determines if a character is a hexidecimal digit. -} unicharIsxdigit :: (B.CallStack.HasCallStack, MonadIO m) => Char {- ^ /@c@/: a Unicode character. -} -> m Bool {- ^ __Returns:__ 'True' if the character is a hexadecimal digit -} unicharIsxdigit c = liftIO $ do let c' = (fromIntegral . ord) c result <- g_unichar_isxdigit c' let result' = (/= 0) result return result' -- function g_unichar_iswide_cjk -- Args : [Arg {argCName = "c", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "g_unichar_iswide_cjk" g_unichar_iswide_cjk :: CInt -> -- c : TBasicType TUniChar IO CInt {- | Determines if a character is typically rendered in a double-width cell under legacy East Asian locales. If a character is wide according to 'GI.GLib.Functions.unicharIswide', then it is also reported wide with this function, but the converse is not necessarily true. See the <http://www.unicode.org/reports/tr11/ Unicode Standard Annex #11> for details. If a character passes the 'GI.GLib.Functions.unicharIswide' test then it will also pass this test, but not the other way around. Note that some characters may pass both this test and 'GI.GLib.Functions.unicharIszerowidth'. /Since: 2.12/ -} unicharIswideCjk :: (B.CallStack.HasCallStack, MonadIO m) => Char {- ^ /@c@/: a Unicode character -} -> m Bool {- ^ __Returns:__ 'True' if the character is wide in legacy East Asian locales -} unicharIswideCjk c = liftIO $ do let c' = (fromIntegral . ord) c result <- g_unichar_iswide_cjk c' let result' = (/= 0) result return result' -- function g_unichar_iswide -- Args : [Arg {argCName = "c", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "g_unichar_iswide" g_unichar_iswide :: CInt -> -- c : TBasicType TUniChar IO CInt {- | Determines if a character is typically rendered in a double-width cell. -} unicharIswide :: (B.CallStack.HasCallStack, MonadIO m) => Char {- ^ /@c@/: a Unicode character -} -> m Bool {- ^ __Returns:__ 'True' if the character is wide -} unicharIswide c = liftIO $ do let c' = (fromIntegral . ord) c result <- g_unichar_iswide c' let result' = (/= 0) result return result' -- function g_unichar_isupper -- Args : [Arg {argCName = "c", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "g_unichar_isupper" g_unichar_isupper :: CInt -> -- c : TBasicType TUniChar IO CInt {- | Determines if a character is uppercase. -} unicharIsupper :: (B.CallStack.HasCallStack, MonadIO m) => Char {- ^ /@c@/: a Unicode character -} -> m Bool {- ^ __Returns:__ 'True' if /@c@/ is an uppercase character -} unicharIsupper c = liftIO $ do let c' = (fromIntegral . ord) c result <- g_unichar_isupper c' let result' = (/= 0) result return result' -- function g_unichar_istitle -- Args : [Arg {argCName = "c", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "g_unichar_istitle" g_unichar_istitle :: CInt -> -- c : TBasicType TUniChar IO CInt {- | Determines if a character is titlecase. Some characters in Unicode which are composites, such as the DZ digraph have three case variants instead of just two. The titlecase form is used at the beginning of a word where only the first letter is capitalized. The titlecase form of the DZ digraph is U+01F2 LATIN CAPITAL LETTTER D WITH SMALL LETTER Z. -} unicharIstitle :: (B.CallStack.HasCallStack, MonadIO m) => Char {- ^ /@c@/: a Unicode character -} -> m Bool {- ^ __Returns:__ 'True' if the character is titlecase -} unicharIstitle c = liftIO $ do let c' = (fromIntegral . ord) c result <- g_unichar_istitle c' let result' = (/= 0) result return result' -- function g_unichar_isspace -- Args : [Arg {argCName = "c", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "g_unichar_isspace" g_unichar_isspace :: CInt -> -- c : TBasicType TUniChar IO CInt {- | Determines whether a character is a space, tab, or line separator (newline, carriage return, etc.). Given some UTF-8 text, obtain a character value with 'GI.GLib.Functions.utf8GetChar'. (Note: don\'t use this to do word breaking; you have to use Pango or equivalent to get word breaking right, the algorithm is fairly complex.) -} unicharIsspace :: (B.CallStack.HasCallStack, MonadIO m) => Char {- ^ /@c@/: a Unicode character -} -> m Bool {- ^ __Returns:__ 'True' if /@c@/ is a space character -} unicharIsspace c = liftIO $ do let c' = (fromIntegral . ord) c result <- g_unichar_isspace c' let result' = (/= 0) result return result' -- function g_unichar_ispunct -- Args : [Arg {argCName = "c", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "g_unichar_ispunct" g_unichar_ispunct :: CInt -> -- c : TBasicType TUniChar IO CInt {- | Determines whether a character is punctuation or a symbol. Given some UTF-8 text, obtain a character value with 'GI.GLib.Functions.utf8GetChar'. -} unicharIspunct :: (B.CallStack.HasCallStack, MonadIO m) => Char {- ^ /@c@/: a Unicode character -} -> m Bool {- ^ __Returns:__ 'True' if /@c@/ is a punctuation or symbol character -} unicharIspunct c = liftIO $ do let c' = (fromIntegral . ord) c result <- g_unichar_ispunct c' let result' = (/= 0) result return result' -- function g_unichar_isprint -- Args : [Arg {argCName = "c", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "g_unichar_isprint" g_unichar_isprint :: CInt -> -- c : TBasicType TUniChar IO CInt {- | Determines whether a character is printable. Unlike 'GI.GLib.Functions.unicharIsgraph', returns 'True' for spaces. Given some UTF-8 text, obtain a character value with 'GI.GLib.Functions.utf8GetChar'. -} unicharIsprint :: (B.CallStack.HasCallStack, MonadIO m) => Char {- ^ /@c@/: a Unicode character -} -> m Bool {- ^ __Returns:__ 'True' if /@c@/ is printable -} unicharIsprint c = liftIO $ do let c' = (fromIntegral . ord) c result <- g_unichar_isprint c' let result' = (/= 0) result return result' -- function g_unichar_ismark -- Args : [Arg {argCName = "c", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "g_unichar_ismark" g_unichar_ismark :: CInt -> -- c : TBasicType TUniChar IO CInt {- | Determines whether a character is a mark (non-spacing mark, combining mark, or enclosing mark in Unicode speak). Given some UTF-8 text, obtain a character value with 'GI.GLib.Functions.utf8GetChar'. Note: in most cases where isalpha characters are allowed, ismark characters should be allowed to as they are essential for writing most European languages as well as many non-Latin scripts. /Since: 2.14/ -} unicharIsmark :: (B.CallStack.HasCallStack, MonadIO m) => Char {- ^ /@c@/: a Unicode character -} -> m Bool {- ^ __Returns:__ 'True' if /@c@/ is a mark character -} unicharIsmark c = liftIO $ do let c' = (fromIntegral . ord) c result <- g_unichar_ismark c' let result' = (/= 0) result return result' -- function g_unichar_islower -- Args : [Arg {argCName = "c", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "g_unichar_islower" g_unichar_islower :: CInt -> -- c : TBasicType TUniChar IO CInt {- | Determines whether a character is a lowercase letter. Given some UTF-8 text, obtain a character value with 'GI.GLib.Functions.utf8GetChar'. -} unicharIslower :: (B.CallStack.HasCallStack, MonadIO m) => Char {- ^ /@c@/: a Unicode character -} -> m Bool {- ^ __Returns:__ 'True' if /@c@/ is a lowercase letter -} unicharIslower c = liftIO $ do let c' = (fromIntegral . ord) c result <- g_unichar_islower c' let result' = (/= 0) result return result' -- function g_unichar_isgraph -- Args : [Arg {argCName = "c", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "g_unichar_isgraph" g_unichar_isgraph :: CInt -> -- c : TBasicType TUniChar IO CInt {- | Determines whether a character is printable and not a space (returns 'False' for control characters, format characters, and spaces). 'GI.GLib.Functions.unicharIsprint' is similar, but returns 'True' for spaces. Given some UTF-8 text, obtain a character value with 'GI.GLib.Functions.utf8GetChar'. -} unicharIsgraph :: (B.CallStack.HasCallStack, MonadIO m) => Char {- ^ /@c@/: a Unicode character -} -> m Bool {- ^ __Returns:__ 'True' if /@c@/ is printable unless it\'s a space -} unicharIsgraph c = liftIO $ do let c' = (fromIntegral . ord) c result <- g_unichar_isgraph c' let result' = (/= 0) result return result' -- function g_unichar_isdigit -- Args : [Arg {argCName = "c", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "g_unichar_isdigit" g_unichar_isdigit :: CInt -> -- c : TBasicType TUniChar IO CInt {- | Determines whether a character is numeric (i.e. a digit). This covers ASCII 0-9 and also digits in other languages\/scripts. Given some UTF-8 text, obtain a character value with 'GI.GLib.Functions.utf8GetChar'. -} unicharIsdigit :: (B.CallStack.HasCallStack, MonadIO m) => Char {- ^ /@c@/: a Unicode character -} -> m Bool {- ^ __Returns:__ 'True' if /@c@/ is a digit -} unicharIsdigit c = liftIO $ do let c' = (fromIntegral . ord) c result <- g_unichar_isdigit c' let result' = (/= 0) result return result' -- function g_unichar_isdefined -- Args : [Arg {argCName = "c", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "g_unichar_isdefined" g_unichar_isdefined :: CInt -> -- c : TBasicType TUniChar IO CInt {- | Determines if a given character is assigned in the Unicode standard. -} unicharIsdefined :: (B.CallStack.HasCallStack, MonadIO m) => Char {- ^ /@c@/: a Unicode character -} -> m Bool {- ^ __Returns:__ 'True' if the character has an assigned value -} unicharIsdefined c = liftIO $ do let c' = (fromIntegral . ord) c result <- g_unichar_isdefined c' let result' = (/= 0) result return result' -- function g_unichar_iscntrl -- Args : [Arg {argCName = "c", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "g_unichar_iscntrl" g_unichar_iscntrl :: CInt -> -- c : TBasicType TUniChar IO CInt {- | Determines whether a character is a control character. Given some UTF-8 text, obtain a character value with 'GI.GLib.Functions.utf8GetChar'. -} unicharIscntrl :: (B.CallStack.HasCallStack, MonadIO m) => Char {- ^ /@c@/: a Unicode character -} -> m Bool {- ^ __Returns:__ 'True' if /@c@/ is a control character -} unicharIscntrl c = liftIO $ do let c' = (fromIntegral . ord) c result <- g_unichar_iscntrl c' let result' = (/= 0) result return result' -- function g_unichar_isalpha -- Args : [Arg {argCName = "c", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "g_unichar_isalpha" g_unichar_isalpha :: CInt -> -- c : TBasicType TUniChar IO CInt {- | Determines whether a character is alphabetic (i.e. a letter). Given some UTF-8 text, obtain a character value with 'GI.GLib.Functions.utf8GetChar'. -} unicharIsalpha :: (B.CallStack.HasCallStack, MonadIO m) => Char {- ^ /@c@/: a Unicode character -} -> m Bool {- ^ __Returns:__ 'True' if /@c@/ is an alphabetic character -} unicharIsalpha c = liftIO $ do let c' = (fromIntegral . ord) c result <- g_unichar_isalpha c' let result' = (/= 0) result return result' -- function g_unichar_isalnum -- Args : [Arg {argCName = "c", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "g_unichar_isalnum" g_unichar_isalnum :: CInt -> -- c : TBasicType TUniChar IO CInt {- | Determines whether a character is alphanumeric. Given some UTF-8 text, obtain a character value with 'GI.GLib.Functions.utf8GetChar'. -} unicharIsalnum :: (B.CallStack.HasCallStack, MonadIO m) => Char {- ^ /@c@/: a Unicode character -} -> m Bool {- ^ __Returns:__ 'True' if /@c@/ is an alphanumeric character -} unicharIsalnum c = liftIO $ do let c' = (fromIntegral . ord) c result <- g_unichar_isalnum c' let result' = (/= 0) result return result' -- function g_unichar_get_script -- Args : [Arg {argCName = "ch", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TInterface (Name {namespace = "GLib", name = "UnicodeScript"})) -- throws : False -- Skip return : False foreign import ccall "g_unichar_get_script" g_unichar_get_script :: CInt -> -- ch : TBasicType TUniChar IO CInt {- | Looks up the 'GI.GLib.Enums.UnicodeScript' for a particular character (as defined by Unicode Standard Annex #24). No check is made for /@ch@/ being a valid Unicode character; if you pass in invalid character, the result is undefined. This function is equivalent to @/pango_script_for_unichar()/@ and the two are interchangeable. /Since: 2.14/ -} unicharGetScript :: (B.CallStack.HasCallStack, MonadIO m) => Char {- ^ /@ch@/: a Unicode character -} -> m GLib.Enums.UnicodeScript {- ^ __Returns:__ the 'GI.GLib.Enums.UnicodeScript' for the character. -} unicharGetScript ch = liftIO $ do let ch' = (fromIntegral . ord) ch result <- g_unichar_get_script ch' let result' = (toEnum . fromIntegral) result return result' -- function g_unichar_get_mirror_char -- Args : [Arg {argCName = "ch", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "mirrored_ch", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "location to store the mirrored character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "g_unichar_get_mirror_char" g_unichar_get_mirror_char :: CInt -> -- ch : TBasicType TUniChar CInt -> -- mirrored_ch : TBasicType TUniChar IO CInt {- | In Unicode, some characters are \"mirrored\". This means that their images are mirrored horizontally in text that is laid out from right to left. For instance, \"(\" would become its mirror image, \")\", in right-to-left text. If /@ch@/ has the Unicode mirrored property and there is another unicode character that typically has a glyph that is the mirror image of /@ch@/\'s glyph and /@mirroredCh@/ is set, it puts that character in the address pointed to by /@mirroredCh@/. Otherwise the original character is put. /Since: 2.4/ -} unicharGetMirrorChar :: (B.CallStack.HasCallStack, MonadIO m) => Char {- ^ /@ch@/: a Unicode character -} -> Char {- ^ /@mirroredCh@/: location to store the mirrored character -} -> m Bool {- ^ __Returns:__ 'True' if /@ch@/ has a mirrored character, 'False' otherwise -} unicharGetMirrorChar ch mirroredCh = liftIO $ do let ch' = (fromIntegral . ord) ch let mirroredCh' = (fromIntegral . ord) mirroredCh result <- g_unichar_get_mirror_char ch' mirroredCh' let result' = (/= 0) result return result' -- function g_unichar_digit_value -- Args : [Arg {argCName = "c", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TInt) -- throws : False -- Skip return : False foreign import ccall "g_unichar_digit_value" g_unichar_digit_value :: CInt -> -- c : TBasicType TUniChar IO Int32 {- | Determines the numeric value of a character as a decimal digit. -} unicharDigitValue :: (B.CallStack.HasCallStack, MonadIO m) => Char {- ^ /@c@/: a Unicode character -} -> m Int32 {- ^ __Returns:__ If /@c@/ is a decimal digit (according to 'GI.GLib.Functions.unicharIsdigit'), its numeric value. Otherwise, -1. -} unicharDigitValue c = liftIO $ do let c' = (fromIntegral . ord) c result <- g_unichar_digit_value c' return result -- function g_unichar_decompose -- Args : [Arg {argCName = "ch", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "a", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "return location for the first component of @ch", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "b", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "return location for the second component of @ch", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "g_unichar_decompose" g_unichar_decompose :: CInt -> -- ch : TBasicType TUniChar CInt -> -- a : TBasicType TUniChar CInt -> -- b : TBasicType TUniChar IO CInt {- | Performs a single decomposition step of the Unicode canonical decomposition algorithm. This function does not include compatibility decompositions. It does, however, include algorithmic Hangul Jamo decomposition, as well as \'singleton\' decompositions which replace a character by a single other character. In the case of singletons */@b@/ will be set to zero. If /@ch@/ is not decomposable, */@a@/ is set to /@ch@/ and */@b@/ is set to zero. Note that the way Unicode decomposition pairs are defined, it is guaranteed that /@b@/ would not decompose further, but /@a@/ may itself decompose. To get the full canonical decomposition for /@ch@/, one would need to recursively call this function on /@a@/. Or use @/g_unichar_fully_decompose()/@. See <http://unicode.org/reports/tr15/ UAX#15> for details. /Since: 2.30/ -} unicharDecompose :: (B.CallStack.HasCallStack, MonadIO m) => Char {- ^ /@ch@/: a Unicode character -} -> Char {- ^ /@a@/: return location for the first component of /@ch@/ -} -> Char {- ^ /@b@/: return location for the second component of /@ch@/ -} -> m Bool {- ^ __Returns:__ 'True' if the character could be decomposed -} unicharDecompose ch a b = liftIO $ do let ch' = (fromIntegral . ord) ch let a' = (fromIntegral . ord) a let b' = (fromIntegral . ord) b result <- g_unichar_decompose ch' a' b' let result' = (/= 0) result return result' -- function g_unichar_compose -- Args : [Arg {argCName = "a", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "b", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "ch", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "return location for the composed character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "g_unichar_compose" g_unichar_compose :: CInt -> -- a : TBasicType TUniChar CInt -> -- b : TBasicType TUniChar CInt -> -- ch : TBasicType TUniChar IO CInt {- | Performs a single composition step of the Unicode canonical composition algorithm. This function includes algorithmic Hangul Jamo composition, but it is not exactly the inverse of 'GI.GLib.Functions.unicharDecompose'. No composition can have either of /@a@/ or /@b@/ equal to zero. To be precise, this function composes if and only if there exists a Primary Composite P which is canonically equivalent to the sequence \</@a@/,/@b@/>. See the Unicode Standard for the definition of Primary Composite. If /@a@/ and /@b@/ do not compose a new character, /@ch@/ is set to zero. See <http://unicode.org/reports/tr15/ UAX#15> for details. /Since: 2.30/ -} unicharCompose :: (B.CallStack.HasCallStack, MonadIO m) => Char {- ^ /@a@/: a Unicode character -} -> Char {- ^ /@b@/: a Unicode character -} -> Char {- ^ /@ch@/: return location for the composed character -} -> m Bool {- ^ __Returns:__ 'True' if the characters could be composed -} unicharCompose a b ch = liftIO $ do let a' = (fromIntegral . ord) a let b' = (fromIntegral . ord) b let ch' = (fromIntegral . ord) ch result <- g_unichar_compose a' b' ch' let result' = (/= 0) result return result' -- function g_unichar_combining_class -- Args : [Arg {argCName = "uc", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TInt) -- throws : False -- Skip return : False foreign import ccall "g_unichar_combining_class" g_unichar_combining_class :: CInt -> -- uc : TBasicType TUniChar IO Int32 {- | Determines the canonical combining class of a Unicode character. /Since: 2.14/ -} unicharCombiningClass :: (B.CallStack.HasCallStack, MonadIO m) => Char {- ^ /@uc@/: a Unicode character -} -> m Int32 {- ^ __Returns:__ the combining class of the character -} unicharCombiningClass uc = liftIO $ do let uc' = (fromIntegral . ord) uc result <- g_unichar_combining_class uc' return result -- function g_unichar_break_type -- Args : [Arg {argCName = "c", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TInterface (Name {namespace = "GLib", name = "UnicodeBreakType"})) -- throws : False -- Skip return : False foreign import ccall "g_unichar_break_type" g_unichar_break_type :: CInt -> -- c : TBasicType TUniChar IO CUInt {- | Determines the break type of /@c@/. /@c@/ should be a Unicode character (to derive a character from UTF-8 encoded text, use 'GI.GLib.Functions.utf8GetChar'). The break type is used to find word and line breaks (\"text boundaries\"), Pango implements the Unicode boundary resolution algorithms and normally you would use a function such as @/pango_break()/@ instead of caring about break types yourself. -} unicharBreakType :: (B.CallStack.HasCallStack, MonadIO m) => Char {- ^ /@c@/: a Unicode character -} -> m GLib.Enums.UnicodeBreakType {- ^ __Returns:__ the break type of /@c@/ -} unicharBreakType c = liftIO $ do let c' = (fromIntegral . ord) c result <- g_unichar_break_type c' let result' = (toEnum . fromIntegral) result return result' -- function g_try_realloc_n -- Args : [Arg {argCName = "mem", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "previously-allocated memory, or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "n_blocks", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the number of blocks to allocate", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "n_block_bytes", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the size of each block in bytes", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TPtr) -- throws : False -- Skip return : False foreign import ccall "g_try_realloc_n" g_try_realloc_n :: Ptr () -> -- mem : TBasicType TPtr Word64 -> -- n_blocks : TBasicType TUInt64 Word64 -> -- n_block_bytes : TBasicType TUInt64 IO (Ptr ()) {- | This function is similar to 'GI.GLib.Functions.tryRealloc', allocating (/@nBlocks@/ * /@nBlockBytes@/) bytes, but care is taken to detect possible overflow during multiplication. /Since: 2.24/ -} tryReallocN :: (B.CallStack.HasCallStack, MonadIO m) => Ptr () {- ^ /@mem@/: previously-allocated memory, or 'Nothing'. -} -> Word64 {- ^ /@nBlocks@/: the number of blocks to allocate -} -> Word64 {- ^ /@nBlockBytes@/: the size of each block in bytes -} -> m (Ptr ()) {- ^ __Returns:__ the allocated memory, or 'Nothing'. -} tryReallocN mem nBlocks nBlockBytes = liftIO $ do result <- g_try_realloc_n mem nBlocks nBlockBytes return result -- function g_try_realloc -- Args : [Arg {argCName = "mem", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "previously-allocated memory, or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "n_bytes", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "number of bytes to allocate.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TPtr) -- throws : False -- Skip return : False foreign import ccall "g_try_realloc" g_try_realloc :: Ptr () -> -- mem : TBasicType TPtr Word64 -> -- n_bytes : TBasicType TUInt64 IO (Ptr ()) {- | Attempts to realloc /@mem@/ to a new size, /@nBytes@/, and returns 'Nothing' on failure. Contrast with 'GI.GLib.Functions.realloc', which aborts the program on failure. If /@mem@/ is 'Nothing', behaves the same as 'GI.GLib.Functions.tryMalloc'. -} tryRealloc :: (B.CallStack.HasCallStack, MonadIO m) => Ptr () {- ^ /@mem@/: previously-allocated memory, or 'Nothing'. -} -> Word64 {- ^ /@nBytes@/: number of bytes to allocate. -} -> m (Ptr ()) {- ^ __Returns:__ the allocated memory, or 'Nothing'. -} tryRealloc mem nBytes = liftIO $ do result <- g_try_realloc mem nBytes return result -- function g_try_malloc_n -- Args : [Arg {argCName = "n_blocks", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the number of blocks to allocate", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "n_block_bytes", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the size of each block in bytes", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TPtr) -- throws : False -- Skip return : False foreign import ccall "g_try_malloc_n" g_try_malloc_n :: Word64 -> -- n_blocks : TBasicType TUInt64 Word64 -> -- n_block_bytes : TBasicType TUInt64 IO (Ptr ()) {- | This function is similar to 'GI.GLib.Functions.tryMalloc', allocating (/@nBlocks@/ * /@nBlockBytes@/) bytes, but care is taken to detect possible overflow during multiplication. /Since: 2.24/ -} tryMallocN :: (B.CallStack.HasCallStack, MonadIO m) => Word64 {- ^ /@nBlocks@/: the number of blocks to allocate -} -> Word64 {- ^ /@nBlockBytes@/: the size of each block in bytes -} -> m (Ptr ()) {- ^ __Returns:__ the allocated memory, or 'Nothing'. -} tryMallocN nBlocks nBlockBytes = liftIO $ do result <- g_try_malloc_n nBlocks nBlockBytes return result -- function g_try_malloc0_n -- Args : [Arg {argCName = "n_blocks", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the number of blocks to allocate", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "n_block_bytes", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the size of each block in bytes", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TPtr) -- throws : False -- Skip return : False foreign import ccall "g_try_malloc0_n" g_try_malloc0_n :: Word64 -> -- n_blocks : TBasicType TUInt64 Word64 -> -- n_block_bytes : TBasicType TUInt64 IO (Ptr ()) {- | This function is similar to 'GI.GLib.Functions.tryMalloc0', allocating (/@nBlocks@/ * /@nBlockBytes@/) bytes, but care is taken to detect possible overflow during multiplication. /Since: 2.24/ -} tryMalloc0N :: (B.CallStack.HasCallStack, MonadIO m) => Word64 {- ^ /@nBlocks@/: the number of blocks to allocate -} -> Word64 {- ^ /@nBlockBytes@/: the size of each block in bytes -} -> m (Ptr ()) {- ^ __Returns:__ the allocated memory, or 'Nothing' -} tryMalloc0N nBlocks nBlockBytes = liftIO $ do result <- g_try_malloc0_n nBlocks nBlockBytes return result -- function g_try_malloc0 -- Args : [Arg {argCName = "n_bytes", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "number of bytes to allocate", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TPtr) -- throws : False -- Skip return : False foreign import ccall "g_try_malloc0" g_try_malloc0 :: Word64 -> -- n_bytes : TBasicType TUInt64 IO (Ptr ()) {- | Attempts to allocate /@nBytes@/, initialized to 0\'s, and returns 'Nothing' on failure. Contrast with 'GI.GLib.Functions.malloc0', which aborts the program on failure. /Since: 2.8/ -} tryMalloc0 :: (B.CallStack.HasCallStack, MonadIO m) => Word64 {- ^ /@nBytes@/: number of bytes to allocate -} -> m (Ptr ()) {- ^ __Returns:__ the allocated memory, or 'Nothing' -} tryMalloc0 nBytes = liftIO $ do result <- g_try_malloc0 nBytes return result -- function g_try_malloc -- Args : [Arg {argCName = "n_bytes", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "number of bytes to allocate.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TPtr) -- throws : False -- Skip return : False foreign import ccall "g_try_malloc" g_try_malloc :: Word64 -> -- n_bytes : TBasicType TUInt64 IO (Ptr ()) {- | Attempts to allocate /@nBytes@/, and returns 'Nothing' on failure. Contrast with 'GI.GLib.Functions.malloc', which aborts the program on failure. -} tryMalloc :: (B.CallStack.HasCallStack, MonadIO m) => Word64 {- ^ /@nBytes@/: number of bytes to allocate. -} -> m (Ptr ()) {- ^ __Returns:__ the allocated memory, or 'Nothing'. -} tryMalloc nBytes = liftIO $ do result <- g_try_malloc nBytes return result -- function g_timeout_source_new_seconds -- Args : [Arg {argCName = "interval", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the timeout interval in seconds", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TInterface (Name {namespace = "GLib", name = "Source"})) -- throws : False -- Skip return : False foreign import ccall "g_timeout_source_new_seconds" g_timeout_source_new_seconds :: Word32 -> -- interval : TBasicType TUInt IO (Ptr GLib.Source.Source) {- | Creates a new timeout source. The source will not initially be associated with any 'GI.GLib.Structs.MainContext.MainContext' and must be added to one with 'GI.GLib.Structs.Source.sourceAttach' before it will be executed. The scheduling granularity\/accuracy of this timeout source will be in seconds. The interval given is in terms of monotonic time, not wall clock time. See 'GI.GLib.Functions.getMonotonicTime'. /Since: 2.14/ -} timeoutSourceNewSeconds :: (B.CallStack.HasCallStack, MonadIO m) => Word32 {- ^ /@interval@/: the timeout interval in seconds -} -> m GLib.Source.Source {- ^ __Returns:__ the newly-created timeout source -} timeoutSourceNewSeconds interval = liftIO $ do result <- g_timeout_source_new_seconds interval checkUnexpectedReturnNULL "timeoutSourceNewSeconds" result result' <- (wrapBoxed GLib.Source.Source) result return result' -- function g_timeout_source_new -- Args : [Arg {argCName = "interval", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the timeout interval in milliseconds.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TInterface (Name {namespace = "GLib", name = "Source"})) -- throws : False -- Skip return : False foreign import ccall "g_timeout_source_new" g_timeout_source_new :: Word32 -> -- interval : TBasicType TUInt IO (Ptr GLib.Source.Source) {- | Creates a new timeout source. The source will not initially be associated with any 'GI.GLib.Structs.MainContext.MainContext' and must be added to one with 'GI.GLib.Structs.Source.sourceAttach' before it will be executed. The interval given is in terms of monotonic time, not wall clock time. See 'GI.GLib.Functions.getMonotonicTime'. -} timeoutSourceNew :: (B.CallStack.HasCallStack, MonadIO m) => Word32 {- ^ /@interval@/: the timeout interval in milliseconds. -} -> m GLib.Source.Source {- ^ __Returns:__ the newly-created timeout source -} timeoutSourceNew interval = liftIO $ do result <- g_timeout_source_new interval checkUnexpectedReturnNULL "timeoutSourceNew" result result' <- (wrapBoxed GLib.Source.Source) result return result' -- function g_timeout_add_seconds_full -- Args : [Arg {argCName = "priority", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the priority of the timeout source. Typically this will be in\n the range between #G_PRIORITY_DEFAULT and #G_PRIORITY_HIGH.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "interval", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the time between calls to the function, in seconds", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "function", argType = TInterface (Name {namespace = "GLib", name = "SourceFunc"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "function to call", sinceVersion = Nothing}, argScope = ScopeTypeNotified, argClosure = 3, argDestroy = 4, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "data to pass to @function", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "notify", argType = TInterface (Name {namespace = "GLib", name = "DestroyNotify"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "function to call when the timeout is removed, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUInt) -- throws : False -- Skip return : False foreign import ccall "g_timeout_add_seconds_full" g_timeout_add_seconds_full :: Int32 -> -- priority : TBasicType TInt Word32 -> -- interval : TBasicType TUInt FunPtr GLib.Callbacks.C_SourceFunc -> -- function : TInterface (Name {namespace = "GLib", name = "SourceFunc"}) Ptr () -> -- data : TBasicType TPtr FunPtr GLib.Callbacks.C_DestroyNotify -> -- notify : TInterface (Name {namespace = "GLib", name = "DestroyNotify"}) IO Word32 {- | Sets a function to be called at regular intervals, with /@priority@/. The function is called repeatedly until it returns 'False', at which point the timeout is automatically destroyed and the function will not be called again. Unlike @/g_timeout_add()/@, this function operates at whole second granularity. The initial starting point of the timer is determined by the implementation and the implementation is expected to group multiple timers together so that they fire all at the same time. To allow this grouping, the /@interval@/ to the first timer is rounded and can deviate up to one second from the specified interval. Subsequent timer iterations will generally run at the specified interval. Note that timeout functions may be delayed, due to the processing of other event sources. Thus they should not be relied on for precise timing. After each call to the timeout function, the time of the next timeout is recalculated based on the current time and the given /@interval@/ See [memory management of sources][mainloop-memory-management] for details on how to handle the return value and memory management of /@data@/. If you want timing more precise than whole seconds, use @/g_timeout_add()/@ instead. The grouping of timers to fire at the same time results in a more power and CPU efficient behavior so if your timer is in multiples of seconds and you don\'t require the first timer exactly one second from now, the use of @/g_timeout_add_seconds()/@ is preferred over @/g_timeout_add()/@. This internally creates a main loop source using 'GI.GLib.Functions.timeoutSourceNewSeconds' and attaches it to the main loop context using 'GI.GLib.Structs.Source.sourceAttach'. You can do these steps manually if you need greater control. The interval given is in terms of monotonic time, not wall clock time. See 'GI.GLib.Functions.getMonotonicTime'. /Since: 2.14/ -} timeoutAddSeconds :: (B.CallStack.HasCallStack, MonadIO m) => Int32 {- ^ /@priority@/: the priority of the timeout source. Typically this will be in the range between 'GI.GLib.Constants.PRIORITY_DEFAULT' and 'GI.GLib.Constants.PRIORITY_HIGH'. -} -> Word32 {- ^ /@interval@/: the time between calls to the function, in seconds -} -> GLib.Callbacks.SourceFunc {- ^ /@function@/: function to call -} -> m Word32 {- ^ __Returns:__ the ID (greater than 0) of the event source. -} timeoutAddSeconds priority interval function = liftIO $ do function' <- GLib.Callbacks.mk_SourceFunc (GLib.Callbacks.wrap_SourceFunc Nothing (GLib.Callbacks.drop_closures_SourceFunc function)) let data_ = castFunPtrToPtr function' let notify = safeFreeFunPtrPtr result <- g_timeout_add_seconds_full priority interval function' data_ notify return result -- function g_timeout_add_full -- Args : [Arg {argCName = "priority", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the priority of the timeout source. Typically this will be in\n the range between #G_PRIORITY_DEFAULT and #G_PRIORITY_HIGH.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "interval", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the time between calls to the function, in milliseconds\n (1/1000ths of a second)", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "function", argType = TInterface (Name {namespace = "GLib", name = "SourceFunc"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "function to call", sinceVersion = Nothing}, argScope = ScopeTypeNotified, argClosure = 3, argDestroy = 4, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "data to pass to @function", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "notify", argType = TInterface (Name {namespace = "GLib", name = "DestroyNotify"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "function to call when the timeout is removed, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUInt) -- throws : False -- Skip return : False foreign import ccall "g_timeout_add_full" g_timeout_add_full :: Int32 -> -- priority : TBasicType TInt Word32 -> -- interval : TBasicType TUInt FunPtr GLib.Callbacks.C_SourceFunc -> -- function : TInterface (Name {namespace = "GLib", name = "SourceFunc"}) Ptr () -> -- data : TBasicType TPtr FunPtr GLib.Callbacks.C_DestroyNotify -> -- notify : TInterface (Name {namespace = "GLib", name = "DestroyNotify"}) IO Word32 {- | Sets a function to be called at regular intervals, with the given priority. The function is called repeatedly until it returns 'False', at which point the timeout is automatically destroyed and the function will not be called again. The /@notify@/ function is called when the timeout is destroyed. The first call to the function will be at the end of the first /@interval@/. Note that timeout functions may be delayed, due to the processing of other event sources. Thus they should not be relied on for precise timing. After each call to the timeout function, the time of the next timeout is recalculated based on the current time and the given interval (it does not try to \'catch up\' time lost in delays). See [memory management of sources][mainloop-memory-management] for details on how to handle the return value and memory management of /@data@/. This internally creates a main loop source using 'GI.GLib.Functions.timeoutSourceNew' and attaches it to the global 'GI.GLib.Structs.MainContext.MainContext' using 'GI.GLib.Structs.Source.sourceAttach', so the callback will be invoked in whichever thread is running that main context. You can do these steps manually if you need greater control or to use a custom main context. The interval given is in terms of monotonic time, not wall clock time. See 'GI.GLib.Functions.getMonotonicTime'. -} timeoutAdd :: (B.CallStack.HasCallStack, MonadIO m) => Int32 {- ^ /@priority@/: the priority of the timeout source. Typically this will be in the range between 'GI.GLib.Constants.PRIORITY_DEFAULT' and 'GI.GLib.Constants.PRIORITY_HIGH'. -} -> Word32 {- ^ /@interval@/: the time between calls to the function, in milliseconds (1\/1000ths of a second) -} -> GLib.Callbacks.SourceFunc {- ^ /@function@/: function to call -} -> m Word32 {- ^ __Returns:__ the ID (greater than 0) of the event source. -} timeoutAdd priority interval function = liftIO $ do function' <- GLib.Callbacks.mk_SourceFunc (GLib.Callbacks.wrap_SourceFunc Nothing (GLib.Callbacks.drop_closures_SourceFunc function)) let data_ = castFunPtrToPtr function' let notify = safeFreeFunPtrPtr result <- g_timeout_add_full priority interval function' data_ notify return result -- function g_test_trap_subprocess -- Args : [Arg {argCName = "test_path", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Test to run in a subprocess", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "usec_timeout", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Timeout for the subprocess test in micro seconds.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "test_flags", argType = TInterface (Name {namespace = "GLib", name = "TestSubprocessFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Flags to modify subprocess behaviour.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_test_trap_subprocess" g_test_trap_subprocess :: CString -> -- test_path : TBasicType TUTF8 Word64 -> -- usec_timeout : TBasicType TUInt64 CUInt -> -- test_flags : TInterface (Name {namespace = "GLib", name = "TestSubprocessFlags"}) IO () {- | Respawns the test program to run only /@testPath@/ in a subprocess. This can be used for a test case that might not return, or that might abort. If /@testPath@/ is 'Nothing' then the same test is re-run in a subprocess. You can use 'GI.GLib.Functions.testSubprocess' to determine whether the test is in a subprocess or not. /@testPath@/ can also be the name of the parent test, followed by \"@\/subprocess\/@\" and then a name for the specific subtest (or just ending with \"@\/subprocess@\" if the test only has one child test); tests with names of this form will automatically be skipped in the parent process. If /@usecTimeout@/ is non-0, the test subprocess is aborted and considered failing if its run time exceeds it. The subprocess behavior can be configured with the 'GI.GLib.Flags.TestSubprocessFlags' flags. You can use methods such as @/g_test_trap_assert_passed()/@, @/g_test_trap_assert_failed()/@, and @/g_test_trap_assert_stderr()/@ to check the results of the subprocess. (But note that @/g_test_trap_assert_stdout()/@ and @/g_test_trap_assert_stderr()/@ cannot be used if /@testFlags@/ specifies that the child should inherit the parent stdout\/stderr.) If your @main ()@ needs to behave differently in the subprocess, you can call 'GI.GLib.Functions.testSubprocess' (after calling @/g_test_init()/@) to see whether you are in a subprocess. The following example tests that calling @my_object_new(1000000)@ will abort with an error message. === /C code/ > > static void > test_create_large_object (void) > { > if (g_test_subprocess ()) > { > my_object_new (1000000); > return; > } > > // Reruns this same test in a subprocess > g_test_trap_subprocess (NULL, 0, 0); > g_test_trap_assert_failed (); > g_test_trap_assert_stderr ("*ERROR*too large*"); > } > > int > main (int argc, char **argv) > { > g_test_init (&argc, &argv, NULL); > > g_test_add_func ("/myobject/create_large_object", > test_create_large_object); > return g_test_run (); > } /Since: 2.38/ -} testTrapSubprocess :: (B.CallStack.HasCallStack, MonadIO m) => Maybe (T.Text) {- ^ /@testPath@/: Test to run in a subprocess -} -> Word64 {- ^ /@usecTimeout@/: Timeout for the subprocess test in micro seconds. -} -> [GLib.Flags.TestSubprocessFlags] {- ^ /@testFlags@/: Flags to modify subprocess behaviour. -} -> m () testTrapSubprocess testPath usecTimeout testFlags = liftIO $ do maybeTestPath <- case testPath of Nothing -> return nullPtr Just jTestPath -> do jTestPath' <- textToCString jTestPath return jTestPath' let testFlags' = gflagsToWord testFlags g_test_trap_subprocess maybeTestPath usecTimeout testFlags' freeMem maybeTestPath return () -- function g_test_trap_reached_timeout -- Args : [] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "g_test_trap_reached_timeout" g_test_trap_reached_timeout :: IO CInt {- | Check the result of the last 'GI.GLib.Functions.testTrapSubprocess' call. /Since: 2.16/ -} testTrapReachedTimeout :: (B.CallStack.HasCallStack, MonadIO m) => m Bool {- ^ __Returns:__ 'True' if the last test subprocess got killed due to a timeout. -} testTrapReachedTimeout = liftIO $ do result <- g_test_trap_reached_timeout let result' = (/= 0) result return result' -- function g_test_trap_has_passed -- Args : [] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "g_test_trap_has_passed" g_test_trap_has_passed :: IO CInt {- | Check the result of the last 'GI.GLib.Functions.testTrapSubprocess' call. /Since: 2.16/ -} testTrapHasPassed :: (B.CallStack.HasCallStack, MonadIO m) => m Bool {- ^ __Returns:__ 'True' if the last test subprocess terminated successfully. -} testTrapHasPassed = liftIO $ do result <- g_test_trap_has_passed let result' = (/= 0) result return result' -- function g_test_trap_fork -- Args : [Arg {argCName = "usec_timeout", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Timeout for the forked test in micro seconds.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "test_trap_flags", argType = TInterface (Name {namespace = "GLib", name = "TestTrapFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Flags to modify forking behaviour.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "g_test_trap_fork" g_test_trap_fork :: Word64 -> -- usec_timeout : TBasicType TUInt64 CUInt -> -- test_trap_flags : TInterface (Name {namespace = "GLib", name = "TestTrapFlags"}) IO CInt {-# DEPRECATED testTrapFork ["This function is implemented only on Unix platforms,","and is not always reliable due to problems inherent in","fork-without-exec. Use 'GI.GLib.Functions.testTrapSubprocess' instead."] #-} {- | Fork the current test program to execute a test case that might not return or that might abort. If /@usecTimeout@/ is non-0, the forked test case is aborted and considered failing if its run time exceeds it. The forking behavior can be configured with the 'GI.GLib.Flags.TestTrapFlags' flags. In the following example, the test code forks, the forked child process produces some sample output and exits successfully. The forking parent process then asserts successful child program termination and validates child program outputs. === /C code/ > > static void > test_fork_patterns (void) > { > if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT | G_TEST_TRAP_SILENCE_STDERR)) > { > g_print ("some stdout text: somagic17\n"); > g_printerr ("some stderr text: semagic43\n"); > exit (0); // successful test run > } > g_test_trap_assert_passed (); > g_test_trap_assert_stdout ("*somagic17*"); > g_test_trap_assert_stderr ("*semagic43*"); > } /Since: 2.16/ -} testTrapFork :: (B.CallStack.HasCallStack, MonadIO m) => Word64 {- ^ /@usecTimeout@/: Timeout for the forked test in micro seconds. -} -> [GLib.Flags.TestTrapFlags] {- ^ /@testTrapFlags@/: Flags to modify forking behaviour. -} -> m Bool {- ^ __Returns:__ 'True' for the forked child and 'False' for the executing parent process. -} testTrapFork usecTimeout testTrapFlags = liftIO $ do let testTrapFlags' = gflagsToWord testTrapFlags result <- g_test_trap_fork usecTimeout testTrapFlags' let result' = (/= 0) result return result' -- function g_test_trap_assertions -- Args : [Arg {argCName = "domain", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "file", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "line", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "func", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "assertion_flags", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "pattern", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_test_trap_assertions" g_test_trap_assertions :: CString -> -- domain : TBasicType TUTF8 CString -> -- file : TBasicType TUTF8 Int32 -> -- line : TBasicType TInt CString -> -- func : TBasicType TUTF8 Word64 -> -- assertion_flags : TBasicType TUInt64 CString -> -- pattern : TBasicType TUTF8 IO () {- | /No description available in the introspection data./ -} testTrapAssertions :: (B.CallStack.HasCallStack, MonadIO m) => T.Text -> T.Text -> Int32 -> T.Text -> Word64 -> T.Text -> m () testTrapAssertions domain file line func assertionFlags pattern = liftIO $ do domain' <- textToCString domain file' <- textToCString file func' <- textToCString func pattern' <- textToCString pattern g_test_trap_assertions domain' file' line func' assertionFlags pattern' freeMem domain' freeMem file' freeMem func' freeMem pattern' return () -- function g_test_timer_start -- Args : [] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_test_timer_start" g_test_timer_start :: IO () {- | Start a timing test. Call 'GI.GLib.Functions.testTimerElapsed' when the task is supposed to be done. Call this function again to restart the timer. /Since: 2.16/ -} testTimerStart :: (B.CallStack.HasCallStack, MonadIO m) => m () testTimerStart = liftIO $ do g_test_timer_start return () -- function g_test_timer_last -- Args : [] -- Lengths : [] -- returnType : Just (TBasicType TDouble) -- throws : False -- Skip return : False foreign import ccall "g_test_timer_last" g_test_timer_last :: IO CDouble {- | Report the last result of 'GI.GLib.Functions.testTimerElapsed'. /Since: 2.16/ -} testTimerLast :: (B.CallStack.HasCallStack, MonadIO m) => m Double {- ^ __Returns:__ the last result of 'GI.GLib.Functions.testTimerElapsed', as a double -} testTimerLast = liftIO $ do result <- g_test_timer_last let result' = realToFrac result return result' -- function g_test_timer_elapsed -- Args : [] -- Lengths : [] -- returnType : Just (TBasicType TDouble) -- throws : False -- Skip return : False foreign import ccall "g_test_timer_elapsed" g_test_timer_elapsed :: IO CDouble {- | Get the time since the last start of the timer with 'GI.GLib.Functions.testTimerStart'. /Since: 2.16/ -} testTimerElapsed :: (B.CallStack.HasCallStack, MonadIO m) => m Double {- ^ __Returns:__ the time since the last start of the timer, as a double -} testTimerElapsed = liftIO $ do result <- g_test_timer_elapsed let result' = realToFrac result return result' -- function g_test_subprocess -- Args : [] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "g_test_subprocess" g_test_subprocess :: IO CInt {- | Returns 'True' (after @/g_test_init()/@ has been called) if the test program is running under 'GI.GLib.Functions.testTrapSubprocess'. /Since: 2.38/ -} testSubprocess :: (B.CallStack.HasCallStack, MonadIO m) => m Bool {- ^ __Returns:__ 'True' if the test program is running under 'GI.GLib.Functions.testTrapSubprocess'. -} testSubprocess = liftIO $ do result <- g_test_subprocess let result' = (/= 0) result return result' -- function g_test_skip -- Args : [Arg {argCName = "msg", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "explanation", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_test_skip" g_test_skip :: CString -> -- msg : TBasicType TUTF8 IO () {- | Indicates that a test was skipped. Calling this function will not stop the test from running, you need to return from the test function yourself. So you can produce additional diagnostic messages or even continue running the test. If not called from inside a test, this function does nothing. /Since: 2.38/ -} testSkip :: (B.CallStack.HasCallStack, MonadIO m) => Maybe (T.Text) {- ^ /@msg@/: explanation -} -> m () testSkip msg = liftIO $ do maybeMsg <- case msg of Nothing -> return nullPtr Just jMsg -> do jMsg' <- textToCString jMsg return jMsg' g_test_skip maybeMsg freeMem maybeMsg return () -- function g_test_set_nonfatal_assertions -- Args : [] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_test_set_nonfatal_assertions" g_test_set_nonfatal_assertions :: IO () {- | Changes the behaviour of @/g_assert_cmpstr()/@, @/g_assert_cmpint()/@, @/g_assert_cmpuint()/@, @/g_assert_cmphex()/@, @/g_assert_cmpfloat()/@, @/g_assert_true()/@, @/g_assert_false()/@, @/g_assert_null()/@, @/g_assert_no_error()/@, @/g_assert_error()/@, @/g_test_assert_expected_messages()/@ and the various g_test_trap_assert_*() macros to not abort to program, but instead call 'GI.GLib.Functions.testFail' and continue. (This also changes the behavior of 'GI.GLib.Functions.testFail' so that it will not cause the test program to abort after completing the failed test.) Note that the @/g_assert_not_reached()/@ and @/g_assert()/@ are not affected by this. This function can only be called after @/g_test_init()/@. /Since: 2.38/ -} testSetNonfatalAssertions :: (B.CallStack.HasCallStack, MonadIO m) => m () testSetNonfatalAssertions = liftIO $ do g_test_set_nonfatal_assertions return () -- function g_test_run_suite -- Args : [Arg {argCName = "suite", argType = TInterface (Name {namespace = "GLib", name = "TestSuite"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GTestSuite", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TInt) -- throws : False -- Skip return : False foreign import ccall "g_test_run_suite" g_test_run_suite :: Ptr GLib.TestSuite.TestSuite -> -- suite : TInterface (Name {namespace = "GLib", name = "TestSuite"}) IO Int32 {- | Execute the tests within /@suite@/ and all nested @/GTestSuites/@. The test suites to be executed are filtered according to test path arguments (@-p testpath@ and @-s testpath@) as parsed by @/g_test_init()/@. See the 'GI.GLib.Functions.testRun' documentation for more information on the order that tests are run in. 'GI.GLib.Functions.testRunSuite' or 'GI.GLib.Functions.testRun' may only be called once in a program. /Since: 2.16/ -} testRunSuite :: (B.CallStack.HasCallStack, MonadIO m) => GLib.TestSuite.TestSuite {- ^ /@suite@/: a 'GI.GLib.Structs.TestSuite.TestSuite' -} -> m Int32 {- ^ __Returns:__ 0 on success -} testRunSuite suite = liftIO $ do suite' <- unsafeManagedPtrGetPtr suite result <- g_test_run_suite suite' touchManagedPtr suite return result -- function g_test_run -- Args : [] -- Lengths : [] -- returnType : Just (TBasicType TInt) -- throws : False -- Skip return : False foreign import ccall "g_test_run" g_test_run :: IO Int32 {- | Runs all tests under the toplevel suite which can be retrieved with @/g_test_get_root()/@. Similar to 'GI.GLib.Functions.testRunSuite', the test cases to be run are filtered according to test path arguments (@-p testpath@ and @-s testpath@) as parsed by @/g_test_init()/@. 'GI.GLib.Functions.testRunSuite' or 'GI.GLib.Functions.testRun' may only be called once in a program. In general, the tests and sub-suites within each suite are run in the order in which they are defined. However, note that prior to GLib 2.36, there was a bug in the @g_test_add_*@ functions which caused them to create multiple suites with the same name, meaning that if you created tests \"\/foo\/simple\", \"\/bar\/simple\", and \"\/foo\/using-bar\" in that order, they would get run in that order (since 'GI.GLib.Functions.testRun' would run the first \"\/foo\" suite, then the \"\/bar\" suite, then the second \"\/foo\" suite). As of 2.36, this bug is fixed, and adding the tests in that order would result in a running order of \"\/foo\/simple\", \"\/foo\/using-bar\", \"\/bar\/simple\". If this new ordering is sub-optimal (because it puts more-complicated tests before simpler ones, making it harder to figure out exactly what has failed), you can fix it by changing the test paths to group tests by suite in a way that will result in the desired running order. Eg, \"\/simple\/foo\", \"\/simple\/bar\", \"\/complex\/foo-using-bar\". However, you should never make the actual result of a test depend on the order that tests are run in. If you need to ensure that some particular code runs before or after a given test case, use @/g_test_add()/@, which lets you specify setup and teardown functions. If all tests are skipped or marked as incomplete (expected failures), this function will return 0 if producing TAP output, or 77 (treated as \"skip test\" by Automake) otherwise. /Since: 2.16/ -} testRun :: (B.CallStack.HasCallStack, MonadIO m) => m Int32 {- ^ __Returns:__ 0 on success, 1 on failure (assuming it returns at all), 0 or 77 if all tests were skipped with 'GI.GLib.Functions.testSkip' and\/or 'GI.GLib.Functions.testIncomplete' -} testRun = liftIO $ do result <- g_test_run return result -- function g_test_rand_int_range -- Args : [Arg {argCName = "begin", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the minimum value returned by this function", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "end", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the smallest value not to be returned by this function", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TInt32) -- throws : False -- Skip return : False foreign import ccall "g_test_rand_int_range" g_test_rand_int_range :: Int32 -> -- begin : TBasicType TInt32 Int32 -> -- end : TBasicType TInt32 IO Int32 {- | Get a reproducible random integer number out of a specified range, see 'GI.GLib.Functions.testRandInt' for details on test case random numbers. /Since: 2.16/ -} testRandIntRange :: (B.CallStack.HasCallStack, MonadIO m) => Int32 {- ^ /@begin@/: the minimum value returned by this function -} -> Int32 {- ^ /@end@/: the smallest value not to be returned by this function -} -> m Int32 {- ^ __Returns:__ a number with /@begin@/ \<= number \< /@end@/. -} testRandIntRange begin end = liftIO $ do result <- g_test_rand_int_range begin end return result -- function g_test_rand_int -- Args : [] -- Lengths : [] -- returnType : Just (TBasicType TInt32) -- throws : False -- Skip return : False foreign import ccall "g_test_rand_int" g_test_rand_int :: IO Int32 {- | Get a reproducible random integer number. The random numbers generated by the g_test_rand_*() family of functions change with every new test program start, unless the --seed option is given when starting test programs. For individual test cases however, the random number generator is reseeded, to avoid dependencies between tests and to make --seed effective for all test cases. /Since: 2.16/ -} testRandInt :: (B.CallStack.HasCallStack, MonadIO m) => m Int32 {- ^ __Returns:__ a random number from the seeded random number generator. -} testRandInt = liftIO $ do result <- g_test_rand_int return result -- function g_test_rand_double_range -- Args : [Arg {argCName = "range_start", argType = TBasicType TDouble, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the minimum value returned by this function", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "range_end", argType = TBasicType TDouble, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the minimum value not returned by this function", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TDouble) -- throws : False -- Skip return : False foreign import ccall "g_test_rand_double_range" g_test_rand_double_range :: CDouble -> -- range_start : TBasicType TDouble CDouble -> -- range_end : TBasicType TDouble IO CDouble {- | Get a reproducible random floating pointer number out of a specified range, see 'GI.GLib.Functions.testRandInt' for details on test case random numbers. /Since: 2.16/ -} testRandDoubleRange :: (B.CallStack.HasCallStack, MonadIO m) => Double {- ^ /@rangeStart@/: the minimum value returned by this function -} -> Double {- ^ /@rangeEnd@/: the minimum value not returned by this function -} -> m Double {- ^ __Returns:__ a number with /@rangeStart@/ \<= number \< /@rangeEnd@/. -} testRandDoubleRange rangeStart rangeEnd = liftIO $ do let rangeStart' = realToFrac rangeStart let rangeEnd' = realToFrac rangeEnd result <- g_test_rand_double_range rangeStart' rangeEnd' let result' = realToFrac result return result' -- function g_test_rand_double -- Args : [] -- Lengths : [] -- returnType : Just (TBasicType TDouble) -- throws : False -- Skip return : False foreign import ccall "g_test_rand_double" g_test_rand_double :: IO CDouble {- | Get a reproducible random floating point number, see 'GI.GLib.Functions.testRandInt' for details on test case random numbers. /Since: 2.16/ -} testRandDouble :: (B.CallStack.HasCallStack, MonadIO m) => m Double {- ^ __Returns:__ a random number from the seeded random number generator. -} testRandDouble = liftIO $ do result <- g_test_rand_double let result' = realToFrac result return result' -- function g_test_queue_free -- Args : [Arg {argCName = "gfree_pointer", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the pointer to be stored.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_test_queue_free" g_test_queue_free :: Ptr () -> -- gfree_pointer : TBasicType TPtr IO () {- | Enqueue a pointer to be released with 'GI.GLib.Functions.free' during the next teardown phase. This is equivalent to calling 'GI.GLib.Functions.testQueueDestroy' with a destroy callback of 'GI.GLib.Functions.free'. /Since: 2.16/ -} testQueueFree :: (B.CallStack.HasCallStack, MonadIO m) => Ptr () {- ^ /@gfreePointer@/: the pointer to be stored. -} -> m () testQueueFree gfreePointer = liftIO $ do g_test_queue_free gfreePointer return () -- function g_test_queue_destroy -- Args : [Arg {argCName = "destroy_func", argType = TInterface (Name {namespace = "GLib", name = "DestroyNotify"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Destroy callback for teardown phase.", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "destroy_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Destroy callback data.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_test_queue_destroy" g_test_queue_destroy :: FunPtr GLib.Callbacks.C_DestroyNotify -> -- destroy_func : TInterface (Name {namespace = "GLib", name = "DestroyNotify"}) Ptr () -> -- destroy_data : TBasicType TPtr IO () {- | This function enqueus a callback /@destroyFunc@/ to be executed during the next test case teardown phase. This is most useful to auto destruct allocated test resources at the end of a test run. Resources are released in reverse queue order, that means enqueueing callback A before callback B will cause @/B()/@ to be called before @/A()/@ during teardown. /Since: 2.16/ -} testQueueDestroy :: (B.CallStack.HasCallStack, MonadIO m) => GLib.Callbacks.DestroyNotify {- ^ /@destroyFunc@/: Destroy callback for teardown phase. -} -> Ptr () {- ^ /@destroyData@/: Destroy callback data. -} -> m () testQueueDestroy destroyFunc destroyData = liftIO $ do ptrdestroyFunc <- callocMem :: IO (Ptr (FunPtr GLib.Callbacks.C_DestroyNotify)) destroyFunc' <- GLib.Callbacks.mk_DestroyNotify (GLib.Callbacks.wrap_DestroyNotify (Just ptrdestroyFunc) destroyFunc) poke ptrdestroyFunc destroyFunc' g_test_queue_destroy destroyFunc' destroyData return () -- function g_test_log_type_name -- Args : [Arg {argCName = "log_type", argType = TInterface (Name {namespace = "GLib", name = "TestLogType"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_test_log_type_name" g_test_log_type_name :: CUInt -> -- log_type : TInterface (Name {namespace = "GLib", name = "TestLogType"}) IO CString {- | /No description available in the introspection data./ -} testLogTypeName :: (B.CallStack.HasCallStack, MonadIO m) => GLib.Enums.TestLogType -> m T.Text testLogTypeName logType = liftIO $ do let logType' = (fromIntegral . fromEnum) logType result <- g_test_log_type_name logType' checkUnexpectedReturnNULL "testLogTypeName" result result' <- cstringToText result return result' -- function g_test_incomplete -- Args : [Arg {argCName = "msg", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "explanation", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_test_incomplete" g_test_incomplete :: CString -> -- msg : TBasicType TUTF8 IO () {- | Indicates that a test failed because of some incomplete functionality. This function can be called multiple times from the same test. Calling this function will not stop the test from running, you need to return from the test function yourself. So you can produce additional diagnostic messages or even continue running the test. If not called from inside a test, this function does nothing. /Since: 2.38/ -} testIncomplete :: (B.CallStack.HasCallStack, MonadIO m) => Maybe (T.Text) {- ^ /@msg@/: explanation -} -> m () testIncomplete msg = liftIO $ do maybeMsg <- case msg of Nothing -> return nullPtr Just jMsg -> do jMsg' <- textToCString jMsg return jMsg' g_test_incomplete maybeMsg freeMem maybeMsg return () -- function g_test_get_dir -- Args : [Arg {argCName = "file_type", argType = TInterface (Name {namespace = "GLib", name = "TestFileType"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the type of file (built vs. distributed)", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TFileName) -- throws : False -- Skip return : False foreign import ccall "g_test_get_dir" g_test_get_dir :: CUInt -> -- file_type : TInterface (Name {namespace = "GLib", name = "TestFileType"}) IO CString {- | Gets the pathname of the directory containing test files of the type specified by /@fileType@/. This is approximately the same as calling g_test_build_filename(\".\"), but you don\'t need to free the return value. /Since: 2.38/ -} testGetDir :: (B.CallStack.HasCallStack, MonadIO m) => GLib.Enums.TestFileType {- ^ /@fileType@/: the type of file (built vs. distributed) -} -> m [Char] {- ^ __Returns:__ the path of the directory, owned by GLib -} testGetDir fileType = liftIO $ do let fileType' = (fromIntegral . fromEnum) fileType result <- g_test_get_dir fileType' checkUnexpectedReturnNULL "testGetDir" result result' <- cstringToString result return result' -- function g_test_failed -- Args : [] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "g_test_failed" g_test_failed :: IO CInt {- | Returns whether a test has already failed. This will be the case when 'GI.GLib.Functions.testFail', 'GI.GLib.Functions.testIncomplete' or 'GI.GLib.Functions.testSkip' have been called, but also if an assertion has failed. This can be useful to return early from a test if continuing after a failed assertion might be harmful. The return value of this function is only meaningful if it is called from inside a test function. /Since: 2.38/ -} testFailed :: (B.CallStack.HasCallStack, MonadIO m) => m Bool {- ^ __Returns:__ 'True' if the test has failed -} testFailed = liftIO $ do result <- g_test_failed let result' = (/= 0) result return result' -- function g_test_fail -- Args : [] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_test_fail" g_test_fail :: IO () {- | Indicates that a test failed. This function can be called multiple times from the same test. You can use this function if your test failed in a recoverable way. Do not use this function if the failure of a test could cause other tests to malfunction. Calling this function will not stop the test from running, you need to return from the test function yourself. So you can produce additional diagnostic messages or even continue running the test. If not called from inside a test, this function does nothing. /Since: 2.30/ -} testFail :: (B.CallStack.HasCallStack, MonadIO m) => m () testFail = liftIO $ do g_test_fail return () -- function g_test_expect_message -- Args : [Arg {argCName = "log_domain", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the log domain of the message", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "log_level", argType = TInterface (Name {namespace = "GLib", name = "LogLevelFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the log level of the message", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "pattern", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a glob-style [pattern][glib-Glob-style-pattern-matching]", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_test_expect_message" g_test_expect_message :: CString -> -- log_domain : TBasicType TUTF8 CInt -> -- log_level : TInterface (Name {namespace = "GLib", name = "LogLevelFlags"}) CString -> -- pattern : TBasicType TUTF8 IO () {- | Indicates that a message with the given /@logDomain@/ and /@logLevel@/, with text matching /@pattern@/, is expected to be logged. When this message is logged, it will not be printed, and the test case will not abort. This API may only be used with the old logging API (@/g_log()/@ without @/G_LOG_USE_STRUCTURED/@ defined). It will not work with the structured logging API. See [Testing for Messages][testing-for-messages]. Use @/g_test_assert_expected_messages()/@ to assert that all previously-expected messages have been seen and suppressed. You can call this multiple times in a row, if multiple messages are expected as a result of a single call. (The messages must appear in the same order as the calls to 'GI.GLib.Functions.testExpectMessage'.) For example: === /C code/ > > // g_main_context_push_thread_default() should fail if the > // context is already owned by another thread. > g_test_expect_message (G_LOG_DOMAIN, > G_LOG_LEVEL_CRITICAL, > "assertion*acquired_context*failed"); > g_main_context_push_thread_default (bad_context); > g_test_assert_expected_messages (); Note that you cannot use this to test @/g_error()/@ messages, since @/g_error()/@ intentionally never returns even if the program doesn\'t abort; use 'GI.GLib.Functions.testTrapSubprocess' in this case. If messages at 'GI.GLib.Flags.LogLevelFlagsLevelDebug' are emitted, but not explicitly expected via 'GI.GLib.Functions.testExpectMessage' then they will be ignored. /Since: 2.34/ -} testExpectMessage :: (B.CallStack.HasCallStack, MonadIO m) => Maybe (T.Text) {- ^ /@logDomain@/: the log domain of the message -} -> [GLib.Flags.LogLevelFlags] {- ^ /@logLevel@/: the log level of the message -} -> T.Text {- ^ /@pattern@/: a glob-style [pattern][glib-Glob-style-pattern-matching] -} -> m () testExpectMessage logDomain logLevel pattern = liftIO $ do maybeLogDomain <- case logDomain of Nothing -> return nullPtr Just jLogDomain -> do jLogDomain' <- textToCString jLogDomain return jLogDomain' let logLevel' = gflagsToWord logLevel pattern' <- textToCString pattern g_test_expect_message maybeLogDomain logLevel' pattern' freeMem maybeLogDomain freeMem pattern' return () -- function g_test_bug_base -- Args : [Arg {argCName = "uri_pattern", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the base pattern for bug URIs", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_test_bug_base" g_test_bug_base :: CString -> -- uri_pattern : TBasicType TUTF8 IO () {- | Specify the base URI for bug reports. The base URI is used to construct bug report messages for @/g_test_message()/@ when 'GI.GLib.Functions.testBug' is called. Calling this function outside of a test case sets the default base URI for all test cases. Calling it from within a test case changes the base URI for the scope of the test case only. Bug URIs are constructed by appending a bug specific URI portion to /@uriPattern@/, or by replacing the special string \'%s\' within /@uriPattern@/ if that is present. /Since: 2.16/ -} testBugBase :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@uriPattern@/: the base pattern for bug URIs -} -> m () testBugBase uriPattern = liftIO $ do uriPattern' <- textToCString uriPattern g_test_bug_base uriPattern' freeMem uriPattern' return () -- function g_test_bug -- Args : [Arg {argCName = "bug_uri_snippet", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Bug specific bug tracker URI portion.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_test_bug" g_test_bug :: CString -> -- bug_uri_snippet : TBasicType TUTF8 IO () {- | This function adds a message to test reports that associates a bug URI with a test case. Bug URIs are constructed from a base URI set with 'GI.GLib.Functions.testBugBase' and /@bugUriSnippet@/. /Since: 2.16/ -} testBug :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@bugUriSnippet@/: Bug specific bug tracker URI portion. -} -> m () testBug bugUriSnippet = liftIO $ do bugUriSnippet' <- textToCString bugUriSnippet g_test_bug bugUriSnippet' freeMem bugUriSnippet' return () -- function g_test_assert_expected_messages_internal -- Args : [Arg {argCName = "domain", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "file", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "line", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "func", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_test_assert_expected_messages_internal" g_test_assert_expected_messages_internal :: CString -> -- domain : TBasicType TUTF8 CString -> -- file : TBasicType TUTF8 Int32 -> -- line : TBasicType TInt CString -> -- func : TBasicType TUTF8 IO () {- | /No description available in the introspection data./ -} testAssertExpectedMessagesInternal :: (B.CallStack.HasCallStack, MonadIO m) => T.Text -> T.Text -> Int32 -> T.Text -> m () testAssertExpectedMessagesInternal domain file line func = liftIO $ do domain' <- textToCString domain file' <- textToCString file func' <- textToCString func g_test_assert_expected_messages_internal domain' file' line func' freeMem domain' freeMem file' freeMem func' return () -- function g_test_add_func -- Args : [Arg {argCName = "testpath", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "/-separated test case path name for the test.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "test_func", argType = TInterface (Name {namespace = "GLib", name = "TestFunc"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The test function to invoke for this test.", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_test_add_func" g_test_add_func :: CString -> -- testpath : TBasicType TUTF8 FunPtr GLib.Callbacks.C_TestFunc -> -- test_func : TInterface (Name {namespace = "GLib", name = "TestFunc"}) IO () {- | Create a new test case, similar to @/g_test_create_case()/@. However the test is assumed to use no fixture, and test suites are automatically created on the fly and added to the root fixture, based on the slash-separated portions of /@testpath@/. If /@testpath@/ includes the component \"subprocess\" anywhere in it, the test will be skipped by default, and only run if explicitly required via the @-p@ command-line option or 'GI.GLib.Functions.testTrapSubprocess'. No component of /@testpath@/ may start with a dot (@.@) if the 'GI.GLib.Constants.TEST_OPTION_ISOLATE_DIRS' option is being used; and it is recommended to do so even if it isn’t. /Since: 2.16/ -} testAddFunc :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@testpath@/: \/-separated test case path name for the test. -} -> GLib.Callbacks.TestFunc {- ^ /@testFunc@/: The test function to invoke for this test. -} -> m () testAddFunc testpath testFunc = liftIO $ do testpath' <- textToCString testpath ptrtestFunc <- callocMem :: IO (Ptr (FunPtr GLib.Callbacks.C_TestFunc)) testFunc' <- GLib.Callbacks.mk_TestFunc (GLib.Callbacks.wrap_TestFunc (Just ptrtestFunc) testFunc) poke ptrtestFunc testFunc' g_test_add_func testpath' testFunc' freeMem testpath' return () -- function g_test_add_data_func -- Args : [Arg {argCName = "testpath", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "/-separated test case path name for the test.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "test_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Test data argument for the test function.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "test_func", argType = TInterface (Name {namespace = "GLib", name = "TestDataFunc"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The test function to invoke for this test.", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_test_add_data_func" g_test_add_data_func :: CString -> -- testpath : TBasicType TUTF8 Ptr () -> -- test_data : TBasicType TPtr FunPtr GLib.Callbacks.C_TestDataFunc -> -- test_func : TInterface (Name {namespace = "GLib", name = "TestDataFunc"}) IO () {- | Create a new test case, similar to @/g_test_create_case()/@. However the test is assumed to use no fixture, and test suites are automatically created on the fly and added to the root fixture, based on the slash-separated portions of /@testpath@/. The /@testData@/ argument will be passed as first argument to /@testFunc@/. If /@testpath@/ includes the component \"subprocess\" anywhere in it, the test will be skipped by default, and only run if explicitly required via the @-p@ command-line option or 'GI.GLib.Functions.testTrapSubprocess'. No component of /@testpath@/ may start with a dot (@.@) if the 'GI.GLib.Constants.TEST_OPTION_ISOLATE_DIRS' option is being used; and it is recommended to do so even if it isn’t. /Since: 2.16/ -} testAddDataFunc :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@testpath@/: \/-separated test case path name for the test. -} -> Ptr () {- ^ /@testData@/: Test data argument for the test function. -} -> GLib.Callbacks.TestDataFunc {- ^ /@testFunc@/: The test function to invoke for this test. -} -> m () testAddDataFunc testpath testData testFunc = liftIO $ do testpath' <- textToCString testpath ptrtestFunc <- callocMem :: IO (Ptr (FunPtr GLib.Callbacks.C_TestDataFunc)) testFunc' <- GLib.Callbacks.mk_TestDataFunc (GLib.Callbacks.wrap_TestDataFunc (Just ptrtestFunc) (GLib.Callbacks.drop_closures_TestDataFunc testFunc)) poke ptrtestFunc testFunc' g_test_add_data_func testpath' testData testFunc' freeMem testpath' return () -- function g_strv_length -- Args : [Arg {argCName = "str_array", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a %NULL-terminated array of strings", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUInt) -- throws : False -- Skip return : False foreign import ccall "g_strv_length" g_strv_length :: CString -> -- str_array : TBasicType TUTF8 IO Word32 {- | Returns the length of the given 'Nothing'-terminated string array /@strArray@/. /@strArray@/ must not be 'Nothing'. /Since: 2.6/ -} strvLength :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@strArray@/: a 'Nothing'-terminated array of strings -} -> m Word32 {- ^ __Returns:__ length of /@strArray@/. -} strvLength strArray = liftIO $ do strArray' <- textToCString strArray result <- g_strv_length strArray' freeMem strArray' return result -- function g_strv_get_type -- Args : [] -- Lengths : [] -- returnType : Just (TBasicType TGType) -- throws : False -- Skip return : False foreign import ccall "g_strv_get_type" g_strv_get_type :: IO CGType {- | /No description available in the introspection data./ -} strvGetType :: (B.CallStack.HasCallStack, MonadIO m) => m GType strvGetType = liftIO $ do result <- g_strv_get_type let result' = GType result return result' -- function g_strv_equal -- Args : [Arg {argCName = "strv1", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a %NULL-terminated array of strings", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "strv2", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "another %NULL-terminated array of strings", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "g_strv_equal" g_strv_equal :: CString -> -- strv1 : TBasicType TUTF8 CString -> -- strv2 : TBasicType TUTF8 IO CInt {- | Checks if /@strv1@/ and /@strv2@/ contain exactly the same elements in exactly the same order. Elements are compared using 'GI.GLib.Functions.strEqual'. To match independently of order, sort the arrays first (using @/g_qsort_with_data()/@ or similar). Two empty arrays are considered equal. Neither /@strv1@/ not /@strv2@/ may be 'Nothing'. /Since: 2.60/ -} strvEqual :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@strv1@/: a 'Nothing'-terminated array of strings -} -> T.Text {- ^ /@strv2@/: another 'Nothing'-terminated array of strings -} -> m Bool {- ^ __Returns:__ 'True' if /@strv1@/ and /@strv2@/ are equal -} strvEqual strv1 strv2 = liftIO $ do strv1' <- textToCString strv1 strv2' <- textToCString strv2 result <- g_strv_equal strv1' strv2' let result' = (/= 0) result freeMem strv1' freeMem strv2' return result' -- function g_strv_contains -- Args : [Arg {argCName = "strv", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a %NULL-terminated array of strings", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "str", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "g_strv_contains" g_strv_contains :: CString -> -- strv : TBasicType TUTF8 CString -> -- str : TBasicType TUTF8 IO CInt {- | Checks if /@strv@/ contains /@str@/. /@strv@/ must not be 'Nothing'. /Since: 2.44/ -} strvContains :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@strv@/: a 'Nothing'-terminated array of strings -} -> T.Text {- ^ /@str@/: a string -} -> m Bool {- ^ __Returns:__ 'True' if /@str@/ is an element of /@strv@/, according to 'GI.GLib.Functions.strEqual'. -} strvContains strv str = liftIO $ do strv' <- textToCString strv str' <- textToCString str result <- g_strv_contains strv' str' let result' = (/= 0) result freeMem strv' freeMem str' return result' -- function g_strup -- Args : [Arg {argCName = "string", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the string to convert", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_strup" g_strup :: CString -> -- string : TBasicType TUTF8 IO CString {-# DEPRECATED strup ["(Since version 2.2)","This function is totally broken for the reasons"," discussed in the 'GI.GLib.Functions.strncasecmp' docs - use 'GI.GLib.Functions.asciiStrup'"," or 'GI.GLib.Functions.utf8Strup' instead."] #-} {- | Converts a string to upper case. -} strup :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@string@/: the string to convert -} -> m T.Text {- ^ __Returns:__ the string -} strup string = liftIO $ do string' <- textToCString string result <- g_strup string' checkUnexpectedReturnNULL "strup" result result' <- cstringToText result freeMem result freeMem string' return result' -- function g_strtod -- Args : [Arg {argCName = "nptr", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the string to convert to a numeric value.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "endptr", argType = TBasicType TUTF8, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "if non-%NULL, it returns the\n character after the last character used in the conversion.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TDouble) -- throws : False -- Skip return : False foreign import ccall "g_strtod" g_strtod :: CString -> -- nptr : TBasicType TUTF8 Ptr CString -> -- endptr : TBasicType TUTF8 IO CDouble {- | Converts a string to a @/gdouble/@ value. It calls the standard @/strtod()/@ function to handle the conversion, but if the string is not completely converted it attempts the conversion again with 'GI.GLib.Functions.asciiStrtod', and returns the best match. This function should seldom be used. The normal situation when reading numbers not for human consumption is to use 'GI.GLib.Functions.asciiStrtod'. Only when you know that you must expect both locale formatted and C formatted numbers should you use this. Make sure that you don\'t pass strings such as comma separated lists of values, since the commas may be interpreted as a decimal point in some locales, causing unexpected results. -} strtod :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@nptr@/: the string to convert to a numeric value. -} -> m ((Double, T.Text)) {- ^ __Returns:__ the @/gdouble/@ value. -} strtod nptr = liftIO $ do nptr' <- textToCString nptr endptr <- allocMem :: IO (Ptr CString) result <- g_strtod nptr' endptr let result' = realToFrac result endptr' <- peek endptr endptr'' <- cstringToText endptr' freeMem nptr' freeMem endptr return (result', endptr'') -- function g_strstr_len -- Args : [Arg {argCName = "haystack", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "haystack_len", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the maximum length of @haystack. Note that -1 is\n a valid length, if @haystack is nul-terminated, meaning it will\n search through the whole string.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "needle", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the string to search for", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_strstr_len" g_strstr_len :: CString -> -- haystack : TBasicType TUTF8 Int64 -> -- haystack_len : TBasicType TInt64 CString -> -- needle : TBasicType TUTF8 IO CString {- | Searches the string /@haystack@/ for the first occurrence of the string /@needle@/, limiting the length of the search to /@haystackLen@/. -} strstrLen :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@haystack@/: a string -} -> Int64 {- ^ /@haystackLen@/: the maximum length of /@haystack@/. Note that -1 is a valid length, if /@haystack@/ is nul-terminated, meaning it will search through the whole string. -} -> T.Text {- ^ /@needle@/: the string to search for -} -> m T.Text {- ^ __Returns:__ a pointer to the found occurrence, or 'Nothing' if not found. -} strstrLen haystack haystackLen needle = liftIO $ do haystack' <- textToCString haystack needle' <- textToCString needle result <- g_strstr_len haystack' haystackLen needle' checkUnexpectedReturnNULL "strstrLen" result result' <- cstringToText result freeMem result freeMem haystack' freeMem needle' return result' -- function g_strsignal -- Args : [Arg {argCName = "signum", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the signal number. See the `signal` documentation", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_strsignal" g_strsignal :: Int32 -> -- signum : TBasicType TInt IO CString {- | Returns a string describing the given signal, e.g. \"Segmentation fault\". You should use this function in preference to @/strsignal()/@, because it returns a string in UTF-8 encoding, and since not all platforms support the @/strsignal()/@ function. -} strsignal :: (B.CallStack.HasCallStack, MonadIO m) => Int32 {- ^ /@signum@/: the signal number. See the @signal@ documentation -} -> m T.Text {- ^ __Returns:__ a UTF-8 string describing the signal. If the signal is unknown, it returns \"unknown signal (\<signum>)\". -} strsignal signum = liftIO $ do result <- g_strsignal signum checkUnexpectedReturnNULL "strsignal" result result' <- cstringToText result return result' -- function g_strrstr_len -- Args : [Arg {argCName = "haystack", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a nul-terminated string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "haystack_len", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the maximum length of @haystack", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "needle", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the nul-terminated string to search for", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_strrstr_len" g_strrstr_len :: CString -> -- haystack : TBasicType TUTF8 Int64 -> -- haystack_len : TBasicType TInt64 CString -> -- needle : TBasicType TUTF8 IO CString {- | Searches the string /@haystack@/ for the last occurrence of the string /@needle@/, limiting the length of the search to /@haystackLen@/. -} strrstrLen :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@haystack@/: a nul-terminated string -} -> Int64 {- ^ /@haystackLen@/: the maximum length of /@haystack@/ -} -> T.Text {- ^ /@needle@/: the nul-terminated string to search for -} -> m T.Text {- ^ __Returns:__ a pointer to the found occurrence, or 'Nothing' if not found. -} strrstrLen haystack haystackLen needle = liftIO $ do haystack' <- textToCString haystack needle' <- textToCString needle result <- g_strrstr_len haystack' haystackLen needle' checkUnexpectedReturnNULL "strrstrLen" result result' <- cstringToText result freeMem result freeMem haystack' freeMem needle' return result' -- function g_strrstr -- Args : [Arg {argCName = "haystack", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a nul-terminated string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "needle", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the nul-terminated string to search for", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_strrstr" g_strrstr :: CString -> -- haystack : TBasicType TUTF8 CString -> -- needle : TBasicType TUTF8 IO CString {- | Searches the string /@haystack@/ for the last occurrence of the string /@needle@/. -} strrstr :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@haystack@/: a nul-terminated string -} -> T.Text {- ^ /@needle@/: the nul-terminated string to search for -} -> m T.Text {- ^ __Returns:__ a pointer to the found occurrence, or 'Nothing' if not found. -} strrstr haystack needle = liftIO $ do haystack' <- textToCString haystack needle' <- textToCString needle result <- g_strrstr haystack' needle' checkUnexpectedReturnNULL "strrstr" result result' <- cstringToText result freeMem result freeMem haystack' freeMem needle' return result' -- function g_strreverse -- Args : [Arg {argCName = "string", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the string to reverse", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_strreverse" g_strreverse :: CString -> -- string : TBasicType TUTF8 IO CString {- | Reverses all of the bytes in a string. For example, @g_strreverse (\"abcdef\")@ will result in \"fedcba\". Note that 'GI.GLib.Functions.strreverse' doesn\'t work on UTF-8 strings containing multibyte characters. For that purpose, use 'GI.GLib.Functions.utf8Strreverse'. -} strreverse :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@string@/: the string to reverse -} -> m T.Text {- ^ __Returns:__ the same pointer passed in as /@string@/ -} strreverse string = liftIO $ do string' <- textToCString string result <- g_strreverse string' checkUnexpectedReturnNULL "strreverse" result result' <- cstringToText result freeMem result freeMem string' return result' -- function g_strnfill -- Args : [Arg {argCName = "length", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the length of the new string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "fill_char", argType = TBasicType TInt8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the byte to fill the string with", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_strnfill" g_strnfill :: Word64 -> -- length : TBasicType TUInt64 Int8 -> -- fill_char : TBasicType TInt8 IO CString {- | Creates a new string /@length@/ bytes long filled with /@fillChar@/. The returned string should be freed when no longer needed. -} strnfill :: (B.CallStack.HasCallStack, MonadIO m) => Word64 {- ^ /@length@/: the length of the new string -} -> Int8 {- ^ /@fillChar@/: the byte to fill the string with -} -> m T.Text {- ^ __Returns:__ a newly-allocated string filled the /@fillChar@/ -} strnfill length_ fillChar = liftIO $ do result <- g_strnfill length_ fillChar checkUnexpectedReturnNULL "strnfill" result result' <- cstringToText result freeMem result return result' -- function g_strndup -- Args : [Arg {argCName = "str", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the string to duplicate", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "n", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the maximum number of bytes to copy from @str", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_strndup" g_strndup :: CString -> -- str : TBasicType TUTF8 Word64 -> -- n : TBasicType TUInt64 IO CString {- | Duplicates the first /@n@/ bytes of a string, returning a newly-allocated buffer /@n@/ + 1 bytes long which will always be nul-terminated. If /@str@/ is less than /@n@/ bytes long the buffer is padded with nuls. If /@str@/ is 'Nothing' it returns 'Nothing'. The returned value should be freed when no longer needed. To copy a number of characters from a UTF-8 encoded string, use 'GI.GLib.Functions.utf8Strncpy' instead. -} strndup :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@str@/: the string to duplicate -} -> Word64 {- ^ /@n@/: the maximum number of bytes to copy from /@str@/ -} -> m T.Text {- ^ __Returns:__ a newly-allocated buffer containing the first /@n@/ bytes of /@str@/, nul-terminated -} strndup str n = liftIO $ do str' <- textToCString str result <- g_strndup str' n checkUnexpectedReturnNULL "strndup" result result' <- cstringToText result freeMem result freeMem str' return result' -- function g_strncasecmp -- Args : [Arg {argCName = "s1", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "s2", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a string to compare with @s1", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "n", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the maximum number of characters to compare", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TInt) -- throws : False -- Skip return : False foreign import ccall "g_strncasecmp" g_strncasecmp :: CString -> -- s1 : TBasicType TUTF8 CString -> -- s2 : TBasicType TUTF8 Word32 -> -- n : TBasicType TUInt IO Int32 {-# DEPRECATED strncasecmp ["(Since version 2.2)","The problem with 'GI.GLib.Functions.strncasecmp' is that it does"," the comparison by calling @/toupper()/@\\/@/tolower()/@. These functions"," are locale-specific and operate on single bytes. However, it is"," impossible to handle things correctly from an internationalization"," standpoint by operating on bytes, since characters may be multibyte."," Thus 'GI.GLib.Functions.strncasecmp' is broken if your string is guaranteed to be"," ASCII, since it is locale-sensitive, and it\\'s broken if your string"," is localized, since it doesn\\'t work on many encodings at all,"," including UTF-8, EUC-JP, etc.",""," There are therefore two replacement techniques: 'GI.GLib.Functions.asciiStrncasecmp',"," which only works on ASCII and is not locale-sensitive, and"," 'GI.GLib.Functions.utf8Casefold' followed by @/strcmp()/@ on the resulting strings,"," which is good for case-insensitive sorting of UTF-8."] #-} {- | A case-insensitive string comparison, corresponding to the standard @/strncasecmp()/@ function on platforms which support it. It is similar to 'GI.GLib.Functions.strcasecmp' except it only compares the first /@n@/ characters of the strings. -} strncasecmp :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@s1@/: a string -} -> T.Text {- ^ /@s2@/: a string to compare with /@s1@/ -} -> Word32 {- ^ /@n@/: the maximum number of characters to compare -} -> m Int32 {- ^ __Returns:__ 0 if the strings match, a negative value if /@s1@/ \< /@s2@/, or a positive value if /@s1@/ > /@s2@/. -} strncasecmp s1 s2 n = liftIO $ do s1' <- textToCString s1 s2' <- textToCString s2 result <- g_strncasecmp s1' s2' n freeMem s1' freeMem s2' return result -- function g_strlcpy -- Args : [Arg {argCName = "dest", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "destination buffer", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "src", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "source buffer", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "dest_size", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "length of @dest in bytes", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUInt64) -- throws : False -- Skip return : False foreign import ccall "g_strlcpy" g_strlcpy :: CString -> -- dest : TBasicType TUTF8 CString -> -- src : TBasicType TUTF8 Word64 -> -- dest_size : TBasicType TUInt64 IO Word64 {- | Portability wrapper that calls @/strlcpy()/@ on systems which have it, and emulates @/strlcpy()/@ otherwise. Copies /@src@/ to /@dest@/; /@dest@/ is guaranteed to be nul-terminated; /@src@/ must be nul-terminated; /@destSize@/ is the buffer size, not the number of bytes to copy. At most /@destSize@/ - 1 characters will be copied. Always nul-terminates (unless /@destSize@/ is 0). This function does not allocate memory. Unlike @/strncpy()/@, this function doesn\'t pad /@dest@/ (so it\'s often faster). It returns the size of the attempted result, strlen (src), so if /@retval@/ >= /@destSize@/, truncation occurred. Caveat: @/strlcpy()/@ is supposedly more secure than @/strcpy()/@ or @/strncpy()/@, but if you really want to avoid screwups, 'GI.GLib.Functions.strdup' is an even better idea. -} strlcpy :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@dest@/: destination buffer -} -> T.Text {- ^ /@src@/: source buffer -} -> Word64 {- ^ /@destSize@/: length of /@dest@/ in bytes -} -> m Word64 {- ^ __Returns:__ length of /@src@/ -} strlcpy dest src destSize = liftIO $ do dest' <- textToCString dest src' <- textToCString src result <- g_strlcpy dest' src' destSize freeMem dest' freeMem src' return result -- function g_strlcat -- Args : [Arg {argCName = "dest", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "destination buffer, already containing one nul-terminated string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "src", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "source buffer", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "dest_size", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "length of @dest buffer in bytes (not length of existing string\n inside @dest)", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUInt64) -- throws : False -- Skip return : False foreign import ccall "g_strlcat" g_strlcat :: CString -> -- dest : TBasicType TUTF8 CString -> -- src : TBasicType TUTF8 Word64 -> -- dest_size : TBasicType TUInt64 IO Word64 {- | Portability wrapper that calls @/strlcat()/@ on systems which have it, and emulates it otherwise. Appends nul-terminated /@src@/ string to /@dest@/, guaranteeing nul-termination for /@dest@/. The total size of /@dest@/ won\'t exceed /@destSize@/. At most /@destSize@/ - 1 characters will be copied. Unlike @/strncat()/@, /@destSize@/ is the full size of dest, not the space left over. This function does not allocate memory. It always nul-terminates (unless /@destSize@/ == 0 or there were no nul characters in the /@destSize@/ characters of dest to start with). Caveat: this is supposedly a more secure alternative to @/strcat()/@ or @/strncat()/@, but for real security @/g_strconcat()/@ is harder to mess up. -} strlcat :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@dest@/: destination buffer, already containing one nul-terminated string -} -> T.Text {- ^ /@src@/: source buffer -} -> Word64 {- ^ /@destSize@/: length of /@dest@/ buffer in bytes (not length of existing string inside /@dest@/) -} -> m Word64 {- ^ __Returns:__ size of attempted result, which is MIN (dest_size, strlen (original dest)) + strlen (src), so if retval >= dest_size, truncation occurred. -} strlcat dest src destSize = liftIO $ do dest' <- textToCString dest src' <- textToCString src result <- g_strlcat dest' src' destSize freeMem dest' freeMem src' return result -- function g_strjoinv -- Args : [Arg {argCName = "separator", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a string to insert between each of the\n strings, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "str_array", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a %NULL-terminated array of strings to join", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_strjoinv" g_strjoinv :: CString -> -- separator : TBasicType TUTF8 CString -> -- str_array : TBasicType TUTF8 IO CString {- | Joins a number of strings together to form one long string, with the optional /@separator@/ inserted between each of them. The returned string should be freed with 'GI.GLib.Functions.free'. If /@strArray@/ has no items, the return value will be an empty string. If /@strArray@/ contains a single item, /@separator@/ will not appear in the resulting string. -} strjoinv :: (B.CallStack.HasCallStack, MonadIO m) => Maybe (T.Text) {- ^ /@separator@/: a string to insert between each of the strings, or 'Nothing' -} -> T.Text {- ^ /@strArray@/: a 'Nothing'-terminated array of strings to join -} -> m T.Text {- ^ __Returns:__ a newly-allocated string containing all of the strings joined together, with /@separator@/ between them -} strjoinv separator strArray = liftIO $ do maybeSeparator <- case separator of Nothing -> return nullPtr Just jSeparator -> do jSeparator' <- textToCString jSeparator return jSeparator' strArray' <- textToCString strArray result <- g_strjoinv maybeSeparator strArray' checkUnexpectedReturnNULL "strjoinv" result result' <- cstringToText result freeMem result freeMem maybeSeparator freeMem strArray' return result' -- function g_strip_context -- Args : [Arg {argCName = "msgid", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "msgval", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "another string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_strip_context" g_strip_context :: CString -> -- msgid : TBasicType TUTF8 CString -> -- msgval : TBasicType TUTF8 IO CString {- | An auxiliary function for @/gettext()/@ support (see @/Q_()/@). /Since: 2.4/ -} stripContext :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@msgid@/: a string -} -> T.Text {- ^ /@msgval@/: another string -} -> m T.Text {- ^ __Returns:__ /@msgval@/, unless /@msgval@/ is identical to /@msgid@/ and contains a \'|\' character, in which case a pointer to the substring of msgid after the first \'|\' character is returned. -} stripContext msgid msgval = liftIO $ do msgid' <- textToCString msgid msgval' <- textToCString msgval result <- g_strip_context msgid' msgval' checkUnexpectedReturnNULL "stripContext" result result' <- cstringToText result freeMem msgid' freeMem msgval' return result' -- function g_string_sized_new -- Args : [Arg {argCName = "dfl_size", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the default size of the space allocated to\n hold the string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TInterface (Name {namespace = "GLib", name = "String"})) -- throws : False -- Skip return : False foreign import ccall "g_string_sized_new" g_string_sized_new :: Word64 -> -- dfl_size : TBasicType TUInt64 IO (Ptr GLib.String.String) {- | Creates a new 'GI.GLib.Structs.String.String', with enough space for /@dflSize@/ bytes. This is useful if you are going to add a lot of text to the string and don\'t want it to be reallocated too often. -} stringSizedNew :: (B.CallStack.HasCallStack, MonadIO m) => Word64 {- ^ /@dflSize@/: the default size of the space allocated to hold the string -} -> m GLib.String.String {- ^ __Returns:__ the new 'GI.GLib.Structs.String.String' -} stringSizedNew dflSize = liftIO $ do result <- g_string_sized_new dflSize checkUnexpectedReturnNULL "stringSizedNew" result result' <- (wrapBoxed GLib.String.String) result return result' -- function g_string_new_len -- Args : [Arg {argCName = "init", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "initial contents of the string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "len", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "length of @init to use", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TInterface (Name {namespace = "GLib", name = "String"})) -- throws : False -- Skip return : False foreign import ccall "g_string_new_len" g_string_new_len :: CString -> -- init : TBasicType TUTF8 Int64 -> -- len : TBasicType TInt64 IO (Ptr GLib.String.String) {- | Creates a new 'GI.GLib.Structs.String.String' with /@len@/ bytes of the /@init@/ buffer. Because a length is provided, /@init@/ need not be nul-terminated, and can contain embedded nul bytes. Since this function does not stop at nul bytes, it is the caller\'s responsibility to ensure that /@init@/ has at least /@len@/ addressable bytes. -} stringNewLen :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@init@/: initial contents of the string -} -> Int64 {- ^ /@len@/: length of /@init@/ to use -} -> m GLib.String.String {- ^ __Returns:__ a new 'GI.GLib.Structs.String.String' -} stringNewLen init len = liftIO $ do init' <- textToCString init result <- g_string_new_len init' len checkUnexpectedReturnNULL "stringNewLen" result result' <- (wrapBoxed GLib.String.String) result freeMem init' return result' -- function g_string_new -- Args : [Arg {argCName = "init", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the initial text to copy into the string, or %NULL to\nstart with an empty string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TInterface (Name {namespace = "GLib", name = "String"})) -- throws : False -- Skip return : False foreign import ccall "g_string_new" g_string_new :: CString -> -- init : TBasicType TUTF8 IO (Ptr GLib.String.String) {- | Creates a new 'GI.GLib.Structs.String.String', initialized with the given string. -} stringNew :: (B.CallStack.HasCallStack, MonadIO m) => Maybe (T.Text) {- ^ /@init@/: the initial text to copy into the string, or 'Nothing' to start with an empty string -} -> m GLib.String.String {- ^ __Returns:__ the new 'GI.GLib.Structs.String.String' -} stringNew init = liftIO $ do maybeInit <- case init of Nothing -> return nullPtr Just jInit -> do jInit' <- textToCString jInit return jInit' result <- g_string_new maybeInit checkUnexpectedReturnNULL "stringNew" result result' <- (wrapBoxed GLib.String.String) result freeMem maybeInit return result' -- function g_strfreev -- Args : [Arg {argCName = "str_array", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a %NULL-terminated array of strings to free", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_strfreev" g_strfreev :: CString -> -- str_array : TBasicType TUTF8 IO () {- | Frees a 'Nothing'-terminated array of strings, as well as each string it contains. If /@strArray@/ is 'Nothing', this function simply returns. -} strfreev :: (B.CallStack.HasCallStack, MonadIO m) => Maybe (T.Text) {- ^ /@strArray@/: a 'Nothing'-terminated array of strings to free -} -> m () strfreev strArray = liftIO $ do maybeStrArray <- case strArray of Nothing -> return nullPtr Just jStrArray -> do jStrArray' <- textToCString jStrArray return jStrArray' g_strfreev maybeStrArray freeMem maybeStrArray return () -- function g_strescape -- Args : [Arg {argCName = "source", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a string to escape", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "exceptions", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a string of characters not to escape in @source", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_strescape" g_strescape :: CString -> -- source : TBasicType TUTF8 CString -> -- exceptions : TBasicType TUTF8 IO CString {- | Escapes the special characters \'\\b\', \'\\f\', \'\\n\', \'\\r\', \'\\t\', \'\\v\', \'\\\' and \'\"\' in the string /@source@/ by inserting a \'\\\' before them. Additionally all characters in the range 0x01-0x1F (everything below SPACE) and in the range 0x7F-0xFF (all non-ASCII chars) are replaced with a \'\\\' followed by their octal representation. Characters supplied in /@exceptions@/ are not escaped. 'GI.GLib.Functions.strcompress' does the reverse conversion. -} strescape :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@source@/: a string to escape -} -> Maybe (T.Text) {- ^ /@exceptions@/: a string of characters not to escape in /@source@/ -} -> m T.Text {- ^ __Returns:__ a newly-allocated copy of /@source@/ with certain characters escaped. See above. -} strescape source exceptions = liftIO $ do source' <- textToCString source maybeExceptions <- case exceptions of Nothing -> return nullPtr Just jExceptions -> do jExceptions' <- textToCString jExceptions return jExceptions' result <- g_strescape source' maybeExceptions checkUnexpectedReturnNULL "strescape" result result' <- cstringToText result freeMem result freeMem source' freeMem maybeExceptions return result' -- function g_strerror -- Args : [Arg {argCName = "errnum", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the system error number. See the standard C %errno\n documentation", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_strerror" g_strerror :: Int32 -> -- errnum : TBasicType TInt IO CString {- | Returns a string corresponding to the given error code, e.g. \"no such process\". Unlike @/strerror()/@, this always returns a string in UTF-8 encoding, and the pointer is guaranteed to remain valid for the lifetime of the process. Note that the string may be translated according to the current locale. The value of @/errno/@ will not be changed by this function. However, it may be changed by intermediate function calls, so you should save its value as soon as the call returns: > > int saved_errno; > > ret = read (blah); > saved_errno = errno; > > g_strerror (saved_errno); -} strerror :: (B.CallStack.HasCallStack, MonadIO m) => Int32 {- ^ /@errnum@/: the system error number. See the standard C @/errno/@ documentation -} -> m T.Text {- ^ __Returns:__ a UTF-8 string describing the error code. If the error code is unknown, it returns a string like \"unknown error (\<code>)\". -} strerror errnum = liftIO $ do result <- g_strerror errnum checkUnexpectedReturnNULL "strerror" result result' <- cstringToText result return result' -- function g_strdup -- Args : [Arg {argCName = "str", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the string to duplicate", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_strdup" g_strdup :: CString -> -- str : TBasicType TUTF8 IO CString {- | Duplicates a string. If /@str@/ is 'Nothing' it returns 'Nothing'. The returned string should be freed with 'GI.GLib.Functions.free' when no longer needed. -} strdup :: (B.CallStack.HasCallStack, MonadIO m) => Maybe (T.Text) {- ^ /@str@/: the string to duplicate -} -> m T.Text {- ^ __Returns:__ a newly-allocated copy of /@str@/ -} strdup str = liftIO $ do maybeStr <- case str of Nothing -> return nullPtr Just jStr -> do jStr' <- textToCString jStr return jStr' result <- g_strdup maybeStr checkUnexpectedReturnNULL "strdup" result result' <- cstringToText result freeMem result freeMem maybeStr return result' -- function g_strdown -- Args : [Arg {argCName = "string", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the string to convert.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_strdown" g_strdown :: CString -> -- string : TBasicType TUTF8 IO CString {-# DEPRECATED strdown ["(Since version 2.2)","This function is totally broken for the reasons discussed","in the 'GI.GLib.Functions.strncasecmp' docs - use 'GI.GLib.Functions.asciiStrdown' or 'GI.GLib.Functions.utf8Strdown'","instead."] #-} {- | Converts a string to lower case. -} strdown :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@string@/: the string to convert. -} -> m T.Text {- ^ __Returns:__ the string -} strdown string = liftIO $ do string' <- textToCString string result <- g_strdown string' checkUnexpectedReturnNULL "strdown" result result' <- cstringToText result freeMem result freeMem string' return result' -- function g_strdelimit -- Args : [Arg {argCName = "string", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the string to convert", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "delimiters", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a string containing the current delimiters,\n or %NULL to use the standard delimiters defined in #G_STR_DELIMITERS", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "new_delimiter", argType = TBasicType TInt8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the new delimiter character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_strdelimit" g_strdelimit :: CString -> -- string : TBasicType TUTF8 CString -> -- delimiters : TBasicType TUTF8 Int8 -> -- new_delimiter : TBasicType TInt8 IO CString {- | Converts any delimiter characters in /@string@/ to /@newDelimiter@/. Any characters in /@string@/ which are found in /@delimiters@/ are changed to the /@newDelimiter@/ character. Modifies /@string@/ in place, and returns /@string@/ itself, not a copy. The return value is to allow nesting such as === /C code/ > > g_ascii_strup (g_strdelimit (str, "abc", '?')) -} strdelimit :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@string@/: the string to convert -} -> Maybe (T.Text) {- ^ /@delimiters@/: a string containing the current delimiters, or 'Nothing' to use the standard delimiters defined in 'GI.GLib.Constants.STR_DELIMITERS' -} -> Int8 {- ^ /@newDelimiter@/: the new delimiter character -} -> m T.Text {- ^ __Returns:__ /@string@/ -} strdelimit string delimiters newDelimiter = liftIO $ do string' <- textToCString string maybeDelimiters <- case delimiters of Nothing -> return nullPtr Just jDelimiters -> do jDelimiters' <- textToCString jDelimiters return jDelimiters' result <- g_strdelimit string' maybeDelimiters newDelimiter checkUnexpectedReturnNULL "strdelimit" result result' <- cstringToText result freeMem result freeMem string' freeMem maybeDelimiters return result' -- function g_strcompress -- Args : [Arg {argCName = "source", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a string to compress", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_strcompress" g_strcompress :: CString -> -- source : TBasicType TUTF8 IO CString {- | Replaces all escaped characters with their one byte equivalent. This function does the reverse conversion of 'GI.GLib.Functions.strescape'. -} strcompress :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@source@/: a string to compress -} -> m T.Text {- ^ __Returns:__ a newly-allocated copy of /@source@/ with all escaped character compressed -} strcompress source = liftIO $ do source' <- textToCString source result <- g_strcompress source' checkUnexpectedReturnNULL "strcompress" result result' <- cstringToText result freeMem result freeMem source' return result' -- function g_strcmp0 -- Args : [Arg {argCName = "str1", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a C string or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "str2", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "another C string or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TInt) -- throws : False -- Skip return : False foreign import ccall "g_strcmp0" g_strcmp0 :: CString -> -- str1 : TBasicType TUTF8 CString -> -- str2 : TBasicType TUTF8 IO Int32 {- | Compares /@str1@/ and /@str2@/ like @/strcmp()/@. Handles 'Nothing' gracefully by sorting it before non-'Nothing' strings. Comparing two 'Nothing' pointers returns 0. /Since: 2.16/ -} strcmp0 :: (B.CallStack.HasCallStack, MonadIO m) => Maybe (T.Text) {- ^ /@str1@/: a C string or 'Nothing' -} -> Maybe (T.Text) {- ^ /@str2@/: another C string or 'Nothing' -} -> m Int32 {- ^ __Returns:__ an integer less than, equal to, or greater than zero, if /@str1@/ is \<, == or > than /@str2@/. -} strcmp0 str1 str2 = liftIO $ do maybeStr1 <- case str1 of Nothing -> return nullPtr Just jStr1 -> do jStr1' <- textToCString jStr1 return jStr1' maybeStr2 <- case str2 of Nothing -> return nullPtr Just jStr2 -> do jStr2' <- textToCString jStr2 return jStr2' result <- g_strcmp0 maybeStr1 maybeStr2 freeMem maybeStr1 freeMem maybeStr2 return result -- function g_strchug -- Args : [Arg {argCName = "string", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a string to remove the leading whitespace from", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_strchug" g_strchug :: CString -> -- string : TBasicType TUTF8 IO CString {- | Removes leading whitespace from a string, by moving the rest of the characters forward. This function doesn\'t allocate or reallocate any memory; it modifies /@string@/ in place. Therefore, it cannot be used on statically allocated strings. The pointer to /@string@/ is returned to allow the nesting of functions. Also see 'GI.GLib.Functions.strchomp' and @/g_strstrip()/@. -} strchug :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@string@/: a string to remove the leading whitespace from -} -> m T.Text {- ^ __Returns:__ /@string@/ -} strchug string = liftIO $ do string' <- textToCString string result <- g_strchug string' checkUnexpectedReturnNULL "strchug" result result' <- cstringToText result freeMem result freeMem string' return result' -- function g_strchomp -- Args : [Arg {argCName = "string", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a string to remove the trailing whitespace from", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_strchomp" g_strchomp :: CString -> -- string : TBasicType TUTF8 IO CString {- | Removes trailing whitespace from a string. This function doesn\'t allocate or reallocate any memory; it modifies /@string@/ in place. Therefore, it cannot be used on statically allocated strings. The pointer to /@string@/ is returned to allow the nesting of functions. Also see 'GI.GLib.Functions.strchug' and @/g_strstrip()/@. -} strchomp :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@string@/: a string to remove the trailing whitespace from -} -> m T.Text {- ^ __Returns:__ /@string@/ -} strchomp string = liftIO $ do string' <- textToCString string result <- g_strchomp string' checkUnexpectedReturnNULL "strchomp" result result' <- cstringToText result freeMem result freeMem string' return result' -- function g_strcasecmp -- Args : [Arg {argCName = "s1", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "s2", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a string to compare with @s1", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TInt) -- throws : False -- Skip return : False foreign import ccall "g_strcasecmp" g_strcasecmp :: CString -> -- s1 : TBasicType TUTF8 CString -> -- s2 : TBasicType TUTF8 IO Int32 {-# DEPRECATED strcasecmp ["(Since version 2.2)","See 'GI.GLib.Functions.strncasecmp' for a discussion of why this"," function is deprecated and how to replace it."] #-} {- | A case-insensitive string comparison, corresponding to the standard @/strcasecmp()/@ function on platforms which support it. -} strcasecmp :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@s1@/: a string -} -> T.Text {- ^ /@s2@/: a string to compare with /@s1@/ -} -> m Int32 {- ^ __Returns:__ 0 if the strings match, a negative value if /@s1@/ \< /@s2@/, or a positive value if /@s1@/ > /@s2@/. -} strcasecmp s1 s2 = liftIO $ do s1' <- textToCString s1 s2' <- textToCString s2 result <- g_strcasecmp s1' s2' freeMem s1' freeMem s2' return result -- function g_strcanon -- Args : [Arg {argCName = "string", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a nul-terminated array of bytes", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "valid_chars", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "bytes permitted in @string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "substitutor", argType = TBasicType TInt8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "replacement character for disallowed bytes", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_strcanon" g_strcanon :: CString -> -- string : TBasicType TUTF8 CString -> -- valid_chars : TBasicType TUTF8 Int8 -> -- substitutor : TBasicType TInt8 IO CString {- | For each character in /@string@/, if the character is not in /@validChars@/, replaces the character with /@substitutor@/. Modifies /@string@/ in place, and return /@string@/ itself, not a copy. The return value is to allow nesting such as === /C code/ > > g_ascii_strup (g_strcanon (str, "abc", '?')) -} strcanon :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@string@/: a nul-terminated array of bytes -} -> T.Text {- ^ /@validChars@/: bytes permitted in /@string@/ -} -> Int8 {- ^ /@substitutor@/: replacement character for disallowed bytes -} -> m T.Text {- ^ __Returns:__ /@string@/ -} strcanon string validChars substitutor = liftIO $ do string' <- textToCString string validChars' <- textToCString validChars result <- g_strcanon string' validChars' substitutor checkUnexpectedReturnNULL "strcanon" result result' <- cstringToText result freeMem result freeMem string' freeMem validChars' return result' -- function g_str_tokenize_and_fold -- Args : [Arg {argCName = "string", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "translit_locale", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the language code (like 'de' or\n 'en_GB') from which @string originates", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "ascii_alternates", argType = TCArray True (-1) (-1) (TBasicType TUTF8), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a\n return location for ASCII alternates", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}] -- Lengths : [] -- returnType : Just (TCArray True (-1) (-1) (TBasicType TUTF8)) -- throws : False -- Skip return : False foreign import ccall "g_str_tokenize_and_fold" g_str_tokenize_and_fold :: CString -> -- string : TBasicType TUTF8 CString -> -- translit_locale : TBasicType TUTF8 Ptr (Ptr CString) -> -- ascii_alternates : TCArray True (-1) (-1) (TBasicType TUTF8) IO (Ptr CString) {- | Tokenises /@string@/ and performs folding on each token. A token is a non-empty sequence of alphanumeric characters in the source string, separated by non-alphanumeric characters. An \"alphanumeric\" character for this purpose is one that matches 'GI.GLib.Functions.unicharIsalnum' or 'GI.GLib.Functions.unicharIsmark'. Each token is then (Unicode) normalised and case-folded. If /@asciiAlternates@/ is non-'Nothing' and some of the returned tokens contain non-ASCII characters, ASCII alternatives will be generated. The number of ASCII alternatives that are generated and the method for doing so is unspecified, but /@translitLocale@/ (if specified) may improve the transliteration if the language of the source string is known. /Since: 2.40/ -} strTokenizeAndFold :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@string@/: a string -} -> Maybe (T.Text) {- ^ /@translitLocale@/: the language code (like \'de\' or \'en_GB\') from which /@string@/ originates -} -> m (([T.Text], [T.Text])) {- ^ __Returns:__ the folded tokens -} strTokenizeAndFold string translitLocale = liftIO $ do string' <- textToCString string maybeTranslitLocale <- case translitLocale of Nothing -> return nullPtr Just jTranslitLocale -> do jTranslitLocale' <- textToCString jTranslitLocale return jTranslitLocale' asciiAlternates <- allocMem :: IO (Ptr (Ptr CString)) result <- g_str_tokenize_and_fold string' maybeTranslitLocale asciiAlternates checkUnexpectedReturnNULL "strTokenizeAndFold" result result' <- unpackZeroTerminatedUTF8CArray result mapZeroTerminatedCArray freeMem result freeMem result asciiAlternates' <- peek asciiAlternates asciiAlternates'' <- unpackZeroTerminatedUTF8CArray asciiAlternates' mapZeroTerminatedCArray freeMem asciiAlternates' freeMem asciiAlternates' freeMem string' freeMem maybeTranslitLocale freeMem asciiAlternates return (result', asciiAlternates'') -- function g_str_to_ascii -- Args : [Arg {argCName = "str", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a string, in UTF-8", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "from_locale", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the source locale, if known", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_str_to_ascii" g_str_to_ascii :: CString -> -- str : TBasicType TUTF8 CString -> -- from_locale : TBasicType TUTF8 IO CString {- | Transliterate /@str@/ to plain ASCII. For best results, /@str@/ should be in composed normalised form. This function performs a reasonably good set of character replacements. The particular set of replacements that is done may change by version or even by runtime environment. If the source language of /@str@/ is known, it can used to improve the accuracy of the translation by passing it as /@fromLocale@/. It should be a valid POSIX locale string (of the form @language[_territory][.codeset][\@modifier]@). If /@fromLocale@/ is 'Nothing' then the current locale is used. If you want to do translation for no specific locale, and you want it to be done independently of the currently locale, specify @\"C\"@ for /@fromLocale@/. /Since: 2.40/ -} strToAscii :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@str@/: a string, in UTF-8 -} -> Maybe (T.Text) {- ^ /@fromLocale@/: the source locale, if known -} -> m T.Text {- ^ __Returns:__ a string in plain ASCII -} strToAscii str fromLocale = liftIO $ do str' <- textToCString str maybeFromLocale <- case fromLocale of Nothing -> return nullPtr Just jFromLocale -> do jFromLocale' <- textToCString jFromLocale return jFromLocale' result <- g_str_to_ascii str' maybeFromLocale checkUnexpectedReturnNULL "strToAscii" result result' <- cstringToText result freeMem result freeMem str' freeMem maybeFromLocale return result' -- function g_str_match_string -- Args : [Arg {argCName = "search_term", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the search term from the user", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "potential_hit", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the text that may be a hit", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "accept_alternates", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "%TRUE to accept ASCII alternates", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "g_str_match_string" g_str_match_string :: CString -> -- search_term : TBasicType TUTF8 CString -> -- potential_hit : TBasicType TUTF8 CInt -> -- accept_alternates : TBasicType TBoolean IO CInt {- | Checks if a search conducted for /@searchTerm@/ should match /@potentialHit@/. This function calls 'GI.GLib.Functions.strTokenizeAndFold' on both /@searchTerm@/ and /@potentialHit@/. ASCII alternates are never taken for /@searchTerm@/ but will be taken for /@potentialHit@/ according to the value of /@acceptAlternates@/. A hit occurs when each folded token in /@searchTerm@/ is a prefix of a folded token from /@potentialHit@/. Depending on how you\'re performing the search, it will typically be faster to call 'GI.GLib.Functions.strTokenizeAndFold' on each string in your corpus and build an index on the returned folded tokens, then call 'GI.GLib.Functions.strTokenizeAndFold' on the search term and perform lookups into that index. As some examples, searching for ‘fred’ would match the potential hit ‘Smith, Fred’ and also ‘Frédéric’. Searching for ‘Fréd’ would match ‘Frédéric’ but not ‘Frederic’ (due to the one-directional nature of accent matching). Searching ‘fo’ would match ‘Foo’ and ‘Bar Foo Baz’, but not ‘SFO’ (because no word has ‘fo’ as a prefix). /Since: 2.40/ -} strMatchString :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@searchTerm@/: the search term from the user -} -> T.Text {- ^ /@potentialHit@/: the text that may be a hit -} -> Bool {- ^ /@acceptAlternates@/: 'True' to accept ASCII alternates -} -> m Bool {- ^ __Returns:__ 'True' if /@potentialHit@/ is a hit -} strMatchString searchTerm potentialHit acceptAlternates = liftIO $ do searchTerm' <- textToCString searchTerm potentialHit' <- textToCString potentialHit let acceptAlternates' = (fromIntegral . fromEnum) acceptAlternates result <- g_str_match_string searchTerm' potentialHit' acceptAlternates' let result' = (/= 0) result freeMem searchTerm' freeMem potentialHit' return result' -- function g_str_is_ascii -- Args : [Arg {argCName = "str", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "g_str_is_ascii" g_str_is_ascii :: CString -> -- str : TBasicType TUTF8 IO CInt {- | Determines if a string is pure ASCII. A string is pure ASCII if it contains no bytes with the high bit set. /Since: 2.40/ -} strIsAscii :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@str@/: a string -} -> m Bool {- ^ __Returns:__ 'True' if /@str@/ is ASCII -} strIsAscii str = liftIO $ do str' <- textToCString str result <- g_str_is_ascii str' let result' = (/= 0) result freeMem str' return result' -- function g_str_hash -- Args : [Arg {argCName = "v", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a string key", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUInt) -- throws : False -- Skip return : False foreign import ccall "g_str_hash" g_str_hash :: Ptr () -> -- v : TBasicType TPtr IO Word32 {- | Converts a string to a hash value. This function implements the widely used \"djb\" hash apparently posted by Daniel Bernstein to comp.lang.c some time ago. The 32 bit unsigned hash value starts at 5381 and for each byte \'c\' in the string, is updated: @hash = hash * 33 + c@. This function uses the signed value of each byte. It can be passed to @/g_hash_table_new()/@ as the /@hashFunc@/ parameter, when using non-'Nothing' strings as keys in a 'GI.GLib.Structs.HashTable.HashTable'. Note that this function may not be a perfect fit for all use cases. For example, it produces some hash collisions with strings as short as 2. -} strHash :: (B.CallStack.HasCallStack, MonadIO m) => Ptr () {- ^ /@v@/: a string key -} -> m Word32 {- ^ __Returns:__ a hash value corresponding to the key -} strHash v = liftIO $ do result <- g_str_hash v return result -- function g_str_has_suffix -- Args : [Arg {argCName = "str", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a nul-terminated string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "suffix", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the nul-terminated suffix to look for", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "g_str_has_suffix" g_str_has_suffix :: CString -> -- str : TBasicType TUTF8 CString -> -- suffix : TBasicType TUTF8 IO CInt {- | Looks whether the string /@str@/ ends with /@suffix@/. /Since: 2.2/ -} strHasSuffix :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@str@/: a nul-terminated string -} -> T.Text {- ^ /@suffix@/: the nul-terminated suffix to look for -} -> m Bool {- ^ __Returns:__ 'True' if /@str@/ end with /@suffix@/, 'False' otherwise. -} strHasSuffix str suffix = liftIO $ do str' <- textToCString str suffix' <- textToCString suffix result <- g_str_has_suffix str' suffix' let result' = (/= 0) result freeMem str' freeMem suffix' return result' -- function g_str_has_prefix -- Args : [Arg {argCName = "str", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a nul-terminated string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "prefix", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the nul-terminated prefix to look for", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "g_str_has_prefix" g_str_has_prefix :: CString -> -- str : TBasicType TUTF8 CString -> -- prefix : TBasicType TUTF8 IO CInt {- | Looks whether the string /@str@/ begins with /@prefix@/. /Since: 2.2/ -} strHasPrefix :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@str@/: a nul-terminated string -} -> T.Text {- ^ /@prefix@/: the nul-terminated prefix to look for -} -> m Bool {- ^ __Returns:__ 'True' if /@str@/ begins with /@prefix@/, 'False' otherwise. -} strHasPrefix str prefix = liftIO $ do str' <- textToCString str prefix' <- textToCString prefix result <- g_str_has_prefix str' prefix' let result' = (/= 0) result freeMem str' freeMem prefix' return result' -- function g_str_equal -- Args : [Arg {argCName = "v1", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a key", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "v2", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a key to compare with @v1", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "g_str_equal" g_str_equal :: Ptr () -> -- v1 : TBasicType TPtr Ptr () -> -- v2 : TBasicType TPtr IO CInt {- | Compares two strings for byte-by-byte equality and returns 'True' if they are equal. It can be passed to @/g_hash_table_new()/@ as the /@keyEqualFunc@/ parameter, when using non-'Nothing' strings as keys in a 'GI.GLib.Structs.HashTable.HashTable'. This function is typically used for hash table comparisons, but can be used for general purpose comparisons of non-'Nothing' strings. For a 'Nothing'-safe string comparison function, see 'GI.GLib.Functions.strcmp0'. -} strEqual :: (B.CallStack.HasCallStack, MonadIO m) => Ptr () {- ^ /@v1@/: a key -} -> Ptr () {- ^ /@v2@/: a key to compare with /@v1@/ -} -> m Bool {- ^ __Returns:__ 'True' if the two keys match -} strEqual v1 v2 = liftIO $ do result <- g_str_equal v1 v2 let result' = (/= 0) result return result' -- function g_stpcpy -- Args : [Arg {argCName = "dest", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "destination buffer.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "src", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "source string.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_stpcpy" g_stpcpy :: CString -> -- dest : TBasicType TUTF8 CString -> -- src : TBasicType TUTF8 IO CString {- | Copies a nul-terminated string into the dest buffer, include the trailing nul, and return a pointer to the trailing nul byte. This is useful for concatenating multiple strings together without having to repeatedly scan for the end. -} stpcpy :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@dest@/: destination buffer. -} -> T.Text {- ^ /@src@/: source string. -} -> m T.Text {- ^ __Returns:__ a pointer to trailing nul byte. -} stpcpy dest src = liftIO $ do dest' <- textToCString dest src' <- textToCString src result <- g_stpcpy dest' src' checkUnexpectedReturnNULL "stpcpy" result result' <- cstringToText result freeMem result freeMem dest' freeMem src' return result' -- function g_spawn_sync -- Args : [Arg {argCName = "working_directory", argType = TBasicType TFileName, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "child's current working\n directory, or %NULL to inherit parent's", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "argv", argType = TCArray True (-1) (-1) (TBasicType TFileName), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "\n child's argument vector", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "envp", argType = TCArray True (-1) (-1) (TBasicType TFileName), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "\n child's environment, or %NULL to inherit parent's", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface (Name {namespace = "GLib", name = "SpawnFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "flags from #GSpawnFlags", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "child_setup", argType = TInterface (Name {namespace = "GLib", name = "SpawnChildSetupFunc"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "function to run in the child just before exec()", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = 5, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user data for @child_setup", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "standard_output", argType = TCArray True (-1) (-1) (TBasicType TUInt8), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "return location for child output, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "standard_error", argType = TCArray True (-1) (-1) (TBasicType TUInt8), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "return location for child error messages, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "exit_status", argType = TBasicType TInt, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "return location for child exit status, as returned by waitpid(), or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : True -- Skip return : False foreign import ccall "g_spawn_sync" g_spawn_sync :: CString -> -- working_directory : TBasicType TFileName Ptr CString -> -- argv : TCArray True (-1) (-1) (TBasicType TFileName) Ptr CString -> -- envp : TCArray True (-1) (-1) (TBasicType TFileName) CUInt -> -- flags : TInterface (Name {namespace = "GLib", name = "SpawnFlags"}) FunPtr GLib.Callbacks.C_SpawnChildSetupFunc -> -- child_setup : TInterface (Name {namespace = "GLib", name = "SpawnChildSetupFunc"}) Ptr () -> -- user_data : TBasicType TPtr Ptr (Ptr Word8) -> -- standard_output : TCArray True (-1) (-1) (TBasicType TUInt8) Ptr (Ptr Word8) -> -- standard_error : TCArray True (-1) (-1) (TBasicType TUInt8) Ptr Int32 -> -- exit_status : TBasicType TInt Ptr (Ptr GError) -> -- error IO CInt {- | Executes a child synchronously (waits for the child to exit before returning). All output from the child is stored in /@standardOutput@/ and /@standardError@/, if those parameters are non-'Nothing'. Note that you must set the 'GI.GLib.Flags.SpawnFlagsStdoutToDevNull' and 'GI.GLib.Flags.SpawnFlagsStderrToDevNull' flags when passing 'Nothing' for /@standardOutput@/ and /@standardError@/. If /@exitStatus@/ is non-'Nothing', the platform-specific exit status of the child is stored there; see the documentation of 'GI.GLib.Functions.spawnCheckExitStatus' for how to use and interpret this. Note that it is invalid to pass 'GI.GLib.Flags.SpawnFlagsDoNotReapChild' in /@flags@/, and on POSIX platforms, the same restrictions as for 'GI.GLib.Functions.childWatchSourceNew' apply. If an error occurs, no data is returned in /@standardOutput@/, /@standardError@/, or /@exitStatus@/. This function calls 'GI.GLib.Functions.spawnAsyncWithPipes' internally; see that function for full details on the other parameters and details on how these functions work on Windows. -} spawnSync :: (B.CallStack.HasCallStack, MonadIO m) => Maybe ([Char]) {- ^ /@workingDirectory@/: child\'s current working directory, or 'Nothing' to inherit parent\'s -} -> [[Char]] {- ^ /@argv@/: child\'s argument vector -} -> Maybe ([[Char]]) {- ^ /@envp@/: child\'s environment, or 'Nothing' to inherit parent\'s -} -> [GLib.Flags.SpawnFlags] {- ^ /@flags@/: flags from 'GI.GLib.Flags.SpawnFlags' -} -> Maybe (GLib.Callbacks.SpawnChildSetupFunc) {- ^ /@childSetup@/: function to run in the child just before @/exec()/@ -} -> m ((ByteString, ByteString, Int32)) {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -} spawnSync workingDirectory argv envp flags childSetup = liftIO $ do maybeWorkingDirectory <- case workingDirectory of Nothing -> return nullPtr Just jWorkingDirectory -> do jWorkingDirectory' <- stringToCString jWorkingDirectory return jWorkingDirectory' argv' <- packZeroTerminatedFileNameArray argv maybeEnvp <- case envp of Nothing -> return nullPtr Just jEnvp -> do jEnvp' <- packZeroTerminatedFileNameArray jEnvp return jEnvp' let flags' = gflagsToWord flags maybeChildSetup <- case childSetup of Nothing -> return (castPtrToFunPtr nullPtr) Just jChildSetup -> do ptrchildSetup <- callocMem :: IO (Ptr (FunPtr GLib.Callbacks.C_SpawnChildSetupFunc)) jChildSetup' <- GLib.Callbacks.mk_SpawnChildSetupFunc (GLib.Callbacks.wrap_SpawnChildSetupFunc (Just ptrchildSetup) (GLib.Callbacks.drop_closures_SpawnChildSetupFunc jChildSetup)) poke ptrchildSetup jChildSetup' return jChildSetup' standardOutput <- allocMem :: IO (Ptr (Ptr Word8)) standardError <- allocMem :: IO (Ptr (Ptr Word8)) exitStatus <- allocMem :: IO (Ptr Int32) let userData = nullPtr onException (do _ <- propagateGError $ g_spawn_sync maybeWorkingDirectory argv' maybeEnvp flags' maybeChildSetup userData standardOutput standardError exitStatus standardOutput' <- peek standardOutput standardOutput'' <- unpackZeroTerminatedByteString standardOutput' freeMem standardOutput' standardError' <- peek standardError standardError'' <- unpackZeroTerminatedByteString standardError' freeMem standardError' exitStatus' <- peek exitStatus freeMem maybeWorkingDirectory mapZeroTerminatedCArray freeMem argv' freeMem argv' mapZeroTerminatedCArray freeMem maybeEnvp freeMem maybeEnvp freeMem standardOutput freeMem standardError freeMem exitStatus return (standardOutput'', standardError'', exitStatus') ) (do freeMem maybeWorkingDirectory mapZeroTerminatedCArray freeMem argv' freeMem argv' mapZeroTerminatedCArray freeMem maybeEnvp freeMem maybeEnvp freeMem standardOutput freeMem standardError freeMem exitStatus ) -- function g_spawn_exit_error_quark -- Args : [] -- Lengths : [] -- returnType : Just (TBasicType TUInt32) -- throws : False -- Skip return : False foreign import ccall "g_spawn_exit_error_quark" g_spawn_exit_error_quark :: IO Word32 {- | /No description available in the introspection data./ -} spawnExitErrorQuark :: (B.CallStack.HasCallStack, MonadIO m) => m Word32 spawnExitErrorQuark = liftIO $ do result <- g_spawn_exit_error_quark return result -- function g_spawn_error_quark -- Args : [] -- Lengths : [] -- returnType : Just (TBasicType TUInt32) -- throws : False -- Skip return : False foreign import ccall "g_spawn_error_quark" g_spawn_error_quark :: IO Word32 {- | /No description available in the introspection data./ -} spawnErrorQuark :: (B.CallStack.HasCallStack, MonadIO m) => m Word32 spawnErrorQuark = liftIO $ do result <- g_spawn_error_quark return result -- function g_spawn_command_line_sync -- Args : [Arg {argCName = "command_line", argType = TBasicType TFileName, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a command line", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "standard_output", argType = TCArray True (-1) (-1) (TBasicType TUInt8), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "return location for child output", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "standard_error", argType = TCArray True (-1) (-1) (TBasicType TUInt8), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "return location for child errors", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "exit_status", argType = TBasicType TInt, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "return location for child exit status, as returned by waitpid()", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : True -- Skip return : False foreign import ccall "g_spawn_command_line_sync" g_spawn_command_line_sync :: CString -> -- command_line : TBasicType TFileName Ptr (Ptr Word8) -> -- standard_output : TCArray True (-1) (-1) (TBasicType TUInt8) Ptr (Ptr Word8) -> -- standard_error : TCArray True (-1) (-1) (TBasicType TUInt8) Ptr Int32 -> -- exit_status : TBasicType TInt Ptr (Ptr GError) -> -- error IO CInt {- | A simple version of 'GI.GLib.Functions.spawnSync' with little-used parameters removed, taking a command line instead of an argument vector. See 'GI.GLib.Functions.spawnSync' for full details. /@commandLine@/ will be parsed by 'GI.GLib.Functions.shellParseArgv'. Unlike 'GI.GLib.Functions.spawnSync', the 'GI.GLib.Flags.SpawnFlagsSearchPath' flag is enabled. Note that 'GI.GLib.Flags.SpawnFlagsSearchPath' can have security implications, so consider using 'GI.GLib.Functions.spawnSync' directly if appropriate. Possible errors are those from 'GI.GLib.Functions.spawnSync' and those from 'GI.GLib.Functions.shellParseArgv'. If /@exitStatus@/ is non-'Nothing', the platform-specific exit status of the child is stored there; see the documentation of 'GI.GLib.Functions.spawnCheckExitStatus' for how to use and interpret this. On Windows, please note the implications of 'GI.GLib.Functions.shellParseArgv' parsing /@commandLine@/. Parsing is done according to Unix shell rules, not Windows command interpreter rules. Space is a separator, and backslashes are special. Thus you cannot simply pass a /@commandLine@/ containing canonical Windows paths, like \"c:\\program files\\app\\app.exe\", as the backslashes will be eaten, and the space will act as a separator. You need to enclose such paths with single quotes, like \"\'c:\\program files\\app\\app.exe\' \'e:\\folder\\argument.txt\'\". -} spawnCommandLineSync :: (B.CallStack.HasCallStack, MonadIO m) => [Char] {- ^ /@commandLine@/: a command line -} -> m ((ByteString, ByteString, Int32)) {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -} spawnCommandLineSync commandLine = liftIO $ do commandLine' <- stringToCString commandLine standardOutput <- allocMem :: IO (Ptr (Ptr Word8)) standardError <- allocMem :: IO (Ptr (Ptr Word8)) exitStatus <- allocMem :: IO (Ptr Int32) onException (do _ <- propagateGError $ g_spawn_command_line_sync commandLine' standardOutput standardError exitStatus standardOutput' <- peek standardOutput standardOutput'' <- unpackZeroTerminatedByteString standardOutput' freeMem standardOutput' standardError' <- peek standardError standardError'' <- unpackZeroTerminatedByteString standardError' freeMem standardError' exitStatus' <- peek exitStatus freeMem commandLine' freeMem standardOutput freeMem standardError freeMem exitStatus return (standardOutput'', standardError'', exitStatus') ) (do freeMem commandLine' freeMem standardOutput freeMem standardError freeMem exitStatus ) -- function g_spawn_command_line_async -- Args : [Arg {argCName = "command_line", argType = TBasicType TFileName, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a command line", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : True -- Skip return : False foreign import ccall "g_spawn_command_line_async" g_spawn_command_line_async :: CString -> -- command_line : TBasicType TFileName Ptr (Ptr GError) -> -- error IO CInt {- | A simple version of 'GI.GLib.Functions.spawnAsync' that parses a command line with 'GI.GLib.Functions.shellParseArgv' and passes it to 'GI.GLib.Functions.spawnAsync'. Runs a command line in the background. Unlike 'GI.GLib.Functions.spawnAsync', the 'GI.GLib.Flags.SpawnFlagsSearchPath' flag is enabled, other flags are not. Note that 'GI.GLib.Flags.SpawnFlagsSearchPath' can have security implications, so consider using 'GI.GLib.Functions.spawnAsync' directly if appropriate. Possible errors are those from 'GI.GLib.Functions.shellParseArgv' and 'GI.GLib.Functions.spawnAsync'. The same concerns on Windows apply as for 'GI.GLib.Functions.spawnCommandLineSync'. -} spawnCommandLineAsync :: (B.CallStack.HasCallStack, MonadIO m) => [Char] {- ^ /@commandLine@/: a command line -} -> m () {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -} spawnCommandLineAsync commandLine = liftIO $ do commandLine' <- stringToCString commandLine onException (do _ <- propagateGError $ g_spawn_command_line_async commandLine' freeMem commandLine' return () ) (do freeMem commandLine' ) -- function g_spawn_close_pid -- Args : [Arg {argCName = "pid", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The process reference to close", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_spawn_close_pid" g_spawn_close_pid :: Int32 -> -- pid : TBasicType TInt IO () {- | On some platforms, notably Windows, the @/GPid/@ type represents a resource which must be closed to prevent resource leaking. 'GI.GLib.Functions.spawnClosePid' is provided for this purpose. It should be used on all platforms, even though it doesn\'t do anything under UNIX. -} spawnClosePid :: (B.CallStack.HasCallStack, MonadIO m) => Int32 {- ^ /@pid@/: The process reference to close -} -> m () spawnClosePid pid = liftIO $ do g_spawn_close_pid pid return () -- function g_spawn_check_exit_status -- Args : [Arg {argCName = "exit_status", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "An exit code as returned from g_spawn_sync()", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : True -- Skip return : False foreign import ccall "g_spawn_check_exit_status" g_spawn_check_exit_status :: Int32 -> -- exit_status : TBasicType TInt Ptr (Ptr GError) -> -- error IO CInt {- | Set /@error@/ if /@exitStatus@/ indicates the child exited abnormally (e.g. with a nonzero exit code, or via a fatal signal). The 'GI.GLib.Functions.spawnSync' and @/g_child_watch_add()/@ family of APIs return an exit status for subprocesses encoded in a platform-specific way. On Unix, this is guaranteed to be in the same format @/waitpid()/@ returns, and on Windows it is guaranteed to be the result of @/GetExitCodeProcess()/@. Prior to the introduction of this function in GLib 2.34, interpreting /@exitStatus@/ required use of platform-specific APIs, which is problematic for software using GLib as a cross-platform layer. Additionally, many programs simply want to determine whether or not the child exited successfully, and either propagate a 'GError' or print a message to standard error. In that common case, this function can be used. Note that the error message in /@error@/ will contain human-readable information about the exit status. The /@domain@/ and /@code@/ of /@error@/ have special semantics in the case where the process has an \"exit code\", as opposed to being killed by a signal. On Unix, this happens if @/WIFEXITED()/@ would be true of /@exitStatus@/. On Windows, it is always the case. The special semantics are that the actual exit code will be the code set in /@error@/, and the domain will be @/G_SPAWN_EXIT_ERROR/@. This allows you to differentiate between different exit codes. If the process was terminated by some means other than an exit status, the domain will be @/G_SPAWN_ERROR/@, and the code will be 'GI.GLib.Enums.SpawnErrorFailed'. This function just offers convenience; you can of course also check the available platform via a macro such as @/G_OS_UNIX/@, and use @/WIFEXITED()/@ and @/WEXITSTATUS()/@ on /@exitStatus@/ directly. Do not attempt to scan or parse the error message string; it may be translated and\/or change in future versions of GLib. /Since: 2.34/ -} spawnCheckExitStatus :: (B.CallStack.HasCallStack, MonadIO m) => Int32 {- ^ /@exitStatus@/: An exit code as returned from 'GI.GLib.Functions.spawnSync' -} -> m () {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -} spawnCheckExitStatus exitStatus = liftIO $ do onException (do _ <- propagateGError $ g_spawn_check_exit_status exitStatus return () ) (do return () ) -- function g_spawn_async_with_pipes -- Args : [Arg {argCName = "working_directory", argType = TBasicType TFileName, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "child's current working\n directory, or %NULL to inherit parent's, in the GLib file name encoding", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "argv", argType = TCArray True (-1) (-1) (TBasicType TFileName), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "child's argument\n vector, in the GLib file name encoding", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "envp", argType = TCArray True (-1) (-1) (TBasicType TFileName), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "\n child's environment, or %NULL to inherit parent's, in the GLib file\n name encoding", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface (Name {namespace = "GLib", name = "SpawnFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "flags from #GSpawnFlags", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "child_setup", argType = TInterface (Name {namespace = "GLib", name = "SpawnChildSetupFunc"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "function to run in the child just before exec()", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = 5, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user data for @child_setup", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "child_pid", argType = TBasicType TInt, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "return location for child process ID, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "standard_input", argType = TBasicType TInt, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "return location for file descriptor to write to child's stdin, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "standard_output", argType = TBasicType TInt, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "return location for file descriptor to read child's stdout, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "standard_error", argType = TBasicType TInt, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "return location for file descriptor to read child's stderr, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : True -- Skip return : False foreign import ccall "g_spawn_async_with_pipes" g_spawn_async_with_pipes :: CString -> -- working_directory : TBasicType TFileName Ptr CString -> -- argv : TCArray True (-1) (-1) (TBasicType TFileName) Ptr CString -> -- envp : TCArray True (-1) (-1) (TBasicType TFileName) CUInt -> -- flags : TInterface (Name {namespace = "GLib", name = "SpawnFlags"}) FunPtr GLib.Callbacks.C_SpawnChildSetupFunc -> -- child_setup : TInterface (Name {namespace = "GLib", name = "SpawnChildSetupFunc"}) Ptr () -> -- user_data : TBasicType TPtr Ptr Int32 -> -- child_pid : TBasicType TInt Ptr Int32 -> -- standard_input : TBasicType TInt Ptr Int32 -> -- standard_output : TBasicType TInt Ptr Int32 -> -- standard_error : TBasicType TInt Ptr (Ptr GError) -> -- error IO CInt {- | Executes a child program asynchronously (your program will not block waiting for the child to exit). The child program is specified by the only argument that must be provided, /@argv@/. /@argv@/ should be a 'Nothing'-terminated array of strings, to be passed as the argument vector for the child. The first string in /@argv@/ is of course the name of the program to execute. By default, the name of the program must be a full path. If /@flags@/ contains the 'GI.GLib.Flags.SpawnFlagsSearchPath' flag, the @PATH@ environment variable is used to search for the executable. If /@flags@/ contains the 'GI.GLib.Flags.SpawnFlagsSearchPathFromEnvp' flag, the @PATH@ variable from /@envp@/ is used to search for the executable. If both the 'GI.GLib.Flags.SpawnFlagsSearchPath' and 'GI.GLib.Flags.SpawnFlagsSearchPathFromEnvp' flags are set, the @PATH@ variable from /@envp@/ takes precedence over the environment variable. If the program name is not a full path and 'GI.GLib.Flags.SpawnFlagsSearchPath' flag is not used, then the program will be run from the current directory (or /@workingDirectory@/, if specified); this might be unexpected or even dangerous in some cases when the current directory is world-writable. On Windows, note that all the string or string vector arguments to this function and the other g_spawn*() functions are in UTF-8, the GLib file name encoding. Unicode characters that are not part of the system codepage passed in these arguments will be correctly available in the spawned program only if it uses wide character API to retrieve its command line. For C programs built with Microsoft\'s tools it is enough to make the program have a @/wmain()/@ instead of @/main()/@. @/wmain()/@ has a wide character argument vector as parameter. At least currently, mingw doesn\'t support @/wmain()/@, so if you use mingw to develop the spawned program, it should call @/g_win32_get_command_line()/@ to get arguments in UTF-8. On Windows the low-level child process creation API @/CreateProcess()/@ doesn\'t use argument vectors, but a command line. The C runtime library\'s spawn*() family of functions (which 'GI.GLib.Functions.spawnAsyncWithPipes' eventually calls) paste the argument vector elements together into a command line, and the C runtime startup code does a corresponding reconstruction of an argument vector from the command line, to be passed to @/main()/@. Complications arise when you have argument vector elements that contain spaces or double quotes. The @spawn*()@ functions don\'t do any quoting or escaping, but on the other hand the startup code does do unquoting and unescaping in order to enable receiving arguments with embedded spaces or double quotes. To work around this asymmetry, 'GI.GLib.Functions.spawnAsyncWithPipes' will do quoting and escaping on argument vector elements that need it before calling the C runtime @/spawn()/@ function. The returned /@childPid@/ on Windows is a handle to the child process, not its identifier. Process handles and process identifiers are different concepts on Windows. /@envp@/ is a 'Nothing'-terminated array of strings, where each string has the form @KEY=VALUE@. This will become the child\'s environment. If /@envp@/ is 'Nothing', the child inherits its parent\'s environment. /@flags@/ should be the bitwise OR of any flags you want to affect the function\'s behaviour. The 'GI.GLib.Flags.SpawnFlagsDoNotReapChild' means that the child will not automatically be reaped; you must use a child watch (@/g_child_watch_add()/@) to be notified about the death of the child process, otherwise it will stay around as a zombie process until this process exits. Eventually you must call 'GI.GLib.Functions.spawnClosePid' on the /@childPid@/, in order to free resources which may be associated with the child process. (On Unix, using a child watch is equivalent to calling @/waitpid()/@ or handling the @/SIGCHLD/@ signal manually. On Windows, calling 'GI.GLib.Functions.spawnClosePid' is equivalent to calling @/CloseHandle()/@ on the process handle returned in /@childPid@/). See @/g_child_watch_add()/@. Open UNIX file descriptors marked as @FD_CLOEXEC@ will be automatically closed in the child process. 'GI.GLib.Flags.SpawnFlagsLeaveDescriptorsOpen' means that other open file descriptors will be inherited by the child; otherwise all descriptors except stdin\/stdout\/stderr will be closed before calling @/exec()/@ in the child. 'GI.GLib.Flags.SpawnFlagsSearchPath' means that /@argv@/[0] need not be an absolute path, it will be looked for in the @PATH@ environment variable. 'GI.GLib.Flags.SpawnFlagsSearchPathFromEnvp' means need not be an absolute path, it will be looked for in the @PATH@ variable from /@envp@/. If both 'GI.GLib.Flags.SpawnFlagsSearchPath' and 'GI.GLib.Flags.SpawnFlagsSearchPathFromEnvp' are used, the value from /@envp@/ takes precedence over the environment. 'GI.GLib.Flags.SpawnFlagsStdoutToDevNull' means that the child\'s standard output will be discarded, instead of going to the same location as the parent\'s standard output. If you use this flag, /@standardOutput@/ must be 'Nothing'. 'GI.GLib.Flags.SpawnFlagsStderrToDevNull' means that the child\'s standard error will be discarded, instead of going to the same location as the parent\'s standard error. If you use this flag, /@standardError@/ must be 'Nothing'. 'GI.GLib.Flags.SpawnFlagsChildInheritsStdin' means that the child will inherit the parent\'s standard input (by default, the child\'s standard input is attached to @\/dev\/null@). If you use this flag, /@standardInput@/ must be 'Nothing'. 'GI.GLib.Flags.SpawnFlagsFileAndArgvZero' means that the first element of /@argv@/ is the file to execute, while the remaining elements are the actual argument vector to pass to the file. Normally 'GI.GLib.Functions.spawnAsyncWithPipes' uses /@argv@/[0] as the file to execute, and passes all of /@argv@/ to the child. /@childSetup@/ and /@userData@/ are a function and user data. On POSIX platforms, the function is called in the child after GLib has performed all the setup it plans to perform (including creating pipes, closing file descriptors, etc.) but before calling @/exec()/@. That is, /@childSetup@/ is called just before calling @/exec()/@ in the child. Obviously actions taken in this function will only affect the child, not the parent. On Windows, there is no separate @/fork()/@ and @/exec()/@ functionality. Child processes are created and run with a single API call, @/CreateProcess()/@. There is no sensible thing /@childSetup@/ could be used for on Windows so it is ignored and not called. If non-'Nothing', /@childPid@/ will on Unix be filled with the child\'s process ID. You can use the process ID to send signals to the child, or to use @/g_child_watch_add()/@ (or @/waitpid()/@) if you specified the 'GI.GLib.Flags.SpawnFlagsDoNotReapChild' flag. On Windows, /@childPid@/ will be filled with a handle to the child process only if you specified the 'GI.GLib.Flags.SpawnFlagsDoNotReapChild' flag. You can then access the child process using the Win32 API, for example wait for its termination with the WaitFor*() functions, or examine its exit code with @/GetExitCodeProcess()/@. You should close the handle with @/CloseHandle()/@ or 'GI.GLib.Functions.spawnClosePid' when you no longer need it. If non-'Nothing', the /@standardInput@/, /@standardOutput@/, /@standardError@/ locations will be filled with file descriptors for writing to the child\'s standard input or reading from its standard output or standard error. The caller of 'GI.GLib.Functions.spawnAsyncWithPipes' must close these file descriptors when they are no longer in use. If these parameters are 'Nothing', the corresponding pipe won\'t be created. If /@standardInput@/ is 'Nothing', the child\'s standard input is attached to @\/dev\/null@ unless 'GI.GLib.Flags.SpawnFlagsChildInheritsStdin' is set. If /@standardError@/ is NULL, the child\'s standard error goes to the same location as the parent\'s standard error unless 'GI.GLib.Flags.SpawnFlagsStderrToDevNull' is set. If /@standardOutput@/ is NULL, the child\'s standard output goes to the same location as the parent\'s standard output unless 'GI.GLib.Flags.SpawnFlagsStdoutToDevNull' is set. /@error@/ can be 'Nothing' to ignore errors, or non-'Nothing' to report errors. If an error is set, the function returns 'False'. Errors are reported even if they occur in the child (for example if the executable in /@argv@/[0] is not found). Typically the @message@ field of returned errors should be displayed to users. Possible errors are those from the @/G_SPAWN_ERROR/@ domain. If an error occurs, /@childPid@/, /@standardInput@/, /@standardOutput@/, and /@standardError@/ will not be filled with valid values. If /@childPid@/ is not 'Nothing' and an error does not occur then the returned process reference must be closed using 'GI.GLib.Functions.spawnClosePid'. On modern UNIX platforms, GLib can use an efficient process launching codepath driven internally by @/posix_spawn()/@. This has the advantage of avoiding the fork-time performance costs of cloning the parent process address space, and avoiding associated memory overcommit checks that are not relevant in the context of immediately executing a distinct process. This optimized codepath will be used provided that the following conditions are met: 1. 'GI.GLib.Flags.SpawnFlagsDoNotReapChild' is set 2. 'GI.GLib.Flags.SpawnFlagsLeaveDescriptorsOpen' is set 3. 'GI.GLib.Flags.SpawnFlagsSearchPathFromEnvp' is not set 4. /@workingDirectory@/ is 'Nothing' 5. /@childSetup@/ is 'Nothing' 6. The program is of a recognised binary format, or has a shebang. Otherwise, GLib will have to execute the program through the shell, which is not done using the optimized codepath. If you are writing a GTK+ application, and the program you are spawning is a graphical application too, then to ensure that the spawned program opens its windows on the right screen, you may want to use @/GdkAppLaunchContext/@, @/GAppLaunchContext/@, or set the @/DISPLAY/@ environment variable. -} spawnAsyncWithPipes :: (B.CallStack.HasCallStack, MonadIO m) => Maybe ([Char]) {- ^ /@workingDirectory@/: child\'s current working directory, or 'Nothing' to inherit parent\'s, in the GLib file name encoding -} -> [[Char]] {- ^ /@argv@/: child\'s argument vector, in the GLib file name encoding -} -> Maybe ([[Char]]) {- ^ /@envp@/: child\'s environment, or 'Nothing' to inherit parent\'s, in the GLib file name encoding -} -> [GLib.Flags.SpawnFlags] {- ^ /@flags@/: flags from 'GI.GLib.Flags.SpawnFlags' -} -> Maybe (GLib.Callbacks.SpawnChildSetupFunc) {- ^ /@childSetup@/: function to run in the child just before @/exec()/@ -} -> m ((Int32, Int32, Int32, Int32)) {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -} spawnAsyncWithPipes workingDirectory argv envp flags childSetup = liftIO $ do maybeWorkingDirectory <- case workingDirectory of Nothing -> return nullPtr Just jWorkingDirectory -> do jWorkingDirectory' <- stringToCString jWorkingDirectory return jWorkingDirectory' argv' <- packZeroTerminatedFileNameArray argv maybeEnvp <- case envp of Nothing -> return nullPtr Just jEnvp -> do jEnvp' <- packZeroTerminatedFileNameArray jEnvp return jEnvp' let flags' = gflagsToWord flags maybeChildSetup <- case childSetup of Nothing -> return (castPtrToFunPtr nullPtr) Just jChildSetup -> do ptrchildSetup <- callocMem :: IO (Ptr (FunPtr GLib.Callbacks.C_SpawnChildSetupFunc)) jChildSetup' <- GLib.Callbacks.mk_SpawnChildSetupFunc (GLib.Callbacks.wrap_SpawnChildSetupFunc (Just ptrchildSetup) (GLib.Callbacks.drop_closures_SpawnChildSetupFunc jChildSetup)) poke ptrchildSetup jChildSetup' return jChildSetup' childPid <- allocMem :: IO (Ptr Int32) standardInput <- allocMem :: IO (Ptr Int32) standardOutput <- allocMem :: IO (Ptr Int32) standardError <- allocMem :: IO (Ptr Int32) let userData = nullPtr onException (do _ <- propagateGError $ g_spawn_async_with_pipes maybeWorkingDirectory argv' maybeEnvp flags' maybeChildSetup userData childPid standardInput standardOutput standardError childPid' <- peek childPid standardInput' <- peek standardInput standardOutput' <- peek standardOutput standardError' <- peek standardError freeMem maybeWorkingDirectory mapZeroTerminatedCArray freeMem argv' freeMem argv' mapZeroTerminatedCArray freeMem maybeEnvp freeMem maybeEnvp freeMem childPid freeMem standardInput freeMem standardOutput freeMem standardError return (childPid', standardInput', standardOutput', standardError') ) (do freeMem maybeWorkingDirectory mapZeroTerminatedCArray freeMem argv' freeMem argv' mapZeroTerminatedCArray freeMem maybeEnvp freeMem maybeEnvp freeMem childPid freeMem standardInput freeMem standardOutput freeMem standardError ) -- function g_spawn_async_with_fds -- Args : [Arg {argCName = "working_directory", argType = TBasicType TFileName, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "child's current working directory, or %NULL to inherit parent's, in the GLib file name encoding", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "argv", argType = TCArray True (-1) (-1) (TBasicType TUTF8), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "child's argument vector, in the GLib file name encoding", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "envp", argType = TCArray True (-1) (-1) (TBasicType TUTF8), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "child's environment, or %NULL to inherit parent's, in the GLib file name encoding", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface (Name {namespace = "GLib", name = "SpawnFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "flags from #GSpawnFlags", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "child_setup", argType = TInterface (Name {namespace = "GLib", name = "SpawnChildSetupFunc"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "function to run in the child just before exec()", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = 5, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user data for @child_setup", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "child_pid", argType = TBasicType TInt, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "return location for child process ID, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "stdin_fd", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "file descriptor to use for child's stdin, or -1", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "stdout_fd", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "file descriptor to use for child's stdout, or -1", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "stderr_fd", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "file descriptor to use for child's stderr, or -1", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : True -- Skip return : False foreign import ccall "g_spawn_async_with_fds" g_spawn_async_with_fds :: CString -> -- working_directory : TBasicType TFileName Ptr CString -> -- argv : TCArray True (-1) (-1) (TBasicType TUTF8) Ptr CString -> -- envp : TCArray True (-1) (-1) (TBasicType TUTF8) CUInt -> -- flags : TInterface (Name {namespace = "GLib", name = "SpawnFlags"}) FunPtr GLib.Callbacks.C_SpawnChildSetupFunc -> -- child_setup : TInterface (Name {namespace = "GLib", name = "SpawnChildSetupFunc"}) Ptr () -> -- user_data : TBasicType TPtr Ptr Int32 -> -- child_pid : TBasicType TInt Int32 -> -- stdin_fd : TBasicType TInt Int32 -> -- stdout_fd : TBasicType TInt Int32 -> -- stderr_fd : TBasicType TInt Ptr (Ptr GError) -> -- error IO CInt {- | Identical to 'GI.GLib.Functions.spawnAsyncWithPipes' but instead of creating pipes for the stdin\/stdout\/stderr, you can pass existing file descriptors into this function through the /@stdinFd@/, /@stdoutFd@/ and /@stderrFd@/ parameters. The following /@flags@/ also have their behaviour slightly tweaked as a result: 'GI.GLib.Flags.SpawnFlagsStdoutToDevNull' means that the child\'s standard output will be discarded, instead of going to the same location as the parent\'s standard output. If you use this flag, /@standardOutput@/ must be -1. 'GI.GLib.Flags.SpawnFlagsStderrToDevNull' means that the child\'s standard error will be discarded, instead of going to the same location as the parent\'s standard error. If you use this flag, /@standardError@/ must be -1. 'GI.GLib.Flags.SpawnFlagsChildInheritsStdin' means that the child will inherit the parent\'s standard input (by default, the child\'s standard input is attached to \/dev\/null). If you use this flag, /@standardInput@/ must be -1. It is valid to pass the same fd in multiple parameters (e.g. you can pass a single fd for both stdout and stderr). /Since: 2.58/ -} spawnAsyncWithFds :: (B.CallStack.HasCallStack, MonadIO m) => Maybe ([Char]) {- ^ /@workingDirectory@/: child\'s current working directory, or 'Nothing' to inherit parent\'s, in the GLib file name encoding -} -> [T.Text] {- ^ /@argv@/: child\'s argument vector, in the GLib file name encoding -} -> Maybe ([T.Text]) {- ^ /@envp@/: child\'s environment, or 'Nothing' to inherit parent\'s, in the GLib file name encoding -} -> [GLib.Flags.SpawnFlags] {- ^ /@flags@/: flags from 'GI.GLib.Flags.SpawnFlags' -} -> Maybe (GLib.Callbacks.SpawnChildSetupFunc) {- ^ /@childSetup@/: function to run in the child just before @/exec()/@ -} -> Int32 {- ^ /@stdinFd@/: file descriptor to use for child\'s stdin, or -1 -} -> Int32 {- ^ /@stdoutFd@/: file descriptor to use for child\'s stdout, or -1 -} -> Int32 {- ^ /@stderrFd@/: file descriptor to use for child\'s stderr, or -1 -} -> m (Int32) {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -} spawnAsyncWithFds workingDirectory argv envp flags childSetup stdinFd stdoutFd stderrFd = liftIO $ do maybeWorkingDirectory <- case workingDirectory of Nothing -> return nullPtr Just jWorkingDirectory -> do jWorkingDirectory' <- stringToCString jWorkingDirectory return jWorkingDirectory' argv' <- packZeroTerminatedUTF8CArray argv maybeEnvp <- case envp of Nothing -> return nullPtr Just jEnvp -> do jEnvp' <- packZeroTerminatedUTF8CArray jEnvp return jEnvp' let flags' = gflagsToWord flags maybeChildSetup <- case childSetup of Nothing -> return (castPtrToFunPtr nullPtr) Just jChildSetup -> do ptrchildSetup <- callocMem :: IO (Ptr (FunPtr GLib.Callbacks.C_SpawnChildSetupFunc)) jChildSetup' <- GLib.Callbacks.mk_SpawnChildSetupFunc (GLib.Callbacks.wrap_SpawnChildSetupFunc (Just ptrchildSetup) (GLib.Callbacks.drop_closures_SpawnChildSetupFunc jChildSetup)) poke ptrchildSetup jChildSetup' return jChildSetup' childPid <- allocMem :: IO (Ptr Int32) let userData = nullPtr onException (do _ <- propagateGError $ g_spawn_async_with_fds maybeWorkingDirectory argv' maybeEnvp flags' maybeChildSetup userData childPid stdinFd stdoutFd stderrFd childPid' <- peek childPid freeMem maybeWorkingDirectory mapZeroTerminatedCArray freeMem argv' freeMem argv' mapZeroTerminatedCArray freeMem maybeEnvp freeMem maybeEnvp freeMem childPid return childPid' ) (do freeMem maybeWorkingDirectory mapZeroTerminatedCArray freeMem argv' freeMem argv' mapZeroTerminatedCArray freeMem maybeEnvp freeMem maybeEnvp freeMem childPid ) -- function g_spawn_async -- Args : [Arg {argCName = "working_directory", argType = TBasicType TFileName, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "child's current working\n directory, or %NULL to inherit parent's", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "argv", argType = TCArray True (-1) (-1) (TBasicType TFileName), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "\n child's argument vector", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "envp", argType = TCArray True (-1) (-1) (TBasicType TFileName), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "\n child's environment, or %NULL to inherit parent's", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface (Name {namespace = "GLib", name = "SpawnFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "flags from #GSpawnFlags", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "child_setup", argType = TInterface (Name {namespace = "GLib", name = "SpawnChildSetupFunc"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "function to run in the child just before exec()", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = 5, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user data for @child_setup", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "child_pid", argType = TBasicType TInt, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "return location for child process reference, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : True -- Skip return : False foreign import ccall "g_spawn_async" g_spawn_async :: CString -> -- working_directory : TBasicType TFileName Ptr CString -> -- argv : TCArray True (-1) (-1) (TBasicType TFileName) Ptr CString -> -- envp : TCArray True (-1) (-1) (TBasicType TFileName) CUInt -> -- flags : TInterface (Name {namespace = "GLib", name = "SpawnFlags"}) FunPtr GLib.Callbacks.C_SpawnChildSetupFunc -> -- child_setup : TInterface (Name {namespace = "GLib", name = "SpawnChildSetupFunc"}) Ptr () -> -- user_data : TBasicType TPtr Ptr Int32 -> -- child_pid : TBasicType TInt Ptr (Ptr GError) -> -- error IO CInt {- | See 'GI.GLib.Functions.spawnAsyncWithPipes' for a full description; this function simply calls the 'GI.GLib.Functions.spawnAsyncWithPipes' without any pipes. You should call 'GI.GLib.Functions.spawnClosePid' on the returned child process reference when you don\'t need it any more. If you are writing a GTK+ application, and the program you are spawning is a graphical application too, then to ensure that the spawned program opens its windows on the right screen, you may want to use @/GdkAppLaunchContext/@, @/GAppLaunchContext/@, or set the @/DISPLAY/@ environment variable. Note that the returned /@childPid@/ on Windows is a handle to the child process and not its identifier. Process handles and process identifiers are different concepts on Windows. -} spawnAsync :: (B.CallStack.HasCallStack, MonadIO m) => Maybe ([Char]) {- ^ /@workingDirectory@/: child\'s current working directory, or 'Nothing' to inherit parent\'s -} -> [[Char]] {- ^ /@argv@/: child\'s argument vector -} -> Maybe ([[Char]]) {- ^ /@envp@/: child\'s environment, or 'Nothing' to inherit parent\'s -} -> [GLib.Flags.SpawnFlags] {- ^ /@flags@/: flags from 'GI.GLib.Flags.SpawnFlags' -} -> Maybe (GLib.Callbacks.SpawnChildSetupFunc) {- ^ /@childSetup@/: function to run in the child just before @/exec()/@ -} -> m (Int32) {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -} spawnAsync workingDirectory argv envp flags childSetup = liftIO $ do maybeWorkingDirectory <- case workingDirectory of Nothing -> return nullPtr Just jWorkingDirectory -> do jWorkingDirectory' <- stringToCString jWorkingDirectory return jWorkingDirectory' argv' <- packZeroTerminatedFileNameArray argv maybeEnvp <- case envp of Nothing -> return nullPtr Just jEnvp -> do jEnvp' <- packZeroTerminatedFileNameArray jEnvp return jEnvp' let flags' = gflagsToWord flags maybeChildSetup <- case childSetup of Nothing -> return (castPtrToFunPtr nullPtr) Just jChildSetup -> do ptrchildSetup <- callocMem :: IO (Ptr (FunPtr GLib.Callbacks.C_SpawnChildSetupFunc)) jChildSetup' <- GLib.Callbacks.mk_SpawnChildSetupFunc (GLib.Callbacks.wrap_SpawnChildSetupFunc (Just ptrchildSetup) (GLib.Callbacks.drop_closures_SpawnChildSetupFunc jChildSetup)) poke ptrchildSetup jChildSetup' return jChildSetup' childPid <- allocMem :: IO (Ptr Int32) let userData = nullPtr onException (do _ <- propagateGError $ g_spawn_async maybeWorkingDirectory argv' maybeEnvp flags' maybeChildSetup userData childPid childPid' <- peek childPid freeMem maybeWorkingDirectory mapZeroTerminatedCArray freeMem argv' freeMem argv' mapZeroTerminatedCArray freeMem maybeEnvp freeMem maybeEnvp freeMem childPid return childPid' ) (do freeMem maybeWorkingDirectory mapZeroTerminatedCArray freeMem argv' freeMem argv' mapZeroTerminatedCArray freeMem maybeEnvp freeMem maybeEnvp freeMem childPid ) -- function g_spaced_primes_closest -- Args : [Arg {argCName = "num", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #guint", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUInt) -- throws : False -- Skip return : False foreign import ccall "g_spaced_primes_closest" g_spaced_primes_closest :: Word32 -> -- num : TBasicType TUInt IO Word32 {- | Gets the smallest prime number from a built-in array of primes which is larger than /@num@/. This is used within GLib to calculate the optimum size of a 'GI.GLib.Structs.HashTable.HashTable'. The built-in array of primes ranges from 11 to 13845163 such that each prime is approximately 1.5-2 times the previous prime. -} spacedPrimesClosest :: (B.CallStack.HasCallStack, MonadIO m) => Word32 {- ^ /@num@/: a @/guint/@ -} -> m Word32 {- ^ __Returns:__ the smallest prime number from a built-in array of primes which is larger than /@num@/ -} spacedPrimesClosest num = liftIO $ do result <- g_spaced_primes_closest num return result -- function g_slice_set_config -- Args : [Arg {argCName = "ckey", argType = TInterface (Name {namespace = "GLib", name = "SliceConfig"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "value", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_slice_set_config" g_slice_set_config :: CUInt -> -- ckey : TInterface (Name {namespace = "GLib", name = "SliceConfig"}) Int64 -> -- value : TBasicType TInt64 IO () {- | /No description available in the introspection data./ -} sliceSetConfig :: (B.CallStack.HasCallStack, MonadIO m) => GLib.Enums.SliceConfig -> Int64 -> m () sliceSetConfig ckey value = liftIO $ do let ckey' = (fromIntegral . fromEnum) ckey g_slice_set_config ckey' value return () -- function g_slice_get_config_state -- Args : [Arg {argCName = "ckey", argType = TInterface (Name {namespace = "GLib", name = "SliceConfig"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "address", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "n_values", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TInt64) -- throws : False -- Skip return : False foreign import ccall "g_slice_get_config_state" g_slice_get_config_state :: CUInt -> -- ckey : TInterface (Name {namespace = "GLib", name = "SliceConfig"}) Int64 -> -- address : TBasicType TInt64 Word32 -> -- n_values : TBasicType TUInt IO Int64 {- | /No description available in the introspection data./ -} sliceGetConfigState :: (B.CallStack.HasCallStack, MonadIO m) => GLib.Enums.SliceConfig -> Int64 -> Word32 -> m Int64 sliceGetConfigState ckey address nValues = liftIO $ do let ckey' = (fromIntegral . fromEnum) ckey result <- g_slice_get_config_state ckey' address nValues return result -- function g_slice_get_config -- Args : [Arg {argCName = "ckey", argType = TInterface (Name {namespace = "GLib", name = "SliceConfig"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TInt64) -- throws : False -- Skip return : False foreign import ccall "g_slice_get_config" g_slice_get_config :: CUInt -> -- ckey : TInterface (Name {namespace = "GLib", name = "SliceConfig"}) IO Int64 {- | /No description available in the introspection data./ -} sliceGetConfig :: (B.CallStack.HasCallStack, MonadIO m) => GLib.Enums.SliceConfig -> m Int64 sliceGetConfig ckey = liftIO $ do let ckey' = (fromIntegral . fromEnum) ckey result <- g_slice_get_config ckey' return result -- function g_slice_free_chain_with_offset -- Args : [Arg {argCName = "block_size", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the size of the blocks", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "mem_chain", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a pointer to the first block of the chain", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "next_offset", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the offset of the @next field in the blocks", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_slice_free_chain_with_offset" g_slice_free_chain_with_offset :: Word64 -> -- block_size : TBasicType TUInt64 Ptr () -> -- mem_chain : TBasicType TPtr Word64 -> -- next_offset : TBasicType TUInt64 IO () {- | Frees a linked list of memory blocks of structure type /@type@/. The memory blocks must be equal-sized, allocated via 'GI.GLib.Functions.sliceAlloc' or 'GI.GLib.Functions.sliceAlloc0' and linked together by a /@next@/ pointer (similar to 'GI.GLib.Structs.SList.SList'). The offset of the /@next@/ field in each block is passed as third argument. Note that the exact release behaviour can be changed with the [@G_DEBUG=gc-friendly@][G_DEBUG] environment variable, also see [@G_SLICE@][G_SLICE] for related debugging options. If /@memChain@/ is 'Nothing', this function does nothing. /Since: 2.10/ -} sliceFreeChainWithOffset :: (B.CallStack.HasCallStack, MonadIO m) => Word64 {- ^ /@blockSize@/: the size of the blocks -} -> Ptr () {- ^ /@memChain@/: a pointer to the first block of the chain -} -> Word64 {- ^ /@nextOffset@/: the offset of the /@next@/ field in the blocks -} -> m () sliceFreeChainWithOffset blockSize memChain nextOffset = liftIO $ do g_slice_free_chain_with_offset blockSize memChain nextOffset return () -- function g_slice_free1 -- Args : [Arg {argCName = "block_size", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the size of the block", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "mem_block", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a pointer to the block to free", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_slice_free1" g_slice_free1 :: Word64 -> -- block_size : TBasicType TUInt64 Ptr () -> -- mem_block : TBasicType TPtr IO () {- | Frees a block of memory. The memory must have been allocated via 'GI.GLib.Functions.sliceAlloc' or 'GI.GLib.Functions.sliceAlloc0' and the /@blockSize@/ has to match the size specified upon allocation. Note that the exact release behaviour can be changed with the [@G_DEBUG=gc-friendly@][G_DEBUG] environment variable, also see [@G_SLICE@][G_SLICE] for related debugging options. If /@memBlock@/ is 'Nothing', this function does nothing. /Since: 2.10/ -} sliceFree1 :: (B.CallStack.HasCallStack, MonadIO m) => Word64 {- ^ /@blockSize@/: the size of the block -} -> Ptr () {- ^ /@memBlock@/: a pointer to the block to free -} -> m () sliceFree1 blockSize memBlock = liftIO $ do g_slice_free1 blockSize memBlock return () -- function g_slice_copy -- Args : [Arg {argCName = "block_size", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the number of bytes to allocate", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "mem_block", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the memory to copy", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TPtr) -- throws : False -- Skip return : False foreign import ccall "g_slice_copy" g_slice_copy :: Word64 -> -- block_size : TBasicType TUInt64 Ptr () -> -- mem_block : TBasicType TPtr IO (Ptr ()) {- | Allocates a block of memory from the slice allocator and copies /@blockSize@/ bytes into it from /@memBlock@/. /@memBlock@/ must be non-'Nothing' if /@blockSize@/ is non-zero. /Since: 2.14/ -} sliceCopy :: (B.CallStack.HasCallStack, MonadIO m) => Word64 {- ^ /@blockSize@/: the number of bytes to allocate -} -> Ptr () {- ^ /@memBlock@/: the memory to copy -} -> m (Ptr ()) {- ^ __Returns:__ a pointer to the allocated memory block, which will be 'Nothing' if and only if /@memSize@/ is 0 -} sliceCopy blockSize memBlock = liftIO $ do result <- g_slice_copy blockSize memBlock return result -- function g_slice_alloc0 -- Args : [Arg {argCName = "block_size", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the number of bytes to allocate", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TPtr) -- throws : False -- Skip return : False foreign import ccall "g_slice_alloc0" g_slice_alloc0 :: Word64 -> -- block_size : TBasicType TUInt64 IO (Ptr ()) {- | Allocates a block of memory via 'GI.GLib.Functions.sliceAlloc' and initializes the returned memory to 0. Note that the underlying slice allocation mechanism can be changed with the [@G_SLICE=always-malloc@][G_SLICE] environment variable. /Since: 2.10/ -} sliceAlloc0 :: (B.CallStack.HasCallStack, MonadIO m) => Word64 {- ^ /@blockSize@/: the number of bytes to allocate -} -> m (Ptr ()) {- ^ __Returns:__ a pointer to the allocated block, which will be 'Nothing' if and only if /@memSize@/ is 0 -} sliceAlloc0 blockSize = liftIO $ do result <- g_slice_alloc0 blockSize return result -- function g_slice_alloc -- Args : [Arg {argCName = "block_size", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the number of bytes to allocate", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TPtr) -- throws : False -- Skip return : False foreign import ccall "g_slice_alloc" g_slice_alloc :: Word64 -> -- block_size : TBasicType TUInt64 IO (Ptr ()) {- | Allocates a block of memory from the slice allocator. The block address handed out can be expected to be aligned to at least 1 * sizeof (void*), though in general slices are 2 * sizeof (void*) bytes aligned, if a @/malloc()/@ fallback implementation is used instead, the alignment may be reduced in a libc dependent fashion. Note that the underlying slice allocation mechanism can be changed with the [@G_SLICE=always-malloc@][G_SLICE] environment variable. /Since: 2.10/ -} sliceAlloc :: (B.CallStack.HasCallStack, MonadIO m) => Word64 {- ^ /@blockSize@/: the number of bytes to allocate -} -> m (Ptr ()) {- ^ __Returns:__ a pointer to the allocated memory block, which will be 'Nothing' if and only if /@memSize@/ is 0 -} sliceAlloc blockSize = liftIO $ do result <- g_slice_alloc blockSize return result -- function g_shell_unquote -- Args : [Arg {argCName = "quoted_string", argType = TBasicType TFileName, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "shell-quoted string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TFileName) -- throws : True -- Skip return : False foreign import ccall "g_shell_unquote" g_shell_unquote :: CString -> -- quoted_string : TBasicType TFileName Ptr (Ptr GError) -> -- error IO CString {- | Unquotes a string as the shell (\/bin\/sh) would. Only handles quotes; if a string contains file globs, arithmetic operators, variables, backticks, redirections, or other special-to-the-shell features, the result will be different from the result a real shell would produce (the variables, backticks, etc. will be passed through literally instead of being expanded). This function is guaranteed to succeed if applied to the result of 'GI.GLib.Functions.shellQuote'. If it fails, it returns 'Nothing' and sets the error. The /@quotedString@/ need not actually contain quoted or escaped text; 'GI.GLib.Functions.shellUnquote' simply goes through the string and unquotes\/unescapes anything that the shell would. Both single and double quotes are handled, as are escapes including escaped newlines. The return value must be freed with 'GI.GLib.Functions.free'. Possible errors are in the @/G_SHELL_ERROR/@ domain. Shell quoting rules are a bit strange. Single quotes preserve the literal string exactly. escape sequences are not allowed; not even \\\' - if you want a \' in the quoted text, you have to do something like \'foo\'\\\'\'bar\'. Double quotes allow $, \`, \", \\, and newline to be escaped with backslash. Otherwise double quotes preserve things literally. -} shellUnquote :: (B.CallStack.HasCallStack, MonadIO m) => [Char] {- ^ /@quotedString@/: shell-quoted string -} -> m [Char] {- ^ __Returns:__ an unquoted string /(Can throw 'Data.GI.Base.GError.GError')/ -} shellUnquote quotedString = liftIO $ do quotedString' <- stringToCString quotedString onException (do result <- propagateGError $ g_shell_unquote quotedString' checkUnexpectedReturnNULL "shellUnquote" result result' <- cstringToString result freeMem result freeMem quotedString' return result' ) (do freeMem quotedString' ) -- function g_shell_quote -- Args : [Arg {argCName = "unquoted_string", argType = TBasicType TFileName, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a literal string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TFileName) -- throws : False -- Skip return : False foreign import ccall "g_shell_quote" g_shell_quote :: CString -> -- unquoted_string : TBasicType TFileName IO CString {- | Quotes a string so that the shell (\/bin\/sh) will interpret the quoted string to mean /@unquotedString@/. If you pass a filename to the shell, for example, you should first quote it with this function. The return value must be freed with 'GI.GLib.Functions.free'. The quoting style used is undefined (single or double quotes may be used). -} shellQuote :: (B.CallStack.HasCallStack, MonadIO m) => [Char] {- ^ /@unquotedString@/: a literal string -} -> m [Char] {- ^ __Returns:__ quoted string -} shellQuote unquotedString = liftIO $ do unquotedString' <- stringToCString unquotedString result <- g_shell_quote unquotedString' checkUnexpectedReturnNULL "shellQuote" result result' <- cstringToString result freeMem result freeMem unquotedString' return result' -- function g_shell_parse_argv -- Args : [Arg {argCName = "command_line", argType = TBasicType TFileName, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "command line to parse", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "argcp", argType = TBasicType TInt, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "return location for number of args", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "argvp", argType = TCArray True (-1) 1 (TBasicType TFileName), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "\n return location for array of args", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : True -- Skip return : False foreign import ccall "g_shell_parse_argv" g_shell_parse_argv :: CString -> -- command_line : TBasicType TFileName Ptr Int32 -> -- argcp : TBasicType TInt Ptr (Ptr CString) -> -- argvp : TCArray True (-1) 1 (TBasicType TFileName) Ptr (Ptr GError) -> -- error IO CInt {- | Parses a command line into an argument vector, in much the same way the shell would, but without many of the expansions the shell would perform (variable expansion, globs, operators, filename expansion, etc. are not supported). The results are defined to be the same as those you would get from a UNIX98 \/bin\/sh, as long as the input contains none of the unsupported shell expansions. If the input does contain such expansions, they are passed through literally. Possible errors are those from the @/G_SHELL_ERROR/@ domain. Free the returned vector with 'GI.GLib.Functions.strfreev'. -} shellParseArgv :: (B.CallStack.HasCallStack, MonadIO m) => [Char] {- ^ /@commandLine@/: command line to parse -} -> m ((Int32, [[Char]])) {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -} shellParseArgv commandLine = liftIO $ do commandLine' <- stringToCString commandLine argcp <- allocMem :: IO (Ptr Int32) argvp <- allocMem :: IO (Ptr (Ptr CString)) onException (do _ <- propagateGError $ g_shell_parse_argv commandLine' argcp argvp argcp' <- peek argcp argvp' <- peek argvp argvp'' <- unpackZeroTerminatedFileNameArray argvp' mapZeroTerminatedCArray freeMem argvp' freeMem argvp' freeMem commandLine' freeMem argcp freeMem argvp return (argcp', argvp'') ) (do freeMem commandLine' freeMem argcp freeMem argvp ) -- function g_shell_error_quark -- Args : [] -- Lengths : [] -- returnType : Just (TBasicType TUInt32) -- throws : False -- Skip return : False foreign import ccall "g_shell_error_quark" g_shell_error_quark :: IO Word32 {- | /No description available in the introspection data./ -} shellErrorQuark :: (B.CallStack.HasCallStack, MonadIO m) => m Word32 shellErrorQuark = liftIO $ do result <- g_shell_error_quark return result -- function g_setenv -- Args : [Arg {argCName = "variable", argType = TBasicType TFileName, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the environment variable to set, must not\n contain '='.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "value", argType = TBasicType TFileName, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the value for to set the variable to.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "overwrite", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "whether to change the variable if it already exists.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "g_setenv" g_setenv :: CString -> -- variable : TBasicType TFileName CString -> -- value : TBasicType TFileName CInt -> -- overwrite : TBasicType TBoolean IO CInt {- | Sets an environment variable. On UNIX, both the variable\'s name and value can be arbitrary byte strings, except that the variable\'s name cannot contain \'=\'. On Windows, they should be in UTF-8. Note that on some systems, when variables are overwritten, the memory used for the previous variables and its value isn\'t reclaimed. You should be mindful of the fact that environment variable handling in UNIX is not thread-safe, and your program may crash if one thread calls 'GI.GLib.Functions.setenv' while another thread is calling @/getenv()/@. (And note that many functions, such as @/gettext()/@, call @/getenv()/@ internally.) This function is only safe to use at the very start of your program, before creating any other threads (or creating objects that create worker threads of their own). If you need to set up the environment for a child process, you can use 'GI.GLib.Functions.getEnviron' to get an environment array, modify that with 'GI.GLib.Functions.environSetenv' and 'GI.GLib.Functions.environUnsetenv', and then pass that array directly to @/execvpe()/@, 'GI.GLib.Functions.spawnAsync', or the like. /Since: 2.4/ -} setenv :: (B.CallStack.HasCallStack, MonadIO m) => [Char] {- ^ /@variable@/: the environment variable to set, must not contain \'=\'. -} -> [Char] {- ^ /@value@/: the value for to set the variable to. -} -> Bool {- ^ /@overwrite@/: whether to change the variable if it already exists. -} -> m Bool {- ^ __Returns:__ 'False' if the environment variable couldn\'t be set. -} setenv variable value overwrite = liftIO $ do variable' <- stringToCString variable value' <- stringToCString value let overwrite' = (fromIntegral . fromEnum) overwrite result <- g_setenv variable' value' overwrite' let result' = (/= 0) result freeMem variable' freeMem value' return result' -- function g_set_prgname -- Args : [Arg {argCName = "prgname", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the name of the program.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_set_prgname" g_set_prgname :: CString -> -- prgname : TBasicType TUTF8 IO () {- | Sets the name of the program. This name should not be localized, in contrast to 'GI.GLib.Functions.setApplicationName'. If you are using @/GApplication/@ the program name is set in @/g_application_run()/@. In case of GDK or GTK+ it is set in @/gdk_init()/@, which is called by @/gtk_init()/@ and the @/GtkApplication::startup/@ handler. The program name is found by taking the last component of /@argv@/[0]. Note that for thread-safety reasons this function can only be called once. -} setPrgname :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@prgname@/: the name of the program. -} -> m () setPrgname prgname = liftIO $ do prgname' <- textToCString prgname g_set_prgname prgname' freeMem prgname' return () -- function g_set_error_literal -- Args : [Arg {argCName = "err", argType = TError, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a return location for a #GError", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "domain", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "error domain", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "code", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "error code", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "message", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "error message", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_set_error_literal" g_set_error_literal :: Ptr (Ptr GError) -> -- err : TError Word32 -> -- domain : TBasicType TUInt32 Int32 -> -- code : TBasicType TInt CString -> -- message : TBasicType TUTF8 IO () {- | Does nothing if /@err@/ is 'Nothing'; if /@err@/ is non-'Nothing', then */@err@/ must be 'Nothing'. A new 'GError' is created and assigned to */@err@/. Unlike @/g_set_error()/@, /@message@/ is not a @/printf()/@-style format string. Use this function if /@message@/ contains text you don\'t have control over, that could include @/printf()/@ escape sequences. /Since: 2.18/ -} setErrorLiteral :: (B.CallStack.HasCallStack, MonadIO m) => Word32 {- ^ /@domain@/: error domain -} -> Int32 {- ^ /@code@/: error code -} -> T.Text {- ^ /@message@/: error message -} -> m (GError) setErrorLiteral domain code message = liftIO $ do err <- allocMem :: IO (Ptr (Ptr GError)) message' <- textToCString message g_set_error_literal err domain code message' err' <- peek err err'' <- (wrapBoxed GError) err' freeMem err freeMem message' return err'' -- function g_set_application_name -- Args : [Arg {argCName = "application_name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "localized name of the application", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_set_application_name" g_set_application_name :: CString -> -- application_name : TBasicType TUTF8 IO () {- | Sets a human-readable name for the application. This name should be localized if possible, and is intended for display to the user. Contrast with 'GI.GLib.Functions.setPrgname', which sets a non-localized name. 'GI.GLib.Functions.setPrgname' will be called automatically by @/gtk_init()/@, but 'GI.GLib.Functions.setApplicationName' will not. Note that for thread safety reasons, this function can only be called once. The application name will be used in contexts such as error messages, or when displaying an application\'s name in the task list. /Since: 2.2/ -} setApplicationName :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@applicationName@/: localized name of the application -} -> m () setApplicationName applicationName = liftIO $ do applicationName' <- textToCString applicationName g_set_application_name applicationName' freeMem applicationName' return () -- function g_rmdir -- Args : [Arg {argCName = "filename", argType = TBasicType TFileName, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a pathname in the GLib file name encoding\n (UTF-8 on Windows)", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TInt) -- throws : False -- Skip return : False foreign import ccall "g_rmdir" g_rmdir :: CString -> -- filename : TBasicType TFileName IO Int32 {- | A wrapper for the POSIX @/rmdir()/@ function. The @/rmdir()/@ function deletes a directory from the filesystem. See your C library manual for more details about how @/rmdir()/@ works on your system. /Since: 2.6/ -} rmdir :: (B.CallStack.HasCallStack, MonadIO m) => [Char] {- ^ /@filename@/: a pathname in the GLib file name encoding (UTF-8 on Windows) -} -> m Int32 {- ^ __Returns:__ 0 if the directory was successfully removed, -1 if an error occurred -} rmdir filename = liftIO $ do filename' <- stringToCString filename result <- g_rmdir filename' freeMem filename' return result -- function g_reload_user_special_dirs_cache -- Args : [] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_reload_user_special_dirs_cache" g_reload_user_special_dirs_cache :: IO () {- | Resets the cache used for 'GI.GLib.Functions.getUserSpecialDir', so that the latest on-disk version is used. Call this only if you just changed the data on disk yourself. Due to thread safety issues this may cause leaking of strings that were previously returned from 'GI.GLib.Functions.getUserSpecialDir' that can\'t be freed. We ensure to only leak the data for the directories that actually changed value though. /Since: 2.22/ -} reloadUserSpecialDirsCache :: (B.CallStack.HasCallStack, MonadIO m) => m () reloadUserSpecialDirsCache = liftIO $ do g_reload_user_special_dirs_cache return () -- function g_ref_string_release -- Args : [Arg {argCName = "str", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a reference counted string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_ref_string_release" g_ref_string_release :: CString -> -- str : TBasicType TUTF8 IO () {- | Releases a reference on a string; if it was the last reference, the resources allocated by the string are freed as well. /Since: 2.58/ -} refStringRelease :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@str@/: a reference counted string -} -> m () refStringRelease str = liftIO $ do str' <- textToCString str g_ref_string_release str' freeMem str' return () -- function g_ref_string_new_len -- Args : [Arg {argCName = "str", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "len", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "length of @str to use, or -1 if @str is nul-terminated", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_ref_string_new_len" g_ref_string_new_len :: CString -> -- str : TBasicType TUTF8 Int64 -> -- len : TBasicType TInt64 IO CString {- | Creates a new reference counted string and copies the contents of /@str@/ into it, up to /@len@/ bytes. Since this function does not stop at nul bytes, it is the caller\'s responsibility to ensure that /@str@/ has at least /@len@/ addressable bytes. /Since: 2.58/ -} refStringNewLen :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@str@/: a string -} -> Int64 {- ^ /@len@/: length of /@str@/ to use, or -1 if /@str@/ is nul-terminated -} -> m T.Text {- ^ __Returns:__ the newly created reference counted string -} refStringNewLen str len = liftIO $ do str' <- textToCString str result <- g_ref_string_new_len str' len checkUnexpectedReturnNULL "refStringNewLen" result result' <- cstringToText result freeMem result freeMem str' return result' -- function g_ref_string_new_intern -- Args : [Arg {argCName = "str", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a NUL-terminated string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_ref_string_new_intern" g_ref_string_new_intern :: CString -> -- str : TBasicType TUTF8 IO CString {- | Creates a new reference counted string and copies the content of /@str@/ into it. If you call this function multiple times with the same /@str@/, or with the same contents of /@str@/, it will return a new reference, instead of creating a new string. /Since: 2.58/ -} refStringNewIntern :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@str@/: a NUL-terminated string -} -> m T.Text {- ^ __Returns:__ the newly created reference counted string, or a new reference to an existing string -} refStringNewIntern str = liftIO $ do str' <- textToCString str result <- g_ref_string_new_intern str' checkUnexpectedReturnNULL "refStringNewIntern" result result' <- cstringToText result freeMem result freeMem str' return result' -- function g_ref_string_new -- Args : [Arg {argCName = "str", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a NUL-terminated string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_ref_string_new" g_ref_string_new :: CString -> -- str : TBasicType TUTF8 IO CString {- | Creates a new reference counted string and copies the contents of /@str@/ into it. /Since: 2.58/ -} refStringNew :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@str@/: a NUL-terminated string -} -> m T.Text {- ^ __Returns:__ the newly created reference counted string -} refStringNew str = liftIO $ do str' <- textToCString str result <- g_ref_string_new str' checkUnexpectedReturnNULL "refStringNew" result result' <- cstringToText result freeMem result freeMem str' return result' -- function g_ref_string_length -- Args : [Arg {argCName = "str", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a reference counted string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUInt64) -- throws : False -- Skip return : False foreign import ccall "g_ref_string_length" g_ref_string_length :: CString -> -- str : TBasicType TUTF8 IO Word64 {- | Retrieves the length of /@str@/. /Since: 2.58/ -} refStringLength :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@str@/: a reference counted string -} -> m Word64 {- ^ __Returns:__ the length of the given string, in bytes -} refStringLength str = liftIO $ do str' <- textToCString str result <- g_ref_string_length str' freeMem str' return result -- function g_ref_string_acquire -- Args : [Arg {argCName = "str", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a reference counted string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_ref_string_acquire" g_ref_string_acquire :: CString -> -- str : TBasicType TUTF8 IO CString {- | Acquires a reference on a string. /Since: 2.58/ -} refStringAcquire :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@str@/: a reference counted string -} -> m T.Text {- ^ __Returns:__ the given string, with its reference count increased -} refStringAcquire str = liftIO $ do str' <- textToCString str result <- g_ref_string_acquire str' checkUnexpectedReturnNULL "refStringAcquire" result result' <- cstringToText result freeMem result freeMem str' return result' -- function g_ref_count_init -- Args : [Arg {argCName = "rc", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the address of a reference count variable", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_ref_count_init" g_ref_count_init :: Int32 -> -- rc : TBasicType TInt IO () {- | Initializes a reference count variable. /Since: 2.58/ -} refCountInit :: (B.CallStack.HasCallStack, MonadIO m) => Int32 {- ^ /@rc@/: the address of a reference count variable -} -> m () refCountInit rc = liftIO $ do g_ref_count_init rc return () -- function g_ref_count_inc -- Args : [Arg {argCName = "rc", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the address of a reference count variable", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_ref_count_inc" g_ref_count_inc :: Int32 -> -- rc : TBasicType TInt IO () {- | Increases the reference count. /Since: 2.58/ -} refCountInc :: (B.CallStack.HasCallStack, MonadIO m) => Int32 {- ^ /@rc@/: the address of a reference count variable -} -> m () refCountInc rc = liftIO $ do g_ref_count_inc rc return () -- function g_ref_count_dec -- Args : [Arg {argCName = "rc", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the address of a reference count variable", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "g_ref_count_dec" g_ref_count_dec :: Int32 -> -- rc : TBasicType TInt IO CInt {- | Decreases the reference count. /Since: 2.58/ -} refCountDec :: (B.CallStack.HasCallStack, MonadIO m) => Int32 {- ^ /@rc@/: the address of a reference count variable -} -> m Bool {- ^ __Returns:__ 'True' if the reference count reached 0, and 'False' otherwise -} refCountDec rc = liftIO $ do result <- g_ref_count_dec rc let result' = (/= 0) result return result' -- function g_ref_count_compare -- Args : [Arg {argCName = "rc", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the address of a reference count variable", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "val", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the value to compare", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "g_ref_count_compare" g_ref_count_compare :: Int32 -> -- rc : TBasicType TInt Int32 -> -- val : TBasicType TInt IO CInt {- | Compares the current value of /@rc@/ with /@val@/. /Since: 2.58/ -} refCountCompare :: (B.CallStack.HasCallStack, MonadIO m) => Int32 {- ^ /@rc@/: the address of a reference count variable -} -> Int32 {- ^ /@val@/: the value to compare -} -> m Bool {- ^ __Returns:__ 'True' if the reference count is the same as the given value -} refCountCompare rc val = liftIO $ do result <- g_ref_count_compare rc val let result' = (/= 0) result return result' -- function g_realloc_n -- Args : [Arg {argCName = "mem", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the memory to reallocate", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "n_blocks", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the number of blocks to allocate", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "n_block_bytes", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the size of each block in bytes", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TPtr) -- throws : False -- Skip return : False foreign import ccall "g_realloc_n" g_realloc_n :: Ptr () -> -- mem : TBasicType TPtr Word64 -> -- n_blocks : TBasicType TUInt64 Word64 -> -- n_block_bytes : TBasicType TUInt64 IO (Ptr ()) {- | This function is similar to 'GI.GLib.Functions.realloc', allocating (/@nBlocks@/ * /@nBlockBytes@/) bytes, but care is taken to detect possible overflow during multiplication. /Since: 2.24/ -} reallocN :: (B.CallStack.HasCallStack, MonadIO m) => Ptr () {- ^ /@mem@/: the memory to reallocate -} -> Word64 {- ^ /@nBlocks@/: the number of blocks to allocate -} -> Word64 {- ^ /@nBlockBytes@/: the size of each block in bytes -} -> m (Ptr ()) {- ^ __Returns:__ the new address of the allocated memory -} reallocN mem nBlocks nBlockBytes = liftIO $ do result <- g_realloc_n mem nBlocks nBlockBytes return result -- function g_realloc -- Args : [Arg {argCName = "mem", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the memory to reallocate", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "n_bytes", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "new size of the memory in bytes", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TPtr) -- throws : False -- Skip return : False foreign import ccall "g_realloc" g_realloc :: Ptr () -> -- mem : TBasicType TPtr Word64 -> -- n_bytes : TBasicType TUInt64 IO (Ptr ()) {- | Reallocates the memory pointed to by /@mem@/, so that it now has space for /@nBytes@/ bytes of memory. It returns the new address of the memory, which may have been moved. /@mem@/ may be 'Nothing', in which case it\'s considered to have zero-length. /@nBytes@/ may be 0, in which case 'Nothing' will be returned and /@mem@/ will be freed unless it is 'Nothing'. -} realloc :: (B.CallStack.HasCallStack, MonadIO m) => Ptr () {- ^ /@mem@/: the memory to reallocate -} -> Word64 {- ^ /@nBytes@/: new size of the memory in bytes -} -> m (Ptr ()) {- ^ __Returns:__ the new address of the allocated memory -} realloc mem nBytes = liftIO $ do result <- g_realloc mem nBytes return result -- function g_rc_box_release_full -- Args : [Arg {argCName = "mem_block", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a pointer to reference counted data", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "clear_func", argType = TInterface (Name {namespace = "GLib", name = "DestroyNotify"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a function to call when clearing the data", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_rc_box_release_full" g_rc_box_release_full :: Ptr () -> -- mem_block : TBasicType TPtr FunPtr GLib.Callbacks.C_DestroyNotify -> -- clear_func : TInterface (Name {namespace = "GLib", name = "DestroyNotify"}) IO () {- | Releases a reference on the data pointed by /@memBlock@/. If the reference was the last one, it will call /@clearFunc@/ to clear the contents of /@memBlock@/, and then will free the resources allocated for /@memBlock@/. /Since: 2.58/ -} rcBoxReleaseFull :: (B.CallStack.HasCallStack, MonadIO m) => Ptr () {- ^ /@memBlock@/: a pointer to reference counted data -} -> GLib.Callbacks.DestroyNotify {- ^ /@clearFunc@/: a function to call when clearing the data -} -> m () rcBoxReleaseFull memBlock clearFunc = liftIO $ do ptrclearFunc <- callocMem :: IO (Ptr (FunPtr GLib.Callbacks.C_DestroyNotify)) clearFunc' <- GLib.Callbacks.mk_DestroyNotify (GLib.Callbacks.wrap_DestroyNotify (Just ptrclearFunc) clearFunc) poke ptrclearFunc clearFunc' g_rc_box_release_full memBlock clearFunc' return () -- function g_rc_box_release -- Args : [Arg {argCName = "mem_block", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a pointer to reference counted data", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_rc_box_release" g_rc_box_release :: Ptr () -> -- mem_block : TBasicType TPtr IO () {- | Releases a reference on the data pointed by /@memBlock@/. If the reference was the last one, it will free the resources allocated for /@memBlock@/. /Since: 2.58/ -} rcBoxRelease :: (B.CallStack.HasCallStack, MonadIO m) => Ptr () {- ^ /@memBlock@/: a pointer to reference counted data -} -> m () rcBoxRelease memBlock = liftIO $ do g_rc_box_release memBlock return () -- function g_rc_box_get_size -- Args : [Arg {argCName = "mem_block", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a pointer to reference counted data", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUInt64) -- throws : False -- Skip return : False foreign import ccall "g_rc_box_get_size" g_rc_box_get_size :: Ptr () -> -- mem_block : TBasicType TPtr IO Word64 {- | Retrieves the size of the reference counted data pointed by /@memBlock@/. /Since: 2.58/ -} rcBoxGetSize :: (B.CallStack.HasCallStack, MonadIO m) => Ptr () {- ^ /@memBlock@/: a pointer to reference counted data -} -> m Word64 {- ^ __Returns:__ the size of the data, in bytes -} rcBoxGetSize memBlock = liftIO $ do result <- g_rc_box_get_size memBlock return result -- function g_rc_box_dup -- Args : [Arg {argCName = "block_size", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the number of bytes to copy, must be greater than 0", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "mem_block", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the memory to copy", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TPtr) -- throws : False -- Skip return : False foreign import ccall "g_rc_box_dup" g_rc_box_dup :: Word64 -> -- block_size : TBasicType TUInt64 Ptr () -> -- mem_block : TBasicType TPtr IO (Ptr ()) {- | Allocates a new block of data with reference counting semantics, and copies /@blockSize@/ bytes of /@memBlock@/ into it. /Since: 2.58/ -} rcBoxDup :: (B.CallStack.HasCallStack, MonadIO m) => Word64 {- ^ /@blockSize@/: the number of bytes to copy, must be greater than 0 -} -> Ptr () {- ^ /@memBlock@/: the memory to copy -} -> m (Ptr ()) {- ^ __Returns:__ a pointer to the allocated memory -} rcBoxDup blockSize memBlock = liftIO $ do result <- g_rc_box_dup blockSize memBlock return result -- function g_rc_box_alloc0 -- Args : [Arg {argCName = "block_size", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the size of the allocation, must be greater than 0", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TPtr) -- throws : False -- Skip return : False foreign import ccall "g_rc_box_alloc0" g_rc_box_alloc0 :: Word64 -> -- block_size : TBasicType TUInt64 IO (Ptr ()) {- | Allocates /@blockSize@/ bytes of memory, and adds reference counting semantics to it. The contents of the returned data is set to zero. The data will be freed when its reference count drops to zero. The allocated data is guaranteed to be suitably aligned for any built-in type. /Since: 2.58/ -} rcBoxAlloc0 :: (B.CallStack.HasCallStack, MonadIO m) => Word64 {- ^ /@blockSize@/: the size of the allocation, must be greater than 0 -} -> m (Ptr ()) {- ^ __Returns:__ a pointer to the allocated memory -} rcBoxAlloc0 blockSize = liftIO $ do result <- g_rc_box_alloc0 blockSize return result -- function g_rc_box_alloc -- Args : [Arg {argCName = "block_size", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the size of the allocation, must be greater than 0", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TPtr) -- throws : False -- Skip return : False foreign import ccall "g_rc_box_alloc" g_rc_box_alloc :: Word64 -> -- block_size : TBasicType TUInt64 IO (Ptr ()) {- | Allocates /@blockSize@/ bytes of memory, and adds reference counting semantics to it. The data will be freed when its reference count drops to zero. The allocated data is guaranteed to be suitably aligned for any built-in type. /Since: 2.58/ -} rcBoxAlloc :: (B.CallStack.HasCallStack, MonadIO m) => Word64 {- ^ /@blockSize@/: the size of the allocation, must be greater than 0 -} -> m (Ptr ()) {- ^ __Returns:__ a pointer to the allocated memory -} rcBoxAlloc blockSize = liftIO $ do result <- g_rc_box_alloc blockSize return result -- function g_rc_box_acquire -- Args : [Arg {argCName = "mem_block", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a pointer to reference counted data", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TPtr) -- throws : False -- Skip return : False foreign import ccall "g_rc_box_acquire" g_rc_box_acquire :: Ptr () -> -- mem_block : TBasicType TPtr IO (Ptr ()) {- | Acquires a reference on the data pointed by /@memBlock@/. /Since: 2.58/ -} rcBoxAcquire :: (B.CallStack.HasCallStack, MonadIO m) => Ptr () {- ^ /@memBlock@/: a pointer to reference counted data -} -> m (Ptr ()) {- ^ __Returns:__ a pointer to the data, with its reference count increased -} rcBoxAcquire memBlock = liftIO $ do result <- g_rc_box_acquire memBlock return result -- function g_random_set_seed -- Args : [Arg {argCName = "seed", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a value to reinitialize the global random number generator", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_random_set_seed" g_random_set_seed :: Word32 -> -- seed : TBasicType TUInt32 IO () {- | Sets the seed for the global random number generator, which is used by the g_random_* functions, to /@seed@/. -} randomSetSeed :: (B.CallStack.HasCallStack, MonadIO m) => Word32 {- ^ /@seed@/: a value to reinitialize the global random number generator -} -> m () randomSetSeed seed = liftIO $ do g_random_set_seed seed return () -- function g_random_int_range -- Args : [Arg {argCName = "begin", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "lower closed bound of the interval", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "end", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "upper open bound of the interval", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TInt32) -- throws : False -- Skip return : False foreign import ccall "g_random_int_range" g_random_int_range :: Int32 -> -- begin : TBasicType TInt32 Int32 -> -- end : TBasicType TInt32 IO Int32 {- | Returns a random @/gint32/@ equally distributed over the range [/@begin@/../@end@/-1]. -} randomIntRange :: (B.CallStack.HasCallStack, MonadIO m) => Int32 {- ^ /@begin@/: lower closed bound of the interval -} -> Int32 {- ^ /@end@/: upper open bound of the interval -} -> m Int32 {- ^ __Returns:__ a random number -} randomIntRange begin end = liftIO $ do result <- g_random_int_range begin end return result -- function g_random_int -- Args : [] -- Lengths : [] -- returnType : Just (TBasicType TUInt32) -- throws : False -- Skip return : False foreign import ccall "g_random_int" g_random_int :: IO Word32 {- | Return a random @/guint32/@ equally distributed over the range [0..2^32-1]. -} randomInt :: (B.CallStack.HasCallStack, MonadIO m) => m Word32 {- ^ __Returns:__ a random number -} randomInt = liftIO $ do result <- g_random_int return result -- function g_random_double_range -- Args : [Arg {argCName = "begin", argType = TBasicType TDouble, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "lower closed bound of the interval", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "end", argType = TBasicType TDouble, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "upper open bound of the interval", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TDouble) -- throws : False -- Skip return : False foreign import ccall "g_random_double_range" g_random_double_range :: CDouble -> -- begin : TBasicType TDouble CDouble -> -- end : TBasicType TDouble IO CDouble {- | Returns a random @/gdouble/@ equally distributed over the range [/@begin@/../@end@/). -} randomDoubleRange :: (B.CallStack.HasCallStack, MonadIO m) => Double {- ^ /@begin@/: lower closed bound of the interval -} -> Double {- ^ /@end@/: upper open bound of the interval -} -> m Double {- ^ __Returns:__ a random number -} randomDoubleRange begin end = liftIO $ do let begin' = realToFrac begin let end' = realToFrac end result <- g_random_double_range begin' end' let result' = realToFrac result return result' -- function g_random_double -- Args : [] -- Lengths : [] -- returnType : Just (TBasicType TDouble) -- throws : False -- Skip return : False foreign import ccall "g_random_double" g_random_double :: IO CDouble {- | Returns a random @/gdouble/@ equally distributed over the range [0..1). -} randomDouble :: (B.CallStack.HasCallStack, MonadIO m) => m Double {- ^ __Returns:__ a random number -} randomDouble = liftIO $ do result <- g_random_double let result' = realToFrac result return result' -- function g_quark_try_string -- Args : [Arg {argCName = "string", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUInt32) -- throws : False -- Skip return : False foreign import ccall "g_quark_try_string" g_quark_try_string :: CString -> -- string : TBasicType TUTF8 IO Word32 {- | Gets the @/GQuark/@ associated with the given string, or 0 if string is 'Nothing' or it has no associated @/GQuark/@. If you want the GQuark to be created if it doesn\'t already exist, use 'GI.GLib.Functions.quarkFromString' or 'GI.GLib.Functions.quarkFromStaticString'. -} quarkTryString :: (B.CallStack.HasCallStack, MonadIO m) => Maybe (T.Text) {- ^ /@string@/: a string -} -> m Word32 {- ^ __Returns:__ the @/GQuark/@ associated with the string, or 0 if /@string@/ is 'Nothing' or there is no @/GQuark/@ associated with it -} quarkTryString string = liftIO $ do maybeString <- case string of Nothing -> return nullPtr Just jString -> do jString' <- textToCString jString return jString' result <- g_quark_try_string maybeString freeMem maybeString return result -- function g_quark_to_string -- Args : [Arg {argCName = "quark", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GQuark.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_quark_to_string" g_quark_to_string :: Word32 -> -- quark : TBasicType TUInt32 IO CString {- | Gets the string associated with the given @/GQuark/@. -} quarkToString :: (B.CallStack.HasCallStack, MonadIO m) => Word32 {- ^ /@quark@/: a @/GQuark/@. -} -> m T.Text {- ^ __Returns:__ the string associated with the @/GQuark/@ -} quarkToString quark = liftIO $ do result <- g_quark_to_string quark checkUnexpectedReturnNULL "quarkToString" result result' <- cstringToText result return result' -- function g_quark_from_string -- Args : [Arg {argCName = "string", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUInt32) -- throws : False -- Skip return : False foreign import ccall "g_quark_from_string" g_quark_from_string :: CString -> -- string : TBasicType TUTF8 IO Word32 {- | Gets the @/GQuark/@ identifying the given string. If the string does not currently have an associated @/GQuark/@, a new @/GQuark/@ is created, using a copy of the string. -} quarkFromString :: (B.CallStack.HasCallStack, MonadIO m) => Maybe (T.Text) {- ^ /@string@/: a string -} -> m Word32 {- ^ __Returns:__ the @/GQuark/@ identifying the string, or 0 if /@string@/ is 'Nothing' -} quarkFromString string = liftIO $ do maybeString <- case string of Nothing -> return nullPtr Just jString -> do jString' <- textToCString jString return jString' result <- g_quark_from_string maybeString freeMem maybeString return result -- function g_quark_from_static_string -- Args : [Arg {argCName = "string", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUInt32) -- throws : False -- Skip return : False foreign import ccall "g_quark_from_static_string" g_quark_from_static_string :: CString -> -- string : TBasicType TUTF8 IO Word32 {- | Gets the @/GQuark/@ identifying the given (static) string. If the string does not currently have an associated @/GQuark/@, a new @/GQuark/@ is created, linked to the given string. Note that this function is identical to 'GI.GLib.Functions.quarkFromString' except that if a new @/GQuark/@ is created the string itself is used rather than a copy. This saves memory, but can only be used if the string will continue to exist until the program terminates. It can be used with statically allocated strings in the main program, but not with statically allocated memory in dynamically loaded modules, if you expect to ever unload the module again (e.g. do not use this function in GTK+ theme engines). -} quarkFromStaticString :: (B.CallStack.HasCallStack, MonadIO m) => Maybe (T.Text) {- ^ /@string@/: a string -} -> m Word32 {- ^ __Returns:__ the @/GQuark/@ identifying the string, or 0 if /@string@/ is 'Nothing' -} quarkFromStaticString string = liftIO $ do maybeString <- case string of Nothing -> return nullPtr Just jString -> do jString' <- textToCString jString return jString' result <- g_quark_from_static_string maybeString freeMem maybeString return result -- function g_propagate_error -- Args : [Arg {argCName = "dest", argType = TError, direction = DirectionOut, mayBeNull = True, argDoc = Documentation {rawDocText = Just "error return location", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "src", argType = TError, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "error to move into the return location", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_propagate_error" g_propagate_error :: Ptr (Ptr GError) -> -- dest : TError Ptr GError -> -- src : TError IO () {- | If /@dest@/ is 'Nothing', free /@src@/; otherwise, moves /@src@/ into */@dest@/. The error variable /@dest@/ points to must be 'Nothing'. /@src@/ must be non-'Nothing'. Note that /@src@/ is no longer valid after this call. If you want to keep using the same GError*, you need to set it to 'Nothing' after calling this function on it. -} propagateError :: (B.CallStack.HasCallStack, MonadIO m) => GError {- ^ /@src@/: error to move into the return location -} -> m ((Maybe GError)) propagateError src = liftIO $ do dest <- allocMem :: IO (Ptr (Ptr GError)) src' <- B.ManagedPtr.disownBoxed src g_propagate_error dest src' dest' <- peek dest maybeDest' <- convertIfNonNull dest' $ \dest'' -> do dest''' <- (wrapBoxed GError) dest'' return dest''' touchManagedPtr src freeMem dest return maybeDest' -- function g_poll -- Args : [Arg {argCName = "fds", argType = TInterface (Name {namespace = "GLib", name = "PollFD"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "file descriptors to poll", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "nfds", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the number of file descriptors in @fds", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "timeout", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "amount of time to wait, in milliseconds, or -1 to wait forever", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TInt) -- throws : False -- Skip return : False foreign import ccall "g_poll" g_poll :: Ptr GLib.PollFD.PollFD -> -- fds : TInterface (Name {namespace = "GLib", name = "PollFD"}) Word32 -> -- nfds : TBasicType TUInt Int32 -> -- timeout : TBasicType TInt IO Int32 {- | Polls /@fds@/, as with the @/poll()/@ system call, but portably. (On systems that don\'t have @/poll()/@, it is emulated using @/select()/@.) This is used internally by 'GI.GLib.Structs.MainContext.MainContext', but it can be called directly if you need to block until a file descriptor is ready, but don\'t want to run the full main loop. Each element of /@fds@/ is a 'GI.GLib.Structs.PollFD.PollFD' describing a single file descriptor to poll. The /@fd@/ field indicates the file descriptor, and the /@events@/ field indicates the events to poll for. On return, the /@revents@/ fields will be filled with the events that actually occurred. On POSIX systems, the file descriptors in /@fds@/ can be any sort of file descriptor, but the situation is much more complicated on Windows. If you need to use 'GI.GLib.Functions.poll' in code that has to run on Windows, the easiest solution is to construct all of your @/GPollFDs/@ with @/g_io_channel_win32_make_pollfd()/@. /Since: 2.20/ -} poll :: (B.CallStack.HasCallStack, MonadIO m) => GLib.PollFD.PollFD {- ^ /@fds@/: file descriptors to poll -} -> Word32 {- ^ /@nfds@/: the number of file descriptors in /@fds@/ -} -> Int32 {- ^ /@timeout@/: amount of time to wait, in milliseconds, or -1 to wait forever -} -> m Int32 {- ^ __Returns:__ the number of entries in /@fds@/ whose /@revents@/ fields were filled in, or 0 if the operation timed out, or -1 on error or if the call was interrupted. -} poll fds nfds timeout = liftIO $ do fds' <- unsafeManagedPtrGetPtr fds result <- g_poll fds' nfds timeout touchManagedPtr fds return result -- function g_pointer_bit_unlock -- Args : [Arg {argCName = "address", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a pointer to a #gpointer-sized value", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "lock_bit", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a bit value between 0 and 31", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_pointer_bit_unlock" g_pointer_bit_unlock :: Ptr () -> -- address : TBasicType TPtr Int32 -> -- lock_bit : TBasicType TInt IO () {- | This is equivalent to g_bit_unlock, but working on pointers (or other pointer-sized values). For portability reasons, you may only lock on the bottom 32 bits of the pointer. /Since: 2.30/ -} pointerBitUnlock :: (B.CallStack.HasCallStack, MonadIO m) => Ptr () {- ^ /@address@/: a pointer to a @/gpointer/@-sized value -} -> Int32 {- ^ /@lockBit@/: a bit value between 0 and 31 -} -> m () pointerBitUnlock address lockBit = liftIO $ do g_pointer_bit_unlock address lockBit return () -- function g_pointer_bit_trylock -- Args : [Arg {argCName = "address", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a pointer to a #gpointer-sized value", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "lock_bit", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a bit value between 0 and 31", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "g_pointer_bit_trylock" g_pointer_bit_trylock :: Ptr () -> -- address : TBasicType TPtr Int32 -> -- lock_bit : TBasicType TInt IO CInt {- | This is equivalent to g_bit_trylock, but working on pointers (or other pointer-sized values). For portability reasons, you may only lock on the bottom 32 bits of the pointer. /Since: 2.30/ -} pointerBitTrylock :: (B.CallStack.HasCallStack, MonadIO m) => Ptr () {- ^ /@address@/: a pointer to a @/gpointer/@-sized value -} -> Int32 {- ^ /@lockBit@/: a bit value between 0 and 31 -} -> m Bool {- ^ __Returns:__ 'True' if the lock was acquired -} pointerBitTrylock address lockBit = liftIO $ do result <- g_pointer_bit_trylock address lockBit let result' = (/= 0) result return result' -- function g_pointer_bit_lock -- Args : [Arg {argCName = "address", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a pointer to a #gpointer-sized value", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "lock_bit", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a bit value between 0 and 31", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_pointer_bit_lock" g_pointer_bit_lock :: Ptr () -> -- address : TBasicType TPtr Int32 -> -- lock_bit : TBasicType TInt IO () {- | This is equivalent to g_bit_lock, but working on pointers (or other pointer-sized values). For portability reasons, you may only lock on the bottom 32 bits of the pointer. /Since: 2.30/ -} pointerBitLock :: (B.CallStack.HasCallStack, MonadIO m) => Ptr () {- ^ /@address@/: a pointer to a @/gpointer/@-sized value -} -> Int32 {- ^ /@lockBit@/: a bit value between 0 and 31 -} -> m () pointerBitLock address lockBit = liftIO $ do g_pointer_bit_lock address lockBit return () -- function g_pattern_match_string -- Args : [Arg {argCName = "pspec", argType = TInterface (Name {namespace = "GLib", name = "PatternSpec"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GPatternSpec", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "string", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the UTF-8 encoded string to match", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "g_pattern_match_string" g_pattern_match_string :: Ptr GLib.PatternSpec.PatternSpec -> -- pspec : TInterface (Name {namespace = "GLib", name = "PatternSpec"}) CString -> -- string : TBasicType TUTF8 IO CInt {- | Matches a string against a compiled pattern. If the string is to be matched against more than one pattern, consider using 'GI.GLib.Functions.patternMatch' instead while supplying the reversed string. -} patternMatchString :: (B.CallStack.HasCallStack, MonadIO m) => GLib.PatternSpec.PatternSpec {- ^ /@pspec@/: a 'GI.GLib.Structs.PatternSpec.PatternSpec' -} -> T.Text {- ^ /@string@/: the UTF-8 encoded string to match -} -> m Bool {- ^ __Returns:__ 'True' if /@string@/ matches /@pspec@/ -} patternMatchString pspec string = liftIO $ do pspec' <- unsafeManagedPtrGetPtr pspec string' <- textToCString string result <- g_pattern_match_string pspec' string' let result' = (/= 0) result touchManagedPtr pspec freeMem string' return result' -- function g_pattern_match_simple -- Args : [Arg {argCName = "pattern", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the UTF-8 encoded pattern", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "string", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the UTF-8 encoded string to match", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "g_pattern_match_simple" g_pattern_match_simple :: CString -> -- pattern : TBasicType TUTF8 CString -> -- string : TBasicType TUTF8 IO CInt {- | Matches a string against a pattern given as a string. If this function is to be called in a loop, it\'s more efficient to compile the pattern once with @/g_pattern_spec_new()/@ and call 'GI.GLib.Functions.patternMatchString' repeatedly. -} patternMatchSimple :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@pattern@/: the UTF-8 encoded pattern -} -> T.Text {- ^ /@string@/: the UTF-8 encoded string to match -} -> m Bool {- ^ __Returns:__ 'True' if /@string@/ matches /@pspec@/ -} patternMatchSimple pattern string = liftIO $ do pattern' <- textToCString pattern string' <- textToCString string result <- g_pattern_match_simple pattern' string' let result' = (/= 0) result freeMem pattern' freeMem string' return result' -- function g_pattern_match -- Args : [Arg {argCName = "pspec", argType = TInterface (Name {namespace = "GLib", name = "PatternSpec"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GPatternSpec", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "string_length", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the length of @string (in bytes, i.e. strlen(),\n not g_utf8_strlen())", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "string", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the UTF-8 encoded string to match", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "string_reversed", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the reverse of @string or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "g_pattern_match" g_pattern_match :: Ptr GLib.PatternSpec.PatternSpec -> -- pspec : TInterface (Name {namespace = "GLib", name = "PatternSpec"}) Word32 -> -- string_length : TBasicType TUInt CString -> -- string : TBasicType TUTF8 CString -> -- string_reversed : TBasicType TUTF8 IO CInt {- | Matches a string against a compiled pattern. Passing the correct length of the string given is mandatory. The reversed string can be omitted by passing 'Nothing', this is more efficient if the reversed version of the string to be matched is not at hand, as 'GI.GLib.Functions.patternMatch' will only construct it if the compiled pattern requires reverse matches. Note that, if the user code will (possibly) match a string against a multitude of patterns containing wildcards, chances are high that some patterns will require a reversed string. In this case, it\'s more efficient to provide the reversed string to avoid multiple constructions thereof in the various calls to 'GI.GLib.Functions.patternMatch'. Note also that the reverse of a UTF-8 encoded string can in general not be obtained by 'GI.GLib.Functions.strreverse'. This works only if the string does not contain any multibyte characters. GLib offers the 'GI.GLib.Functions.utf8Strreverse' function to reverse UTF-8 encoded strings. -} patternMatch :: (B.CallStack.HasCallStack, MonadIO m) => GLib.PatternSpec.PatternSpec {- ^ /@pspec@/: a 'GI.GLib.Structs.PatternSpec.PatternSpec' -} -> Word32 {- ^ /@stringLength@/: the length of /@string@/ (in bytes, i.e. @/strlen()/@, not 'GI.GLib.Functions.utf8Strlen') -} -> T.Text {- ^ /@string@/: the UTF-8 encoded string to match -} -> Maybe (T.Text) {- ^ /@stringReversed@/: the reverse of /@string@/ or 'Nothing' -} -> m Bool {- ^ __Returns:__ 'True' if /@string@/ matches /@pspec@/ -} patternMatch pspec stringLength string stringReversed = liftIO $ do pspec' <- unsafeManagedPtrGetPtr pspec string' <- textToCString string maybeStringReversed <- case stringReversed of Nothing -> return nullPtr Just jStringReversed -> do jStringReversed' <- textToCString jStringReversed return jStringReversed' result <- g_pattern_match pspec' stringLength string' maybeStringReversed let result' = (/= 0) result touchManagedPtr pspec freeMem string' freeMem maybeStringReversed return result' -- function g_path_skip_root -- Args : [Arg {argCName = "file_name", argType = TBasicType TFileName, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a file name", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TFileName) -- throws : False -- Skip return : False foreign import ccall "g_path_skip_root" g_path_skip_root :: CString -> -- file_name : TBasicType TFileName IO CString {- | Returns a pointer into /@fileName@/ after the root component, i.e. after the \"\/\" in UNIX or \"C:\\\" under Windows. If /@fileName@/ is not an absolute path it returns 'Nothing'. -} pathSkipRoot :: (B.CallStack.HasCallStack, MonadIO m) => [Char] {- ^ /@fileName@/: a file name -} -> m (Maybe [Char]) {- ^ __Returns:__ a pointer into /@fileName@/ after the root component -} pathSkipRoot fileName = liftIO $ do fileName' <- stringToCString fileName result <- g_path_skip_root fileName' maybeResult <- convertIfNonNull result $ \result' -> do result'' <- cstringToString result' return result'' freeMem fileName' return maybeResult -- function g_path_is_absolute -- Args : [Arg {argCName = "file_name", argType = TBasicType TFileName, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a file name", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "g_path_is_absolute" g_path_is_absolute :: CString -> -- file_name : TBasicType TFileName IO CInt {- | Returns 'True' if the given /@fileName@/ is an absolute file name. Note that this is a somewhat vague concept on Windows. On POSIX systems, an absolute file name is well-defined. It always starts from the single root directory. For example \"\/usr\/local\". On Windows, the concepts of current drive and drive-specific current directory introduce vagueness. This function interprets as an absolute file name one that either begins with a directory separator such as \"\\Users\\tml\" or begins with the root on a drive, for example \"C:\\Windows\". The first case also includes UNC paths such as \"\\\\myserver\\docs\\foo\". In all cases, either slashes or backslashes are accepted. Note that a file name relative to the current drive root does not truly specify a file uniquely over time and across processes, as the current drive is a per-process value and can be changed. File names relative the current directory on some specific drive, such as \"D:foo\/bar\", are not interpreted as absolute by this function, but they obviously are not relative to the normal current directory as returned by @/getcwd()/@ or 'GI.GLib.Functions.getCurrentDir' either. Such paths should be avoided, or need to be handled using Windows-specific code. -} pathIsAbsolute :: (B.CallStack.HasCallStack, MonadIO m) => [Char] {- ^ /@fileName@/: a file name -} -> m Bool {- ^ __Returns:__ 'True' if /@fileName@/ is absolute -} pathIsAbsolute fileName = liftIO $ do fileName' <- stringToCString fileName result <- g_path_is_absolute fileName' let result' = (/= 0) result freeMem fileName' return result' -- function g_path_get_dirname -- Args : [Arg {argCName = "file_name", argType = TBasicType TFileName, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the name of the file", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TFileName) -- throws : False -- Skip return : False foreign import ccall "g_path_get_dirname" g_path_get_dirname :: CString -> -- file_name : TBasicType TFileName IO CString {- | Gets the directory components of a file name. For example, the directory component of @\/usr\/bin\/test@ is @\/usr\/bin@. The directory component of @\/@ is @\/@. If the file name has no directory components \".\" is returned. The returned string should be freed when no longer needed. -} pathGetDirname :: (B.CallStack.HasCallStack, MonadIO m) => [Char] {- ^ /@fileName@/: the name of the file -} -> m [Char] {- ^ __Returns:__ the directory components of the file -} pathGetDirname fileName = liftIO $ do fileName' <- stringToCString fileName result <- g_path_get_dirname fileName' checkUnexpectedReturnNULL "pathGetDirname" result result' <- cstringToString result freeMem result freeMem fileName' return result' -- function g_path_get_basename -- Args : [Arg {argCName = "file_name", argType = TBasicType TFileName, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the name of the file", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TFileName) -- throws : False -- Skip return : False foreign import ccall "g_path_get_basename" g_path_get_basename :: CString -> -- file_name : TBasicType TFileName IO CString {- | Gets the last component of the filename. If /@fileName@/ ends with a directory separator it gets the component before the last slash. If /@fileName@/ consists only of directory separators (and on Windows, possibly a drive letter), a single separator is returned. If /@fileName@/ is empty, it gets \".\". -} pathGetBasename :: (B.CallStack.HasCallStack, MonadIO m) => [Char] {- ^ /@fileName@/: the name of the file -} -> m [Char] {- ^ __Returns:__ a newly allocated string containing the last component of the filename -} pathGetBasename fileName = liftIO $ do fileName' <- stringToCString fileName result <- g_path_get_basename fileName' checkUnexpectedReturnNULL "pathGetBasename" result result' <- cstringToString result freeMem result freeMem fileName' return result' -- function g_parse_debug_string -- Args : [Arg {argCName = "string", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a list of debug options separated by colons, spaces, or\ncommas, or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "keys", argType = TCArray False (-1) 2 (TInterface (Name {namespace = "GLib", name = "DebugKey"})), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "pointer to an array of #GDebugKey which associate\n strings with bit flags.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "nkeys", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the number of #GDebugKeys in the array.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [Arg {argCName = "nkeys", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the number of #GDebugKeys in the array.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- returnType : Just (TBasicType TUInt) -- throws : False -- Skip return : False foreign import ccall "g_parse_debug_string" g_parse_debug_string :: CString -> -- string : TBasicType TUTF8 Ptr GLib.DebugKey.DebugKey -> -- keys : TCArray False (-1) 2 (TInterface (Name {namespace = "GLib", name = "DebugKey"})) Word32 -> -- nkeys : TBasicType TUInt IO Word32 {- | Parses a string containing debugging options into a @/guint/@ containing bit flags. This is used within GDK and GTK+ to parse the debug options passed on the command line or through environment variables. If /@string@/ is equal to \"all\", all flags are set. Any flags specified along with \"all\" in /@string@/ are inverted; thus, \"all,foo,bar\" or \"foo,bar,all\" sets all flags except those corresponding to \"foo\" and \"bar\". If /@string@/ is equal to \"help\", all the available keys in /@keys@/ are printed out to standard error. -} parseDebugString :: (B.CallStack.HasCallStack, MonadIO m) => Maybe (T.Text) {- ^ /@string@/: a list of debug options separated by colons, spaces, or commas, or 'Nothing'. -} -> [GLib.DebugKey.DebugKey] {- ^ /@keys@/: pointer to an array of 'GI.GLib.Structs.DebugKey.DebugKey' which associate strings with bit flags. -} -> m Word32 {- ^ __Returns:__ the combined set of bit flags. -} parseDebugString string keys = liftIO $ do let nkeys = fromIntegral $ length keys maybeString <- case string of Nothing -> return nullPtr Just jString -> do jString' <- textToCString jString return jString' keys' <- mapM unsafeManagedPtrGetPtr keys keys'' <- packBlockArray 16 keys' result <- g_parse_debug_string maybeString keys'' nkeys mapM_ touchManagedPtr keys freeMem maybeString freeMem keys'' return result -- function g_option_error_quark -- Args : [] -- Lengths : [] -- returnType : Just (TBasicType TUInt32) -- throws : False -- Skip return : False foreign import ccall "g_option_error_quark" g_option_error_quark :: IO Word32 {- | /No description available in the introspection data./ -} optionErrorQuark :: (B.CallStack.HasCallStack, MonadIO m) => m Word32 optionErrorQuark = liftIO $ do result <- g_option_error_quark return result -- function g_on_error_stack_trace -- Args : [Arg {argCName = "prg_name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the program name, needed by gdb for the \"[S]tack trace\"\n option", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_on_error_stack_trace" g_on_error_stack_trace :: CString -> -- prg_name : TBasicType TUTF8 IO () {- | Invokes gdb, which attaches to the current process and shows a stack trace. Called by 'GI.GLib.Functions.onErrorQuery' when the \"[S]tack trace\" option is selected. You can get the current process\'s program name with 'GI.GLib.Functions.getPrgname', assuming that you have called @/gtk_init()/@ or @/gdk_init()/@. This function may cause different actions on non-UNIX platforms. -} onErrorStackTrace :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@prgName@/: the program name, needed by gdb for the \"[S]tack trace\" option -} -> m () onErrorStackTrace prgName = liftIO $ do prgName' <- textToCString prgName g_on_error_stack_trace prgName' freeMem prgName' return () -- function g_on_error_query -- Args : [Arg {argCName = "prg_name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the program name, needed by gdb for the \"[S]tack trace\"\n option. If @prg_name is %NULL, g_get_prgname() is called to get\n the program name (which will work correctly if gdk_init() or\n gtk_init() has been called)", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_on_error_query" g_on_error_query :: CString -> -- prg_name : TBasicType TUTF8 IO () {- | Prompts the user with @[E]xit, [H]alt, show [S]tack trace or [P]roceed@. This function is intended to be used for debugging use only. The following example shows how it can be used together with the @/g_log()/@ functions. === /C code/ > >#include <glib.h> > >static void >log_handler (const gchar *log_domain, > GLogLevelFlags log_level, > const gchar *message, > gpointer user_data) >{ > g_log_default_handler (log_domain, log_level, message, user_data); > > g_on_error_query (MY_PROGRAM_NAME); >} > >int >main (int argc, char *argv[]) >{ > g_log_set_handler (MY_LOG_DOMAIN, > G_LOG_LEVEL_WARNING | > G_LOG_LEVEL_ERROR | > G_LOG_LEVEL_CRITICAL, > log_handler, > NULL); > ... If \"[E]xit\" is selected, the application terminates with a call to _exit(0). If \"[S]tack\" trace is selected, 'GI.GLib.Functions.onErrorStackTrace' is called. This invokes gdb, which attaches to the current process and shows a stack trace. The prompt is then shown again. If \"[P]roceed\" is selected, the function returns. This function may cause different actions on non-UNIX platforms. -} onErrorQuery :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@prgName@/: the program name, needed by gdb for the \"[S]tack trace\" option. If /@prgName@/ is 'Nothing', 'GI.GLib.Functions.getPrgname' is called to get the program name (which will work correctly if @/gdk_init()/@ or @/gtk_init()/@ has been called) -} -> m () onErrorQuery prgName = liftIO $ do prgName' <- textToCString prgName g_on_error_query prgName' freeMem prgName' return () -- function g_number_parser_error_quark -- Args : [] -- Lengths : [] -- returnType : Just (TBasicType TUInt32) -- throws : False -- Skip return : False foreign import ccall "g_number_parser_error_quark" g_number_parser_error_quark :: IO Word32 {- | /No description available in the introspection data./ -} numberParserErrorQuark :: (B.CallStack.HasCallStack, MonadIO m) => m Word32 numberParserErrorQuark = liftIO $ do result <- g_number_parser_error_quark return result -- function g_nullify_pointer -- Args : [Arg {argCName = "nullify_location", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the memory address of the pointer.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_nullify_pointer" g_nullify_pointer :: Ptr () -> -- nullify_location : TBasicType TPtr IO () {- | Set the pointer at the specified location to 'Nothing'. -} nullifyPointer :: (B.CallStack.HasCallStack, MonadIO m) => Ptr () {- ^ /@nullifyLocation@/: the memory address of the pointer. -} -> m () nullifyPointer nullifyLocation = liftIO $ do g_nullify_pointer nullifyLocation return () -- function g_mkdir_with_parents -- Args : [Arg {argCName = "pathname", argType = TBasicType TFileName, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a pathname in the GLib file name encoding", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "mode", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "permissions to use for newly created directories", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TInt) -- throws : False -- Skip return : False foreign import ccall "g_mkdir_with_parents" g_mkdir_with_parents :: CString -> -- pathname : TBasicType TFileName Int32 -> -- mode : TBasicType TInt IO Int32 {- | Create a directory if it doesn\'t already exist. Create intermediate parent directories as needed, too. /Since: 2.8/ -} mkdirWithParents :: (B.CallStack.HasCallStack, MonadIO m) => [Char] {- ^ /@pathname@/: a pathname in the GLib file name encoding -} -> Int32 {- ^ /@mode@/: permissions to use for newly created directories -} -> m Int32 {- ^ __Returns:__ 0 if the directory already exists, or was successfully created. Returns -1 if an error occurred, with errno set. -} mkdirWithParents pathname mode = liftIO $ do pathname' <- stringToCString pathname result <- g_mkdir_with_parents pathname' mode freeMem pathname' return result -- function g_memdup -- Args : [Arg {argCName = "mem", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the memory to copy.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "byte_size", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the number of bytes to copy.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TPtr) -- throws : False -- Skip return : False foreign import ccall "g_memdup" g_memdup :: Ptr () -> -- mem : TBasicType TPtr Word32 -> -- byte_size : TBasicType TUInt IO (Ptr ()) {- | Allocates /@byteSize@/ bytes of memory, and copies /@byteSize@/ bytes into it from /@mem@/. If /@mem@/ is 'Nothing' it returns 'Nothing'. -} memdup :: (B.CallStack.HasCallStack, MonadIO m) => Ptr () {- ^ /@mem@/: the memory to copy. -} -> Word32 {- ^ /@byteSize@/: the number of bytes to copy. -} -> m (Ptr ()) {- ^ __Returns:__ a pointer to the newly-allocated copy of the memory, or 'Nothing' if /@mem@/ is 'Nothing'. -} memdup mem byteSize = liftIO $ do result <- g_memdup mem byteSize return result -- function g_mem_set_vtable -- Args : [Arg {argCName = "vtable", argType = TInterface (Name {namespace = "GLib", name = "MemVTable"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "table of memory allocation routines.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_mem_set_vtable" g_mem_set_vtable :: Ptr GLib.MemVTable.MemVTable -> -- vtable : TInterface (Name {namespace = "GLib", name = "MemVTable"}) IO () {-# DEPRECATED memSetVtable ["(Since version 2.46)","This function now does nothing. Use other memory","profiling tools instead"] #-} {- | This function used to let you override the memory allocation function. However, its use was incompatible with the use of global constructors in GLib and GIO, because those use the GLib allocators before main is reached. Therefore this function is now deprecated and is just a stub. -} memSetVtable :: (B.CallStack.HasCallStack, MonadIO m) => GLib.MemVTable.MemVTable {- ^ /@vtable@/: table of memory allocation routines. -} -> m () memSetVtable vtable = liftIO $ do vtable' <- unsafeManagedPtrGetPtr vtable g_mem_set_vtable vtable' touchManagedPtr vtable return () -- function g_mem_profile -- Args : [] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_mem_profile" g_mem_profile :: IO () {-# DEPRECATED memProfile ["(Since version 2.46)","Use other memory profiling tools instead"] #-} {- | GLib used to support some tools for memory profiling, but this no longer works. There are many other useful tools for memory profiling these days which can be used instead. -} memProfile :: (B.CallStack.HasCallStack, MonadIO m) => m () memProfile = liftIO $ do g_mem_profile return () -- function g_mem_is_system_malloc -- Args : [] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "g_mem_is_system_malloc" g_mem_is_system_malloc :: IO CInt {-# DEPRECATED memIsSystemMalloc ["(Since version 2.46)","GLib always uses the system malloc, so this function always","returns 'True'."] #-} {- | Checks whether the allocator used by 'GI.GLib.Functions.malloc' is the system\'s malloc implementation. If it returns 'True' memory allocated with @/malloc()/@ can be used interchangeable with memory allocated using 'GI.GLib.Functions.malloc'. This function is useful for avoiding an extra copy of allocated memory returned by a non-GLib-based API. -} memIsSystemMalloc :: (B.CallStack.HasCallStack, MonadIO m) => m Bool {- ^ __Returns:__ if 'True', @/malloc()/@ and 'GI.GLib.Functions.malloc' can be mixed. -} memIsSystemMalloc = liftIO $ do result <- g_mem_is_system_malloc let result' = (/= 0) result return result' -- function g_markup_escape_text -- Args : [Arg {argCName = "text", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "some valid UTF-8 text", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "length", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "length of @text in bytes, or -1 if the text is nul-terminated", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_markup_escape_text" g_markup_escape_text :: CString -> -- text : TBasicType TUTF8 Int64 -> -- length : TBasicType TInt64 IO CString {- | Escapes text so that the markup parser will parse it verbatim. Less than, greater than, ampersand, etc. are replaced with the corresponding entities. This function would typically be used when writing out a file to be parsed with the markup parser. Note that this function doesn\'t protect whitespace and line endings from being processed according to the XML rules for normalization of line endings and attribute values. Note also that this function will produce character references in the range of &@/x1/@; ... &@/x1f/@; for all control sequences except for tabstop, newline and carriage return. The character references in this range are not valid XML 1.0, but they are valid XML 1.1 and will be accepted by the GMarkup parser. -} markupEscapeText :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@text@/: some valid UTF-8 text -} -> Int64 {- ^ /@length@/: length of /@text@/ in bytes, or -1 if the text is nul-terminated -} -> m T.Text {- ^ __Returns:__ a newly allocated string with the escaped text -} markupEscapeText text length_ = liftIO $ do text' <- textToCString text result <- g_markup_escape_text text' length_ checkUnexpectedReturnNULL "markupEscapeText" result result' <- cstringToText result freeMem result freeMem text' return result' -- function g_markup_error_quark -- Args : [] -- Lengths : [] -- returnType : Just (TBasicType TUInt32) -- throws : False -- Skip return : False foreign import ccall "g_markup_error_quark" g_markup_error_quark :: IO Word32 {- | /No description available in the introspection data./ -} markupErrorQuark :: (B.CallStack.HasCallStack, MonadIO m) => m Word32 markupErrorQuark = liftIO $ do result <- g_markup_error_quark return result -- function g_malloc_n -- Args : [Arg {argCName = "n_blocks", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the number of blocks to allocate", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "n_block_bytes", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the size of each block in bytes", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TPtr) -- throws : False -- Skip return : False foreign import ccall "g_malloc_n" g_malloc_n :: Word64 -> -- n_blocks : TBasicType TUInt64 Word64 -> -- n_block_bytes : TBasicType TUInt64 IO (Ptr ()) {- | This function is similar to 'GI.GLib.Functions.malloc', allocating (/@nBlocks@/ * /@nBlockBytes@/) bytes, but care is taken to detect possible overflow during multiplication. /Since: 2.24/ -} mallocN :: (B.CallStack.HasCallStack, MonadIO m) => Word64 {- ^ /@nBlocks@/: the number of blocks to allocate -} -> Word64 {- ^ /@nBlockBytes@/: the size of each block in bytes -} -> m (Ptr ()) {- ^ __Returns:__ a pointer to the allocated memory -} mallocN nBlocks nBlockBytes = liftIO $ do result <- g_malloc_n nBlocks nBlockBytes return result -- function g_malloc0_n -- Args : [Arg {argCName = "n_blocks", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the number of blocks to allocate", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "n_block_bytes", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the size of each block in bytes", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TPtr) -- throws : False -- Skip return : False foreign import ccall "g_malloc0_n" g_malloc0_n :: Word64 -> -- n_blocks : TBasicType TUInt64 Word64 -> -- n_block_bytes : TBasicType TUInt64 IO (Ptr ()) {- | This function is similar to 'GI.GLib.Functions.malloc0', allocating (/@nBlocks@/ * /@nBlockBytes@/) bytes, but care is taken to detect possible overflow during multiplication. /Since: 2.24/ -} malloc0N :: (B.CallStack.HasCallStack, MonadIO m) => Word64 {- ^ /@nBlocks@/: the number of blocks to allocate -} -> Word64 {- ^ /@nBlockBytes@/: the size of each block in bytes -} -> m (Ptr ()) {- ^ __Returns:__ a pointer to the allocated memory -} malloc0N nBlocks nBlockBytes = liftIO $ do result <- g_malloc0_n nBlocks nBlockBytes return result -- function g_malloc0 -- Args : [Arg {argCName = "n_bytes", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the number of bytes to allocate", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TPtr) -- throws : False -- Skip return : False foreign import ccall "g_malloc0" g_malloc0 :: Word64 -> -- n_bytes : TBasicType TUInt64 IO (Ptr ()) {- | Allocates /@nBytes@/ bytes of memory, initialized to 0\'s. If /@nBytes@/ is 0 it returns 'Nothing'. -} malloc0 :: (B.CallStack.HasCallStack, MonadIO m) => Word64 {- ^ /@nBytes@/: the number of bytes to allocate -} -> m (Ptr ()) {- ^ __Returns:__ a pointer to the allocated memory -} malloc0 nBytes = liftIO $ do result <- g_malloc0 nBytes return result -- function g_malloc -- Args : [Arg {argCName = "n_bytes", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the number of bytes to allocate", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TPtr) -- throws : False -- Skip return : False foreign import ccall "g_malloc" g_malloc :: Word64 -> -- n_bytes : TBasicType TUInt64 IO (Ptr ()) {- | Allocates /@nBytes@/ bytes of memory. If /@nBytes@/ is 0 it returns 'Nothing'. -} malloc :: (B.CallStack.HasCallStack, MonadIO m) => Word64 {- ^ /@nBytes@/: the number of bytes to allocate -} -> m (Ptr ()) {- ^ __Returns:__ a pointer to the allocated memory -} malloc nBytes = liftIO $ do result <- g_malloc nBytes return result -- function g_main_depth -- Args : [] -- Lengths : [] -- returnType : Just (TBasicType TInt) -- throws : False -- Skip return : False foreign import ccall "g_main_depth" g_main_depth :: IO Int32 {- | Returns the depth of the stack of calls to 'GI.GLib.Structs.MainContext.mainContextDispatch' on any 'GI.GLib.Structs.MainContext.MainContext' in the current thread. That is, when called from the toplevel, it gives 0. When called from within a callback from 'GI.GLib.Structs.MainContext.mainContextIteration' (or 'GI.GLib.Structs.MainLoop.mainLoopRun', etc.) it returns 1. When called from within a callback to a recursive call to 'GI.GLib.Structs.MainContext.mainContextIteration', it returns 2. And so forth. This function is useful in a situation like the following: Imagine an extremely simple \"garbage collected\" system. === /C code/ > >static GList *free_list; > >gpointer >allocate_memory (gsize size) >{ > gpointer result = g_malloc (size); > free_list = g_list_prepend (free_list, result); > return result; >} > >void >free_allocated_memory (void) >{ > GList *l; > for (l = free_list; l; l = l->next); > g_free (l->data); > g_list_free (free_list); > free_list = NULL; > } > >[...] > >while (TRUE); > { > g_main_context_iteration (NULL, TRUE); > free_allocated_memory(); > } This works from an application, however, if you want to do the same thing from a library, it gets more difficult, since you no longer control the main loop. You might think you can simply use an idle function to make the call to @/free_allocated_memory()/@, but that doesn\'t work, since the idle function could be called from a recursive callback. This can be fixed by using 'GI.GLib.Functions.mainDepth' === /C code/ > >gpointer >allocate_memory (gsize size) >{ > FreeListBlock *block = g_new (FreeListBlock, 1); > block->mem = g_malloc (size); > block->depth = g_main_depth (); > free_list = g_list_prepend (free_list, block); > return block->mem; >} > >void >free_allocated_memory (void) >{ > GList *l; > > int depth = g_main_depth (); > for (l = free_list; l; ); > { > GList *next = l->next; > FreeListBlock *block = l->data; > if (block->depth > depth) > { > g_free (block->mem); > g_free (block); > free_list = g_list_delete_link (free_list, l); > } > > l = next; > } > } There is a temptation to use 'GI.GLib.Functions.mainDepth' to solve problems with reentrancy. For instance, while waiting for data to be received from the network in response to a menu item, the menu item might be selected again. It might seem that one could make the menu item\'s callback return immediately and do nothing if 'GI.GLib.Functions.mainDepth' returns a value greater than 1. However, this should be avoided since the user then sees selecting the menu item do nothing. Furthermore, you\'ll find yourself adding these checks all over your code, since there are doubtless many, many things that the user could do. Instead, you can use the following techniques: 1. Use @/gtk_widget_set_sensitive()/@ or modal dialogs to prevent the user from interacting with elements while the main loop is recursing. 2. Avoid main loop recursion in situations where you can\'t handle arbitrary callbacks. Instead, structure your code so that you simply return to the main loop and then get called again when there is more work to do. -} mainDepth :: (B.CallStack.HasCallStack, MonadIO m) => m Int32 {- ^ __Returns:__ The main loop recursion level in the current thread -} mainDepth = liftIO $ do result <- g_main_depth return result -- function g_main_current_source -- Args : [] -- Lengths : [] -- returnType : Just (TInterface (Name {namespace = "GLib", name = "Source"})) -- throws : False -- Skip return : False foreign import ccall "g_main_current_source" g_main_current_source :: IO (Ptr GLib.Source.Source) {- | Returns the currently firing source for this thread. /Since: 2.12/ -} mainCurrentSource :: (B.CallStack.HasCallStack, MonadIO m) => m GLib.Source.Source {- ^ __Returns:__ The currently firing source or 'Nothing'. -} mainCurrentSource = liftIO $ do result <- g_main_current_source checkUnexpectedReturnNULL "mainCurrentSource" result result' <- (newBoxed GLib.Source.Source) result return result' -- function g_log_writer_supports_color -- Args : [Arg {argCName = "output_fd", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "output file descriptor to check", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "g_log_writer_supports_color" g_log_writer_supports_color :: Int32 -> -- output_fd : TBasicType TInt IO CInt {- | Check whether the given /@outputFd@/ file descriptor supports ANSI color escape sequences. If so, they can safely be used when formatting log messages. /Since: 2.50/ -} logWriterSupportsColor :: (B.CallStack.HasCallStack, MonadIO m) => Int32 {- ^ /@outputFd@/: output file descriptor to check -} -> m Bool {- ^ __Returns:__ 'True' if ANSI color escapes are supported, 'False' otherwise -} logWriterSupportsColor outputFd = liftIO $ do result <- g_log_writer_supports_color outputFd let result' = (/= 0) result return result' -- function g_log_writer_standard_streams -- Args : [Arg {argCName = "log_level", argType = TInterface (Name {namespace = "GLib", name = "LogLevelFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "log level, either from #GLogLevelFlags, or a user-defined\n level", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "fields", argType = TCArray False (-1) 2 (TInterface (Name {namespace = "GLib", name = "LogField"})), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "key\8211value pairs of structured data forming\n the log message", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "n_fields", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "number of elements in the @fields array", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user data passed to g_log_set_writer_func()", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [Arg {argCName = "n_fields", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "number of elements in the @fields array", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- returnType : Just (TInterface (Name {namespace = "GLib", name = "LogWriterOutput"})) -- throws : False -- Skip return : False foreign import ccall "g_log_writer_standard_streams" g_log_writer_standard_streams :: CInt -> -- log_level : TInterface (Name {namespace = "GLib", name = "LogLevelFlags"}) Ptr GLib.LogField.LogField -> -- fields : TCArray False (-1) 2 (TInterface (Name {namespace = "GLib", name = "LogField"})) Word64 -> -- n_fields : TBasicType TUInt64 Ptr () -> -- user_data : TBasicType TPtr IO CUInt {- | Format a structured log message and print it to either @stdout@ or @stderr@, depending on its log level. 'GI.GLib.Flags.LogLevelFlagsLevelInfo' and 'GI.GLib.Flags.LogLevelFlagsLevelDebug' messages are sent to @stdout@; all other log levels are sent to @stderr@. Only fields which are understood by this function are included in the formatted string which is printed. If the output stream supports ANSI color escape sequences, they will be used in the output. A trailing new-line character is added to the log message when it is printed. This is suitable for use as a 'GI.GLib.Callbacks.LogWriterFunc'. /Since: 2.50/ -} logWriterStandardStreams :: (B.CallStack.HasCallStack, MonadIO m) => [GLib.Flags.LogLevelFlags] {- ^ /@logLevel@/: log level, either from 'GI.GLib.Flags.LogLevelFlags', or a user-defined level -} -> [GLib.LogField.LogField] {- ^ /@fields@/: key–value pairs of structured data forming the log message -} -> Ptr () {- ^ /@userData@/: user data passed to 'GI.GLib.Functions.logSetWriterFunc' -} -> m GLib.Enums.LogWriterOutput {- ^ __Returns:__ 'GI.GLib.Enums.LogWriterOutputHandled' on success, 'GI.GLib.Enums.LogWriterOutputUnhandled' otherwise -} logWriterStandardStreams logLevel fields userData = liftIO $ do let nFields = fromIntegral $ length fields let logLevel' = gflagsToWord logLevel fields' <- mapM unsafeManagedPtrGetPtr fields fields'' <- packBlockArray 24 fields' result <- g_log_writer_standard_streams logLevel' fields'' nFields userData let result' = (toEnum . fromIntegral) result mapM_ touchManagedPtr fields freeMem fields'' return result' -- function g_log_writer_journald -- Args : [Arg {argCName = "log_level", argType = TInterface (Name {namespace = "GLib", name = "LogLevelFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "log level, either from #GLogLevelFlags, or a user-defined\n level", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "fields", argType = TCArray False (-1) 2 (TInterface (Name {namespace = "GLib", name = "LogField"})), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "key\8211value pairs of structured data forming\n the log message", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "n_fields", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "number of elements in the @fields array", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user data passed to g_log_set_writer_func()", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [Arg {argCName = "n_fields", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "number of elements in the @fields array", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- returnType : Just (TInterface (Name {namespace = "GLib", name = "LogWriterOutput"})) -- throws : False -- Skip return : False foreign import ccall "g_log_writer_journald" g_log_writer_journald :: CInt -> -- log_level : TInterface (Name {namespace = "GLib", name = "LogLevelFlags"}) Ptr GLib.LogField.LogField -> -- fields : TCArray False (-1) 2 (TInterface (Name {namespace = "GLib", name = "LogField"})) Word64 -> -- n_fields : TBasicType TUInt64 Ptr () -> -- user_data : TBasicType TPtr IO CUInt {- | Format a structured log message and send it to the systemd journal as a set of key–value pairs. All fields are sent to the journal, but if a field has length zero (indicating program-specific data) then only its key will be sent. This is suitable for use as a 'GI.GLib.Callbacks.LogWriterFunc'. If GLib has been compiled without systemd support, this function is still defined, but will always return 'GI.GLib.Enums.LogWriterOutputUnhandled'. /Since: 2.50/ -} logWriterJournald :: (B.CallStack.HasCallStack, MonadIO m) => [GLib.Flags.LogLevelFlags] {- ^ /@logLevel@/: log level, either from 'GI.GLib.Flags.LogLevelFlags', or a user-defined level -} -> [GLib.LogField.LogField] {- ^ /@fields@/: key–value pairs of structured data forming the log message -} -> Ptr () {- ^ /@userData@/: user data passed to 'GI.GLib.Functions.logSetWriterFunc' -} -> m GLib.Enums.LogWriterOutput {- ^ __Returns:__ 'GI.GLib.Enums.LogWriterOutputHandled' on success, 'GI.GLib.Enums.LogWriterOutputUnhandled' otherwise -} logWriterJournald logLevel fields userData = liftIO $ do let nFields = fromIntegral $ length fields let logLevel' = gflagsToWord logLevel fields' <- mapM unsafeManagedPtrGetPtr fields fields'' <- packBlockArray 24 fields' result <- g_log_writer_journald logLevel' fields'' nFields userData let result' = (toEnum . fromIntegral) result mapM_ touchManagedPtr fields freeMem fields'' return result' -- function g_log_writer_is_journald -- Args : [Arg {argCName = "output_fd", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "output file descriptor to check", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "g_log_writer_is_journald" g_log_writer_is_journald :: Int32 -> -- output_fd : TBasicType TInt IO CInt {- | Check whether the given /@outputFd@/ file descriptor is a connection to the systemd journal, or something else (like a log file or @stdout@ or @stderr@). Invalid file descriptors are accepted and return 'False', which allows for the following construct without needing any additional error handling: === /C code/ > > is_journald = g_log_writer_is_journald (fileno (stderr)); /Since: 2.50/ -} logWriterIsJournald :: (B.CallStack.HasCallStack, MonadIO m) => Int32 {- ^ /@outputFd@/: output file descriptor to check -} -> m Bool {- ^ __Returns:__ 'True' if /@outputFd@/ points to the journal, 'False' otherwise -} logWriterIsJournald outputFd = liftIO $ do result <- g_log_writer_is_journald outputFd let result' = (/= 0) result return result' -- function g_log_writer_format_fields -- Args : [Arg {argCName = "log_level", argType = TInterface (Name {namespace = "GLib", name = "LogLevelFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "log level, either from #GLogLevelFlags, or a user-defined\n level", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "fields", argType = TCArray False (-1) 2 (TInterface (Name {namespace = "GLib", name = "LogField"})), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "key\8211value pairs of structured data forming\n the log message", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "n_fields", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "number of elements in the @fields array", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "use_color", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "%TRUE to use ANSI color escape sequences when formatting the\n message, %FALSE to not", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [Arg {argCName = "n_fields", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "number of elements in the @fields array", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_log_writer_format_fields" g_log_writer_format_fields :: CInt -> -- log_level : TInterface (Name {namespace = "GLib", name = "LogLevelFlags"}) Ptr GLib.LogField.LogField -> -- fields : TCArray False (-1) 2 (TInterface (Name {namespace = "GLib", name = "LogField"})) Word64 -> -- n_fields : TBasicType TUInt64 CInt -> -- use_color : TBasicType TBoolean IO CString {- | Format a structured log message as a string suitable for outputting to the terminal (or elsewhere). This will include the values of all fields it knows how to interpret, which includes @MESSAGE@ and @GLIB_DOMAIN@ (see the documentation for @/g_log_structured()/@). It does not include values from unknown fields. The returned string does **not** have a trailing new-line character. It is encoded in the character set of the current locale, which is not necessarily UTF-8. /Since: 2.50/ -} logWriterFormatFields :: (B.CallStack.HasCallStack, MonadIO m) => [GLib.Flags.LogLevelFlags] {- ^ /@logLevel@/: log level, either from 'GI.GLib.Flags.LogLevelFlags', or a user-defined level -} -> [GLib.LogField.LogField] {- ^ /@fields@/: key–value pairs of structured data forming the log message -} -> Bool {- ^ /@useColor@/: 'True' to use ANSI color escape sequences when formatting the message, 'False' to not -} -> m T.Text {- ^ __Returns:__ string containing the formatted log message, in the character set of the current locale -} logWriterFormatFields logLevel fields useColor = liftIO $ do let nFields = fromIntegral $ length fields let logLevel' = gflagsToWord logLevel fields' <- mapM unsafeManagedPtrGetPtr fields fields'' <- packBlockArray 24 fields' let useColor' = (fromIntegral . fromEnum) useColor result <- g_log_writer_format_fields logLevel' fields'' nFields useColor' checkUnexpectedReturnNULL "logWriterFormatFields" result result' <- cstringToText result freeMem result mapM_ touchManagedPtr fields freeMem fields'' return result' -- function g_log_writer_default -- Args : [Arg {argCName = "log_level", argType = TInterface (Name {namespace = "GLib", name = "LogLevelFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "log level, either from #GLogLevelFlags, or a user-defined\n level", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "fields", argType = TCArray False (-1) 2 (TInterface (Name {namespace = "GLib", name = "LogField"})), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "key\8211value pairs of structured data forming\n the log message", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "n_fields", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "number of elements in the @fields array", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user data passed to g_log_set_writer_func()", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [Arg {argCName = "n_fields", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "number of elements in the @fields array", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- returnType : Just (TInterface (Name {namespace = "GLib", name = "LogWriterOutput"})) -- throws : False -- Skip return : False foreign import ccall "g_log_writer_default" g_log_writer_default :: CInt -> -- log_level : TInterface (Name {namespace = "GLib", name = "LogLevelFlags"}) Ptr GLib.LogField.LogField -> -- fields : TCArray False (-1) 2 (TInterface (Name {namespace = "GLib", name = "LogField"})) Word64 -> -- n_fields : TBasicType TUInt64 Ptr () -> -- user_data : TBasicType TPtr IO CUInt {- | Format a structured log message and output it to the default log destination for the platform. On Linux, this is typically the systemd journal, falling back to @stdout@ or @stderr@ if running from the terminal or if output is being redirected to a file. Support for other platform-specific logging mechanisms may be added in future. Distributors of GLib may modify this function to impose their own (documented) platform-specific log writing policies. This is suitable for use as a 'GI.GLib.Callbacks.LogWriterFunc', and is the default writer used if no other is set using 'GI.GLib.Functions.logSetWriterFunc'. As with 'GI.GLib.Functions.logDefaultHandler', this function drops debug and informational messages unless their log domain (or @all@) is listed in the space-separated @G_MESSAGES_DEBUG@ environment variable. /Since: 2.50/ -} logWriterDefault :: (B.CallStack.HasCallStack, MonadIO m) => [GLib.Flags.LogLevelFlags] {- ^ /@logLevel@/: log level, either from 'GI.GLib.Flags.LogLevelFlags', or a user-defined level -} -> [GLib.LogField.LogField] {- ^ /@fields@/: key–value pairs of structured data forming the log message -} -> Ptr () {- ^ /@userData@/: user data passed to 'GI.GLib.Functions.logSetWriterFunc' -} -> m GLib.Enums.LogWriterOutput {- ^ __Returns:__ 'GI.GLib.Enums.LogWriterOutputHandled' on success, 'GI.GLib.Enums.LogWriterOutputUnhandled' otherwise -} logWriterDefault logLevel fields userData = liftIO $ do let nFields = fromIntegral $ length fields let logLevel' = gflagsToWord logLevel fields' <- mapM unsafeManagedPtrGetPtr fields fields'' <- packBlockArray 24 fields' result <- g_log_writer_default logLevel' fields'' nFields userData let result' = (toEnum . fromIntegral) result mapM_ touchManagedPtr fields freeMem fields'' return result' -- function g_log_variant -- Args : [Arg {argCName = "log_domain", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "log domain, usually %G_LOG_DOMAIN", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "log_level", argType = TInterface (Name {namespace = "GLib", name = "LogLevelFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "log level, either from #GLogLevelFlags, or a user-defined\n level", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "fields", argType = TVariant, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a dictionary (#GVariant of the type %G_VARIANT_TYPE_VARDICT)\ncontaining the key-value pairs of message data.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_log_variant" g_log_variant :: CString -> -- log_domain : TBasicType TUTF8 CInt -> -- log_level : TInterface (Name {namespace = "GLib", name = "LogLevelFlags"}) Ptr GVariant -> -- fields : TVariant IO () {- | Log a message with structured data, accepting the data within a 'GVariant'. This version is especially useful for use in other languages, via introspection. The only mandatory item in the /@fields@/ dictionary is the \"MESSAGE\" which must contain the text shown to the user. The values in the /@fields@/ dictionary are likely to be of type String (@/G_VARIANT_TYPE_STRING/@). Array of bytes (@/G_VARIANT_TYPE_BYTESTRING/@) is also supported. In this case the message is handled as binary and will be forwarded to the log writer as such. The size of the array should not be higher than @/G_MAXSSIZE/@. Otherwise it will be truncated to this size. For other types 'GI.GLib.Structs.Variant.variantPrint' will be used to convert the value into a string. For more details on its usage and about the parameters, see @/g_log_structured()/@. /Since: 2.50/ -} logVariant :: (B.CallStack.HasCallStack, MonadIO m) => Maybe (T.Text) {- ^ /@logDomain@/: log domain, usually 'GI.GLib.Constants.LOG_DOMAIN' -} -> [GLib.Flags.LogLevelFlags] {- ^ /@logLevel@/: log level, either from 'GI.GLib.Flags.LogLevelFlags', or a user-defined level -} -> GVariant {- ^ /@fields@/: a dictionary ('GVariant' of the type @/G_VARIANT_TYPE_VARDICT/@) containing the key-value pairs of message data. -} -> m () logVariant logDomain logLevel fields = liftIO $ do maybeLogDomain <- case logDomain of Nothing -> return nullPtr Just jLogDomain -> do jLogDomain' <- textToCString jLogDomain return jLogDomain' let logLevel' = gflagsToWord logLevel fields' <- unsafeManagedPtrGetPtr fields g_log_variant maybeLogDomain logLevel' fields' touchManagedPtr fields freeMem maybeLogDomain return () -- function g_log_structured_array -- Args : [Arg {argCName = "log_level", argType = TInterface (Name {namespace = "GLib", name = "LogLevelFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "log level, either from #GLogLevelFlags, or a user-defined\n level", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "fields", argType = TCArray False (-1) 2 (TInterface (Name {namespace = "GLib", name = "LogField"})), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "key\8211value pairs of structured data to add\n to the log message", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "n_fields", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "number of elements in the @fields array", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [Arg {argCName = "n_fields", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "number of elements in the @fields array", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_log_structured_array" g_log_structured_array :: CInt -> -- log_level : TInterface (Name {namespace = "GLib", name = "LogLevelFlags"}) Ptr GLib.LogField.LogField -> -- fields : TCArray False (-1) 2 (TInterface (Name {namespace = "GLib", name = "LogField"})) Word64 -> -- n_fields : TBasicType TUInt64 IO () {- | Log a message with structured data. The message will be passed through to the log writer set by the application using 'GI.GLib.Functions.logSetWriterFunc'. If the message is fatal (i.e. its log level is 'GI.GLib.Flags.LogLevelFlagsLevelError'), the program will be aborted at the end of this function. See @/g_log_structured()/@ for more documentation. This assumes that /@logLevel@/ is already present in /@fields@/ (typically as the @PRIORITY@ field). /Since: 2.50/ -} logStructuredArray :: (B.CallStack.HasCallStack, MonadIO m) => [GLib.Flags.LogLevelFlags] {- ^ /@logLevel@/: log level, either from 'GI.GLib.Flags.LogLevelFlags', or a user-defined level -} -> [GLib.LogField.LogField] {- ^ /@fields@/: key–value pairs of structured data to add to the log message -} -> m () logStructuredArray logLevel fields = liftIO $ do let nFields = fromIntegral $ length fields let logLevel' = gflagsToWord logLevel fields' <- mapM unsafeManagedPtrGetPtr fields fields'' <- packBlockArray 24 fields' g_log_structured_array logLevel' fields'' nFields mapM_ touchManagedPtr fields freeMem fields'' return () -- function g_log_set_writer_func -- XXX Could not generate function g_log_set_writer_func -- Error was : Bad introspection data: "Closure not found! Callable\n { returnType = Nothing\n , returnMayBeNull = False\n , returnTransfer = TransferNothing\n , returnDocumentation =\n Documentation { rawDocText = Nothing , sinceVersion = Nothing }\n , args =\n [ Arg\n { argCName = \"func\"\n , argType =\n TInterface Name { namespace = \"GLib\" , name = \"LogWriterFunc\" }\n , direction = DirectionIn\n , mayBeNull = True\n , argDoc =\n Documentation\n { rawDocText = Just \"log writer function, which must not be %NULL\"\n , sinceVersion = Nothing\n }\n , argScope = ScopeTypeNotified\n , argClosure = 1\n , argDestroy = 2\n , argCallerAllocates = False\n , transfer = TransferNothing\n }\n , Arg\n { argCName = \"user_data\"\n , argType = TBasicType TPtr\n , direction = DirectionIn\n , mayBeNull = True\n , argDoc =\n Documentation\n { rawDocText = Just \"user data to pass to @func\"\n , sinceVersion = Nothing\n }\n , argScope = ScopeTypeInvalid\n , argClosure = 0\n , argDestroy = -1\n , argCallerAllocates = False\n , transfer = TransferNothing\n }\n , Arg\n { argCName = \"user_data_free\"\n , argType =\n TInterface Name { namespace = \"GLib\" , name = \"DestroyNotify\" }\n , direction = DirectionIn\n , mayBeNull = False\n , argDoc =\n Documentation\n { rawDocText =\n Just\n \"function to free @user_data once it\\8217s\\n finished with, if non-%NULL\"\n , sinceVersion = Nothing\n }\n , argScope = ScopeTypeAsync\n , argClosure = -1\n , argDestroy = 0\n , argCallerAllocates = False\n , transfer = TransferNothing\n }\n ]\n , skipReturn = False\n , callableThrows = False\n , callableDeprecated = Nothing\n , callableDocumentation =\n Documentation\n { rawDocText =\n Just\n \"Set a writer function which will be called to format and write out each log\\nmessage. Each program should set a writer function, or the default writer\\n(g_log_writer_default()) will be used.\\n\\nLibraries **must not** call this function \\8212 only programs are allowed to\\ninstall a writer function, as there must be a single, central point where\\nlog messages are formatted and outputted.\\n\\nThere can only be one writer function. It is an error to set more than one.\"\n , sinceVersion = Just \"2.50\"\n }\n }\nfromList []\n1" -- function g_log_set_handler_full -- Args : [Arg {argCName = "log_domain", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the log domain, or %NULL for the default \"\"\n application domain", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "log_levels", argType = TInterface (Name {namespace = "GLib", name = "LogLevelFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the log levels to apply the log handler for.\n To handle fatal and recursive messages as well, combine\n the log levels with the #G_LOG_FLAG_FATAL and\n #G_LOG_FLAG_RECURSION bit flags.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "log_func", argType = TInterface (Name {namespace = "GLib", name = "LogFunc"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the log handler function", sinceVersion = Nothing}, argScope = ScopeTypeNotified, argClosure = 3, argDestroy = 4, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "data passed to the log handler", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "destroy", argType = TInterface (Name {namespace = "GLib", name = "DestroyNotify"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "destroy notify for @user_data, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUInt) -- throws : False -- Skip return : False foreign import ccall "g_log_set_handler_full" g_log_set_handler_full :: CString -> -- log_domain : TBasicType TUTF8 CInt -> -- log_levels : TInterface (Name {namespace = "GLib", name = "LogLevelFlags"}) FunPtr GLib.Callbacks.C_LogFunc -> -- log_func : TInterface (Name {namespace = "GLib", name = "LogFunc"}) Ptr () -> -- user_data : TBasicType TPtr FunPtr GLib.Callbacks.C_DestroyNotify -> -- destroy : TInterface (Name {namespace = "GLib", name = "DestroyNotify"}) IO Word32 {- | Like @/g_log_set_handler()/@, but takes a destroy notify for the /@userData@/. This has no effect if structured logging is enabled; see [Using Structured Logging][using-structured-logging]. /Since: 2.46/ -} logSetHandler :: (B.CallStack.HasCallStack, MonadIO m) => Maybe (T.Text) {- ^ /@logDomain@/: the log domain, or 'Nothing' for the default \"\" application domain -} -> [GLib.Flags.LogLevelFlags] {- ^ /@logLevels@/: the log levels to apply the log handler for. To handle fatal and recursive messages as well, combine the log levels with the @/G_LOG_FLAG_FATAL/@ and @/G_LOG_FLAG_RECURSION/@ bit flags. -} -> GLib.Callbacks.LogFunc {- ^ /@logFunc@/: the log handler function -} -> m Word32 {- ^ __Returns:__ the id of the new handler -} logSetHandler logDomain logLevels logFunc = liftIO $ do maybeLogDomain <- case logDomain of Nothing -> return nullPtr Just jLogDomain -> do jLogDomain' <- textToCString jLogDomain return jLogDomain' let logLevels' = gflagsToWord logLevels logFunc' <- GLib.Callbacks.mk_LogFunc (GLib.Callbacks.wrap_LogFunc Nothing (GLib.Callbacks.drop_closures_LogFunc logFunc)) let userData = castFunPtrToPtr logFunc' let destroy = safeFreeFunPtrPtr result <- g_log_set_handler_full maybeLogDomain logLevels' logFunc' userData destroy freeMem maybeLogDomain return result -- function g_log_set_fatal_mask -- Args : [Arg {argCName = "log_domain", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the log domain", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "fatal_mask", argType = TInterface (Name {namespace = "GLib", name = "LogLevelFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the new fatal mask", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TInterface (Name {namespace = "GLib", name = "LogLevelFlags"})) -- throws : False -- Skip return : False foreign import ccall "g_log_set_fatal_mask" g_log_set_fatal_mask :: CString -> -- log_domain : TBasicType TUTF8 CInt -> -- fatal_mask : TInterface (Name {namespace = "GLib", name = "LogLevelFlags"}) IO CInt {- | Sets the log levels which are fatal in the given domain. 'GI.GLib.Flags.LogLevelFlagsLevelError' is always fatal. This has no effect on structured log messages (using @/g_log_structured()/@ or 'GI.GLib.Functions.logStructuredArray'). To change the fatal behaviour for specific log messages, programs must install a custom log writer function using 'GI.GLib.Functions.logSetWriterFunc'. See [Using Structured Logging][using-structured-logging]. This function is mostly intended to be used with 'GI.GLib.Flags.LogLevelFlagsLevelCritical'. You should typically not set 'GI.GLib.Flags.LogLevelFlagsLevelWarning', 'GI.GLib.Flags.LogLevelFlagsLevelMessage', 'GI.GLib.Flags.LogLevelFlagsLevelInfo' or 'GI.GLib.Flags.LogLevelFlagsLevelDebug' as fatal except inside of test programs. -} logSetFatalMask :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@logDomain@/: the log domain -} -> [GLib.Flags.LogLevelFlags] {- ^ /@fatalMask@/: the new fatal mask -} -> m [GLib.Flags.LogLevelFlags] {- ^ __Returns:__ the old fatal mask for the log domain -} logSetFatalMask logDomain fatalMask = liftIO $ do logDomain' <- textToCString logDomain let fatalMask' = gflagsToWord fatalMask result <- g_log_set_fatal_mask logDomain' fatalMask' let result' = wordToGFlags result freeMem logDomain' return result' -- function g_log_set_always_fatal -- Args : [Arg {argCName = "fatal_mask", argType = TInterface (Name {namespace = "GLib", name = "LogLevelFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the mask containing bits set for each level\n of error which is to be fatal", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TInterface (Name {namespace = "GLib", name = "LogLevelFlags"})) -- throws : False -- Skip return : False foreign import ccall "g_log_set_always_fatal" g_log_set_always_fatal :: CInt -> -- fatal_mask : TInterface (Name {namespace = "GLib", name = "LogLevelFlags"}) IO CInt {- | Sets the message levels which are always fatal, in any log domain. When a message with any of these levels is logged the program terminates. You can only set the levels defined by GLib to be fatal. 'GI.GLib.Flags.LogLevelFlagsLevelError' is always fatal. You can also make some message levels fatal at runtime by setting the @G_DEBUG@ environment variable (see <http://developer.gnome.org/glib/stable/glib-running.html Running GLib Applications>). Libraries should not call this function, as it affects all messages logged by a process, including those from other libraries. Structured log messages (using @/g_log_structured()/@ and 'GI.GLib.Functions.logStructuredArray') are fatal only if the default log writer is used; otherwise it is up to the writer function to determine which log messages are fatal. See [Using Structured Logging][using-structured-logging]. -} logSetAlwaysFatal :: (B.CallStack.HasCallStack, MonadIO m) => [GLib.Flags.LogLevelFlags] {- ^ /@fatalMask@/: the mask containing bits set for each level of error which is to be fatal -} -> m [GLib.Flags.LogLevelFlags] {- ^ __Returns:__ the old fatal mask -} logSetAlwaysFatal fatalMask = liftIO $ do let fatalMask' = gflagsToWord fatalMask result <- g_log_set_always_fatal fatalMask' let result' = wordToGFlags result return result' -- function g_log_remove_handler -- Args : [Arg {argCName = "log_domain", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the log domain", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "handler_id", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the id of the handler, which was returned\n in g_log_set_handler()", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_log_remove_handler" g_log_remove_handler :: CString -> -- log_domain : TBasicType TUTF8 Word32 -> -- handler_id : TBasicType TUInt IO () {- | Removes the log handler. This has no effect if structured logging is enabled; see [Using Structured Logging][using-structured-logging]. -} logRemoveHandler :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@logDomain@/: the log domain -} -> Word32 {- ^ /@handlerId@/: the id of the handler, which was returned in @/g_log_set_handler()/@ -} -> m () logRemoveHandler logDomain handlerId = liftIO $ do logDomain' <- textToCString logDomain g_log_remove_handler logDomain' handlerId freeMem logDomain' return () -- function g_log_default_handler -- Args : [Arg {argCName = "log_domain", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the log domain of the message, or %NULL for the\ndefault \"\" application domain", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "log_level", argType = TInterface (Name {namespace = "GLib", name = "LogLevelFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the level of the message", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "message", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the message", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "unused_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "data passed from g_log() which is unused", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_log_default_handler" g_log_default_handler :: CString -> -- log_domain : TBasicType TUTF8 CInt -> -- log_level : TInterface (Name {namespace = "GLib", name = "LogLevelFlags"}) CString -> -- message : TBasicType TUTF8 Ptr () -> -- unused_data : TBasicType TPtr IO () {- | The default log handler set up by GLib; @/g_log_set_default_handler()/@ allows to install an alternate default log handler. This is used if no log handler has been set for the particular log domain and log level combination. It outputs the message to stderr or stdout and if the log level is fatal it calls @/G_BREAKPOINT()/@. It automatically prints a new-line character after the message, so one does not need to be manually included in /@message@/. The behavior of this log handler can be influenced by a number of environment variables: * @G_MESSAGES_PREFIXED@: A :-separated list of log levels for which messages should be prefixed by the program name and PID of the aplication. * @G_MESSAGES_DEBUG@: A space-separated list of log domains for which debug and informational messages are printed. By default these messages are not printed. stderr is used for levels 'GI.GLib.Flags.LogLevelFlagsLevelError', 'GI.GLib.Flags.LogLevelFlagsLevelCritical', 'GI.GLib.Flags.LogLevelFlagsLevelWarning' and 'GI.GLib.Flags.LogLevelFlagsLevelMessage'. stdout is used for the rest. This has no effect if structured logging is enabled; see [Using Structured Logging][using-structured-logging]. -} logDefaultHandler :: (B.CallStack.HasCallStack, MonadIO m) => Maybe (T.Text) {- ^ /@logDomain@/: the log domain of the message, or 'Nothing' for the default \"\" application domain -} -> [GLib.Flags.LogLevelFlags] {- ^ /@logLevel@/: the level of the message -} -> Maybe (T.Text) {- ^ /@message@/: the message -} -> Ptr () {- ^ /@unusedData@/: data passed from @/g_log()/@ which is unused -} -> m () logDefaultHandler logDomain logLevel message unusedData = liftIO $ do maybeLogDomain <- case logDomain of Nothing -> return nullPtr Just jLogDomain -> do jLogDomain' <- textToCString jLogDomain return jLogDomain' let logLevel' = gflagsToWord logLevel maybeMessage <- case message of Nothing -> return nullPtr Just jMessage -> do jMessage' <- textToCString jMessage return jMessage' g_log_default_handler maybeLogDomain logLevel' maybeMessage unusedData freeMem maybeLogDomain freeMem maybeMessage return () -- function g_locale_to_utf8 -- Args : [Arg {argCName = "opsysstring", argType = TCArray False (-1) 1 (TBasicType TUInt8), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a string in the\n encoding of the current locale. On Windows\n this means the system codepage.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "len", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the length of the string, or -1 if the string is\n nul-terminated (Note that some encodings may allow nul\n bytes to occur inside strings. In that case, using -1\n for the @len parameter is unsafe)", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "bytes_read", argType = TBasicType TUInt64, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "location to store the number of bytes in the\n input string that were successfully converted, or %NULL.\n Even if the conversion was successful, this may be\n less than @len if there were partial characters\n at the end of the input. If the error\n %G_CONVERT_ERROR_ILLEGAL_SEQUENCE occurs, the value\n stored will be the byte offset after the last valid\n input sequence.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "bytes_written", argType = TBasicType TUInt64, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the number of bytes stored in the output\n buffer (not including the terminating nul).", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}] -- Lengths : [Arg {argCName = "len", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the length of the string, or -1 if the string is\n nul-terminated (Note that some encodings may allow nul\n bytes to occur inside strings. In that case, using -1\n for the @len parameter is unsafe)", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- returnType : Just (TBasicType TUTF8) -- throws : True -- Skip return : False foreign import ccall "g_locale_to_utf8" g_locale_to_utf8 :: Ptr Word8 -> -- opsysstring : TCArray False (-1) 1 (TBasicType TUInt8) Int64 -> -- len : TBasicType TInt64 Ptr Word64 -> -- bytes_read : TBasicType TUInt64 Ptr Word64 -> -- bytes_written : TBasicType TUInt64 Ptr (Ptr GError) -> -- error IO CString {- | Converts a string which is in the encoding used for strings by the C runtime (usually the same as that used by the operating system) in the [current locale][setlocale] into a UTF-8 string. If the source encoding is not UTF-8 and the conversion output contains a nul character, the error 'GI.GLib.Enums.ConvertErrorEmbeddedNul' is set and the function returns 'Nothing'. If the source encoding is UTF-8, an embedded nul character is treated with the 'GI.GLib.Enums.ConvertErrorIllegalSequence' error for backward compatibility with earlier versions of this library. Use 'GI.GLib.Functions.convert' to produce output that may contain embedded nul characters. -} localeToUtf8 :: (B.CallStack.HasCallStack, MonadIO m) => ByteString {- ^ /@opsysstring@/: a string in the encoding of the current locale. On Windows this means the system codepage. -} -> m ((T.Text, Word64, Word64)) {- ^ __Returns:__ The converted string, or 'Nothing' on an error. /(Can throw 'Data.GI.Base.GError.GError')/ -} localeToUtf8 opsysstring = liftIO $ do let len = fromIntegral $ B.length opsysstring opsysstring' <- packByteString opsysstring bytesRead <- allocMem :: IO (Ptr Word64) bytesWritten <- allocMem :: IO (Ptr Word64) onException (do result <- propagateGError $ g_locale_to_utf8 opsysstring' len bytesRead bytesWritten checkUnexpectedReturnNULL "localeToUtf8" result result' <- cstringToText result freeMem result bytesRead' <- peek bytesRead bytesWritten' <- peek bytesWritten freeMem opsysstring' freeMem bytesRead freeMem bytesWritten return (result', bytesRead', bytesWritten') ) (do freeMem opsysstring' freeMem bytesRead freeMem bytesWritten ) -- function g_locale_from_utf8 -- Args : [Arg {argCName = "utf8string", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a UTF-8 encoded string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "len", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the length of the string, or -1 if the string is\n nul-terminated.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "bytes_read", argType = TBasicType TUInt64, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "location to store the number of bytes in the\n input string that were successfully converted, or %NULL.\n Even if the conversion was successful, this may be\n less than @len if there were partial characters\n at the end of the input. If the error\n %G_CONVERT_ERROR_ILLEGAL_SEQUENCE occurs, the value\n stored will be the byte offset after the last valid\n input sequence.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "bytes_written", argType = TBasicType TUInt64, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the number of bytes stored in the output\n buffer (not including the terminating nul).", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}] -- Lengths : [Arg {argCName = "bytes_written", argType = TBasicType TUInt64, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the number of bytes stored in the output\n buffer (not including the terminating nul).", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}] -- returnType : Just (TCArray False (-1) 3 (TBasicType TUInt8)) -- throws : True -- Skip return : False foreign import ccall "g_locale_from_utf8" g_locale_from_utf8 :: CString -> -- utf8string : TBasicType TUTF8 Int64 -> -- len : TBasicType TInt64 Ptr Word64 -> -- bytes_read : TBasicType TUInt64 Ptr Word64 -> -- bytes_written : TBasicType TUInt64 Ptr (Ptr GError) -> -- error IO (Ptr Word8) {- | Converts a string from UTF-8 to the encoding used for strings by the C runtime (usually the same as that used by the operating system) in the [current locale][setlocale]. On Windows this means the system codepage. The input string shall not contain nul characters even if the /@len@/ argument is positive. A nul character found inside the string will result in error 'GI.GLib.Enums.ConvertErrorIllegalSequence'. Use 'GI.GLib.Functions.convert' to convert input that may contain embedded nul characters. -} localeFromUtf8 :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@utf8string@/: a UTF-8 encoded string -} -> Int64 {- ^ /@len@/: the length of the string, or -1 if the string is nul-terminated. -} -> m ((ByteString, Word64)) {- ^ __Returns:__ A newly-allocated buffer containing the converted string, or 'Nothing' on an error, and error will be set. /(Can throw 'Data.GI.Base.GError.GError')/ -} localeFromUtf8 utf8string len = liftIO $ do utf8string' <- textToCString utf8string bytesRead <- allocMem :: IO (Ptr Word64) bytesWritten <- allocMem :: IO (Ptr Word64) onException (do result <- propagateGError $ g_locale_from_utf8 utf8string' len bytesRead bytesWritten bytesWritten' <- peek bytesWritten checkUnexpectedReturnNULL "localeFromUtf8" result result' <- (unpackByteStringWithLength bytesWritten') result freeMem result bytesRead' <- peek bytesRead freeMem utf8string' freeMem bytesRead freeMem bytesWritten return (result', bytesRead') ) (do freeMem utf8string' freeMem bytesRead freeMem bytesWritten ) -- function g_listenv -- Args : [] -- Lengths : [] -- returnType : Just (TCArray True (-1) (-1) (TBasicType TFileName)) -- throws : False -- Skip return : False foreign import ccall "g_listenv" g_listenv :: IO (Ptr CString) {- | Gets the names of all variables set in the environment. Programs that want to be portable to Windows should typically use this function and 'GI.GLib.Functions.getenv' instead of using the environ array from the C library directly. On Windows, the strings in the environ array are in system codepage encoding, while in most of the typical use cases for environment variables in GLib-using programs you want the UTF-8 encoding that this function and 'GI.GLib.Functions.getenv' provide. /Since: 2.8/ -} listenv :: (B.CallStack.HasCallStack, MonadIO m) => m [[Char]] {- ^ __Returns:__ a 'Nothing'-terminated list of strings which must be freed with 'GI.GLib.Functions.strfreev'. -} listenv = liftIO $ do result <- g_listenv checkUnexpectedReturnNULL "listenv" result result' <- unpackZeroTerminatedFileNameArray result mapZeroTerminatedCArray freeMem result freeMem result return result' -- function g_io_create_watch -- Args : [Arg {argCName = "channel", argType = TInterface (Name {namespace = "GLib", name = "IOChannel"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GIOChannel to watch", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "condition", argType = TInterface (Name {namespace = "GLib", name = "IOCondition"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "conditions to watch for", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TInterface (Name {namespace = "GLib", name = "Source"})) -- throws : False -- Skip return : False foreign import ccall "g_io_create_watch" g_io_create_watch :: Ptr GLib.IOChannel.IOChannel -> -- channel : TInterface (Name {namespace = "GLib", name = "IOChannel"}) CUInt -> -- condition : TInterface (Name {namespace = "GLib", name = "IOCondition"}) IO (Ptr GLib.Source.Source) {- | Creates a 'GI.GLib.Structs.Source.Source' that\'s dispatched when /@condition@/ is met for the given /@channel@/. For example, if condition is @/G_IO_IN/@, the source will be dispatched when there\'s data available for reading. @/g_io_add_watch()/@ is a simpler interface to this same functionality, for the case where you want to add the source to the default main loop context at the default priority. On Windows, polling a 'GI.GLib.Structs.Source.Source' created to watch a channel for a socket puts the socket in non-blocking mode. This is a side-effect of the implementation and unavoidable. -} ioCreateWatch :: (B.CallStack.HasCallStack, MonadIO m) => GLib.IOChannel.IOChannel {- ^ /@channel@/: a 'GI.GLib.Structs.IOChannel.IOChannel' to watch -} -> [GLib.Flags.IOCondition] {- ^ /@condition@/: conditions to watch for -} -> m GLib.Source.Source {- ^ __Returns:__ a new 'GI.GLib.Structs.Source.Source' -} ioCreateWatch channel condition = liftIO $ do channel' <- unsafeManagedPtrGetPtr channel let condition' = gflagsToWord condition result <- g_io_create_watch channel' condition' checkUnexpectedReturnNULL "ioCreateWatch" result result' <- (wrapBoxed GLib.Source.Source) result touchManagedPtr channel return result' -- function g_io_add_watch_full -- Args : [Arg {argCName = "channel", argType = TInterface (Name {namespace = "GLib", name = "IOChannel"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GIOChannel", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "priority", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the priority of the #GIOChannel source", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "condition", argType = TInterface (Name {namespace = "GLib", name = "IOCondition"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the condition to watch for", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "func", argType = TInterface (Name {namespace = "GLib", name = "IOFunc"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the function to call when the condition is satisfied", sinceVersion = Nothing}, argScope = ScopeTypeNotified, argClosure = 4, argDestroy = 5, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user data to pass to @func", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "notify", argType = TInterface (Name {namespace = "GLib", name = "DestroyNotify"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the function to call when the source is removed", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUInt) -- throws : False -- Skip return : False foreign import ccall "g_io_add_watch_full" g_io_add_watch_full :: Ptr GLib.IOChannel.IOChannel -> -- channel : TInterface (Name {namespace = "GLib", name = "IOChannel"}) Int32 -> -- priority : TBasicType TInt CUInt -> -- condition : TInterface (Name {namespace = "GLib", name = "IOCondition"}) FunPtr GLib.Callbacks.C_IOFunc -> -- func : TInterface (Name {namespace = "GLib", name = "IOFunc"}) Ptr () -> -- user_data : TBasicType TPtr FunPtr GLib.Callbacks.C_DestroyNotify -> -- notify : TInterface (Name {namespace = "GLib", name = "DestroyNotify"}) IO Word32 {- | Adds the 'GI.GLib.Structs.IOChannel.IOChannel' into the default main loop context with the given priority. This internally creates a main loop source using 'GI.GLib.Functions.ioCreateWatch' and attaches it to the main loop context with 'GI.GLib.Structs.Source.sourceAttach'. You can do these steps manually if you need greater control. -} ioAddWatch :: (B.CallStack.HasCallStack, MonadIO m) => GLib.IOChannel.IOChannel {- ^ /@channel@/: a 'GI.GLib.Structs.IOChannel.IOChannel' -} -> Int32 {- ^ /@priority@/: the priority of the 'GI.GLib.Structs.IOChannel.IOChannel' source -} -> [GLib.Flags.IOCondition] {- ^ /@condition@/: the condition to watch for -} -> GLib.Callbacks.IOFunc {- ^ /@func@/: the function to call when the condition is satisfied -} -> m Word32 {- ^ __Returns:__ the event source id -} ioAddWatch channel priority condition func = liftIO $ do channel' <- unsafeManagedPtrGetPtr channel let condition' = gflagsToWord condition func' <- GLib.Callbacks.mk_IOFunc (GLib.Callbacks.wrap_IOFunc Nothing func) let userData = castFunPtrToPtr func' let notify = safeFreeFunPtrPtr result <- g_io_add_watch_full channel' priority condition' func' userData notify touchManagedPtr channel return result -- function g_intern_string -- Args : [Arg {argCName = "string", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_intern_string" g_intern_string :: CString -> -- string : TBasicType TUTF8 IO CString {- | Returns a canonical representation for /@string@/. Interned strings can be compared for equality by comparing the pointers, instead of using @/strcmp()/@. /Since: 2.10/ -} internString :: (B.CallStack.HasCallStack, MonadIO m) => Maybe (T.Text) {- ^ /@string@/: a string -} -> m T.Text {- ^ __Returns:__ a canonical representation for the string -} internString string = liftIO $ do maybeString <- case string of Nothing -> return nullPtr Just jString -> do jString' <- textToCString jString return jString' result <- g_intern_string maybeString checkUnexpectedReturnNULL "internString" result result' <- cstringToText result freeMem maybeString return result' -- function g_intern_static_string -- Args : [Arg {argCName = "string", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a static string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_intern_static_string" g_intern_static_string :: CString -> -- string : TBasicType TUTF8 IO CString {- | Returns a canonical representation for /@string@/. Interned strings can be compared for equality by comparing the pointers, instead of using @/strcmp()/@. 'GI.GLib.Functions.internStaticString' does not copy the string, therefore /@string@/ must not be freed or modified. /Since: 2.10/ -} internStaticString :: (B.CallStack.HasCallStack, MonadIO m) => Maybe (T.Text) {- ^ /@string@/: a static string -} -> m T.Text {- ^ __Returns:__ a canonical representation for the string -} internStaticString string = liftIO $ do maybeString <- case string of Nothing -> return nullPtr Just jString -> do jString' <- textToCString jString return jString' result <- g_intern_static_string maybeString checkUnexpectedReturnNULL "internStaticString" result result' <- cstringToText result freeMem maybeString return result' -- function g_int_hash -- Args : [Arg {argCName = "v", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a pointer to a #gint key", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUInt) -- throws : False -- Skip return : False foreign import ccall "g_int_hash" g_int_hash :: Ptr () -> -- v : TBasicType TPtr IO Word32 {- | Converts a pointer to a @/gint/@ to a hash value. It can be passed to @/g_hash_table_new()/@ as the /@hashFunc@/ parameter, when using non-'Nothing' pointers to integer values as keys in a 'GI.GLib.Structs.HashTable.HashTable'. Note that this function acts on pointers to @/gint/@, not on @/gint/@ directly: if your hash table\'s keys are of the form @GINT_TO_POINTER (n)@, use 'GI.GLib.Functions.directHash' instead. -} intHash :: (B.CallStack.HasCallStack, MonadIO m) => Ptr () {- ^ /@v@/: a pointer to a @/gint/@ key -} -> m Word32 {- ^ __Returns:__ a hash value corresponding to the key. -} intHash v = liftIO $ do result <- g_int_hash v return result -- function g_int_equal -- Args : [Arg {argCName = "v1", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a pointer to a #gint key", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "v2", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a pointer to a #gint key to compare with @v1", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "g_int_equal" g_int_equal :: Ptr () -> -- v1 : TBasicType TPtr Ptr () -> -- v2 : TBasicType TPtr IO CInt {- | Compares the two @/gint/@ values being pointed to and returns 'True' if they are equal. It can be passed to @/g_hash_table_new()/@ as the /@keyEqualFunc@/ parameter, when using non-'Nothing' pointers to integers as keys in a 'GI.GLib.Structs.HashTable.HashTable'. Note that this function acts on pointers to @/gint/@, not on @/gint/@ directly: if your hash table\'s keys are of the form @GINT_TO_POINTER (n)@, use 'GI.GLib.Functions.directEqual' instead. -} intEqual :: (B.CallStack.HasCallStack, MonadIO m) => Ptr () {- ^ /@v1@/: a pointer to a @/gint/@ key -} -> Ptr () {- ^ /@v2@/: a pointer to a @/gint/@ key to compare with /@v1@/ -} -> m Bool {- ^ __Returns:__ 'True' if the two keys match. -} intEqual v1 v2 = liftIO $ do result <- g_int_equal v1 v2 let result' = (/= 0) result return result' -- function g_int64_hash -- Args : [Arg {argCName = "v", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a pointer to a #gint64 key", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUInt) -- throws : False -- Skip return : False foreign import ccall "g_int64_hash" g_int64_hash :: Ptr () -> -- v : TBasicType TPtr IO Word32 {- | Converts a pointer to a @/gint64/@ to a hash value. It can be passed to @/g_hash_table_new()/@ as the /@hashFunc@/ parameter, when using non-'Nothing' pointers to 64-bit integer values as keys in a 'GI.GLib.Structs.HashTable.HashTable'. /Since: 2.22/ -} int64Hash :: (B.CallStack.HasCallStack, MonadIO m) => Ptr () {- ^ /@v@/: a pointer to a @/gint64/@ key -} -> m Word32 {- ^ __Returns:__ a hash value corresponding to the key. -} int64Hash v = liftIO $ do result <- g_int64_hash v return result -- function g_int64_equal -- Args : [Arg {argCName = "v1", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a pointer to a #gint64 key", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "v2", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a pointer to a #gint64 key to compare with @v1", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "g_int64_equal" g_int64_equal :: Ptr () -> -- v1 : TBasicType TPtr Ptr () -> -- v2 : TBasicType TPtr IO CInt {- | Compares the two @/gint64/@ values being pointed to and returns 'True' if they are equal. It can be passed to @/g_hash_table_new()/@ as the /@keyEqualFunc@/ parameter, when using non-'Nothing' pointers to 64-bit integers as keys in a 'GI.GLib.Structs.HashTable.HashTable'. /Since: 2.22/ -} int64Equal :: (B.CallStack.HasCallStack, MonadIO m) => Ptr () {- ^ /@v1@/: a pointer to a @/gint64/@ key -} -> Ptr () {- ^ /@v2@/: a pointer to a @/gint64/@ key to compare with /@v1@/ -} -> m Bool {- ^ __Returns:__ 'True' if the two keys match. -} int64Equal v1 v2 = liftIO $ do result <- g_int64_equal v1 v2 let result' = (/= 0) result return result' -- function g_idle_source_new -- Args : [] -- Lengths : [] -- returnType : Just (TInterface (Name {namespace = "GLib", name = "Source"})) -- throws : False -- Skip return : False foreign import ccall "g_idle_source_new" g_idle_source_new :: IO (Ptr GLib.Source.Source) {- | Creates a new idle source. The source will not initially be associated with any 'GI.GLib.Structs.MainContext.MainContext' and must be added to one with 'GI.GLib.Structs.Source.sourceAttach' before it will be executed. Note that the default priority for idle sources is 'GI.GLib.Constants.PRIORITY_DEFAULT_IDLE', as compared to other sources which have a default priority of 'GI.GLib.Constants.PRIORITY_DEFAULT'. -} idleSourceNew :: (B.CallStack.HasCallStack, MonadIO m) => m GLib.Source.Source {- ^ __Returns:__ the newly-created idle source -} idleSourceNew = liftIO $ do result <- g_idle_source_new checkUnexpectedReturnNULL "idleSourceNew" result result' <- (wrapBoxed GLib.Source.Source) result return result' -- function g_idle_remove_by_data -- Args : [Arg {argCName = "data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the data for the idle source's callback.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "g_idle_remove_by_data" g_idle_remove_by_data :: Ptr () -> -- data : TBasicType TPtr IO CInt {- | Removes the idle function with the given data. -} idleRemoveByData :: (B.CallStack.HasCallStack, MonadIO m) => Ptr () {- ^ /@data@/: the data for the idle source\'s callback. -} -> m Bool {- ^ __Returns:__ 'True' if an idle source was found and removed. -} idleRemoveByData data_ = liftIO $ do result <- g_idle_remove_by_data data_ let result' = (/= 0) result return result' -- function g_idle_add_full -- Args : [Arg {argCName = "priority", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the priority of the idle source. Typically this will be in the\n range between #G_PRIORITY_DEFAULT_IDLE and #G_PRIORITY_HIGH_IDLE.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "function", argType = TInterface (Name {namespace = "GLib", name = "SourceFunc"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "function to call", sinceVersion = Nothing}, argScope = ScopeTypeNotified, argClosure = 2, argDestroy = 3, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "data to pass to @function", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "notify", argType = TInterface (Name {namespace = "GLib", name = "DestroyNotify"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "function to call when the idle is removed, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUInt) -- throws : False -- Skip return : False foreign import ccall "g_idle_add_full" g_idle_add_full :: Int32 -> -- priority : TBasicType TInt FunPtr GLib.Callbacks.C_SourceFunc -> -- function : TInterface (Name {namespace = "GLib", name = "SourceFunc"}) Ptr () -> -- data : TBasicType TPtr FunPtr GLib.Callbacks.C_DestroyNotify -> -- notify : TInterface (Name {namespace = "GLib", name = "DestroyNotify"}) IO Word32 {- | Adds a function to be called whenever there are no higher priority events pending. If the function returns 'False' it is automatically removed from the list of event sources and will not be called again. See [memory management of sources][mainloop-memory-management] for details on how to handle the return value and memory management of /@data@/. This internally creates a main loop source using 'GI.GLib.Functions.idleSourceNew' and attaches it to the global 'GI.GLib.Structs.MainContext.MainContext' using 'GI.GLib.Structs.Source.sourceAttach', so the callback will be invoked in whichever thread is running that main context. You can do these steps manually if you need greater control or to use a custom main context. -} idleAdd :: (B.CallStack.HasCallStack, MonadIO m) => Int32 {- ^ /@priority@/: the priority of the idle source. Typically this will be in the range between 'GI.GLib.Constants.PRIORITY_DEFAULT_IDLE' and 'GI.GLib.Constants.PRIORITY_HIGH_IDLE'. -} -> GLib.Callbacks.SourceFunc {- ^ /@function@/: function to call -} -> m Word32 {- ^ __Returns:__ the ID (greater than 0) of the event source. -} idleAdd priority function = liftIO $ do function' <- GLib.Callbacks.mk_SourceFunc (GLib.Callbacks.wrap_SourceFunc Nothing (GLib.Callbacks.drop_closures_SourceFunc function)) let data_ = castFunPtrToPtr function' let notify = safeFreeFunPtrPtr result <- g_idle_add_full priority function' data_ notify return result -- function g_hostname_to_unicode -- Args : [Arg {argCName = "hostname", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a valid UTF-8 or ASCII hostname", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_hostname_to_unicode" g_hostname_to_unicode :: CString -> -- hostname : TBasicType TUTF8 IO CString {- | Converts /@hostname@/ to its canonical presentation form; a UTF-8 string in Unicode normalization form C, containing no uppercase letters, no forbidden characters, and no ASCII-encoded segments, and not ending with a trailing dot. Of course if /@hostname@/ is not an internationalized hostname, then the canonical presentation form will be entirely ASCII. /Since: 2.22/ -} hostnameToUnicode :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@hostname@/: a valid UTF-8 or ASCII hostname -} -> m T.Text {- ^ __Returns:__ a UTF-8 hostname, which must be freed, or 'Nothing' if /@hostname@/ is in some way invalid. -} hostnameToUnicode hostname = liftIO $ do hostname' <- textToCString hostname result <- g_hostname_to_unicode hostname' checkUnexpectedReturnNULL "hostnameToUnicode" result result' <- cstringToText result freeMem result freeMem hostname' return result' -- function g_hostname_to_ascii -- Args : [Arg {argCName = "hostname", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a valid UTF-8 or ASCII hostname", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_hostname_to_ascii" g_hostname_to_ascii :: CString -> -- hostname : TBasicType TUTF8 IO CString {- | Converts /@hostname@/ to its canonical ASCII form; an ASCII-only string containing no uppercase letters and not ending with a trailing dot. /Since: 2.22/ -} hostnameToAscii :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@hostname@/: a valid UTF-8 or ASCII hostname -} -> m T.Text {- ^ __Returns:__ an ASCII hostname, which must be freed, or 'Nothing' if /@hostname@/ is in some way invalid. -} hostnameToAscii hostname = liftIO $ do hostname' <- textToCString hostname result <- g_hostname_to_ascii hostname' checkUnexpectedReturnNULL "hostnameToAscii" result result' <- cstringToText result freeMem result freeMem hostname' return result' -- function g_hostname_is_non_ascii -- Args : [Arg {argCName = "hostname", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a hostname", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "g_hostname_is_non_ascii" g_hostname_is_non_ascii :: CString -> -- hostname : TBasicType TUTF8 IO CInt {- | Tests if /@hostname@/ contains Unicode characters. If this returns 'True', you need to encode the hostname with 'GI.GLib.Functions.hostnameToAscii' before using it in non-IDN-aware contexts. Note that a hostname might contain a mix of encoded and unencoded segments, and so it is possible for 'GI.GLib.Functions.hostnameIsNonAscii' and 'GI.GLib.Functions.hostnameIsAsciiEncoded' to both return 'True' for a name. /Since: 2.22/ -} hostnameIsNonAscii :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@hostname@/: a hostname -} -> m Bool {- ^ __Returns:__ 'True' if /@hostname@/ contains any non-ASCII characters -} hostnameIsNonAscii hostname = liftIO $ do hostname' <- textToCString hostname result <- g_hostname_is_non_ascii hostname' let result' = (/= 0) result freeMem hostname' return result' -- function g_hostname_is_ip_address -- Args : [Arg {argCName = "hostname", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a hostname (or IP address in string form)", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "g_hostname_is_ip_address" g_hostname_is_ip_address :: CString -> -- hostname : TBasicType TUTF8 IO CInt {- | Tests if /@hostname@/ is the string form of an IPv4 or IPv6 address. (Eg, \"192.168.0.1\".) /Since: 2.22/ -} hostnameIsIpAddress :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@hostname@/: a hostname (or IP address in string form) -} -> m Bool {- ^ __Returns:__ 'True' if /@hostname@/ is an IP address -} hostnameIsIpAddress hostname = liftIO $ do hostname' <- textToCString hostname result <- g_hostname_is_ip_address hostname' let result' = (/= 0) result freeMem hostname' return result' -- function g_hostname_is_ascii_encoded -- Args : [Arg {argCName = "hostname", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a hostname", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "g_hostname_is_ascii_encoded" g_hostname_is_ascii_encoded :: CString -> -- hostname : TBasicType TUTF8 IO CInt {- | Tests if /@hostname@/ contains segments with an ASCII-compatible encoding of an Internationalized Domain Name. If this returns 'True', you should decode the hostname with 'GI.GLib.Functions.hostnameToUnicode' before displaying it to the user. Note that a hostname might contain a mix of encoded and unencoded segments, and so it is possible for 'GI.GLib.Functions.hostnameIsNonAscii' and 'GI.GLib.Functions.hostnameIsAsciiEncoded' to both return 'True' for a name. /Since: 2.22/ -} hostnameIsAsciiEncoded :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@hostname@/: a hostname -} -> m Bool {- ^ __Returns:__ 'True' if /@hostname@/ contains any ASCII-encoded segments. -} hostnameIsAsciiEncoded hostname = liftIO $ do hostname' <- textToCString hostname result <- g_hostname_is_ascii_encoded hostname' let result' = (/= 0) result freeMem hostname' return result' -- function g_getenv -- Args : [Arg {argCName = "variable", argType = TBasicType TFileName, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the environment variable to get", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TFileName) -- throws : False -- Skip return : False foreign import ccall "g_getenv" g_getenv :: CString -> -- variable : TBasicType TFileName IO CString {- | Returns the value of an environment variable. On UNIX, the name and value are byte strings which might or might not be in some consistent character set and encoding. On Windows, they are in UTF-8. On Windows, in case the environment variable\'s value contains references to other environment variables, they are expanded. -} getenv :: (B.CallStack.HasCallStack, MonadIO m) => [Char] {- ^ /@variable@/: the environment variable to get -} -> m [Char] {- ^ __Returns:__ the value of the environment variable, or 'Nothing' if the environment variable is not found. The returned string may be overwritten by the next call to 'GI.GLib.Functions.getenv', 'GI.GLib.Functions.setenv' or 'GI.GLib.Functions.unsetenv'. -} getenv variable = liftIO $ do variable' <- stringToCString variable result <- g_getenv variable' checkUnexpectedReturnNULL "getenv" result result' <- cstringToString result freeMem variable' return result' -- function g_get_user_special_dir -- Args : [Arg {argCName = "directory", argType = TInterface (Name {namespace = "GLib", name = "UserDirectory"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the logical id of special directory", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TFileName) -- throws : False -- Skip return : False foreign import ccall "g_get_user_special_dir" g_get_user_special_dir :: CUInt -> -- directory : TInterface (Name {namespace = "GLib", name = "UserDirectory"}) IO CString {- | Returns the full path of a special directory using its logical id. On UNIX this is done using the XDG special user directories. For compatibility with existing practise, 'GI.GLib.Enums.UserDirectoryDirectoryDesktop' falls back to @$HOME\/Desktop@ when XDG special user directories have not been set up. Depending on the platform, the user might be able to change the path of the special directory without requiring the session to restart; GLib will not reflect any change once the special directories are loaded. /Since: 2.14/ -} getUserSpecialDir :: (B.CallStack.HasCallStack, MonadIO m) => GLib.Enums.UserDirectory {- ^ /@directory@/: the logical id of special directory -} -> m [Char] {- ^ __Returns:__ the path to the specified special directory, or 'Nothing' if the logical id was not found. The returned string is owned by GLib and should not be modified or freed. -} getUserSpecialDir directory = liftIO $ do let directory' = (fromIntegral . fromEnum) directory result <- g_get_user_special_dir directory' checkUnexpectedReturnNULL "getUserSpecialDir" result result' <- cstringToString result return result' -- function g_get_user_runtime_dir -- Args : [] -- Lengths : [] -- returnType : Just (TBasicType TFileName) -- throws : False -- Skip return : False foreign import ccall "g_get_user_runtime_dir" g_get_user_runtime_dir :: IO CString {- | Returns a directory that is unique to the current user on the local system. This is determined using the mechanisms described in the <http://www.freedesktop.org/Standards/basedir-spec XDG Base Directory Specification>. This is the directory specified in the @XDG_RUNTIME_DIR@ environment variable. In the case that this variable is not set, we return the value of 'GI.GLib.Functions.getUserCacheDir', after verifying that it exists. /Since: 2.28/ -} getUserRuntimeDir :: (B.CallStack.HasCallStack, MonadIO m) => m [Char] {- ^ __Returns:__ a string owned by GLib that must not be modified or freed. -} getUserRuntimeDir = liftIO $ do result <- g_get_user_runtime_dir checkUnexpectedReturnNULL "getUserRuntimeDir" result result' <- cstringToString result return result' -- function g_get_user_name -- Args : [] -- Lengths : [] -- returnType : Just (TBasicType TFileName) -- throws : False -- Skip return : False foreign import ccall "g_get_user_name" g_get_user_name :: IO CString {- | Gets the user name of the current user. The encoding of the returned string is system-defined. On UNIX, it might be the preferred file name encoding, or something else, and there is no guarantee that it is even consistent on a machine. On Windows, it is always UTF-8. -} getUserName :: (B.CallStack.HasCallStack, MonadIO m) => m [Char] {- ^ __Returns:__ the user name of the current user. -} getUserName = liftIO $ do result <- g_get_user_name checkUnexpectedReturnNULL "getUserName" result result' <- cstringToString result return result' -- function g_get_user_data_dir -- Args : [] -- Lengths : [] -- returnType : Just (TBasicType TFileName) -- throws : False -- Skip return : False foreign import ccall "g_get_user_data_dir" g_get_user_data_dir :: IO CString {- | Returns a base directory in which to access application data such as icons that is customized for a particular user. On UNIX platforms this is determined using the mechanisms described in the <http://www.freedesktop.org/Standards/basedir-spec XDG Base Directory Specification>. In this case the directory retrieved will be @XDG_DATA_HOME@. On Windows it follows XDG Base Directory Specification if @XDG_DATA_HOME@ is defined. If @XDG_DATA_HOME@ is undefined, the folder to use for local (as opposed to roaming) application data is used instead. See the <https://msdn.microsoft.com/en-us/library/windows/desktop/bb762494%28v=vs.85%29.aspx#csidl_local_appdata documentation for `CSIDL_LOCAL_APPDATA`>. Note that in this case on Windows it will be the same as what 'GI.GLib.Functions.getUserConfigDir' returns. /Since: 2.6/ -} getUserDataDir :: (B.CallStack.HasCallStack, MonadIO m) => m [Char] {- ^ __Returns:__ a string owned by GLib that must not be modified or freed. -} getUserDataDir = liftIO $ do result <- g_get_user_data_dir checkUnexpectedReturnNULL "getUserDataDir" result result' <- cstringToString result return result' -- function g_get_user_config_dir -- Args : [] -- Lengths : [] -- returnType : Just (TBasicType TFileName) -- throws : False -- Skip return : False foreign import ccall "g_get_user_config_dir" g_get_user_config_dir :: IO CString {- | Returns a base directory in which to store user-specific application configuration information such as user preferences and settings. On UNIX platforms this is determined using the mechanisms described in the <http://www.freedesktop.org/Standards/basedir-spec XDG Base Directory Specification>. In this case the directory retrieved will be @XDG_CONFIG_HOME@. On Windows it follows XDG Base Directory Specification if @XDG_CONFIG_HOME@ is defined. If @XDG_CONFIG_HOME@ is undefined, the folder to use for local (as opposed to roaming) application data is used instead. See the <https://msdn.microsoft.com/en-us/library/windows/desktop/bb762494%28v=vs.85%29.aspx#csidl_local_appdata documentation for `CSIDL_LOCAL_APPDATA`>. Note that in this case on Windows it will be the same as what 'GI.GLib.Functions.getUserDataDir' returns. /Since: 2.6/ -} getUserConfigDir :: (B.CallStack.HasCallStack, MonadIO m) => m [Char] {- ^ __Returns:__ a string owned by GLib that must not be modified or freed. -} getUserConfigDir = liftIO $ do result <- g_get_user_config_dir checkUnexpectedReturnNULL "getUserConfigDir" result result' <- cstringToString result return result' -- function g_get_user_cache_dir -- Args : [] -- Lengths : [] -- returnType : Just (TBasicType TFileName) -- throws : False -- Skip return : False foreign import ccall "g_get_user_cache_dir" g_get_user_cache_dir :: IO CString {- | Returns a base directory in which to store non-essential, cached data specific to particular user. On UNIX platforms this is determined using the mechanisms described in the <http://www.freedesktop.org/Standards/basedir-spec XDG Base Directory Specification>. In this case the directory retrieved will be @XDG_CACHE_HOME@. On Windows it follows XDG Base Directory Specification if @XDG_CACHE_HOME@ is defined. If @XDG_CACHE_HOME@ is undefined, the directory that serves as a common repository for temporary Internet files is used instead. A typical path is @C:\\Documents and Settings\\username\\Local Settings\\Temporary Internet Files@. See the <https://msdn.microsoft.com/en-us/library/windows/desktop/bb762494%28v=vs.85%29.aspx#csidl_internet_cache documentation for `CSIDL_INTERNET_CACHE`>. /Since: 2.6/ -} getUserCacheDir :: (B.CallStack.HasCallStack, MonadIO m) => m [Char] {- ^ __Returns:__ a string owned by GLib that must not be modified or freed. -} getUserCacheDir = liftIO $ do result <- g_get_user_cache_dir checkUnexpectedReturnNULL "getUserCacheDir" result result' <- cstringToString result return result' -- function g_get_tmp_dir -- Args : [] -- Lengths : [] -- returnType : Just (TBasicType TFileName) -- throws : False -- Skip return : False foreign import ccall "g_get_tmp_dir" g_get_tmp_dir :: IO CString {- | Gets the directory to use for temporary files. On UNIX, this is taken from the @TMPDIR@ environment variable. If the variable is not set, @P_tmpdir@ is used, as defined by the system C library. Failing that, a hard-coded default of \"\/tmp\" is returned. On Windows, the @TEMP@ environment variable is used, with the root directory of the Windows installation (eg: \"C:\\\") used as a default. The encoding of the returned string is system-defined. On Windows, it is always UTF-8. The return value is never 'Nothing' or the empty string. -} getTmpDir :: (B.CallStack.HasCallStack, MonadIO m) => m [Char] {- ^ __Returns:__ the directory to use for temporary files. -} getTmpDir = liftIO $ do result <- g_get_tmp_dir checkUnexpectedReturnNULL "getTmpDir" result result' <- cstringToString result return result' -- function g_get_system_data_dirs -- Args : [] -- Lengths : [] -- returnType : Just (TCArray True (-1) (-1) (TBasicType TFileName)) -- throws : False -- Skip return : False foreign import ccall "g_get_system_data_dirs" g_get_system_data_dirs :: IO (Ptr CString) {- | Returns an ordered list of base directories in which to access system-wide application data. On UNIX platforms this is determined using the mechanisms described in the <http://www.freedesktop.org/Standards/basedir-spec XDG Base Directory Specification> In this case the list of directories retrieved will be @XDG_DATA_DIRS@. On Windows it follows XDG Base Directory Specification if @XDG_DATA_DIRS@ is defined. If @XDG_DATA_DIRS@ is undefined, the first elements in the list are the Application Data and Documents folders for All Users. (These can be determined only on Windows 2000 or later and are not present in the list on other Windows versions.) See documentation for CSIDL_COMMON_APPDATA and CSIDL_COMMON_DOCUMENTS. Then follows the \"share\" subfolder in the installation folder for the package containing the DLL that calls this function, if it can be determined. Finally the list contains the \"share\" subfolder in the installation folder for GLib, and in the installation folder for the package the application\'s .exe file belongs to. The installation folders above are determined by looking up the folder where the module (DLL or EXE) in question is located. If the folder\'s name is \"bin\", its parent is used, otherwise the folder itself. Note that on Windows the returned list can vary depending on where this function is called. /Since: 2.6/ -} getSystemDataDirs :: (B.CallStack.HasCallStack, MonadIO m) => m [[Char]] {- ^ __Returns:__ a 'Nothing'-terminated array of strings owned by GLib that must not be modified or freed. -} getSystemDataDirs = liftIO $ do result <- g_get_system_data_dirs checkUnexpectedReturnNULL "getSystemDataDirs" result result' <- unpackZeroTerminatedFileNameArray result return result' -- function g_get_system_config_dirs -- Args : [] -- Lengths : [] -- returnType : Just (TCArray True (-1) (-1) (TBasicType TFileName)) -- throws : False -- Skip return : False foreign import ccall "g_get_system_config_dirs" g_get_system_config_dirs :: IO (Ptr CString) {- | Returns an ordered list of base directories in which to access system-wide configuration information. On UNIX platforms this is determined using the mechanisms described in the <http://www.freedesktop.org/Standards/basedir-spec XDG Base Directory Specification>. In this case the list of directories retrieved will be @XDG_CONFIG_DIRS@. On Windows it follows XDG Base Directory Specification if @XDG_CONFIG_DIRS@ is defined. If @XDG_CONFIG_DIRS@ is undefined, the directory that contains application data for all users is used instead. A typical path is @C:\\Documents and Settings\\All Users\\Application Data@. This folder is used for application data that is not user specific. For example, an application can store a spell-check dictionary, a database of clip art, or a log file in the CSIDL_COMMON_APPDATA folder. This information will not roam and is available to anyone using the computer. /Since: 2.6/ -} getSystemConfigDirs :: (B.CallStack.HasCallStack, MonadIO m) => m [[Char]] {- ^ __Returns:__ a 'Nothing'-terminated array of strings owned by GLib that must not be modified or freed. -} getSystemConfigDirs = liftIO $ do result <- g_get_system_config_dirs checkUnexpectedReturnNULL "getSystemConfigDirs" result result' <- unpackZeroTerminatedFileNameArray result return result' -- function g_get_real_time -- Args : [] -- Lengths : [] -- returnType : Just (TBasicType TInt64) -- throws : False -- Skip return : False foreign import ccall "g_get_real_time" g_get_real_time :: IO Int64 {- | Queries the system wall-clock time. This call is functionally equivalent to 'GI.GLib.Functions.getCurrentTime' except that the return value is often more convenient than dealing with a 'GI.GLib.Structs.TimeVal.TimeVal'. You should only use this call if you are actually interested in the real wall-clock time. 'GI.GLib.Functions.getMonotonicTime' is probably more useful for measuring intervals. /Since: 2.28/ -} getRealTime :: (B.CallStack.HasCallStack, MonadIO m) => m Int64 {- ^ __Returns:__ the number of microseconds since January 1, 1970 UTC. -} getRealTime = liftIO $ do result <- g_get_real_time return result -- function g_get_real_name -- Args : [] -- Lengths : [] -- returnType : Just (TBasicType TFileName) -- throws : False -- Skip return : False foreign import ccall "g_get_real_name" g_get_real_name :: IO CString {- | Gets the real name of the user. This usually comes from the user\'s entry in the @passwd@ file. The encoding of the returned string is system-defined. (On Windows, it is, however, always UTF-8.) If the real user name cannot be determined, the string \"Unknown\" is returned. -} getRealName :: (B.CallStack.HasCallStack, MonadIO m) => m [Char] {- ^ __Returns:__ the user\'s real name. -} getRealName = liftIO $ do result <- g_get_real_name checkUnexpectedReturnNULL "getRealName" result result' <- cstringToString result return result' -- function g_get_prgname -- Args : [] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_get_prgname" g_get_prgname :: IO CString {- | Gets the name of the program. This name should not be localized, in contrast to 'GI.GLib.Functions.getApplicationName'. If you are using @/GApplication/@ the program name is set in @/g_application_run()/@. In case of GDK or GTK+ it is set in @/gdk_init()/@, which is called by @/gtk_init()/@ and the @/GtkApplication::startup/@ handler. The program name is found by taking the last component of /@argv@/[0]. -} getPrgname :: (B.CallStack.HasCallStack, MonadIO m) => m T.Text {- ^ __Returns:__ the name of the program. The returned string belongs to GLib and must not be modified or freed. -} getPrgname = liftIO $ do result <- g_get_prgname checkUnexpectedReturnNULL "getPrgname" result result' <- cstringToText result return result' -- function g_get_num_processors -- Args : [] -- Lengths : [] -- returnType : Just (TBasicType TUInt) -- throws : False -- Skip return : False foreign import ccall "g_get_num_processors" g_get_num_processors :: IO Word32 {- | Determine the approximate number of threads that the system will schedule simultaneously for this process. This is intended to be used as a parameter to @/g_thread_pool_new()/@ for CPU bound tasks and similar cases. /Since: 2.36/ -} getNumProcessors :: (B.CallStack.HasCallStack, MonadIO m) => m Word32 {- ^ __Returns:__ Number of schedulable threads, always greater than 0 -} getNumProcessors = liftIO $ do result <- g_get_num_processors return result -- function g_get_monotonic_time -- Args : [] -- Lengths : [] -- returnType : Just (TBasicType TInt64) -- throws : False -- Skip return : False foreign import ccall "g_get_monotonic_time" g_get_monotonic_time :: IO Int64 {- | Queries the system monotonic time. The monotonic clock will always increase and doesn\'t suffer discontinuities when the user (or NTP) changes the system time. It may or may not continue to tick during times where the machine is suspended. We try to use the clock that corresponds as closely as possible to the passage of time as measured by system calls such as @/poll()/@ but it may not always be possible to do this. /Since: 2.28/ -} getMonotonicTime :: (B.CallStack.HasCallStack, MonadIO m) => m Int64 {- ^ __Returns:__ the monotonic time, in microseconds -} getMonotonicTime = liftIO $ do result <- g_get_monotonic_time return result -- function g_get_locale_variants -- Args : [Arg {argCName = "locale", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a locale identifier", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TCArray True (-1) (-1) (TBasicType TUTF8)) -- throws : False -- Skip return : False foreign import ccall "g_get_locale_variants" g_get_locale_variants :: CString -> -- locale : TBasicType TUTF8 IO (Ptr CString) {- | Returns a list of derived variants of /@locale@/, which can be used to e.g. construct locale-dependent filenames or search paths. The returned list is sorted from most desirable to least desirable. This function handles territory, charset and extra locale modifiers. For example, if /@locale@/ is \"fr_BE\", then the returned list is \"fr_BE\", \"fr\". If you need the list of variants for the current locale, use 'GI.GLib.Functions.getLanguageNames'. /Since: 2.28/ -} getLocaleVariants :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@locale@/: a locale identifier -} -> m [T.Text] {- ^ __Returns:__ a newly allocated array of newly allocated strings with the locale variants. Free with 'GI.GLib.Functions.strfreev'. -} getLocaleVariants locale = liftIO $ do locale' <- textToCString locale result <- g_get_locale_variants locale' checkUnexpectedReturnNULL "getLocaleVariants" result result' <- unpackZeroTerminatedUTF8CArray result mapZeroTerminatedCArray freeMem result freeMem result freeMem locale' return result' -- function g_get_language_names_with_category -- Args : [Arg {argCName = "category_name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a locale category name", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TCArray True (-1) (-1) (TBasicType TUTF8)) -- throws : False -- Skip return : False foreign import ccall "g_get_language_names_with_category" g_get_language_names_with_category :: CString -> -- category_name : TBasicType TUTF8 IO (Ptr CString) {- | Computes a list of applicable locale names with a locale category name, which can be used to construct the fallback locale-dependent filenames or search paths. The returned list is sorted from most desirable to least desirable and always contains the default locale \"C\". This function consults the environment variables @LANGUAGE@, @LC_ALL@, /@categoryName@/, and @LANG@ to find the list of locales specified by the user. 'GI.GLib.Functions.getLanguageNames' returns g_get_language_names_with_category(\"LC_MESSAGES\"). /Since: 2.58/ -} getLanguageNamesWithCategory :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@categoryName@/: a locale category name -} -> m [T.Text] {- ^ __Returns:__ a 'Nothing'-terminated array of strings owned by the thread g_get_language_names_with_category was called from. It must not be modified or freed. It must be copied if planned to be used in another thread. -} getLanguageNamesWithCategory categoryName = liftIO $ do categoryName' <- textToCString categoryName result <- g_get_language_names_with_category categoryName' checkUnexpectedReturnNULL "getLanguageNamesWithCategory" result result' <- unpackZeroTerminatedUTF8CArray result freeMem categoryName' return result' -- function g_get_language_names -- Args : [] -- Lengths : [] -- returnType : Just (TCArray True (-1) (-1) (TBasicType TUTF8)) -- throws : False -- Skip return : False foreign import ccall "g_get_language_names" g_get_language_names :: IO (Ptr CString) {- | Computes a list of applicable locale names, which can be used to e.g. construct locale-dependent filenames or search paths. The returned list is sorted from most desirable to least desirable and always contains the default locale \"C\". For example, if LANGUAGE=de:en_US, then the returned list is \"de\", \"en_US\", \"en\", \"C\". This function consults the environment variables @LANGUAGE@, @LC_ALL@, @LC_MESSAGES@ and @LANG@ to find the list of locales specified by the user. /Since: 2.6/ -} getLanguageNames :: (B.CallStack.HasCallStack, MonadIO m) => m [T.Text] {- ^ __Returns:__ a 'Nothing'-terminated array of strings owned by GLib that must not be modified or freed. -} getLanguageNames = liftIO $ do result <- g_get_language_names checkUnexpectedReturnNULL "getLanguageNames" result result' <- unpackZeroTerminatedUTF8CArray result return result' -- function g_get_host_name -- Args : [] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_get_host_name" g_get_host_name :: IO CString {- | Return a name for the machine. The returned name is not necessarily a fully-qualified domain name, or even present in DNS or some other name service at all. It need not even be unique on your local network or site, but usually it is. Callers should not rely on the return value having any specific properties like uniqueness for security purposes. Even if the name of the machine is changed while an application is running, the return value from this function does not change. The returned string is owned by GLib and should not be modified or freed. If no name can be determined, a default fixed string \"localhost\" is returned. The encoding of the returned string is UTF-8. /Since: 2.8/ -} getHostName :: (B.CallStack.HasCallStack, MonadIO m) => m T.Text {- ^ __Returns:__ the host name of the machine. -} getHostName = liftIO $ do result <- g_get_host_name checkUnexpectedReturnNULL "getHostName" result result' <- cstringToText result return result' -- function g_get_home_dir -- Args : [] -- Lengths : [] -- returnType : Just (TBasicType TFileName) -- throws : False -- Skip return : False foreign import ccall "g_get_home_dir" g_get_home_dir :: IO CString {- | Gets the current user\'s home directory. As with most UNIX tools, this function will return the value of the @HOME@ environment variable if it is set to an existing absolute path name, falling back to the @passwd@ file in the case that it is unset. If the path given in @HOME@ is non-absolute, does not exist, or is not a directory, the result is undefined. Before version 2.36 this function would ignore the @HOME@ environment variable, taking the value from the @passwd@ database instead. This was changed to increase the compatibility of GLib with other programs (and the XDG basedir specification) and to increase testability of programs based on GLib (by making it easier to run them from test frameworks). If your program has a strong requirement for either the new or the old behaviour (and if you don\'t wish to increase your GLib dependency to ensure that the new behaviour is in effect) then you should either directly check the @HOME@ environment variable yourself or unset it before calling any functions in GLib. -} getHomeDir :: (B.CallStack.HasCallStack, MonadIO m) => m [Char] {- ^ __Returns:__ the current user\'s home directory -} getHomeDir = liftIO $ do result <- g_get_home_dir checkUnexpectedReturnNULL "getHomeDir" result result' <- cstringToString result return result' -- function g_get_filename_charsets -- Args : [Arg {argCName = "filename_charsets", argType = TCArray True (-1) (-1) (TBasicType TUTF8), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "\n return location for the %NULL-terminated list of encoding names", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "g_get_filename_charsets" g_get_filename_charsets :: Ptr (Ptr CString) -> -- filename_charsets : TCArray True (-1) (-1) (TBasicType TUTF8) IO CInt {- | Determines the preferred character sets used for filenames. The first character set from the /@charsets@/ is the filename encoding, the subsequent character sets are used when trying to generate a displayable representation of a filename, see 'GI.GLib.Functions.filenameDisplayName'. On Unix, the character sets are determined by consulting the environment variables @G_FILENAME_ENCODING@ and @G_BROKEN_FILENAMES@. On Windows, the character set used in the GLib API is always UTF-8 and said environment variables have no effect. @G_FILENAME_ENCODING@ may be set to a comma-separated list of character set names. The special token \"\@locale\" is taken to mean the character set for the [current locale][setlocale]. If @G_FILENAME_ENCODING@ is not set, but @G_BROKEN_FILENAMES@ is, the character set of the current locale is taken as the filename encoding. If neither environment variable is set, UTF-8 is taken as the filename encoding, but the character set of the current locale is also put in the list of encodings. The returned /@charsets@/ belong to GLib and must not be freed. Note that on Unix, regardless of the locale character set or @G_FILENAME_ENCODING@ value, the actual file names present on a system might be in any random encoding or just gibberish. /Since: 2.6/ -} getFilenameCharsets :: (B.CallStack.HasCallStack, MonadIO m) => m ((Bool, [T.Text])) {- ^ __Returns:__ 'True' if the filename encoding is UTF-8. -} getFilenameCharsets = liftIO $ do filenameCharsets <- allocMem :: IO (Ptr (Ptr CString)) result <- g_get_filename_charsets filenameCharsets let result' = (/= 0) result filenameCharsets' <- peek filenameCharsets filenameCharsets'' <- unpackZeroTerminatedUTF8CArray filenameCharsets' freeMem filenameCharsets return (result', filenameCharsets'') -- function g_get_environ -- Args : [] -- Lengths : [] -- returnType : Just (TCArray True (-1) (-1) (TBasicType TFileName)) -- throws : False -- Skip return : False foreign import ccall "g_get_environ" g_get_environ :: IO (Ptr CString) {- | Gets the list of environment variables for the current process. The list is 'Nothing' terminated and each item in the list is of the form \'NAME=VALUE\'. This is equivalent to direct access to the \'environ\' global variable, except portable. The return value is freshly allocated and it should be freed with 'GI.GLib.Functions.strfreev' when it is no longer needed. /Since: 2.28/ -} getEnviron :: (B.CallStack.HasCallStack, MonadIO m) => m [[Char]] {- ^ __Returns:__ the list of environment variables -} getEnviron = liftIO $ do result <- g_get_environ checkUnexpectedReturnNULL "getEnviron" result result' <- unpackZeroTerminatedFileNameArray result mapZeroTerminatedCArray freeMem result freeMem result return result' -- function g_get_current_time -- Args : [Arg {argCName = "result", argType = TInterface (Name {namespace = "GLib", name = "TimeVal"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "#GTimeVal structure in which to store current time.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_get_current_time" g_get_current_time :: Ptr GLib.TimeVal.TimeVal -> -- result : TInterface (Name {namespace = "GLib", name = "TimeVal"}) IO () {- | Equivalent to the UNIX @/gettimeofday()/@ function, but portable. You may find 'GI.GLib.Functions.getRealTime' to be more convenient. -} getCurrentTime :: (B.CallStack.HasCallStack, MonadIO m) => GLib.TimeVal.TimeVal {- ^ /@result@/: 'GI.GLib.Structs.TimeVal.TimeVal' structure in which to store current time. -} -> m () getCurrentTime result_ = liftIO $ do result_' <- unsafeManagedPtrGetPtr result_ g_get_current_time result_' touchManagedPtr result_ return () -- function g_get_current_dir -- Args : [] -- Lengths : [] -- returnType : Just (TBasicType TFileName) -- throws : False -- Skip return : False foreign import ccall "g_get_current_dir" g_get_current_dir :: IO CString {- | Gets the current directory. The returned string should be freed when no longer needed. The encoding of the returned string is system defined. On Windows, it is always UTF-8. Since GLib 2.40, this function will return the value of the \"PWD\" environment variable if it is set and it happens to be the same as the current directory. This can make a difference in the case that the current directory is the target of a symbolic link. -} getCurrentDir :: (B.CallStack.HasCallStack, MonadIO m) => m [Char] {- ^ __Returns:__ the current directory -} getCurrentDir = liftIO $ do result <- g_get_current_dir checkUnexpectedReturnNULL "getCurrentDir" result result' <- cstringToString result freeMem result return result' -- function g_get_codeset -- Args : [] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_get_codeset" g_get_codeset :: IO CString {- | Gets the character set for the current locale. -} getCodeset :: (B.CallStack.HasCallStack, MonadIO m) => m T.Text {- ^ __Returns:__ a newly allocated string containing the name of the character set. This string must be freed with 'GI.GLib.Functions.free'. -} getCodeset = liftIO $ do result <- g_get_codeset checkUnexpectedReturnNULL "getCodeset" result result' <- cstringToText result freeMem result return result' -- function g_get_charset -- Args : [Arg {argCName = "charset", argType = TBasicType TUTF8, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "return location for character set\n name, or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "g_get_charset" g_get_charset :: Ptr CString -> -- charset : TBasicType TUTF8 IO CInt {- | Obtains the character set for the [current locale][setlocale]; you might use this character set as an argument to 'GI.GLib.Functions.convert', to convert from the current locale\'s encoding to some other encoding. (Frequently 'GI.GLib.Functions.localeToUtf8' and 'GI.GLib.Functions.localeFromUtf8' are nice shortcuts, though.) On Windows the character set returned by this function is the so-called system default ANSI code-page. That is the character set used by the \"narrow\" versions of C library and Win32 functions that handle file names. It might be different from the character set used by the C library\'s current locale. On Linux, the character set is found by consulting @/nl_langinfo()/@ if available. If not, the environment variables @LC_ALL@, @LC_CTYPE@, @LANG@ and @CHARSET@ are queried in order. The return value is 'True' if the locale\'s encoding is UTF-8, in that case you can perhaps avoid calling 'GI.GLib.Functions.convert'. The string returned in /@charset@/ is not allocated, and should not be freed. -} getCharset :: (B.CallStack.HasCallStack, MonadIO m) => m ((Bool, T.Text)) {- ^ __Returns:__ 'True' if the returned charset is UTF-8 -} getCharset = liftIO $ do charset <- allocMem :: IO (Ptr CString) result <- g_get_charset charset let result' = (/= 0) result charset' <- peek charset charset'' <- cstringToText charset' freeMem charset return (result', charset'') -- function g_get_application_name -- Args : [] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_get_application_name" g_get_application_name :: IO CString {- | Gets a human-readable name for the application, as set by 'GI.GLib.Functions.setApplicationName'. This name should be localized if possible, and is intended for display to the user. Contrast with 'GI.GLib.Functions.getPrgname', which gets a non-localized name. If 'GI.GLib.Functions.setApplicationName' has not been called, returns the result of 'GI.GLib.Functions.getPrgname' (which may be 'Nothing' if 'GI.GLib.Functions.setPrgname' has also not been called). /Since: 2.2/ -} getApplicationName :: (B.CallStack.HasCallStack, MonadIO m) => m T.Text {- ^ __Returns:__ human-readable application name. may return 'Nothing' -} getApplicationName = liftIO $ do result <- g_get_application_name checkUnexpectedReturnNULL "getApplicationName" result result' <- cstringToText result return result' -- function g_free -- Args : [Arg {argCName = "mem", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the memory to free", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_free" g_free :: Ptr () -> -- mem : TBasicType TPtr IO () {- | Frees the memory pointed to by /@mem@/. If /@mem@/ is 'Nothing' it simply returns, so there is no need to check /@mem@/ against 'Nothing' before calling this function. -} free :: (B.CallStack.HasCallStack, MonadIO m) => Ptr () {- ^ /@mem@/: the memory to free -} -> m () free mem = liftIO $ do g_free mem return () -- function g_format_size_full -- Args : [Arg {argCName = "size", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a size in bytes", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface (Name {namespace = "GLib", name = "FormatSizeFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "#GFormatSizeFlags to modify the output", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_format_size_full" g_format_size_full :: Word64 -> -- size : TBasicType TUInt64 CUInt -> -- flags : TInterface (Name {namespace = "GLib", name = "FormatSizeFlags"}) IO CString {- | Formats a size. This function is similar to 'GI.GLib.Functions.formatSize' but allows for flags that modify the output. See 'GI.GLib.Flags.FormatSizeFlags'. /Since: 2.30/ -} formatSizeFull :: (B.CallStack.HasCallStack, MonadIO m) => Word64 {- ^ /@size@/: a size in bytes -} -> [GLib.Flags.FormatSizeFlags] {- ^ /@flags@/: 'GI.GLib.Flags.FormatSizeFlags' to modify the output -} -> m T.Text {- ^ __Returns:__ a newly-allocated formatted string containing a human readable file size -} formatSizeFull size flags = liftIO $ do let flags' = gflagsToWord flags result <- g_format_size_full size flags' checkUnexpectedReturnNULL "formatSizeFull" result result' <- cstringToText result freeMem result return result' -- function g_format_size_for_display -- Args : [Arg {argCName = "size", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a size in bytes", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_format_size_for_display" g_format_size_for_display :: Int64 -> -- size : TBasicType TInt64 IO CString {-# DEPRECATED formatSizeForDisplay ["(Since version 2.30)","This function is broken due to its use of SI"," suffixes to denote IEC units. Use 'GI.GLib.Functions.formatSize' instead."] #-} {- | Formats a size (for example the size of a file) into a human readable string. Sizes are rounded to the nearest size prefix (KB, MB, GB) and are displayed rounded to the nearest tenth. E.g. the file size 3292528 bytes will be converted into the string \"3.1 MB\". The prefix units base is 1024 (i.e. 1 KB is 1024 bytes). This string should be freed with 'GI.GLib.Functions.free' when not needed any longer. /Since: 2.16/ -} formatSizeForDisplay :: (B.CallStack.HasCallStack, MonadIO m) => Int64 {- ^ /@size@/: a size in bytes -} -> m T.Text {- ^ __Returns:__ a newly-allocated formatted string containing a human readable file size -} formatSizeForDisplay size = liftIO $ do result <- g_format_size_for_display size checkUnexpectedReturnNULL "formatSizeForDisplay" result result' <- cstringToText result freeMem result return result' -- function g_format_size -- Args : [Arg {argCName = "size", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a size in bytes", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_format_size" g_format_size :: Word64 -> -- size : TBasicType TUInt64 IO CString {- | Formats a size (for example the size of a file) into a human readable string. Sizes are rounded to the nearest size prefix (kB, MB, GB) and are displayed rounded to the nearest tenth. E.g. the file size 3292528 bytes will be converted into the string \"3.2 MB\". The returned string is UTF-8, and may use a non-breaking space to separate the number and units, to ensure they aren’t separated when line wrapped. The prefix units base is 1000 (i.e. 1 kB is 1000 bytes). This string should be freed with 'GI.GLib.Functions.free' when not needed any longer. See 'GI.GLib.Functions.formatSizeFull' for more options about how the size might be formatted. /Since: 2.30/ -} formatSize :: (B.CallStack.HasCallStack, MonadIO m) => Word64 {- ^ /@size@/: a size in bytes -} -> m T.Text {- ^ __Returns:__ a newly-allocated formatted string containing a human readable file size -} formatSize size = liftIO $ do result <- g_format_size size checkUnexpectedReturnNULL "formatSize" result result' <- cstringToText result freeMem result return result' -- function g_find_program_in_path -- Args : [Arg {argCName = "program", argType = TBasicType TFileName, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a program name in the GLib file name encoding", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TFileName) -- throws : False -- Skip return : False foreign import ccall "g_find_program_in_path" g_find_program_in_path :: CString -> -- program : TBasicType TFileName IO CString {- | Locates the first executable named /@program@/ in the user\'s path, in the same way that @/execvp()/@ would locate it. Returns an allocated string with the absolute path name, or 'Nothing' if the program is not found in the path. If /@program@/ is already an absolute path, returns a copy of /@program@/ if /@program@/ exists and is executable, and 'Nothing' otherwise. On Windows, if /@program@/ does not have a file type suffix, tries with the suffixes .exe, .cmd, .bat and .com, and the suffixes in the @PATHEXT@ environment variable. On Windows, it looks for the file in the same way as @/CreateProcess()/@ would. This means first in the directory where the executing program was loaded from, then in the current directory, then in the Windows 32-bit system directory, then in the Windows directory, and finally in the directories in the @PATH@ environment variable. If the program is found, the return value contains the full name including the type suffix. -} findProgramInPath :: (B.CallStack.HasCallStack, MonadIO m) => [Char] {- ^ /@program@/: a program name in the GLib file name encoding -} -> m [Char] {- ^ __Returns:__ a newly-allocated string with the absolute path, or 'Nothing' -} findProgramInPath program = liftIO $ do program' <- stringToCString program result <- g_find_program_in_path program' checkUnexpectedReturnNULL "findProgramInPath" result result' <- cstringToString result freeMem result freeMem program' return result' -- function g_filename_to_utf8 -- Args : [Arg {argCName = "opsysstring", argType = TBasicType TFileName, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a string in the encoding for filenames", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "len", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the length of the string, or -1 if the string is\n nul-terminated (Note that some encodings may allow nul\n bytes to occur inside strings. In that case, using -1\n for the @len parameter is unsafe)", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "bytes_read", argType = TBasicType TUInt64, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "location to store the number of bytes in the\n input string that were successfully converted, or %NULL.\n Even if the conversion was successful, this may be\n less than @len if there were partial characters\n at the end of the input. If the error\n %G_CONVERT_ERROR_ILLEGAL_SEQUENCE occurs, the value\n stored will be the byte offset after the last valid\n input sequence.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "bytes_written", argType = TBasicType TUInt64, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the number of bytes stored in the output\n buffer (not including the terminating nul).", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : True -- Skip return : False foreign import ccall "g_filename_to_utf8" g_filename_to_utf8 :: CString -> -- opsysstring : TBasicType TFileName Int64 -> -- len : TBasicType TInt64 Ptr Word64 -> -- bytes_read : TBasicType TUInt64 Ptr Word64 -> -- bytes_written : TBasicType TUInt64 Ptr (Ptr GError) -> -- error IO CString {- | Converts a string which is in the encoding used by GLib for filenames into a UTF-8 string. Note that on Windows GLib uses UTF-8 for filenames; on other platforms, this function indirectly depends on the [current locale][setlocale]. The input string shall not contain nul characters even if the /@len@/ argument is positive. A nul character found inside the string will result in error 'GI.GLib.Enums.ConvertErrorIllegalSequence'. If the source encoding is not UTF-8 and the conversion output contains a nul character, the error 'GI.GLib.Enums.ConvertErrorEmbeddedNul' is set and the function returns 'Nothing'. Use 'GI.GLib.Functions.convert' to produce output that may contain embedded nul characters. -} filenameToUtf8 :: (B.CallStack.HasCallStack, MonadIO m) => [Char] {- ^ /@opsysstring@/: a string in the encoding for filenames -} -> Int64 {- ^ /@len@/: the length of the string, or -1 if the string is nul-terminated (Note that some encodings may allow nul bytes to occur inside strings. In that case, using -1 for the /@len@/ parameter is unsafe) -} -> m ((T.Text, Word64, Word64)) {- ^ __Returns:__ The converted string, or 'Nothing' on an error. /(Can throw 'Data.GI.Base.GError.GError')/ -} filenameToUtf8 opsysstring len = liftIO $ do opsysstring' <- stringToCString opsysstring bytesRead <- allocMem :: IO (Ptr Word64) bytesWritten <- allocMem :: IO (Ptr Word64) onException (do result <- propagateGError $ g_filename_to_utf8 opsysstring' len bytesRead bytesWritten checkUnexpectedReturnNULL "filenameToUtf8" result result' <- cstringToText result freeMem result bytesRead' <- peek bytesRead bytesWritten' <- peek bytesWritten freeMem opsysstring' freeMem bytesRead freeMem bytesWritten return (result', bytesRead', bytesWritten') ) (do freeMem opsysstring' freeMem bytesRead freeMem bytesWritten ) -- function g_filename_to_uri -- Args : [Arg {argCName = "filename", argType = TBasicType TFileName, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an absolute filename specified in the GLib file\n name encoding, which is the on-disk file name bytes on Unix, and UTF-8\n on Windows", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "hostname", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "A UTF-8 encoded hostname, or %NULL for none.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : True -- Skip return : False foreign import ccall "g_filename_to_uri" g_filename_to_uri :: CString -> -- filename : TBasicType TFileName CString -> -- hostname : TBasicType TUTF8 Ptr (Ptr GError) -> -- error IO CString {- | Converts an absolute filename to an escaped ASCII-encoded URI, with the path component following Section 3.3. of RFC 2396. -} filenameToUri :: (B.CallStack.HasCallStack, MonadIO m) => [Char] {- ^ /@filename@/: an absolute filename specified in the GLib file name encoding, which is the on-disk file name bytes on Unix, and UTF-8 on Windows -} -> Maybe (T.Text) {- ^ /@hostname@/: A UTF-8 encoded hostname, or 'Nothing' for none. -} -> m T.Text {- ^ __Returns:__ a newly-allocated string holding the resulting URI, or 'Nothing' on an error. /(Can throw 'Data.GI.Base.GError.GError')/ -} filenameToUri filename hostname = liftIO $ do filename' <- stringToCString filename maybeHostname <- case hostname of Nothing -> return nullPtr Just jHostname -> do jHostname' <- textToCString jHostname return jHostname' onException (do result <- propagateGError $ g_filename_to_uri filename' maybeHostname checkUnexpectedReturnNULL "filenameToUri" result result' <- cstringToText result freeMem result freeMem filename' freeMem maybeHostname return result' ) (do freeMem filename' freeMem maybeHostname ) -- function g_filename_from_utf8 -- Args : [Arg {argCName = "utf8string", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a UTF-8 encoded string.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "len", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the length of the string, or -1 if the string is\n nul-terminated.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "bytes_read", argType = TBasicType TUInt64, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "location to store the number of bytes in\n the input string that were successfully converted, or %NULL.\n Even if the conversion was successful, this may be\n less than @len if there were partial characters\n at the end of the input. If the error\n %G_CONVERT_ERROR_ILLEGAL_SEQUENCE occurs, the value\n stored will be the byte offset after the last valid\n input sequence.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "bytes_written", argType = TBasicType TUInt64, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the number of bytes stored in\n the output buffer (not including the terminating nul).", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}] -- Lengths : [] -- returnType : Just (TBasicType TFileName) -- throws : True -- Skip return : False foreign import ccall "g_filename_from_utf8" g_filename_from_utf8 :: CString -> -- utf8string : TBasicType TUTF8 Int64 -> -- len : TBasicType TInt64 Ptr Word64 -> -- bytes_read : TBasicType TUInt64 Ptr Word64 -> -- bytes_written : TBasicType TUInt64 Ptr (Ptr GError) -> -- error IO CString {- | Converts a string from UTF-8 to the encoding GLib uses for filenames. Note that on Windows GLib uses UTF-8 for filenames; on other platforms, this function indirectly depends on the [current locale][setlocale]. The input string shall not contain nul characters even if the /@len@/ argument is positive. A nul character found inside the string will result in error 'GI.GLib.Enums.ConvertErrorIllegalSequence'. If the filename encoding is not UTF-8 and the conversion output contains a nul character, the error 'GI.GLib.Enums.ConvertErrorEmbeddedNul' is set and the function returns 'Nothing'. -} filenameFromUtf8 :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@utf8string@/: a UTF-8 encoded string. -} -> Int64 {- ^ /@len@/: the length of the string, or -1 if the string is nul-terminated. -} -> m (([Char], Word64, Word64)) {- ^ __Returns:__ The converted string, or 'Nothing' on an error. /(Can throw 'Data.GI.Base.GError.GError')/ -} filenameFromUtf8 utf8string len = liftIO $ do utf8string' <- textToCString utf8string bytesRead <- allocMem :: IO (Ptr Word64) bytesWritten <- allocMem :: IO (Ptr Word64) onException (do result <- propagateGError $ g_filename_from_utf8 utf8string' len bytesRead bytesWritten checkUnexpectedReturnNULL "filenameFromUtf8" result result' <- cstringToString result freeMem result bytesRead' <- peek bytesRead bytesWritten' <- peek bytesWritten freeMem utf8string' freeMem bytesRead freeMem bytesWritten return (result', bytesRead', bytesWritten') ) (do freeMem utf8string' freeMem bytesRead freeMem bytesWritten ) -- function g_filename_from_uri -- Args : [Arg {argCName = "uri", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a uri describing a filename (escaped, encoded in ASCII).", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "hostname", argType = TBasicType TUTF8, direction = DirectionOut, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Location to store hostname for the URI.\n If there is no hostname in the URI, %NULL will be\n stored in this location.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}] -- Lengths : [] -- returnType : Just (TBasicType TFileName) -- throws : True -- Skip return : False foreign import ccall "g_filename_from_uri" g_filename_from_uri :: CString -> -- uri : TBasicType TUTF8 Ptr CString -> -- hostname : TBasicType TUTF8 Ptr (Ptr GError) -> -- error IO CString {- | Converts an escaped ASCII-encoded URI to a local filename in the encoding used for filenames. -} filenameFromUri :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@uri@/: a uri describing a filename (escaped, encoded in ASCII). -} -> m (([Char], Maybe T.Text)) {- ^ __Returns:__ a newly-allocated string holding the resulting filename, or 'Nothing' on an error. /(Can throw 'Data.GI.Base.GError.GError')/ -} filenameFromUri uri = liftIO $ do uri' <- textToCString uri hostname <- allocMem :: IO (Ptr CString) onException (do result <- propagateGError $ g_filename_from_uri uri' hostname checkUnexpectedReturnNULL "filenameFromUri" result result' <- cstringToString result freeMem result hostname' <- peek hostname maybeHostname' <- convertIfNonNull hostname' $ \hostname'' -> do hostname''' <- cstringToText hostname'' return hostname''' freeMem hostname' freeMem uri' freeMem hostname return (result', maybeHostname') ) (do freeMem uri' freeMem hostname ) -- function g_filename_display_name -- Args : [Arg {argCName = "filename", argType = TBasicType TFileName, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a pathname hopefully in the\n GLib file name encoding", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_filename_display_name" g_filename_display_name :: CString -> -- filename : TBasicType TFileName IO CString {- | Converts a filename into a valid UTF-8 string. The conversion is not necessarily reversible, so you should keep the original around and use the return value of this function only for display purposes. Unlike 'GI.GLib.Functions.filenameToUtf8', the result is guaranteed to be non-'Nothing' even if the filename actually isn\'t in the GLib file name encoding. If GLib cannot make sense of the encoding of /@filename@/, as a last resort it replaces unknown characters with U+FFFD, the Unicode replacement character. You can search the result for the UTF-8 encoding of this character (which is \"\\357\\277\\275\" in octal notation) to find out if /@filename@/ was in an invalid encoding. If you know the whole pathname of the file you should use 'GI.GLib.Functions.filenameDisplayBasename', since that allows location-based translation of filenames. /Since: 2.6/ -} filenameDisplayName :: (B.CallStack.HasCallStack, MonadIO m) => [Char] {- ^ /@filename@/: a pathname hopefully in the GLib file name encoding -} -> m T.Text {- ^ __Returns:__ a newly allocated string containing a rendition of the filename in valid UTF-8 -} filenameDisplayName filename = liftIO $ do filename' <- stringToCString filename result <- g_filename_display_name filename' checkUnexpectedReturnNULL "filenameDisplayName" result result' <- cstringToText result freeMem result freeMem filename' return result' -- function g_filename_display_basename -- Args : [Arg {argCName = "filename", argType = TBasicType TFileName, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an absolute pathname in the\n GLib file name encoding", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_filename_display_basename" g_filename_display_basename :: CString -> -- filename : TBasicType TFileName IO CString {- | Returns the display basename for the particular filename, guaranteed to be valid UTF-8. The display name might not be identical to the filename, for instance there might be problems converting it to UTF-8, and some files can be translated in the display. If GLib cannot make sense of the encoding of /@filename@/, as a last resort it replaces unknown characters with U+FFFD, the Unicode replacement character. You can search the result for the UTF-8 encoding of this character (which is \"\\357\\277\\275\" in octal notation) to find out if /@filename@/ was in an invalid encoding. You must pass the whole absolute pathname to this functions so that translation of well known locations can be done. This function is preferred over 'GI.GLib.Functions.filenameDisplayName' if you know the whole path, as it allows translation. /Since: 2.6/ -} filenameDisplayBasename :: (B.CallStack.HasCallStack, MonadIO m) => [Char] {- ^ /@filename@/: an absolute pathname in the GLib file name encoding -} -> m T.Text {- ^ __Returns:__ a newly allocated string containing a rendition of the basename of the filename in valid UTF-8 -} filenameDisplayBasename filename = liftIO $ do filename' <- stringToCString filename result <- g_filename_display_basename filename' checkUnexpectedReturnNULL "filenameDisplayBasename" result result' <- cstringToText result freeMem result freeMem filename' return result' -- function g_file_test -- Args : [Arg {argCName = "filename", argType = TBasicType TFileName, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a filename to test in the\n GLib file name encoding", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "test", argType = TInterface (Name {namespace = "GLib", name = "FileTest"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "bitfield of #GFileTest flags", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "g_file_test" g_file_test :: CString -> -- filename : TBasicType TFileName CUInt -> -- test : TInterface (Name {namespace = "GLib", name = "FileTest"}) IO CInt {- | Returns 'True' if any of the tests in the bitfield /@test@/ are 'True'. For example, @(G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)@ will return 'True' if the file exists; the check whether it\'s a directory doesn\'t matter since the existence test is 'True'. With the current set of available tests, there\'s no point passing in more than one test at a time. Apart from 'GI.GLib.Flags.FileTestIsSymlink' all tests follow symbolic links, so for a symbolic link to a regular file 'GI.GLib.Functions.fileTest' will return 'True' for both 'GI.GLib.Flags.FileTestIsSymlink' and 'GI.GLib.Flags.FileTestIsRegular'. Note, that for a dangling symbolic link 'GI.GLib.Functions.fileTest' will return 'True' for 'GI.GLib.Flags.FileTestIsSymlink' and 'False' for all other flags. You should never use 'GI.GLib.Functions.fileTest' to test whether it is safe to perform an operation, because there is always the possibility of the condition changing before you actually perform the operation. For example, you might think you could use 'GI.GLib.Flags.FileTestIsSymlink' to know whether it is safe to write to a file without being tricked into writing into a different location. It doesn\'t work! === /C code/ > > // DON'T DO THIS > if (!g_file_test (filename, G_FILE_TEST_IS_SYMLINK)) > { > fd = g_open (filename, O_WRONLY); > // write to fd > } Another thing to note is that 'GI.GLib.Flags.FileTestExists' and 'GI.GLib.Flags.FileTestIsExecutable' are implemented using the @/access()/@ system call. This usually doesn\'t matter, but if your program is setuid or setgid it means that these tests will give you the answer for the real user ID and group ID, rather than the effective user ID and group ID. On Windows, there are no symlinks, so testing for 'GI.GLib.Flags.FileTestIsSymlink' will always return 'False'. Testing for 'GI.GLib.Flags.FileTestIsExecutable' will just check that the file exists and its name indicates that it is executable, checking for well-known extensions and those listed in the @PATHEXT@ environment variable. -} fileTest :: (B.CallStack.HasCallStack, MonadIO m) => [Char] {- ^ /@filename@/: a filename to test in the GLib file name encoding -} -> [GLib.Flags.FileTest] {- ^ /@test@/: bitfield of 'GI.GLib.Flags.FileTest' flags -} -> m Bool {- ^ __Returns:__ whether a test was 'True' -} fileTest filename test = liftIO $ do filename' <- stringToCString filename let test' = gflagsToWord test result <- g_file_test filename' test' let result' = (/= 0) result freeMem filename' return result' -- function g_file_set_contents -- Args : [Arg {argCName = "filename", argType = TBasicType TFileName, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "name of a file to write @contents to, in the GLib file name\n encoding", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "contents", argType = TCArray False (-1) 2 (TBasicType TUInt8), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "string to write to the file", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "length", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "length of @contents, or -1 if @contents is a nul-terminated string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [Arg {argCName = "length", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "length of @contents, or -1 if @contents is a nul-terminated string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- returnType : Just (TBasicType TBoolean) -- throws : True -- Skip return : False foreign import ccall "g_file_set_contents" g_file_set_contents :: CString -> -- filename : TBasicType TFileName Ptr Word8 -> -- contents : TCArray False (-1) 2 (TBasicType TUInt8) Int64 -> -- length : TBasicType TInt64 Ptr (Ptr GError) -> -- error IO CInt {- | Writes all of /@contents@/ to a file named /@filename@/, with good error checking. If a file called /@filename@/ already exists it will be overwritten. This write is atomic in the sense that it is first written to a temporary file which is then renamed to the final name. Notes: * On UNIX, if /@filename@/ already exists hard links to /@filename@/ will break. Also since the file is recreated, existing permissions, access control lists, metadata etc. may be lost. If /@filename@/ is a symbolic link, the link itself will be replaced, not the linked file. * On UNIX, if /@filename@/ already exists and is non-empty, and if the system supports it (via a journalling filesystem or equivalent), the @/fsync()/@ call (or equivalent) will be used to ensure atomic replacement: /@filename@/ will contain either its old contents or /@contents@/, even in the face of system power loss, the disk being unsafely removed, etc. * On UNIX, if /@filename@/ does not already exist or is empty, there is a possibility that system power loss etc. after calling this function will leave /@filename@/ empty or full of NUL bytes, depending on the underlying filesystem. * On Windows renaming a file will not remove an existing file with the new name, so on Windows there is a race condition between the existing file being removed and the temporary file being renamed. * On Windows there is no way to remove a file that is open to some process, or mapped into memory. Thus, this function will fail if /@filename@/ already exists and is open. If the call was successful, it returns 'True'. If the call was not successful, it returns 'False' and sets /@error@/. The error domain is @/G_FILE_ERROR/@. Possible error codes are those in the 'GI.GLib.Enums.FileError' enumeration. Note that the name for the temporary file is constructed by appending up to 7 characters to /@filename@/. /Since: 2.8/ -} fileSetContents :: (B.CallStack.HasCallStack, MonadIO m) => [Char] {- ^ /@filename@/: name of a file to write /@contents@/ to, in the GLib file name encoding -} -> ByteString {- ^ /@contents@/: string to write to the file -} -> m () {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -} fileSetContents filename contents = liftIO $ do let length_ = fromIntegral $ B.length contents filename' <- stringToCString filename contents' <- packByteString contents onException (do _ <- propagateGError $ g_file_set_contents filename' contents' length_ freeMem filename' freeMem contents' return () ) (do freeMem filename' freeMem contents' ) -- function g_file_read_link -- Args : [Arg {argCName = "filename", argType = TBasicType TFileName, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the symbolic link", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TFileName) -- throws : True -- Skip return : False foreign import ccall "g_file_read_link" g_file_read_link :: CString -> -- filename : TBasicType TFileName Ptr (Ptr GError) -> -- error IO CString {- | Reads the contents of the symbolic link /@filename@/ like the POSIX @/readlink()/@ function. The returned string is in the encoding used for filenames. Use 'GI.GLib.Functions.filenameToUtf8' to convert it to UTF-8. /Since: 2.4/ -} fileReadLink :: (B.CallStack.HasCallStack, MonadIO m) => [Char] {- ^ /@filename@/: the symbolic link -} -> m [Char] {- ^ __Returns:__ A newly-allocated string with the contents of the symbolic link, or 'Nothing' if an error occurred. /(Can throw 'Data.GI.Base.GError.GError')/ -} fileReadLink filename = liftIO $ do filename' <- stringToCString filename onException (do result <- propagateGError $ g_file_read_link filename' checkUnexpectedReturnNULL "fileReadLink" result result' <- cstringToString result freeMem result freeMem filename' return result' ) (do freeMem filename' ) -- function g_file_open_tmp -- Args : [Arg {argCName = "tmpl", argType = TBasicType TFileName, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Template for file name, as in\n g_mkstemp(), basename only, or %NULL for a default template", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "name_used", argType = TBasicType TFileName, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "location to store actual name used,\n or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}] -- Lengths : [] -- returnType : Just (TBasicType TInt) -- throws : True -- Skip return : False foreign import ccall "g_file_open_tmp" g_file_open_tmp :: CString -> -- tmpl : TBasicType TFileName Ptr CString -> -- name_used : TBasicType TFileName Ptr (Ptr GError) -> -- error IO Int32 {- | Opens a file for writing in the preferred directory for temporary files (as returned by 'GI.GLib.Functions.getTmpDir'). /@tmpl@/ should be a string in the GLib file name encoding containing a sequence of six \'X\' characters, as the parameter to @/g_mkstemp()/@. However, unlike these functions, the template should only be a basename, no directory components are allowed. If template is 'Nothing', a default template is used. Note that in contrast to @/g_mkstemp()/@ (and @/mkstemp()/@) /@tmpl@/ is not modified, and might thus be a read-only literal string. Upon success, and if /@nameUsed@/ is non-'Nothing', the actual name used is returned in /@nameUsed@/. This string should be freed with 'GI.GLib.Functions.free' when not needed any longer. The returned name is in the GLib file name encoding. -} fileOpenTmp :: (B.CallStack.HasCallStack, MonadIO m) => Maybe ([Char]) {- ^ /@tmpl@/: Template for file name, as in @/g_mkstemp()/@, basename only, or 'Nothing' for a default template -} -> m ((Int32, [Char])) {- ^ __Returns:__ A file handle (as from @/open()/@) to the file opened for reading and writing. The file is opened in binary mode on platforms where there is a difference. The file handle should be closed with @/close()/@. In case of errors, -1 is returned and /@error@/ will be set. /(Can throw 'Data.GI.Base.GError.GError')/ -} fileOpenTmp tmpl = liftIO $ do maybeTmpl <- case tmpl of Nothing -> return nullPtr Just jTmpl -> do jTmpl' <- stringToCString jTmpl return jTmpl' nameUsed <- allocMem :: IO (Ptr CString) onException (do result <- propagateGError $ g_file_open_tmp maybeTmpl nameUsed nameUsed' <- peek nameUsed nameUsed'' <- cstringToString nameUsed' freeMem nameUsed' freeMem maybeTmpl freeMem nameUsed return (result, nameUsed'') ) (do freeMem maybeTmpl freeMem nameUsed ) -- function g_file_get_contents -- Args : [Arg {argCName = "filename", argType = TBasicType TFileName, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "name of a file to read contents from, in the GLib file name encoding", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "contents", argType = TCArray False (-1) 2 (TBasicType TUInt8), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "location to store an allocated string, use g_free() to free\n the returned string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "length", argType = TBasicType TUInt64, direction = DirectionOut, mayBeNull = True, argDoc = Documentation {rawDocText = Just "location to store length in bytes of the contents, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}] -- Lengths : [Arg {argCName = "length", argType = TBasicType TUInt64, direction = DirectionOut, mayBeNull = True, argDoc = Documentation {rawDocText = Just "location to store length in bytes of the contents, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}] -- returnType : Just (TBasicType TBoolean) -- throws : True -- Skip return : False foreign import ccall "g_file_get_contents" g_file_get_contents :: CString -> -- filename : TBasicType TFileName Ptr (Ptr Word8) -> -- contents : TCArray False (-1) 2 (TBasicType TUInt8) Ptr Word64 -> -- length : TBasicType TUInt64 Ptr (Ptr GError) -> -- error IO CInt {- | Reads an entire file into allocated memory, with good error checking. If the call was successful, it returns 'True' and sets /@contents@/ to the file contents and /@length@/ to the length of the file contents in bytes. The string stored in /@contents@/ will be nul-terminated, so for text files you can pass 'Nothing' for the /@length@/ argument. If the call was not successful, it returns 'False' and sets /@error@/. The error domain is @/G_FILE_ERROR/@. Possible error codes are those in the 'GI.GLib.Enums.FileError' enumeration. In the error case, /@contents@/ is set to 'Nothing' and /@length@/ is set to zero. -} fileGetContents :: (B.CallStack.HasCallStack, MonadIO m) => [Char] {- ^ /@filename@/: name of a file to read contents from, in the GLib file name encoding -} -> m (ByteString) {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -} fileGetContents filename = liftIO $ do filename' <- stringToCString filename contents <- allocMem :: IO (Ptr (Ptr Word8)) length_ <- allocMem :: IO (Ptr Word64) onException (do _ <- propagateGError $ g_file_get_contents filename' contents length_ length_' <- peek length_ contents' <- peek contents contents'' <- (unpackByteStringWithLength length_') contents' freeMem contents' freeMem filename' freeMem contents freeMem length_ return contents'' ) (do freeMem filename' freeMem contents freeMem length_ ) -- function g_file_error_quark -- Args : [] -- Lengths : [] -- returnType : Just (TBasicType TUInt32) -- throws : False -- Skip return : False foreign import ccall "g_file_error_quark" g_file_error_quark :: IO Word32 {- | /No description available in the introspection data./ -} fileErrorQuark :: (B.CallStack.HasCallStack, MonadIO m) => m Word32 fileErrorQuark = liftIO $ do result <- g_file_error_quark return result -- function g_file_error_from_errno -- Args : [Arg {argCName = "err_no", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an \"errno\" value", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TInterface (Name {namespace = "GLib", name = "FileError"})) -- throws : False -- Skip return : False foreign import ccall "g_file_error_from_errno" g_file_error_from_errno :: Int32 -> -- err_no : TBasicType TInt IO CUInt {- | Gets a 'GI.GLib.Enums.FileError' constant based on the passed-in /@errNo@/. For example, if you pass in @EEXIST@ this function returns @/G_FILE_ERROR_EXIST/@. Unlike @errno@ values, you can portably assume that all 'GI.GLib.Enums.FileError' values will exist. Normally a 'GI.GLib.Enums.FileError' value goes into a 'GError' returned from a function that manipulates files. So you would use 'GI.GLib.Functions.fileErrorFromErrno' when constructing a 'GError'. -} fileErrorFromErrno :: (B.CallStack.HasCallStack, MonadIO m) => Int32 {- ^ /@errNo@/: an \"errno\" value -} -> m GLib.Enums.FileError {- ^ __Returns:__ 'GI.GLib.Enums.FileError' corresponding to the given /@errno@/ -} fileErrorFromErrno errNo = liftIO $ do result <- g_file_error_from_errno errNo let result' = (toEnum . fromIntegral) result return result' -- function g_environ_unsetenv -- Args : [Arg {argCName = "envp", argType = TCArray True (-1) (-1) (TBasicType TFileName), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "\n an environment list that can be freed using g_strfreev() (e.g., as\n returned from g_get_environ()), or %NULL for an empty environment list", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "variable", argType = TBasicType TFileName, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the environment variable to remove, must not\n contain '='", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TCArray True (-1) (-1) (TBasicType TFileName)) -- throws : False -- Skip return : False foreign import ccall "g_environ_unsetenv" g_environ_unsetenv :: Ptr CString -> -- envp : TCArray True (-1) (-1) (TBasicType TFileName) CString -> -- variable : TBasicType TFileName IO (Ptr CString) {- | Removes the environment variable /@variable@/ from the provided environment /@envp@/. /Since: 2.32/ -} environUnsetenv :: (B.CallStack.HasCallStack, MonadIO m) => Maybe ([[Char]]) {- ^ /@envp@/: an environment list that can be freed using 'GI.GLib.Functions.strfreev' (e.g., as returned from 'GI.GLib.Functions.getEnviron'), or 'Nothing' for an empty environment list -} -> [Char] {- ^ /@variable@/: the environment variable to remove, must not contain \'=\' -} -> m [[Char]] {- ^ __Returns:__ the updated environment list. Free it using 'GI.GLib.Functions.strfreev'. -} environUnsetenv envp variable = liftIO $ do maybeEnvp <- case envp of Nothing -> return nullPtr Just jEnvp -> do jEnvp' <- packZeroTerminatedFileNameArray jEnvp return jEnvp' variable' <- stringToCString variable result <- g_environ_unsetenv maybeEnvp variable' checkUnexpectedReturnNULL "environUnsetenv" result result' <- unpackZeroTerminatedFileNameArray result mapZeroTerminatedCArray freeMem result freeMem result freeMem variable' return result' -- function g_environ_setenv -- Args : [Arg {argCName = "envp", argType = TCArray True (-1) (-1) (TBasicType TFileName), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "\n an environment list that can be freed using g_strfreev() (e.g., as\n returned from g_get_environ()), or %NULL for an empty\n environment list", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "variable", argType = TBasicType TFileName, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the environment variable to set, must not\n contain '='", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "value", argType = TBasicType TFileName, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the value for to set the variable to", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "overwrite", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "whether to change the variable if it already exists", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TCArray True (-1) (-1) (TBasicType TFileName)) -- throws : False -- Skip return : False foreign import ccall "g_environ_setenv" g_environ_setenv :: Ptr CString -> -- envp : TCArray True (-1) (-1) (TBasicType TFileName) CString -> -- variable : TBasicType TFileName CString -> -- value : TBasicType TFileName CInt -> -- overwrite : TBasicType TBoolean IO (Ptr CString) {- | Sets the environment variable /@variable@/ in the provided list /@envp@/ to /@value@/. /Since: 2.32/ -} environSetenv :: (B.CallStack.HasCallStack, MonadIO m) => Maybe ([[Char]]) {- ^ /@envp@/: an environment list that can be freed using 'GI.GLib.Functions.strfreev' (e.g., as returned from 'GI.GLib.Functions.getEnviron'), or 'Nothing' for an empty environment list -} -> [Char] {- ^ /@variable@/: the environment variable to set, must not contain \'=\' -} -> [Char] {- ^ /@value@/: the value for to set the variable to -} -> Bool {- ^ /@overwrite@/: whether to change the variable if it already exists -} -> m [[Char]] {- ^ __Returns:__ the updated environment list. Free it using 'GI.GLib.Functions.strfreev'. -} environSetenv envp variable value overwrite = liftIO $ do maybeEnvp <- case envp of Nothing -> return nullPtr Just jEnvp -> do jEnvp' <- packZeroTerminatedFileNameArray jEnvp return jEnvp' variable' <- stringToCString variable value' <- stringToCString value let overwrite' = (fromIntegral . fromEnum) overwrite result <- g_environ_setenv maybeEnvp variable' value' overwrite' checkUnexpectedReturnNULL "environSetenv" result result' <- unpackZeroTerminatedFileNameArray result mapZeroTerminatedCArray freeMem result freeMem result freeMem variable' freeMem value' return result' -- function g_environ_getenv -- Args : [Arg {argCName = "envp", argType = TCArray True (-1) (-1) (TBasicType TFileName), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "\n an environment list (eg, as returned from g_get_environ()), or %NULL\n for an empty environment list", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "variable", argType = TBasicType TFileName, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the environment variable to get", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TFileName) -- throws : False -- Skip return : False foreign import ccall "g_environ_getenv" g_environ_getenv :: Ptr CString -> -- envp : TCArray True (-1) (-1) (TBasicType TFileName) CString -> -- variable : TBasicType TFileName IO CString {- | Returns the value of the environment variable /@variable@/ in the provided list /@envp@/. /Since: 2.32/ -} environGetenv :: (B.CallStack.HasCallStack, MonadIO m) => Maybe ([[Char]]) {- ^ /@envp@/: an environment list (eg, as returned from 'GI.GLib.Functions.getEnviron'), or 'Nothing' for an empty environment list -} -> [Char] {- ^ /@variable@/: the environment variable to get -} -> m [Char] {- ^ __Returns:__ the value of the environment variable, or 'Nothing' if the environment variable is not set in /@envp@/. The returned string is owned by /@envp@/, and will be freed if /@variable@/ is set or unset again. -} environGetenv envp variable = liftIO $ do maybeEnvp <- case envp of Nothing -> return nullPtr Just jEnvp -> do jEnvp' <- packZeroTerminatedFileNameArray jEnvp return jEnvp' variable' <- stringToCString variable result <- g_environ_getenv maybeEnvp variable' checkUnexpectedReturnNULL "environGetenv" result result' <- cstringToString result mapZeroTerminatedCArray freeMem maybeEnvp freeMem maybeEnvp freeMem variable' return result' -- function g_dpgettext2 -- Args : [Arg {argCName = "domain", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the translation domain to use, or %NULL to use\n the domain set with textdomain()", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "context", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the message context", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "msgid", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the message", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_dpgettext2" g_dpgettext2 :: CString -> -- domain : TBasicType TUTF8 CString -> -- context : TBasicType TUTF8 CString -> -- msgid : TBasicType TUTF8 IO CString {- | This function is a variant of 'GI.GLib.Functions.dgettext' which supports a disambiguating message context. GNU gettext uses the \'\\004\' character to separate the message context and message id in /@msgctxtid@/. This uses 'GI.GLib.Functions.dgettext' internally. See that functions for differences with @/dgettext()/@ proper. This function differs from @/C_()/@ in that it is not a macro and thus you may use non-string-literals as context and msgid arguments. /Since: 2.18/ -} dpgettext2 :: (B.CallStack.HasCallStack, MonadIO m) => Maybe (T.Text) {- ^ /@domain@/: the translation domain to use, or 'Nothing' to use the domain set with @/textdomain()/@ -} -> T.Text {- ^ /@context@/: the message context -} -> T.Text {- ^ /@msgid@/: the message -} -> m T.Text {- ^ __Returns:__ The translated string -} dpgettext2 domain context msgid = liftIO $ do maybeDomain <- case domain of Nothing -> return nullPtr Just jDomain -> do jDomain' <- textToCString jDomain return jDomain' context' <- textToCString context msgid' <- textToCString msgid result <- g_dpgettext2 maybeDomain context' msgid' checkUnexpectedReturnNULL "dpgettext2" result result' <- cstringToText result freeMem maybeDomain freeMem context' freeMem msgid' return result' -- function g_dpgettext -- Args : [Arg {argCName = "domain", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the translation domain to use, or %NULL to use\n the domain set with textdomain()", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "msgctxtid", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a combined message context and message id, separated\n by a \\004 character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "msgidoffset", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the offset of the message id in @msgctxid", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_dpgettext" g_dpgettext :: CString -> -- domain : TBasicType TUTF8 CString -> -- msgctxtid : TBasicType TUTF8 Word64 -> -- msgidoffset : TBasicType TUInt64 IO CString {- | This function is a variant of 'GI.GLib.Functions.dgettext' which supports a disambiguating message context. GNU gettext uses the \'\\004\' character to separate the message context and message id in /@msgctxtid@/. If 0 is passed as /@msgidoffset@/, this function will fall back to trying to use the deprecated convention of using \"|\" as a separation character. This uses 'GI.GLib.Functions.dgettext' internally. See that functions for differences with @/dgettext()/@ proper. Applications should normally not use this function directly, but use the @/C_()/@ macro for translations with context. /Since: 2.16/ -} dpgettext :: (B.CallStack.HasCallStack, MonadIO m) => Maybe (T.Text) {- ^ /@domain@/: the translation domain to use, or 'Nothing' to use the domain set with @/textdomain()/@ -} -> T.Text {- ^ /@msgctxtid@/: a combined message context and message id, separated by a \\004 character -} -> Word64 {- ^ /@msgidoffset@/: the offset of the message id in /@msgctxid@/ -} -> m T.Text {- ^ __Returns:__ The translated string -} dpgettext domain msgctxtid msgidoffset = liftIO $ do maybeDomain <- case domain of Nothing -> return nullPtr Just jDomain -> do jDomain' <- textToCString jDomain return jDomain' msgctxtid' <- textToCString msgctxtid result <- g_dpgettext maybeDomain msgctxtid' msgidoffset checkUnexpectedReturnNULL "dpgettext" result result' <- cstringToText result freeMem maybeDomain freeMem msgctxtid' return result' -- function g_double_hash -- Args : [Arg {argCName = "v", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a pointer to a #gdouble key", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUInt) -- throws : False -- Skip return : False foreign import ccall "g_double_hash" g_double_hash :: Ptr () -> -- v : TBasicType TPtr IO Word32 {- | Converts a pointer to a @/gdouble/@ to a hash value. It can be passed to @/g_hash_table_new()/@ as the /@hashFunc@/ parameter, It can be passed to @/g_hash_table_new()/@ as the /@hashFunc@/ parameter, when using non-'Nothing' pointers to doubles as keys in a 'GI.GLib.Structs.HashTable.HashTable'. /Since: 2.22/ -} doubleHash :: (B.CallStack.HasCallStack, MonadIO m) => Ptr () {- ^ /@v@/: a pointer to a @/gdouble/@ key -} -> m Word32 {- ^ __Returns:__ a hash value corresponding to the key. -} doubleHash v = liftIO $ do result <- g_double_hash v return result -- function g_double_equal -- Args : [Arg {argCName = "v1", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a pointer to a #gdouble key", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "v2", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a pointer to a #gdouble key to compare with @v1", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "g_double_equal" g_double_equal :: Ptr () -> -- v1 : TBasicType TPtr Ptr () -> -- v2 : TBasicType TPtr IO CInt {- | Compares the two @/gdouble/@ values being pointed to and returns 'True' if they are equal. It can be passed to @/g_hash_table_new()/@ as the /@keyEqualFunc@/ parameter, when using non-'Nothing' pointers to doubles as keys in a 'GI.GLib.Structs.HashTable.HashTable'. /Since: 2.22/ -} doubleEqual :: (B.CallStack.HasCallStack, MonadIO m) => Ptr () {- ^ /@v1@/: a pointer to a @/gdouble/@ key -} -> Ptr () {- ^ /@v2@/: a pointer to a @/gdouble/@ key to compare with /@v1@/ -} -> m Bool {- ^ __Returns:__ 'True' if the two keys match. -} doubleEqual v1 v2 = liftIO $ do result <- g_double_equal v1 v2 let result' = (/= 0) result return result' -- function g_dngettext -- Args : [Arg {argCName = "domain", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the translation domain to use, or %NULL to use\n the domain set with textdomain()", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "msgid", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "message to translate", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "msgid_plural", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "plural form of the message", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "n", argType = TBasicType TULong, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the quantity for which translation is needed", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_dngettext" g_dngettext :: CString -> -- domain : TBasicType TUTF8 CString -> -- msgid : TBasicType TUTF8 CString -> -- msgid_plural : TBasicType TUTF8 CULong -> -- n : TBasicType TULong IO CString {- | This function is a wrapper of @/dngettext()/@ which does not translate the message if the default domain as set with @/textdomain()/@ has no translations for the current locale. See 'GI.GLib.Functions.dgettext' for details of how this differs from @/dngettext()/@ proper. /Since: 2.18/ -} dngettext :: (B.CallStack.HasCallStack, MonadIO m) => Maybe (T.Text) {- ^ /@domain@/: the translation domain to use, or 'Nothing' to use the domain set with @/textdomain()/@ -} -> T.Text {- ^ /@msgid@/: message to translate -} -> T.Text {- ^ /@msgidPlural@/: plural form of the message -} -> CULong {- ^ /@n@/: the quantity for which translation is needed -} -> m T.Text {- ^ __Returns:__ The translated string -} dngettext domain msgid msgidPlural n = liftIO $ do maybeDomain <- case domain of Nothing -> return nullPtr Just jDomain -> do jDomain' <- textToCString jDomain return jDomain' msgid' <- textToCString msgid msgidPlural' <- textToCString msgidPlural result <- g_dngettext maybeDomain msgid' msgidPlural' n checkUnexpectedReturnNULL "dngettext" result result' <- cstringToText result freeMem maybeDomain freeMem msgid' freeMem msgidPlural' return result' -- function g_direct_hash -- Args : [Arg {argCName = "v", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #gpointer key", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUInt) -- throws : False -- Skip return : False foreign import ccall "g_direct_hash" g_direct_hash :: Ptr () -> -- v : TBasicType TPtr IO Word32 {- | Converts a gpointer to a hash value. It can be passed to @/g_hash_table_new()/@ as the /@hashFunc@/ parameter, when using opaque pointers compared by pointer value as keys in a 'GI.GLib.Structs.HashTable.HashTable'. This hash function is also appropriate for keys that are integers stored in pointers, such as @GINT_TO_POINTER (n)@. -} directHash :: (B.CallStack.HasCallStack, MonadIO m) => Ptr () {- ^ /@v@/: a @/gpointer/@ key -} -> m Word32 {- ^ __Returns:__ a hash value corresponding to the key. -} directHash v = liftIO $ do result <- g_direct_hash v return result -- function g_direct_equal -- Args : [Arg {argCName = "v1", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a key", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "v2", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a key to compare with @v1", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "g_direct_equal" g_direct_equal :: Ptr () -> -- v1 : TBasicType TPtr Ptr () -> -- v2 : TBasicType TPtr IO CInt {- | Compares two @/gpointer/@ arguments and returns 'True' if they are equal. It can be passed to @/g_hash_table_new()/@ as the /@keyEqualFunc@/ parameter, when using opaque pointers compared by pointer value as keys in a 'GI.GLib.Structs.HashTable.HashTable'. This equality function is also appropriate for keys that are integers stored in pointers, such as @GINT_TO_POINTER (n)@. -} directEqual :: (B.CallStack.HasCallStack, MonadIO m) => Ptr () {- ^ /@v1@/: a key -} -> Ptr () {- ^ /@v2@/: a key to compare with /@v1@/ -} -> m Bool {- ^ __Returns:__ 'True' if the two keys match. -} directEqual v1 v2 = liftIO $ do result <- g_direct_equal v1 v2 let result' = (/= 0) result return result' -- function g_dgettext -- Args : [Arg {argCName = "domain", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the translation domain to use, or %NULL to use\n the domain set with textdomain()", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "msgid", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "message to translate", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_dgettext" g_dgettext :: CString -> -- domain : TBasicType TUTF8 CString -> -- msgid : TBasicType TUTF8 IO CString {- | This function is a wrapper of @/dgettext()/@ which does not translate the message if the default domain as set with @/textdomain()/@ has no translations for the current locale. The advantage of using this function over @/dgettext()/@ proper is that libraries using this function (like GTK+) will not use translations if the application using the library does not have translations for the current locale. This results in a consistent English-only interface instead of one having partial translations. For this feature to work, the call to @/textdomain()/@ and @/setlocale()/@ should precede any 'GI.GLib.Functions.dgettext' invocations. For GTK+, it means calling @/textdomain()/@ before gtk_init or its variants. This function disables translations if and only if upon its first call all the following conditions hold: * /@domain@/ is not 'Nothing' * @/textdomain()/@ has been called to set a default text domain * there is no translations available for the default text domain and the current locale * current locale is not \"C\" or any English locales (those starting with \"en_\") Note that this behavior may not be desired for example if an application has its untranslated messages in a language other than English. In those cases the application should call @/textdomain()/@ after initializing GTK+. Applications should normally not use this function directly, but use the @/_()/@ macro for translations. /Since: 2.18/ -} dgettext :: (B.CallStack.HasCallStack, MonadIO m) => Maybe (T.Text) {- ^ /@domain@/: the translation domain to use, or 'Nothing' to use the domain set with @/textdomain()/@ -} -> T.Text {- ^ /@msgid@/: message to translate -} -> m T.Text {- ^ __Returns:__ The translated string -} dgettext domain msgid = liftIO $ do maybeDomain <- case domain of Nothing -> return nullPtr Just jDomain -> do jDomain' <- textToCString jDomain return jDomain' msgid' <- textToCString msgid result <- g_dgettext maybeDomain msgid' checkUnexpectedReturnNULL "dgettext" result result' <- cstringToText result freeMem maybeDomain freeMem msgid' return result' -- function g_dcgettext -- Args : [Arg {argCName = "domain", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the translation domain to use, or %NULL to use\n the domain set with textdomain()", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "msgid", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "message to translate", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "category", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a locale category", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_dcgettext" g_dcgettext :: CString -> -- domain : TBasicType TUTF8 CString -> -- msgid : TBasicType TUTF8 Int32 -> -- category : TBasicType TInt IO CString {- | This is a variant of 'GI.GLib.Functions.dgettext' that allows specifying a locale category instead of always using @LC_MESSAGES@. See 'GI.GLib.Functions.dgettext' for more information about how this functions differs from calling @/dcgettext()/@ directly. /Since: 2.26/ -} dcgettext :: (B.CallStack.HasCallStack, MonadIO m) => Maybe (T.Text) {- ^ /@domain@/: the translation domain to use, or 'Nothing' to use the domain set with @/textdomain()/@ -} -> T.Text {- ^ /@msgid@/: message to translate -} -> Int32 {- ^ /@category@/: a locale category -} -> m T.Text {- ^ __Returns:__ the translated string for the given locale category -} dcgettext domain msgid category = liftIO $ do maybeDomain <- case domain of Nothing -> return nullPtr Just jDomain -> do jDomain' <- textToCString jDomain return jDomain' msgid' <- textToCString msgid result <- g_dcgettext maybeDomain msgid' category checkUnexpectedReturnNULL "dcgettext" result result' <- cstringToText result freeMem maybeDomain freeMem msgid' return result' -- function g_dataset_id_get_data -- Args : [Arg {argCName = "dataset_location", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the location identifying the dataset.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "key_id", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GQuark id to identify the data element.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TPtr) -- throws : False -- Skip return : False foreign import ccall "g_dataset_id_get_data" g_dataset_id_get_data :: Ptr () -> -- dataset_location : TBasicType TPtr Word32 -> -- key_id : TBasicType TUInt32 IO (Ptr ()) {- | Gets the data element corresponding to a @/GQuark/@. -} datasetIdGetData :: (B.CallStack.HasCallStack, MonadIO m) => Ptr () {- ^ /@datasetLocation@/: the location identifying the dataset. -} -> Word32 {- ^ /@keyId@/: the @/GQuark/@ id to identify the data element. -} -> m (Ptr ()) {- ^ __Returns:__ the data element corresponding to the @/GQuark/@, or 'Nothing' if it is not found. -} datasetIdGetData datasetLocation keyId = liftIO $ do result <- g_dataset_id_get_data datasetLocation keyId return result -- function g_dataset_foreach -- Args : [Arg {argCName = "dataset_location", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the location identifying the dataset.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "func", argType = TInterface (Name {namespace = "GLib", name = "DataForeachFunc"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the function to call for each data element.", sinceVersion = Nothing}, argScope = ScopeTypeCall, argClosure = 2, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user data to pass to the function.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_dataset_foreach" g_dataset_foreach :: Ptr () -> -- dataset_location : TBasicType TPtr FunPtr GLib.Callbacks.C_DataForeachFunc -> -- func : TInterface (Name {namespace = "GLib", name = "DataForeachFunc"}) Ptr () -> -- user_data : TBasicType TPtr IO () {- | Calls the given function for each data element which is associated with the given location. Note that this function is NOT thread-safe. So unless /@datasetLocation@/ can be protected from any modifications during invocation of this function, it should not be called. /@func@/ can make changes to the dataset, but the iteration will not reflect changes made during the 'GI.GLib.Functions.datasetForeach' call, other than skipping over elements that are removed. -} datasetForeach :: (B.CallStack.HasCallStack, MonadIO m) => Ptr () {- ^ /@datasetLocation@/: the location identifying the dataset. -} -> GLib.Callbacks.DataForeachFunc {- ^ /@func@/: the function to call for each data element. -} -> m () datasetForeach datasetLocation func = liftIO $ do func' <- GLib.Callbacks.mk_DataForeachFunc (GLib.Callbacks.wrap_DataForeachFunc Nothing (GLib.Callbacks.drop_closures_DataForeachFunc func)) let userData = nullPtr g_dataset_foreach datasetLocation func' userData safeFreeFunPtr $ castFunPtrToPtr func' return () -- function g_dataset_destroy -- Args : [Arg {argCName = "dataset_location", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the location identifying the dataset.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_dataset_destroy" g_dataset_destroy :: Ptr () -> -- dataset_location : TBasicType TPtr IO () {- | Destroys the dataset, freeing all memory allocated, and calling any destroy functions set for data elements. -} datasetDestroy :: (B.CallStack.HasCallStack, MonadIO m) => Ptr () {- ^ /@datasetLocation@/: the location identifying the dataset. -} -> m () datasetDestroy datasetLocation = liftIO $ do g_dataset_destroy datasetLocation return () -- function g_datalist_unset_flags -- Args : [Arg {argCName = "datalist", argType = TInterface (Name {namespace = "GLib", name = "Data"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "pointer to the location that holds a list", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the flags to turn off. The values of the flags are\n restricted by %G_DATALIST_FLAGS_MASK (currently\n 3: giving two possible boolean flags).\n A value for @flags that doesn't fit within the mask is\n an error.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_datalist_unset_flags" g_datalist_unset_flags :: Ptr GLib.Data.Data -> -- datalist : TInterface (Name {namespace = "GLib", name = "Data"}) Word32 -> -- flags : TBasicType TUInt IO () {- | Turns off flag values for a data list. See 'GI.GLib.Functions.datalistUnsetFlags' /Since: 2.8/ -} datalistUnsetFlags :: (B.CallStack.HasCallStack, MonadIO m) => GLib.Data.Data {- ^ /@datalist@/: pointer to the location that holds a list -} -> Word32 {- ^ /@flags@/: the flags to turn off. The values of the flags are restricted by 'GI.GLib.Constants.DATALIST_FLAGS_MASK' (currently 3: giving two possible boolean flags). A value for /@flags@/ that doesn\'t fit within the mask is an error. -} -> m () datalistUnsetFlags datalist flags = liftIO $ do datalist' <- unsafeManagedPtrGetPtr datalist g_datalist_unset_flags datalist' flags touchManagedPtr datalist return () -- function g_datalist_set_flags -- Args : [Arg {argCName = "datalist", argType = TInterface (Name {namespace = "GLib", name = "Data"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "pointer to the location that holds a list", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the flags to turn on. The values of the flags are\n restricted by %G_DATALIST_FLAGS_MASK (currently\n 3; giving two possible boolean flags).\n A value for @flags that doesn't fit within the mask is\n an error.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_datalist_set_flags" g_datalist_set_flags :: Ptr GLib.Data.Data -> -- datalist : TInterface (Name {namespace = "GLib", name = "Data"}) Word32 -> -- flags : TBasicType TUInt IO () {- | Turns on flag values for a data list. This function is used to keep a small number of boolean flags in an object with a data list without using any additional space. It is not generally useful except in circumstances where space is very tight. (It is used in the base @/GObject/@ type, for example.) /Since: 2.8/ -} datalistSetFlags :: (B.CallStack.HasCallStack, MonadIO m) => GLib.Data.Data {- ^ /@datalist@/: pointer to the location that holds a list -} -> Word32 {- ^ /@flags@/: the flags to turn on. The values of the flags are restricted by 'GI.GLib.Constants.DATALIST_FLAGS_MASK' (currently 3; giving two possible boolean flags). A value for /@flags@/ that doesn\'t fit within the mask is an error. -} -> m () datalistSetFlags datalist flags = liftIO $ do datalist' <- unsafeManagedPtrGetPtr datalist g_datalist_set_flags datalist' flags touchManagedPtr datalist return () -- function g_datalist_id_get_data -- Args : [Arg {argCName = "datalist", argType = TInterface (Name {namespace = "GLib", name = "Data"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a datalist.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "key_id", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GQuark identifying a data element.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TPtr) -- throws : False -- Skip return : False foreign import ccall "g_datalist_id_get_data" g_datalist_id_get_data :: Ptr GLib.Data.Data -> -- datalist : TInterface (Name {namespace = "GLib", name = "Data"}) Word32 -> -- key_id : TBasicType TUInt32 IO (Ptr ()) {- | Retrieves the data element corresponding to /@keyId@/. -} datalistIdGetData :: (B.CallStack.HasCallStack, MonadIO m) => GLib.Data.Data {- ^ /@datalist@/: a datalist. -} -> Word32 {- ^ /@keyId@/: the @/GQuark/@ identifying a data element. -} -> m (Ptr ()) {- ^ __Returns:__ the data element, or 'Nothing' if it is not found. -} datalistIdGetData datalist keyId = liftIO $ do datalist' <- unsafeManagedPtrGetPtr datalist result <- g_datalist_id_get_data datalist' keyId touchManagedPtr datalist return result -- function g_datalist_get_flags -- Args : [Arg {argCName = "datalist", argType = TInterface (Name {namespace = "GLib", name = "Data"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "pointer to the location that holds a list", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUInt) -- throws : False -- Skip return : False foreign import ccall "g_datalist_get_flags" g_datalist_get_flags :: Ptr GLib.Data.Data -> -- datalist : TInterface (Name {namespace = "GLib", name = "Data"}) IO Word32 {- | Gets flags values packed in together with the datalist. See 'GI.GLib.Functions.datalistSetFlags'. /Since: 2.8/ -} datalistGetFlags :: (B.CallStack.HasCallStack, MonadIO m) => GLib.Data.Data {- ^ /@datalist@/: pointer to the location that holds a list -} -> m Word32 {- ^ __Returns:__ the flags of the datalist -} datalistGetFlags datalist = liftIO $ do datalist' <- unsafeManagedPtrGetPtr datalist result <- g_datalist_get_flags datalist' touchManagedPtr datalist return result -- function g_datalist_get_data -- Args : [Arg {argCName = "datalist", argType = TInterface (Name {namespace = "GLib", name = "Data"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a datalist.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "key", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the string identifying a data element.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TPtr) -- throws : False -- Skip return : False foreign import ccall "g_datalist_get_data" g_datalist_get_data :: Ptr GLib.Data.Data -> -- datalist : TInterface (Name {namespace = "GLib", name = "Data"}) CString -> -- key : TBasicType TUTF8 IO (Ptr ()) {- | Gets a data element, using its string identifier. This is slower than 'GI.GLib.Functions.datalistIdGetData' because it compares strings. -} datalistGetData :: (B.CallStack.HasCallStack, MonadIO m) => GLib.Data.Data {- ^ /@datalist@/: a datalist. -} -> T.Text {- ^ /@key@/: the string identifying a data element. -} -> m (Ptr ()) {- ^ __Returns:__ the data element, or 'Nothing' if it is not found. -} datalistGetData datalist key = liftIO $ do datalist' <- unsafeManagedPtrGetPtr datalist key' <- textToCString key result <- g_datalist_get_data datalist' key' touchManagedPtr datalist freeMem key' return result -- function g_datalist_foreach -- Args : [Arg {argCName = "datalist", argType = TInterface (Name {namespace = "GLib", name = "Data"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a datalist.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "func", argType = TInterface (Name {namespace = "GLib", name = "DataForeachFunc"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the function to call for each data element.", sinceVersion = Nothing}, argScope = ScopeTypeCall, argClosure = 2, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user data to pass to the function.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_datalist_foreach" g_datalist_foreach :: Ptr GLib.Data.Data -> -- datalist : TInterface (Name {namespace = "GLib", name = "Data"}) FunPtr GLib.Callbacks.C_DataForeachFunc -> -- func : TInterface (Name {namespace = "GLib", name = "DataForeachFunc"}) Ptr () -> -- user_data : TBasicType TPtr IO () {- | Calls the given function for each data element of the datalist. The function is called with each data element\'s @/GQuark/@ id and data, together with the given /@userData@/ parameter. Note that this function is NOT thread-safe. So unless /@datalist@/ can be protected from any modifications during invocation of this function, it should not be called. /@func@/ can make changes to /@datalist@/, but the iteration will not reflect changes made during the 'GI.GLib.Functions.datalistForeach' call, other than skipping over elements that are removed. -} datalistForeach :: (B.CallStack.HasCallStack, MonadIO m) => GLib.Data.Data {- ^ /@datalist@/: a datalist. -} -> GLib.Callbacks.DataForeachFunc {- ^ /@func@/: the function to call for each data element. -} -> m () datalistForeach datalist func = liftIO $ do datalist' <- unsafeManagedPtrGetPtr datalist func' <- GLib.Callbacks.mk_DataForeachFunc (GLib.Callbacks.wrap_DataForeachFunc Nothing (GLib.Callbacks.drop_closures_DataForeachFunc func)) let userData = nullPtr g_datalist_foreach datalist' func' userData safeFreeFunPtr $ castFunPtrToPtr func' touchManagedPtr datalist return () -- function g_convert_with_fallback -- Args : [Arg {argCName = "str", argType = TCArray False (-1) 1 (TBasicType TUInt8), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "\n the string to convert.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "len", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the length of the string in bytes, or -1 if the string is\n nul-terminated (Note that some encodings may allow nul\n bytes to occur inside strings. In that case, using -1\n for the @len parameter is unsafe)", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "to_codeset", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "name of character set into which to convert @str", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "from_codeset", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "character set of @str.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "fallback", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "UTF-8 string to use in place of characters not\n present in the target encoding. (The string must be\n representable in the target encoding).\n If %NULL, characters not in the target encoding will\n be represented as Unicode escapes \\uxxxx or \\Uxxxxyyyy.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "bytes_read", argType = TBasicType TUInt64, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "location to store the number of bytes in\n the input string that were successfully converted, or %NULL.\n Even if the conversion was successful, this may be\n less than @len if there were partial characters\n at the end of the input.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "bytes_written", argType = TBasicType TUInt64, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the number of bytes stored in\n the output buffer (not including the terminating nul).", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}] -- Lengths : [Arg {argCName = "len", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the length of the string in bytes, or -1 if the string is\n nul-terminated (Note that some encodings may allow nul\n bytes to occur inside strings. In that case, using -1\n for the @len parameter is unsafe)", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "bytes_written", argType = TBasicType TUInt64, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the number of bytes stored in\n the output buffer (not including the terminating nul).", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}] -- returnType : Just (TCArray False (-1) 6 (TBasicType TUInt8)) -- throws : True -- Skip return : False foreign import ccall "g_convert_with_fallback" g_convert_with_fallback :: Ptr Word8 -> -- str : TCArray False (-1) 1 (TBasicType TUInt8) Int64 -> -- len : TBasicType TInt64 CString -> -- to_codeset : TBasicType TUTF8 CString -> -- from_codeset : TBasicType TUTF8 CString -> -- fallback : TBasicType TUTF8 Ptr Word64 -> -- bytes_read : TBasicType TUInt64 Ptr Word64 -> -- bytes_written : TBasicType TUInt64 Ptr (Ptr GError) -> -- error IO (Ptr Word8) {- | Converts a string from one character set to another, possibly including fallback sequences for characters not representable in the output. Note that it is not guaranteed that the specification for the fallback sequences in /@fallback@/ will be honored. Some systems may do an approximate conversion from /@fromCodeset@/ to /@toCodeset@/ in their @/iconv()/@ functions, in which case GLib will simply return that approximate conversion. Note that you should use @/g_iconv()/@ for streaming conversions. Despite the fact that /@bytesRead@/ can return information about partial characters, the g_convert_... functions are not generally suitable for streaming. If the underlying converter maintains internal state, then this won\'t be preserved across successive calls to 'GI.GLib.Functions.convert', @/g_convert_with_iconv()/@ or 'GI.GLib.Functions.convertWithFallback'. (An example of this is the GNU C converter for CP1255 which does not emit a base character until it knows that the next character is not a mark that could combine with the base character.) -} convertWithFallback :: (B.CallStack.HasCallStack, MonadIO m) => ByteString {- ^ /@str@/: the string to convert. -} -> T.Text {- ^ /@toCodeset@/: name of character set into which to convert /@str@/ -} -> T.Text {- ^ /@fromCodeset@/: character set of /@str@/. -} -> T.Text {- ^ /@fallback@/: UTF-8 string to use in place of characters not present in the target encoding. (The string must be representable in the target encoding). If 'Nothing', characters not in the target encoding will be represented as Unicode escapes \\uxxxx or \\Uxxxxyyyy. -} -> m ((ByteString, Word64)) {- ^ __Returns:__ If the conversion was successful, a newly allocated buffer containing the converted string, which must be freed with 'GI.GLib.Functions.free'. Otherwise 'Nothing' and /@error@/ will be set. /(Can throw 'Data.GI.Base.GError.GError')/ -} convertWithFallback str toCodeset fromCodeset fallback = liftIO $ do let len = fromIntegral $ B.length str str' <- packByteString str toCodeset' <- textToCString toCodeset fromCodeset' <- textToCString fromCodeset fallback' <- textToCString fallback bytesRead <- allocMem :: IO (Ptr Word64) bytesWritten <- allocMem :: IO (Ptr Word64) onException (do result <- propagateGError $ g_convert_with_fallback str' len toCodeset' fromCodeset' fallback' bytesRead bytesWritten bytesWritten' <- peek bytesWritten checkUnexpectedReturnNULL "convertWithFallback" result result' <- (unpackByteStringWithLength bytesWritten') result freeMem result bytesRead' <- peek bytesRead freeMem str' freeMem toCodeset' freeMem fromCodeset' freeMem fallback' freeMem bytesRead freeMem bytesWritten return (result', bytesRead') ) (do freeMem str' freeMem toCodeset' freeMem fromCodeset' freeMem fallback' freeMem bytesRead freeMem bytesWritten ) -- function g_convert_error_quark -- Args : [] -- Lengths : [] -- returnType : Just (TBasicType TUInt32) -- throws : False -- Skip return : False foreign import ccall "g_convert_error_quark" g_convert_error_quark :: IO Word32 {- | /No description available in the introspection data./ -} convertErrorQuark :: (B.CallStack.HasCallStack, MonadIO m) => m Word32 convertErrorQuark = liftIO $ do result <- g_convert_error_quark return result -- function g_convert -- Args : [Arg {argCName = "str", argType = TCArray False (-1) 1 (TBasicType TUInt8), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "\n the string to convert.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "len", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the length of the string in bytes, or -1 if the string is\n nul-terminated (Note that some encodings may allow nul\n bytes to occur inside strings. In that case, using -1\n for the @len parameter is unsafe)", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "to_codeset", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "name of character set into which to convert @str", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "from_codeset", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "character set of @str.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "bytes_read", argType = TBasicType TUInt64, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "location to store the number of bytes in\n the input string that were successfully converted, or %NULL.\n Even if the conversion was successful, this may be\n less than @len if there were partial characters\n at the end of the input. If the error\n #G_CONVERT_ERROR_ILLEGAL_SEQUENCE occurs, the value\n stored will be the byte offset after the last valid\n input sequence.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "bytes_written", argType = TBasicType TUInt64, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the number of bytes stored in\n the output buffer (not including the terminating nul).", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}] -- Lengths : [Arg {argCName = "len", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the length of the string in bytes, or -1 if the string is\n nul-terminated (Note that some encodings may allow nul\n bytes to occur inside strings. In that case, using -1\n for the @len parameter is unsafe)", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "bytes_written", argType = TBasicType TUInt64, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the number of bytes stored in\n the output buffer (not including the terminating nul).", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}] -- returnType : Just (TCArray False (-1) 5 (TBasicType TUInt8)) -- throws : True -- Skip return : False foreign import ccall "g_convert" g_convert :: Ptr Word8 -> -- str : TCArray False (-1) 1 (TBasicType TUInt8) Int64 -> -- len : TBasicType TInt64 CString -> -- to_codeset : TBasicType TUTF8 CString -> -- from_codeset : TBasicType TUTF8 Ptr Word64 -> -- bytes_read : TBasicType TUInt64 Ptr Word64 -> -- bytes_written : TBasicType TUInt64 Ptr (Ptr GError) -> -- error IO (Ptr Word8) {- | Converts a string from one character set to another. Note that you should use @/g_iconv()/@ for streaming conversions. Despite the fact that /@bytesRead@/ can return information about partial characters, the g_convert_... functions are not generally suitable for streaming. If the underlying converter maintains internal state, then this won\'t be preserved across successive calls to 'GI.GLib.Functions.convert', @/g_convert_with_iconv()/@ or 'GI.GLib.Functions.convertWithFallback'. (An example of this is the GNU C converter for CP1255 which does not emit a base character until it knows that the next character is not a mark that could combine with the base character.) Using extensions such as \"\/\/TRANSLIT\" may not work (or may not work well) on many platforms. Consider using 'GI.GLib.Functions.strToAscii' instead. -} convert :: (B.CallStack.HasCallStack, MonadIO m) => ByteString {- ^ /@str@/: the string to convert. -} -> T.Text {- ^ /@toCodeset@/: name of character set into which to convert /@str@/ -} -> T.Text {- ^ /@fromCodeset@/: character set of /@str@/. -} -> m ((ByteString, Word64)) {- ^ __Returns:__ If the conversion was successful, a newly allocated buffer containing the converted string, which must be freed with 'GI.GLib.Functions.free'. Otherwise 'Nothing' and /@error@/ will be set. /(Can throw 'Data.GI.Base.GError.GError')/ -} convert str toCodeset fromCodeset = liftIO $ do let len = fromIntegral $ B.length str str' <- packByteString str toCodeset' <- textToCString toCodeset fromCodeset' <- textToCString fromCodeset bytesRead <- allocMem :: IO (Ptr Word64) bytesWritten <- allocMem :: IO (Ptr Word64) onException (do result <- propagateGError $ g_convert str' len toCodeset' fromCodeset' bytesRead bytesWritten bytesWritten' <- peek bytesWritten checkUnexpectedReturnNULL "convert" result result' <- (unpackByteStringWithLength bytesWritten') result freeMem result bytesRead' <- peek bytesRead freeMem str' freeMem toCodeset' freeMem fromCodeset' freeMem bytesRead freeMem bytesWritten return (result', bytesRead') ) (do freeMem str' freeMem toCodeset' freeMem fromCodeset' freeMem bytesRead freeMem bytesWritten ) -- function g_compute_hmac_for_string -- Args : [Arg {argCName = "digest_type", argType = TInterface (Name {namespace = "GLib", name = "ChecksumType"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GChecksumType to use for the HMAC", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "key", argType = TCArray False (-1) 2 (TBasicType TUInt8), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the key to use in the HMAC", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "key_len", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the length of the key", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "str", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the string to compute the HMAC for", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "length", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the length of the string, or -1 if the string is nul-terminated", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [Arg {argCName = "key_len", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the length of the key", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_compute_hmac_for_string" g_compute_hmac_for_string :: CUInt -> -- digest_type : TInterface (Name {namespace = "GLib", name = "ChecksumType"}) Ptr Word8 -> -- key : TCArray False (-1) 2 (TBasicType TUInt8) Word64 -> -- key_len : TBasicType TUInt64 CString -> -- str : TBasicType TUTF8 Int64 -> -- length : TBasicType TInt64 IO CString {- | Computes the HMAC for a string. The hexadecimal string returned will be in lower case. /Since: 2.30/ -} computeHmacForString :: (B.CallStack.HasCallStack, MonadIO m) => GLib.Enums.ChecksumType {- ^ /@digestType@/: a 'GI.GLib.Enums.ChecksumType' to use for the HMAC -} -> ByteString {- ^ /@key@/: the key to use in the HMAC -} -> T.Text {- ^ /@str@/: the string to compute the HMAC for -} -> Int64 {- ^ /@length@/: the length of the string, or -1 if the string is nul-terminated -} -> m T.Text {- ^ __Returns:__ the HMAC as a hexadecimal string. The returned string should be freed with 'GI.GLib.Functions.free' when done using it. -} computeHmacForString digestType key str length_ = liftIO $ do let keyLen = fromIntegral $ B.length key let digestType' = (fromIntegral . fromEnum) digestType key' <- packByteString key str' <- textToCString str result <- g_compute_hmac_for_string digestType' key' keyLen str' length_ checkUnexpectedReturnNULL "computeHmacForString" result result' <- cstringToText result freeMem result freeMem key' freeMem str' return result' -- function g_compute_hmac_for_data -- Args : [Arg {argCName = "digest_type", argType = TInterface (Name {namespace = "GLib", name = "ChecksumType"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GChecksumType to use for the HMAC", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "key", argType = TCArray False (-1) 2 (TBasicType TUInt8), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the key to use in the HMAC", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "key_len", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the length of the key", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "data", argType = TCArray False (-1) 4 (TBasicType TUInt8), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "binary blob to compute the HMAC of", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "length", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "length of @data", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [Arg {argCName = "length", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "length of @data", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "key_len", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the length of the key", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_compute_hmac_for_data" g_compute_hmac_for_data :: CUInt -> -- digest_type : TInterface (Name {namespace = "GLib", name = "ChecksumType"}) Ptr Word8 -> -- key : TCArray False (-1) 2 (TBasicType TUInt8) Word64 -> -- key_len : TBasicType TUInt64 Ptr Word8 -> -- data : TCArray False (-1) 4 (TBasicType TUInt8) Word64 -> -- length : TBasicType TUInt64 IO CString {- | Computes the HMAC for a binary /@data@/ of /@length@/. This is a convenience wrapper for @/g_hmac_new()/@, 'GI.GLib.Structs.Hmac.hmacGetString' and 'GI.GLib.Structs.Hmac.hmacUnref'. The hexadecimal string returned will be in lower case. /Since: 2.30/ -} computeHmacForData :: (B.CallStack.HasCallStack, MonadIO m) => GLib.Enums.ChecksumType {- ^ /@digestType@/: a 'GI.GLib.Enums.ChecksumType' to use for the HMAC -} -> ByteString {- ^ /@key@/: the key to use in the HMAC -} -> ByteString {- ^ /@data@/: binary blob to compute the HMAC of -} -> m T.Text {- ^ __Returns:__ the HMAC of the binary data as a string in hexadecimal. The returned string should be freed with 'GI.GLib.Functions.free' when done using it. -} computeHmacForData digestType key data_ = liftIO $ do let length_ = fromIntegral $ B.length data_ let keyLen = fromIntegral $ B.length key let digestType' = (fromIntegral . fromEnum) digestType key' <- packByteString key data_' <- packByteString data_ result <- g_compute_hmac_for_data digestType' key' keyLen data_' length_ checkUnexpectedReturnNULL "computeHmacForData" result result' <- cstringToText result freeMem result freeMem key' freeMem data_' return result' -- function g_compute_hmac_for_bytes -- Args : [Arg {argCName = "digest_type", argType = TInterface (Name {namespace = "GLib", name = "ChecksumType"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GChecksumType to use for the HMAC", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "key", argType = TInterface (Name {namespace = "GLib", name = "Bytes"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the key to use in the HMAC", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "data", argType = TInterface (Name {namespace = "GLib", name = "Bytes"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "binary blob to compute the HMAC of", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_compute_hmac_for_bytes" g_compute_hmac_for_bytes :: CUInt -> -- digest_type : TInterface (Name {namespace = "GLib", name = "ChecksumType"}) Ptr GLib.Bytes.Bytes -> -- key : TInterface (Name {namespace = "GLib", name = "Bytes"}) Ptr GLib.Bytes.Bytes -> -- data : TInterface (Name {namespace = "GLib", name = "Bytes"}) IO CString {- | Computes the HMAC for a binary /@data@/. This is a convenience wrapper for @/g_hmac_new()/@, 'GI.GLib.Structs.Hmac.hmacGetString' and 'GI.GLib.Structs.Hmac.hmacUnref'. The hexadecimal string returned will be in lower case. /Since: 2.50/ -} computeHmacForBytes :: (B.CallStack.HasCallStack, MonadIO m) => GLib.Enums.ChecksumType {- ^ /@digestType@/: a 'GI.GLib.Enums.ChecksumType' to use for the HMAC -} -> GLib.Bytes.Bytes {- ^ /@key@/: the key to use in the HMAC -} -> GLib.Bytes.Bytes {- ^ /@data@/: binary blob to compute the HMAC of -} -> m T.Text {- ^ __Returns:__ the HMAC of the binary data as a string in hexadecimal. The returned string should be freed with 'GI.GLib.Functions.free' when done using it. -} computeHmacForBytes digestType key data_ = liftIO $ do let digestType' = (fromIntegral . fromEnum) digestType key' <- unsafeManagedPtrGetPtr key data_' <- unsafeManagedPtrGetPtr data_ result <- g_compute_hmac_for_bytes digestType' key' data_' checkUnexpectedReturnNULL "computeHmacForBytes" result result' <- cstringToText result freeMem result touchManagedPtr key touchManagedPtr data_ return result' -- function g_compute_checksum_for_string -- Args : [Arg {argCName = "checksum_type", argType = TInterface (Name {namespace = "GLib", name = "ChecksumType"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GChecksumType", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "str", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the string to compute the checksum of", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "length", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the length of the string, or -1 if the string is null-terminated.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_compute_checksum_for_string" g_compute_checksum_for_string :: CUInt -> -- checksum_type : TInterface (Name {namespace = "GLib", name = "ChecksumType"}) CString -> -- str : TBasicType TUTF8 Int64 -> -- length : TBasicType TInt64 IO CString {- | Computes the checksum of a string. The hexadecimal string returned will be in lower case. /Since: 2.16/ -} computeChecksumForString :: (B.CallStack.HasCallStack, MonadIO m) => GLib.Enums.ChecksumType {- ^ /@checksumType@/: a 'GI.GLib.Enums.ChecksumType' -} -> T.Text {- ^ /@str@/: the string to compute the checksum of -} -> Int64 {- ^ /@length@/: the length of the string, or -1 if the string is null-terminated. -} -> m T.Text {- ^ __Returns:__ the checksum as a hexadecimal string. The returned string should be freed with 'GI.GLib.Functions.free' when done using it. -} computeChecksumForString checksumType str length_ = liftIO $ do let checksumType' = (fromIntegral . fromEnum) checksumType str' <- textToCString str result <- g_compute_checksum_for_string checksumType' str' length_ checkUnexpectedReturnNULL "computeChecksumForString" result result' <- cstringToText result freeMem result freeMem str' return result' -- function g_compute_checksum_for_data -- Args : [Arg {argCName = "checksum_type", argType = TInterface (Name {namespace = "GLib", name = "ChecksumType"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GChecksumType", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "data", argType = TCArray False (-1) 2 (TBasicType TUInt8), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "binary blob to compute the digest of", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "length", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "length of @data", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [Arg {argCName = "length", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "length of @data", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_compute_checksum_for_data" g_compute_checksum_for_data :: CUInt -> -- checksum_type : TInterface (Name {namespace = "GLib", name = "ChecksumType"}) Ptr Word8 -> -- data : TCArray False (-1) 2 (TBasicType TUInt8) Word64 -> -- length : TBasicType TUInt64 IO CString {- | Computes the checksum for a binary /@data@/ of /@length@/. This is a convenience wrapper for 'GI.GLib.Structs.Checksum.checksumNew', 'GI.GLib.Structs.Checksum.checksumGetString' and 'GI.GLib.Structs.Checksum.checksumFree'. The hexadecimal string returned will be in lower case. /Since: 2.16/ -} computeChecksumForData :: (B.CallStack.HasCallStack, MonadIO m) => GLib.Enums.ChecksumType {- ^ /@checksumType@/: a 'GI.GLib.Enums.ChecksumType' -} -> ByteString {- ^ /@data@/: binary blob to compute the digest of -} -> m T.Text {- ^ __Returns:__ the digest of the binary data as a string in hexadecimal. The returned string should be freed with 'GI.GLib.Functions.free' when done using it. -} computeChecksumForData checksumType data_ = liftIO $ do let length_ = fromIntegral $ B.length data_ let checksumType' = (fromIntegral . fromEnum) checksumType data_' <- packByteString data_ result <- g_compute_checksum_for_data checksumType' data_' length_ checkUnexpectedReturnNULL "computeChecksumForData" result result' <- cstringToText result freeMem result freeMem data_' return result' -- function g_compute_checksum_for_bytes -- Args : [Arg {argCName = "checksum_type", argType = TInterface (Name {namespace = "GLib", name = "ChecksumType"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GChecksumType", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "data", argType = TInterface (Name {namespace = "GLib", name = "Bytes"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "binary blob to compute the digest of", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_compute_checksum_for_bytes" g_compute_checksum_for_bytes :: CUInt -> -- checksum_type : TInterface (Name {namespace = "GLib", name = "ChecksumType"}) Ptr GLib.Bytes.Bytes -> -- data : TInterface (Name {namespace = "GLib", name = "Bytes"}) IO CString {- | Computes the checksum for a binary /@data@/. This is a convenience wrapper for 'GI.GLib.Structs.Checksum.checksumNew', 'GI.GLib.Structs.Checksum.checksumGetString' and 'GI.GLib.Structs.Checksum.checksumFree'. The hexadecimal string returned will be in lower case. /Since: 2.34/ -} computeChecksumForBytes :: (B.CallStack.HasCallStack, MonadIO m) => GLib.Enums.ChecksumType {- ^ /@checksumType@/: a 'GI.GLib.Enums.ChecksumType' -} -> GLib.Bytes.Bytes {- ^ /@data@/: binary blob to compute the digest of -} -> m T.Text {- ^ __Returns:__ the digest of the binary data as a string in hexadecimal. The returned string should be freed with 'GI.GLib.Functions.free' when done using it. -} computeChecksumForBytes checksumType data_ = liftIO $ do let checksumType' = (fromIntegral . fromEnum) checksumType data_' <- unsafeManagedPtrGetPtr data_ result <- g_compute_checksum_for_bytes checksumType' data_' checkUnexpectedReturnNULL "computeChecksumForBytes" result result' <- cstringToText result freeMem result touchManagedPtr data_ return result' -- function g_close -- Args : [Arg {argCName = "fd", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A file descriptor", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : True -- Skip return : False foreign import ccall "g_close" g_close :: Int32 -> -- fd : TBasicType TInt Ptr (Ptr GError) -> -- error IO CInt {- | This wraps the @/close()/@ call; in case of error, @/errno/@ will be preserved, but the error will also be stored as a 'GError' in /@error@/. Besides using 'GError', there is another major reason to prefer this function over the call provided by the system; on Unix, it will attempt to correctly handle @/EINTR/@, which has platform-specific semantics. /Since: 2.36/ -} close :: (B.CallStack.HasCallStack, MonadIO m) => Int32 {- ^ /@fd@/: A file descriptor -} -> m () {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -} close fd = liftIO $ do onException (do _ <- propagateGError $ g_close fd return () ) (do return () ) -- function g_clear_error -- Args : [] -- Lengths : [] -- returnType : Nothing -- throws : True -- Skip return : False foreign import ccall "g_clear_error" g_clear_error :: Ptr (Ptr GError) -> -- error IO () {- | If /@err@/ or */@err@/ is 'Nothing', does nothing. Otherwise, calls 'GI.GLib.Structs.Error.errorFree' on */@err@/ and sets */@err@/ to 'Nothing'. -} clearError :: (B.CallStack.HasCallStack, MonadIO m) => m () {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -} clearError = liftIO $ do onException (do propagateGError $ g_clear_error return () ) (do return () ) -- function g_child_watch_source_new -- Args : [Arg {argCName = "pid", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "process to watch. On POSIX the positive pid of a child process. On\nWindows a handle for a process (which doesn't have to be a child).", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TInterface (Name {namespace = "GLib", name = "Source"})) -- throws : False -- Skip return : False foreign import ccall "g_child_watch_source_new" g_child_watch_source_new :: Int32 -> -- pid : TBasicType TInt IO (Ptr GLib.Source.Source) {- | Creates a new child_watch source. The source will not initially be associated with any 'GI.GLib.Structs.MainContext.MainContext' and must be added to one with 'GI.GLib.Structs.Source.sourceAttach' before it will be executed. Note that child watch sources can only be used in conjunction with @g_spawn...@ when the 'GI.GLib.Flags.SpawnFlagsDoNotReapChild' flag is used. Note that on platforms where @/GPid/@ must be explicitly closed (see 'GI.GLib.Functions.spawnClosePid') /@pid@/ must not be closed while the source is still active. Typically, you will want to call 'GI.GLib.Functions.spawnClosePid' in the callback function for the source. On POSIX platforms, the following restrictions apply to this API due to limitations in POSIX process interfaces: * /@pid@/ must be a child of this process * /@pid@/ must be positive * the application must not call @waitpid@ with a non-positive first argument, for instance in another thread * the application must not wait for /@pid@/ to exit by any other mechanism, including @waitpid(pid, ...)@ or a second child-watch source for the same /@pid@/ * the application must not ignore SIGCHILD If any of those conditions are not met, this and related APIs will not work correctly. This can often be diagnosed via a GLib warning stating that @ECHILD@ was received by @waitpid@. Calling @waitpid@ for specific processes other than /@pid@/ remains a valid thing to do. /Since: 2.4/ -} childWatchSourceNew :: (B.CallStack.HasCallStack, MonadIO m) => Int32 {- ^ /@pid@/: process to watch. On POSIX the positive pid of a child process. On Windows a handle for a process (which doesn\'t have to be a child). -} -> m GLib.Source.Source {- ^ __Returns:__ the newly-created child watch source -} childWatchSourceNew pid = liftIO $ do result <- g_child_watch_source_new pid checkUnexpectedReturnNULL "childWatchSourceNew" result result' <- (wrapBoxed GLib.Source.Source) result return result' -- function g_child_watch_add_full -- Args : [Arg {argCName = "priority", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the priority of the idle source. Typically this will be in the\n range between #G_PRIORITY_DEFAULT_IDLE and #G_PRIORITY_HIGH_IDLE.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "pid", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "process to watch. On POSIX the positive pid of a child process. On\nWindows a handle for a process (which doesn't have to be a child).", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "function", argType = TInterface (Name {namespace = "GLib", name = "ChildWatchFunc"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "function to call", sinceVersion = Nothing}, argScope = ScopeTypeNotified, argClosure = 3, argDestroy = 4, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "data to pass to @function", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "notify", argType = TInterface (Name {namespace = "GLib", name = "DestroyNotify"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "function to call when the idle is removed, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUInt) -- throws : False -- Skip return : False foreign import ccall "g_child_watch_add_full" g_child_watch_add_full :: Int32 -> -- priority : TBasicType TInt Int32 -> -- pid : TBasicType TInt FunPtr GLib.Callbacks.C_ChildWatchFunc -> -- function : TInterface (Name {namespace = "GLib", name = "ChildWatchFunc"}) Ptr () -> -- data : TBasicType TPtr FunPtr GLib.Callbacks.C_DestroyNotify -> -- notify : TInterface (Name {namespace = "GLib", name = "DestroyNotify"}) IO Word32 {- | Sets a function to be called when the child indicated by /@pid@/ exits, at the priority /@priority@/. If you obtain /@pid@/ from 'GI.GLib.Functions.spawnAsync' or 'GI.GLib.Functions.spawnAsyncWithPipes' you will need to pass @/G_SPAWN_DO_NOT_REAP_CHILD/@ as flag to the spawn function for the child watching to work. In many programs, you will want to call 'GI.GLib.Functions.spawnCheckExitStatus' in the callback to determine whether or not the child exited successfully. Also, note that on platforms where @/GPid/@ must be explicitly closed (see 'GI.GLib.Functions.spawnClosePid') /@pid@/ must not be closed while the source is still active. Typically, you should invoke 'GI.GLib.Functions.spawnClosePid' in the callback function for the source. GLib supports only a single callback per process id. On POSIX platforms, the same restrictions mentioned for 'GI.GLib.Functions.childWatchSourceNew' apply to this function. This internally creates a main loop source using 'GI.GLib.Functions.childWatchSourceNew' and attaches it to the main loop context using 'GI.GLib.Structs.Source.sourceAttach'. You can do these steps manually if you need greater control. /Since: 2.4/ -} childWatchAdd :: (B.CallStack.HasCallStack, MonadIO m) => Int32 {- ^ /@priority@/: the priority of the idle source. Typically this will be in the range between 'GI.GLib.Constants.PRIORITY_DEFAULT_IDLE' and 'GI.GLib.Constants.PRIORITY_HIGH_IDLE'. -} -> Int32 {- ^ /@pid@/: process to watch. On POSIX the positive pid of a child process. On Windows a handle for a process (which doesn\'t have to be a child). -} -> GLib.Callbacks.ChildWatchFunc {- ^ /@function@/: function to call -} -> m Word32 {- ^ __Returns:__ the ID (greater than 0) of the event source. -} childWatchAdd priority pid function = liftIO $ do function' <- GLib.Callbacks.mk_ChildWatchFunc (GLib.Callbacks.wrap_ChildWatchFunc Nothing (GLib.Callbacks.drop_closures_ChildWatchFunc function)) let data_ = castFunPtrToPtr function' let notify = safeFreeFunPtrPtr result <- g_child_watch_add_full priority pid function' data_ notify return result -- function glib_check_version -- Args : [Arg {argCName = "required_major", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the required major version", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "required_minor", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the required minor version", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "required_micro", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the required micro version", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "glib_check_version" glib_check_version :: Word32 -> -- required_major : TBasicType TUInt Word32 -> -- required_minor : TBasicType TUInt Word32 -> -- required_micro : TBasicType TUInt IO CString {- | Checks that the GLib library in use is compatible with the given version. Generally you would pass in the constants 'GI.GLib.Constants.MAJOR_VERSION', 'GI.GLib.Constants.MINOR_VERSION', 'GI.GLib.Constants.MICRO_VERSION' as the three arguments to this function; that produces a check that the library in use is compatible with the version of GLib the application or module was compiled against. Compatibility is defined by two things: first the version of the running library is newer than the version /@requiredMajor@/.required_minor./@requiredMicro@/. Second the running library must be binary compatible with the version /@requiredMajor@/.required_minor./@requiredMicro@/ (same major version.) /Since: 2.6/ -} checkVersion :: (B.CallStack.HasCallStack, MonadIO m) => Word32 {- ^ /@requiredMajor@/: the required major version -} -> Word32 {- ^ /@requiredMinor@/: the required minor version -} -> Word32 {- ^ /@requiredMicro@/: the required micro version -} -> m T.Text {- ^ __Returns:__ 'Nothing' if the GLib library is compatible with the given version, or a string describing the version mismatch. The returned string is owned by GLib and must not be modified or freed. -} checkVersion requiredMajor requiredMinor requiredMicro = liftIO $ do result <- glib_check_version requiredMajor requiredMinor requiredMicro checkUnexpectedReturnNULL "checkVersion" result result' <- cstringToText result return result' -- function g_chdir -- Args : [Arg {argCName = "path", argType = TBasicType TFileName, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a pathname in the GLib file name encoding\n (UTF-8 on Windows)", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TInt) -- throws : False -- Skip return : False foreign import ccall "g_chdir" g_chdir :: CString -> -- path : TBasicType TFileName IO Int32 {- | A wrapper for the POSIX @/chdir()/@ function. The function changes the current directory of the process to /@path@/. See your C library manual for more details about @/chdir()/@. /Since: 2.8/ -} chdir :: (B.CallStack.HasCallStack, MonadIO m) => [Char] {- ^ /@path@/: a pathname in the GLib file name encoding (UTF-8 on Windows) -} -> m Int32 {- ^ __Returns:__ 0 on success, -1 if an error occurred. -} chdir path = liftIO $ do path' <- stringToCString path result <- g_chdir path' freeMem path' return result -- function g_canonicalize_filename -- Args : [Arg {argCName = "filename", argType = TBasicType TFileName, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the name of the file", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "relative_to", argType = TBasicType TFileName, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the relative directory, or %NULL\nto use the current working directory", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TFileName) -- throws : False -- Skip return : False foreign import ccall "g_canonicalize_filename" g_canonicalize_filename :: CString -> -- filename : TBasicType TFileName CString -> -- relative_to : TBasicType TFileName IO CString {- | Gets the canonical file name from /@filename@/. All triple slashes are turned into single slashes, and all @..@ and @.@s resolved against /@relativeTo@/. Symlinks are not followed, and the returned path is guaranteed to be absolute. If /@filename@/ is an absolute path, /@relativeTo@/ is ignored. Otherwise, /@relativeTo@/ will be prepended to /@filename@/ to make it absolute. /@relativeTo@/ must be an absolute path, or 'Nothing'. If /@relativeTo@/ is 'Nothing', it\'ll fallback to 'GI.GLib.Functions.getCurrentDir'. This function never fails, and will canonicalize file paths even if they don\'t exist. No file system I\/O is done. /Since: 2.58/ -} canonicalizeFilename :: (B.CallStack.HasCallStack, MonadIO m) => [Char] {- ^ /@filename@/: the name of the file -} -> Maybe ([Char]) {- ^ /@relativeTo@/: the relative directory, or 'Nothing' to use the current working directory -} -> m [Char] {- ^ __Returns:__ a newly allocated string with the canonical file path -} canonicalizeFilename filename relativeTo = liftIO $ do filename' <- stringToCString filename maybeRelativeTo <- case relativeTo of Nothing -> return nullPtr Just jRelativeTo -> do jRelativeTo' <- stringToCString jRelativeTo return jRelativeTo' result <- g_canonicalize_filename filename' maybeRelativeTo checkUnexpectedReturnNULL "canonicalizeFilename" result result' <- cstringToString result freeMem result freeMem filename' freeMem maybeRelativeTo return result' -- function g_build_pathv -- Args : [Arg {argCName = "separator", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a string used to separator the elements of the path.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "args", argType = TCArray True (-1) (-1) (TBasicType TFileName), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "%NULL-terminated\n array of strings containing the path elements.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TFileName) -- throws : False -- Skip return : False foreign import ccall "g_build_pathv" g_build_pathv :: CString -> -- separator : TBasicType TUTF8 Ptr CString -> -- args : TCArray True (-1) (-1) (TBasicType TFileName) IO CString {- | Behaves exactly like @/g_build_path()/@, but takes the path elements as a string array, instead of varargs. This function is mainly meant for language bindings. /Since: 2.8/ -} buildPathv :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@separator@/: a string used to separator the elements of the path. -} -> [[Char]] {- ^ /@args@/: 'Nothing'-terminated array of strings containing the path elements. -} -> m [Char] {- ^ __Returns:__ a newly-allocated string that must be freed with 'GI.GLib.Functions.free'. -} buildPathv separator args = liftIO $ do separator' <- textToCString separator args' <- packZeroTerminatedFileNameArray args result <- g_build_pathv separator' args' checkUnexpectedReturnNULL "buildPathv" result result' <- cstringToString result freeMem result freeMem separator' mapZeroTerminatedCArray freeMem args' freeMem args' return result' -- function g_build_filenamev -- Args : [Arg {argCName = "args", argType = TCArray True (-1) (-1) (TBasicType TFileName), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "%NULL-terminated\n array of strings containing the path elements.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TFileName) -- throws : False -- Skip return : False foreign import ccall "g_build_filenamev" g_build_filenamev :: Ptr CString -> -- args : TCArray True (-1) (-1) (TBasicType TFileName) IO CString {- | Behaves exactly like @/g_build_filename()/@, but takes the path elements as a string array, instead of varargs. This function is mainly meant for language bindings. /Since: 2.8/ -} buildFilenamev :: (B.CallStack.HasCallStack, MonadIO m) => [[Char]] {- ^ /@args@/: 'Nothing'-terminated array of strings containing the path elements. -} -> m [Char] {- ^ __Returns:__ a newly-allocated string that must be freed with 'GI.GLib.Functions.free'. -} buildFilenamev args = liftIO $ do args' <- packZeroTerminatedFileNameArray args result <- g_build_filenamev args' checkUnexpectedReturnNULL "buildFilenamev" result result' <- cstringToString result freeMem result mapZeroTerminatedCArray freeMem args' freeMem args' return result' -- function g_bit_unlock -- Args : [Arg {argCName = "address", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a pointer to an integer", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "lock_bit", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a bit value between 0 and 31", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_bit_unlock" g_bit_unlock :: Int32 -> -- address : TBasicType TInt Int32 -> -- lock_bit : TBasicType TInt IO () {- | Clears the indicated /@lockBit@/ in /@address@/. If another thread is currently blocked in 'GI.GLib.Functions.bitLock' on this same bit then it will be woken up. This function accesses /@address@/ atomically. All other accesses to /@address@/ must be atomic in order for this function to work reliably. /Since: 2.24/ -} bitUnlock :: (B.CallStack.HasCallStack, MonadIO m) => Int32 {- ^ /@address@/: a pointer to an integer -} -> Int32 {- ^ /@lockBit@/: a bit value between 0 and 31 -} -> m () bitUnlock address lockBit = liftIO $ do g_bit_unlock address lockBit return () -- function g_bit_trylock -- Args : [Arg {argCName = "address", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a pointer to an integer", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "lock_bit", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a bit value between 0 and 31", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "g_bit_trylock" g_bit_trylock :: Int32 -> -- address : TBasicType TInt Int32 -> -- lock_bit : TBasicType TInt IO CInt {- | Sets the indicated /@lockBit@/ in /@address@/, returning 'True' if successful. If the bit is already set, returns 'False' immediately. Attempting to lock on two different bits within the same integer is not supported. The value of the bit that is set is (1u \<\< /@bit@/). If /@bit@/ is not between 0 and 31 then the result is undefined. This function accesses /@address@/ atomically. All other accesses to /@address@/ must be atomic in order for this function to work reliably. /Since: 2.24/ -} bitTrylock :: (B.CallStack.HasCallStack, MonadIO m) => Int32 {- ^ /@address@/: a pointer to an integer -} -> Int32 {- ^ /@lockBit@/: a bit value between 0 and 31 -} -> m Bool {- ^ __Returns:__ 'True' if the lock was acquired -} bitTrylock address lockBit = liftIO $ do result <- g_bit_trylock address lockBit let result' = (/= 0) result return result' -- function g_bit_storage -- Args : [Arg {argCName = "number", argType = TBasicType TULong, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #guint", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUInt) -- throws : False -- Skip return : False foreign import ccall "g_bit_storage" g_bit_storage :: CULong -> -- number : TBasicType TULong IO Word32 {- | Gets the number of bits used to hold /@number@/, e.g. if /@number@/ is 4, 3 bits are needed. -} bitStorage :: (B.CallStack.HasCallStack, MonadIO m) => CULong {- ^ /@number@/: a @/guint/@ -} -> m Word32 {- ^ __Returns:__ the number of bits used to hold /@number@/ -} bitStorage number = liftIO $ do result <- g_bit_storage number return result -- function g_bit_nth_msf -- Args : [Arg {argCName = "mask", argType = TBasicType TULong, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #gulong containing flags", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "nth_bit", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the index of the bit to start the search from", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TInt) -- throws : False -- Skip return : False foreign import ccall "g_bit_nth_msf" g_bit_nth_msf :: CULong -> -- mask : TBasicType TULong Int32 -> -- nth_bit : TBasicType TInt IO Int32 {- | Find the position of the first bit set in /@mask@/, searching from (but not including) /@nthBit@/ downwards. Bits are numbered from 0 (least significant) to sizeof(@/gulong/@) * 8 - 1 (31 or 63, usually). To start searching from the last bit, set /@nthBit@/ to -1 or GLIB_SIZEOF_LONG * 8. -} bitNthMsf :: (B.CallStack.HasCallStack, MonadIO m) => CULong {- ^ /@mask@/: a @/gulong/@ containing flags -} -> Int32 {- ^ /@nthBit@/: the index of the bit to start the search from -} -> m Int32 {- ^ __Returns:__ the index of the first bit set which is lower than /@nthBit@/, or -1 if no lower bits are set -} bitNthMsf mask nthBit = liftIO $ do result <- g_bit_nth_msf mask nthBit return result -- function g_bit_nth_lsf -- Args : [Arg {argCName = "mask", argType = TBasicType TULong, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #gulong containing flags", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "nth_bit", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the index of the bit to start the search from", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TInt) -- throws : False -- Skip return : False foreign import ccall "g_bit_nth_lsf" g_bit_nth_lsf :: CULong -> -- mask : TBasicType TULong Int32 -> -- nth_bit : TBasicType TInt IO Int32 {- | Find the position of the first bit set in /@mask@/, searching from (but not including) /@nthBit@/ upwards. Bits are numbered from 0 (least significant) to sizeof(@/gulong/@) * 8 - 1 (31 or 63, usually). To start searching from the 0th bit, set /@nthBit@/ to -1. -} bitNthLsf :: (B.CallStack.HasCallStack, MonadIO m) => CULong {- ^ /@mask@/: a @/gulong/@ containing flags -} -> Int32 {- ^ /@nthBit@/: the index of the bit to start the search from -} -> m Int32 {- ^ __Returns:__ the index of the first bit set which is higher than /@nthBit@/, or -1 if no higher bits are set -} bitNthLsf mask nthBit = liftIO $ do result <- g_bit_nth_lsf mask nthBit return result -- function g_bit_lock -- Args : [Arg {argCName = "address", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a pointer to an integer", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "lock_bit", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a bit value between 0 and 31", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_bit_lock" g_bit_lock :: Int32 -> -- address : TBasicType TInt Int32 -> -- lock_bit : TBasicType TInt IO () {- | Sets the indicated /@lockBit@/ in /@address@/. If the bit is already set, this call will block until 'GI.GLib.Functions.bitUnlock' unsets the corresponding bit. Attempting to lock on two different bits within the same integer is not supported and will very probably cause deadlocks. The value of the bit that is set is (1u \<\< /@bit@/). If /@bit@/ is not between 0 and 31 then the result is undefined. This function accesses /@address@/ atomically. All other accesses to /@address@/ must be atomic in order for this function to work reliably. /Since: 2.24/ -} bitLock :: (B.CallStack.HasCallStack, MonadIO m) => Int32 {- ^ /@address@/: a pointer to an integer -} -> Int32 {- ^ /@lockBit@/: a bit value between 0 and 31 -} -> m () bitLock address lockBit = liftIO $ do g_bit_lock address lockBit return () -- function g_basename -- Args : [Arg {argCName = "file_name", argType = TBasicType TFileName, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the name of the file", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TFileName) -- throws : False -- Skip return : False foreign import ccall "g_basename" g_basename :: CString -> -- file_name : TBasicType TFileName IO CString {-# DEPRECATED basename ["(Since version 2.2)","Use 'GI.GLib.Functions.pathGetBasename' instead, but notice"," that 'GI.GLib.Functions.pathGetBasename' allocates new memory for the"," returned string, unlike this function which returns a pointer"," into the argument."] #-} {- | Gets the name of the file without any leading directory components. It returns a pointer into the given file name string. -} basename :: (B.CallStack.HasCallStack, MonadIO m) => [Char] {- ^ /@fileName@/: the name of the file -} -> m [Char] {- ^ __Returns:__ the name of the file without any leading directory components -} basename fileName = liftIO $ do fileName' <- stringToCString fileName result <- g_basename fileName' checkUnexpectedReturnNULL "basename" result result' <- cstringToString result freeMem fileName' return result' -- function g_base64_encode -- Args : [Arg {argCName = "data", argType = TCArray False (-1) 1 (TBasicType TUInt8), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the binary data to encode", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "len", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the length of @data", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [Arg {argCName = "len", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the length of @data", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_base64_encode" g_base64_encode :: Ptr Word8 -> -- data : TCArray False (-1) 1 (TBasicType TUInt8) Word64 -> -- len : TBasicType TUInt64 IO CString {- | Encode a sequence of binary data into its Base-64 stringified representation. /Since: 2.12/ -} base64Encode :: (B.CallStack.HasCallStack, MonadIO m) => Maybe (ByteString) {- ^ /@data@/: the binary data to encode -} -> m T.Text {- ^ __Returns:__ a newly allocated, zero-terminated Base-64 encoded string representing /@data@/. The returned string must be freed with 'GI.GLib.Functions.free'. -} base64Encode data_ = liftIO $ do let len = case data_ of Nothing -> 0 Just jData_ -> fromIntegral $ B.length jData_ maybeData_ <- case data_ of Nothing -> return nullPtr Just jData_ -> do jData_' <- packByteString jData_ return jData_' result <- g_base64_encode maybeData_ len checkUnexpectedReturnNULL "base64Encode" result result' <- cstringToText result freeMem result freeMem maybeData_ return result' -- function g_base64_decode_inplace -- Args : [Arg {argCName = "text", argType = TCArray False (-1) 1 (TBasicType TUInt8), direction = DirectionInout, mayBeNull = False, argDoc = Documentation {rawDocText = Just "zero-terminated\n string with base64 text to decode", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "out_len", argType = TBasicType TUInt64, direction = DirectionInout, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The length of the decoded data is written here", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [Arg {argCName = "out_len", argType = TBasicType TUInt64, direction = DirectionInout, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The length of the decoded data is written here", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- returnType : Just (TBasicType TUInt8) -- throws : False -- Skip return : False foreign import ccall "g_base64_decode_inplace" g_base64_decode_inplace :: Ptr (Ptr Word8) -> -- text : TCArray False (-1) 1 (TBasicType TUInt8) Ptr Word64 -> -- out_len : TBasicType TUInt64 IO Word8 {- | Decode a sequence of Base-64 encoded text into binary data by overwriting the input data. /Since: 2.20/ -} base64DecodeInplace :: (B.CallStack.HasCallStack, MonadIO m) => ByteString {- ^ /@text@/: zero-terminated string with base64 text to decode -} -> m ((Word8, ByteString)) {- ^ __Returns:__ The binary data that /@text@/ responds. This pointer is the same as the input /@text@/. -} base64DecodeInplace text = liftIO $ do let outLen = fromIntegral $ B.length text text' <- packByteString text text'' <- allocMem :: IO (Ptr (Ptr Word8)) poke text'' text' outLen' <- allocMem :: IO (Ptr Word64) poke outLen' outLen result <- g_base64_decode_inplace text'' outLen' outLen'' <- peek outLen' text''' <- peek text'' text'''' <- (unpackByteStringWithLength outLen'') text''' freeMem text''' freeMem text'' freeMem outLen' return (result, text'''') -- function g_base64_decode -- Args : [Arg {argCName = "text", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "zero-terminated string with base64 text to decode", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "out_len", argType = TBasicType TUInt64, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The length of the decoded data is written here", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}] -- Lengths : [Arg {argCName = "out_len", argType = TBasicType TUInt64, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The length of the decoded data is written here", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}] -- returnType : Just (TCArray False (-1) 1 (TBasicType TUInt8)) -- throws : False -- Skip return : False foreign import ccall "g_base64_decode" g_base64_decode :: CString -> -- text : TBasicType TUTF8 Ptr Word64 -> -- out_len : TBasicType TUInt64 IO (Ptr Word8) {- | Decode a sequence of Base-64 encoded text into binary data. Note that the returned binary data is not necessarily zero-terminated, so it should not be used as a character string. /Since: 2.12/ -} base64Decode :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@text@/: zero-terminated string with base64 text to decode -} -> m ByteString {- ^ __Returns:__ newly allocated buffer containing the binary data that /@text@/ represents. The returned buffer must be freed with 'GI.GLib.Functions.free'. -} base64Decode text = liftIO $ do text' <- textToCString text outLen <- allocMem :: IO (Ptr Word64) result <- g_base64_decode text' outLen outLen' <- peek outLen checkUnexpectedReturnNULL "base64Decode" result result' <- (unpackByteStringWithLength outLen') result freeMem result freeMem text' freeMem outLen return result' -- function g_atomic_ref_count_init -- Args : [Arg {argCName = "arc", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the address of an atomic reference count variable", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_atomic_ref_count_init" g_atomic_ref_count_init :: Int32 -> -- arc : TBasicType TInt IO () {- | Initializes a reference count variable. /Since: 2.58/ -} atomicRefCountInit :: (B.CallStack.HasCallStack, MonadIO m) => Int32 {- ^ /@arc@/: the address of an atomic reference count variable -} -> m () atomicRefCountInit arc = liftIO $ do g_atomic_ref_count_init arc return () -- function g_atomic_ref_count_inc -- Args : [Arg {argCName = "arc", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the address of an atomic reference count variable", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_atomic_ref_count_inc" g_atomic_ref_count_inc :: Int32 -> -- arc : TBasicType TInt IO () {- | Atomically increases the reference count. /Since: 2.58/ -} atomicRefCountInc :: (B.CallStack.HasCallStack, MonadIO m) => Int32 {- ^ /@arc@/: the address of an atomic reference count variable -} -> m () atomicRefCountInc arc = liftIO $ do g_atomic_ref_count_inc arc return () -- function g_atomic_ref_count_dec -- Args : [Arg {argCName = "arc", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the address of an atomic reference count variable", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "g_atomic_ref_count_dec" g_atomic_ref_count_dec :: Int32 -> -- arc : TBasicType TInt IO CInt {- | Atomically decreases the reference count. /Since: 2.58/ -} atomicRefCountDec :: (B.CallStack.HasCallStack, MonadIO m) => Int32 {- ^ /@arc@/: the address of an atomic reference count variable -} -> m Bool {- ^ __Returns:__ 'True' if the reference count reached 0, and 'False' otherwise -} atomicRefCountDec arc = liftIO $ do result <- g_atomic_ref_count_dec arc let result' = (/= 0) result return result' -- function g_atomic_ref_count_compare -- Args : [Arg {argCName = "arc", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the address of an atomic reference count variable", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "val", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the value to compare", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "g_atomic_ref_count_compare" g_atomic_ref_count_compare :: Int32 -> -- arc : TBasicType TInt Int32 -> -- val : TBasicType TInt IO CInt {- | Atomically compares the current value of /@arc@/ with /@val@/. /Since: 2.58/ -} atomicRefCountCompare :: (B.CallStack.HasCallStack, MonadIO m) => Int32 {- ^ /@arc@/: the address of an atomic reference count variable -} -> Int32 {- ^ /@val@/: the value to compare -} -> m Bool {- ^ __Returns:__ 'True' if the reference count is the same as the given value -} atomicRefCountCompare arc val = liftIO $ do result <- g_atomic_ref_count_compare arc val let result' = (/= 0) result return result' -- function g_atomic_rc_box_release_full -- Args : [Arg {argCName = "mem_block", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a pointer to reference counted data", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "clear_func", argType = TInterface (Name {namespace = "GLib", name = "DestroyNotify"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a function to call when clearing the data", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_atomic_rc_box_release_full" g_atomic_rc_box_release_full :: Ptr () -> -- mem_block : TBasicType TPtr FunPtr GLib.Callbacks.C_DestroyNotify -> -- clear_func : TInterface (Name {namespace = "GLib", name = "DestroyNotify"}) IO () {- | Atomically releases a reference on the data pointed by /@memBlock@/. If the reference was the last one, it will call /@clearFunc@/ to clear the contents of /@memBlock@/, and then will free the resources allocated for /@memBlock@/. /Since: 2.58/ -} atomicRcBoxReleaseFull :: (B.CallStack.HasCallStack, MonadIO m) => Ptr () {- ^ /@memBlock@/: a pointer to reference counted data -} -> GLib.Callbacks.DestroyNotify {- ^ /@clearFunc@/: a function to call when clearing the data -} -> m () atomicRcBoxReleaseFull memBlock clearFunc = liftIO $ do ptrclearFunc <- callocMem :: IO (Ptr (FunPtr GLib.Callbacks.C_DestroyNotify)) clearFunc' <- GLib.Callbacks.mk_DestroyNotify (GLib.Callbacks.wrap_DestroyNotify (Just ptrclearFunc) clearFunc) poke ptrclearFunc clearFunc' g_atomic_rc_box_release_full memBlock clearFunc' return () -- function g_atomic_rc_box_release -- Args : [Arg {argCName = "mem_block", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a pointer to reference counted data", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_atomic_rc_box_release" g_atomic_rc_box_release :: Ptr () -> -- mem_block : TBasicType TPtr IO () {- | Atomically releases a reference on the data pointed by /@memBlock@/. If the reference was the last one, it will free the resources allocated for /@memBlock@/. /Since: 2.58/ -} atomicRcBoxRelease :: (B.CallStack.HasCallStack, MonadIO m) => Ptr () {- ^ /@memBlock@/: a pointer to reference counted data -} -> m () atomicRcBoxRelease memBlock = liftIO $ do g_atomic_rc_box_release memBlock return () -- function g_atomic_rc_box_get_size -- Args : [Arg {argCName = "mem_block", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a pointer to reference counted data", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUInt64) -- throws : False -- Skip return : False foreign import ccall "g_atomic_rc_box_get_size" g_atomic_rc_box_get_size :: Ptr () -> -- mem_block : TBasicType TPtr IO Word64 {- | Retrieves the size of the reference counted data pointed by /@memBlock@/. /Since: 2.58/ -} atomicRcBoxGetSize :: (B.CallStack.HasCallStack, MonadIO m) => Ptr () {- ^ /@memBlock@/: a pointer to reference counted data -} -> m Word64 {- ^ __Returns:__ the size of the data, in bytes -} atomicRcBoxGetSize memBlock = liftIO $ do result <- g_atomic_rc_box_get_size memBlock return result -- function g_atomic_rc_box_dup -- Args : [Arg {argCName = "block_size", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the number of bytes to copy, must be greater than 0", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "mem_block", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the memory to copy", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TPtr) -- throws : False -- Skip return : False foreign import ccall "g_atomic_rc_box_dup" g_atomic_rc_box_dup :: Word64 -> -- block_size : TBasicType TUInt64 Ptr () -> -- mem_block : TBasicType TPtr IO (Ptr ()) {- | Allocates a new block of data with atomit reference counting semantics, and copies /@blockSize@/ bytes of /@memBlock@/ into it. /Since: 2.58/ -} atomicRcBoxDup :: (B.CallStack.HasCallStack, MonadIO m) => Word64 {- ^ /@blockSize@/: the number of bytes to copy, must be greater than 0 -} -> Ptr () {- ^ /@memBlock@/: the memory to copy -} -> m (Ptr ()) {- ^ __Returns:__ a pointer to the allocated memory -} atomicRcBoxDup blockSize memBlock = liftIO $ do result <- g_atomic_rc_box_dup blockSize memBlock return result -- function g_atomic_rc_box_alloc0 -- Args : [Arg {argCName = "block_size", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the size of the allocation, must be greater than 0", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TPtr) -- throws : False -- Skip return : False foreign import ccall "g_atomic_rc_box_alloc0" g_atomic_rc_box_alloc0 :: Word64 -> -- block_size : TBasicType TUInt64 IO (Ptr ()) {- | Allocates /@blockSize@/ bytes of memory, and adds atomic referenc counting semantics to it. The contents of the returned data is set to zero. The data will be freed when its reference count drops to zero. The allocated data is guaranteed to be suitably aligned for any built-in type. /Since: 2.58/ -} atomicRcBoxAlloc0 :: (B.CallStack.HasCallStack, MonadIO m) => Word64 {- ^ /@blockSize@/: the size of the allocation, must be greater than 0 -} -> m (Ptr ()) {- ^ __Returns:__ a pointer to the allocated memory -} atomicRcBoxAlloc0 blockSize = liftIO $ do result <- g_atomic_rc_box_alloc0 blockSize return result -- function g_atomic_rc_box_alloc -- Args : [Arg {argCName = "block_size", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the size of the allocation, must be greater than 0", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TPtr) -- throws : False -- Skip return : False foreign import ccall "g_atomic_rc_box_alloc" g_atomic_rc_box_alloc :: Word64 -> -- block_size : TBasicType TUInt64 IO (Ptr ()) {- | Allocates /@blockSize@/ bytes of memory, and adds atomic reference counting semantics to it. The data will be freed when its reference count drops to zero. The allocated data is guaranteed to be suitably aligned for any built-in type. /Since: 2.58/ -} atomicRcBoxAlloc :: (B.CallStack.HasCallStack, MonadIO m) => Word64 {- ^ /@blockSize@/: the size of the allocation, must be greater than 0 -} -> m (Ptr ()) {- ^ __Returns:__ a pointer to the allocated memory -} atomicRcBoxAlloc blockSize = liftIO $ do result <- g_atomic_rc_box_alloc blockSize return result -- function g_atomic_rc_box_acquire -- Args : [Arg {argCName = "mem_block", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a pointer to reference counted data", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TPtr) -- throws : False -- Skip return : False foreign import ccall "g_atomic_rc_box_acquire" g_atomic_rc_box_acquire :: Ptr () -> -- mem_block : TBasicType TPtr IO (Ptr ()) {- | Atomically acquires a reference on the data pointed by /@memBlock@/. /Since: 2.58/ -} atomicRcBoxAcquire :: (B.CallStack.HasCallStack, MonadIO m) => Ptr () {- ^ /@memBlock@/: a pointer to reference counted data -} -> m (Ptr ()) {- ^ __Returns:__ a pointer to the data, with its reference count increased -} atomicRcBoxAcquire memBlock = liftIO $ do result <- g_atomic_rc_box_acquire memBlock return result -- function g_atomic_pointer_xor -- Args : [Arg {argCName = "atomic", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a pointer to a #gpointer-sized value", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "val", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the value to 'xor'", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUInt64) -- throws : False -- Skip return : False foreign import ccall "g_atomic_pointer_xor" g_atomic_pointer_xor :: Ptr () -> -- atomic : TBasicType TPtr Word64 -> -- val : TBasicType TUInt64 IO Word64 {- | Performs an atomic bitwise \'xor\' of the value of /@atomic@/ and /@val@/, storing the result back in /@atomic@/. Think of this operation as an atomic version of @{ tmp = *atomic; *atomic ^= val; return tmp; }@. This call acts as a full compiler and hardware memory barrier. /Since: 2.30/ -} atomicPointerXor :: (B.CallStack.HasCallStack, MonadIO m) => Ptr () {- ^ /@atomic@/: a pointer to a @/gpointer/@-sized value -} -> Word64 {- ^ /@val@/: the value to \'xor\' -} -> m Word64 {- ^ __Returns:__ the value of /@atomic@/ before the operation, unsigned -} atomicPointerXor atomic val = liftIO $ do result <- g_atomic_pointer_xor atomic val return result -- function g_atomic_pointer_set -- Args : [Arg {argCName = "atomic", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a pointer to a #gpointer-sized value", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "newval", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a new value to store", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_atomic_pointer_set" g_atomic_pointer_set :: Ptr () -> -- atomic : TBasicType TPtr Ptr () -> -- newval : TBasicType TPtr IO () {- | Sets the value of /@atomic@/ to /@newval@/. This call acts as a full compiler and hardware memory barrier (after the set). /Since: 2.4/ -} atomicPointerSet :: (B.CallStack.HasCallStack, MonadIO m) => Ptr () {- ^ /@atomic@/: a pointer to a @/gpointer/@-sized value -} -> Ptr () {- ^ /@newval@/: a new value to store -} -> m () atomicPointerSet atomic newval = liftIO $ do g_atomic_pointer_set atomic newval return () -- function g_atomic_pointer_or -- Args : [Arg {argCName = "atomic", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a pointer to a #gpointer-sized value", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "val", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the value to 'or'", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUInt64) -- throws : False -- Skip return : False foreign import ccall "g_atomic_pointer_or" g_atomic_pointer_or :: Ptr () -> -- atomic : TBasicType TPtr Word64 -> -- val : TBasicType TUInt64 IO Word64 {- | Performs an atomic bitwise \'or\' of the value of /@atomic@/ and /@val@/, storing the result back in /@atomic@/. Think of this operation as an atomic version of @{ tmp = *atomic; *atomic |= val; return tmp; }@. This call acts as a full compiler and hardware memory barrier. /Since: 2.30/ -} atomicPointerOr :: (B.CallStack.HasCallStack, MonadIO m) => Ptr () {- ^ /@atomic@/: a pointer to a @/gpointer/@-sized value -} -> Word64 {- ^ /@val@/: the value to \'or\' -} -> m Word64 {- ^ __Returns:__ the value of /@atomic@/ before the operation, unsigned -} atomicPointerOr atomic val = liftIO $ do result <- g_atomic_pointer_or atomic val return result -- function g_atomic_pointer_get -- Args : [Arg {argCName = "atomic", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a pointer to a #gpointer-sized value", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TPtr) -- throws : False -- Skip return : False foreign import ccall "g_atomic_pointer_get" g_atomic_pointer_get :: Ptr () -> -- atomic : TBasicType TPtr IO (Ptr ()) {- | Gets the current value of /@atomic@/. This call acts as a full compiler and hardware memory barrier (before the get). /Since: 2.4/ -} atomicPointerGet :: (B.CallStack.HasCallStack, MonadIO m) => Ptr () {- ^ /@atomic@/: a pointer to a @/gpointer/@-sized value -} -> m (Ptr ()) {- ^ __Returns:__ the value of the pointer -} atomicPointerGet atomic = liftIO $ do result <- g_atomic_pointer_get atomic return result -- function g_atomic_pointer_compare_and_exchange -- Args : [Arg {argCName = "atomic", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a pointer to a #gpointer-sized value", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "oldval", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the value to compare with", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "newval", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the value to conditionally replace with", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "g_atomic_pointer_compare_and_exchange" g_atomic_pointer_compare_and_exchange :: Ptr () -> -- atomic : TBasicType TPtr Ptr () -> -- oldval : TBasicType TPtr Ptr () -> -- newval : TBasicType TPtr IO CInt {- | Compares /@atomic@/ to /@oldval@/ and, if equal, sets it to /@newval@/. If /@atomic@/ was not equal to /@oldval@/ then no change occurs. This compare and exchange is done atomically. Think of this operation as an atomic version of @{ if (*atomic == oldval) { *atomic = newval; return TRUE; } else return FALSE; }@. This call acts as a full compiler and hardware memory barrier. /Since: 2.4/ -} atomicPointerCompareAndExchange :: (B.CallStack.HasCallStack, MonadIO m) => Ptr () {- ^ /@atomic@/: a pointer to a @/gpointer/@-sized value -} -> Ptr () {- ^ /@oldval@/: the value to compare with -} -> Ptr () {- ^ /@newval@/: the value to conditionally replace with -} -> m Bool {- ^ __Returns:__ 'True' if the exchange took place -} atomicPointerCompareAndExchange atomic oldval newval = liftIO $ do result <- g_atomic_pointer_compare_and_exchange atomic oldval newval let result' = (/= 0) result return result' -- function g_atomic_pointer_and -- Args : [Arg {argCName = "atomic", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a pointer to a #gpointer-sized value", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "val", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the value to 'and'", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUInt64) -- throws : False -- Skip return : False foreign import ccall "g_atomic_pointer_and" g_atomic_pointer_and :: Ptr () -> -- atomic : TBasicType TPtr Word64 -> -- val : TBasicType TUInt64 IO Word64 {- | Performs an atomic bitwise \'and\' of the value of /@atomic@/ and /@val@/, storing the result back in /@atomic@/. Think of this operation as an atomic version of @{ tmp = *atomic; *atomic &= val; return tmp; }@. This call acts as a full compiler and hardware memory barrier. /Since: 2.30/ -} atomicPointerAnd :: (B.CallStack.HasCallStack, MonadIO m) => Ptr () {- ^ /@atomic@/: a pointer to a @/gpointer/@-sized value -} -> Word64 {- ^ /@val@/: the value to \'and\' -} -> m Word64 {- ^ __Returns:__ the value of /@atomic@/ before the operation, unsigned -} atomicPointerAnd atomic val = liftIO $ do result <- g_atomic_pointer_and atomic val return result -- function g_atomic_pointer_add -- Args : [Arg {argCName = "atomic", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a pointer to a #gpointer-sized value", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "val", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the value to add", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TInt64) -- throws : False -- Skip return : False foreign import ccall "g_atomic_pointer_add" g_atomic_pointer_add :: Ptr () -> -- atomic : TBasicType TPtr Int64 -> -- val : TBasicType TInt64 IO Int64 {- | Atomically adds /@val@/ to the value of /@atomic@/. Think of this operation as an atomic version of @{ tmp = *atomic; *atomic += val; return tmp; }@. This call acts as a full compiler and hardware memory barrier. /Since: 2.30/ -} atomicPointerAdd :: (B.CallStack.HasCallStack, MonadIO m) => Ptr () {- ^ /@atomic@/: a pointer to a @/gpointer/@-sized value -} -> Int64 {- ^ /@val@/: the value to add -} -> m Int64 {- ^ __Returns:__ the value of /@atomic@/ before the add, signed -} atomicPointerAdd atomic val = liftIO $ do result <- g_atomic_pointer_add atomic val return result -- function g_atomic_int_xor -- Args : [Arg {argCName = "atomic", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a pointer to a #gint or #guint", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "val", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the value to 'xor'", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUInt) -- throws : False -- Skip return : False foreign import ccall "g_atomic_int_xor" g_atomic_int_xor :: Word32 -> -- atomic : TBasicType TUInt Word32 -> -- val : TBasicType TUInt IO Word32 {- | Performs an atomic bitwise \'xor\' of the value of /@atomic@/ and /@val@/, storing the result back in /@atomic@/. Think of this operation as an atomic version of @{ tmp = *atomic; *atomic ^= val; return tmp; }@. This call acts as a full compiler and hardware memory barrier. /Since: 2.30/ -} atomicIntXor :: (B.CallStack.HasCallStack, MonadIO m) => Word32 {- ^ /@atomic@/: a pointer to a @/gint/@ or @/guint/@ -} -> Word32 {- ^ /@val@/: the value to \'xor\' -} -> m Word32 {- ^ __Returns:__ the value of /@atomic@/ before the operation, unsigned -} atomicIntXor atomic val = liftIO $ do result <- g_atomic_int_xor atomic val return result -- function g_atomic_int_set -- Args : [Arg {argCName = "atomic", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a pointer to a #gint or #guint", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "newval", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a new value to store", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_atomic_int_set" g_atomic_int_set :: Int32 -> -- atomic : TBasicType TInt Int32 -> -- newval : TBasicType TInt IO () {- | Sets the value of /@atomic@/ to /@newval@/. This call acts as a full compiler and hardware memory barrier (after the set). /Since: 2.4/ -} atomicIntSet :: (B.CallStack.HasCallStack, MonadIO m) => Int32 {- ^ /@atomic@/: a pointer to a @/gint/@ or @/guint/@ -} -> Int32 {- ^ /@newval@/: a new value to store -} -> m () atomicIntSet atomic newval = liftIO $ do g_atomic_int_set atomic newval return () -- function g_atomic_int_or -- Args : [Arg {argCName = "atomic", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a pointer to a #gint or #guint", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "val", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the value to 'or'", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUInt) -- throws : False -- Skip return : False foreign import ccall "g_atomic_int_or" g_atomic_int_or :: Word32 -> -- atomic : TBasicType TUInt Word32 -> -- val : TBasicType TUInt IO Word32 {- | Performs an atomic bitwise \'or\' of the value of /@atomic@/ and /@val@/, storing the result back in /@atomic@/. Think of this operation as an atomic version of @{ tmp = *atomic; *atomic |= val; return tmp; }@. This call acts as a full compiler and hardware memory barrier. /Since: 2.30/ -} atomicIntOr :: (B.CallStack.HasCallStack, MonadIO m) => Word32 {- ^ /@atomic@/: a pointer to a @/gint/@ or @/guint/@ -} -> Word32 {- ^ /@val@/: the value to \'or\' -} -> m Word32 {- ^ __Returns:__ the value of /@atomic@/ before the operation, unsigned -} atomicIntOr atomic val = liftIO $ do result <- g_atomic_int_or atomic val return result -- function g_atomic_int_inc -- Args : [Arg {argCName = "atomic", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a pointer to a #gint or #guint", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_atomic_int_inc" g_atomic_int_inc :: Int32 -> -- atomic : TBasicType TInt IO () {- | Increments the value of /@atomic@/ by 1. Think of this operation as an atomic version of @{ *atomic += 1; }@. This call acts as a full compiler and hardware memory barrier. /Since: 2.4/ -} atomicIntInc :: (B.CallStack.HasCallStack, MonadIO m) => Int32 {- ^ /@atomic@/: a pointer to a @/gint/@ or @/guint/@ -} -> m () atomicIntInc atomic = liftIO $ do g_atomic_int_inc atomic return () -- function g_atomic_int_get -- Args : [Arg {argCName = "atomic", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a pointer to a #gint or #guint", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TInt) -- throws : False -- Skip return : False foreign import ccall "g_atomic_int_get" g_atomic_int_get :: Int32 -> -- atomic : TBasicType TInt IO Int32 {- | Gets the current value of /@atomic@/. This call acts as a full compiler and hardware memory barrier (before the get). /Since: 2.4/ -} atomicIntGet :: (B.CallStack.HasCallStack, MonadIO m) => Int32 {- ^ /@atomic@/: a pointer to a @/gint/@ or @/guint/@ -} -> m Int32 {- ^ __Returns:__ the value of the integer -} atomicIntGet atomic = liftIO $ do result <- g_atomic_int_get atomic return result -- function g_atomic_int_exchange_and_add -- Args : [Arg {argCName = "atomic", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a pointer to a #gint", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "val", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the value to add", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TInt) -- throws : False -- Skip return : False foreign import ccall "g_atomic_int_exchange_and_add" g_atomic_int_exchange_and_add :: Int32 -> -- atomic : TBasicType TInt Int32 -> -- val : TBasicType TInt IO Int32 {-# DEPRECATED atomicIntExchangeAndAdd ["(Since version 2.30)","Use 'GI.GLib.Functions.atomicIntAdd' instead."] #-} {- | This function existed before 'GI.GLib.Functions.atomicIntAdd' returned the prior value of the integer (which it now does). It is retained only for compatibility reasons. Don\'t use this function in new code. /Since: 2.4/ -} atomicIntExchangeAndAdd :: (B.CallStack.HasCallStack, MonadIO m) => Int32 {- ^ /@atomic@/: a pointer to a @/gint/@ -} -> Int32 {- ^ /@val@/: the value to add -} -> m Int32 {- ^ __Returns:__ the value of /@atomic@/ before the add, signed -} atomicIntExchangeAndAdd atomic val = liftIO $ do result <- g_atomic_int_exchange_and_add atomic val return result -- function g_atomic_int_dec_and_test -- Args : [Arg {argCName = "atomic", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a pointer to a #gint or #guint", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "g_atomic_int_dec_and_test" g_atomic_int_dec_and_test :: Int32 -> -- atomic : TBasicType TInt IO CInt {- | Decrements the value of /@atomic@/ by 1. Think of this operation as an atomic version of @{ *atomic -= 1; return (*atomic == 0); }@. This call acts as a full compiler and hardware memory barrier. /Since: 2.4/ -} atomicIntDecAndTest :: (B.CallStack.HasCallStack, MonadIO m) => Int32 {- ^ /@atomic@/: a pointer to a @/gint/@ or @/guint/@ -} -> m Bool {- ^ __Returns:__ 'True' if the resultant value is zero -} atomicIntDecAndTest atomic = liftIO $ do result <- g_atomic_int_dec_and_test atomic let result' = (/= 0) result return result' -- function g_atomic_int_compare_and_exchange -- Args : [Arg {argCName = "atomic", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a pointer to a #gint or #guint", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "oldval", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the value to compare with", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "newval", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the value to conditionally replace with", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "g_atomic_int_compare_and_exchange" g_atomic_int_compare_and_exchange :: Int32 -> -- atomic : TBasicType TInt Int32 -> -- oldval : TBasicType TInt Int32 -> -- newval : TBasicType TInt IO CInt {- | Compares /@atomic@/ to /@oldval@/ and, if equal, sets it to /@newval@/. If /@atomic@/ was not equal to /@oldval@/ then no change occurs. This compare and exchange is done atomically. Think of this operation as an atomic version of @{ if (*atomic == oldval) { *atomic = newval; return TRUE; } else return FALSE; }@. This call acts as a full compiler and hardware memory barrier. /Since: 2.4/ -} atomicIntCompareAndExchange :: (B.CallStack.HasCallStack, MonadIO m) => Int32 {- ^ /@atomic@/: a pointer to a @/gint/@ or @/guint/@ -} -> Int32 {- ^ /@oldval@/: the value to compare with -} -> Int32 {- ^ /@newval@/: the value to conditionally replace with -} -> m Bool {- ^ __Returns:__ 'True' if the exchange took place -} atomicIntCompareAndExchange atomic oldval newval = liftIO $ do result <- g_atomic_int_compare_and_exchange atomic oldval newval let result' = (/= 0) result return result' -- function g_atomic_int_and -- Args : [Arg {argCName = "atomic", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a pointer to a #gint or #guint", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "val", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the value to 'and'", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUInt) -- throws : False -- Skip return : False foreign import ccall "g_atomic_int_and" g_atomic_int_and :: Word32 -> -- atomic : TBasicType TUInt Word32 -> -- val : TBasicType TUInt IO Word32 {- | Performs an atomic bitwise \'and\' of the value of /@atomic@/ and /@val@/, storing the result back in /@atomic@/. This call acts as a full compiler and hardware memory barrier. Think of this operation as an atomic version of @{ tmp = *atomic; *atomic &= val; return tmp; }@. /Since: 2.30/ -} atomicIntAnd :: (B.CallStack.HasCallStack, MonadIO m) => Word32 {- ^ /@atomic@/: a pointer to a @/gint/@ or @/guint/@ -} -> Word32 {- ^ /@val@/: the value to \'and\' -} -> m Word32 {- ^ __Returns:__ the value of /@atomic@/ before the operation, unsigned -} atomicIntAnd atomic val = liftIO $ do result <- g_atomic_int_and atomic val return result -- function g_atomic_int_add -- Args : [Arg {argCName = "atomic", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a pointer to a #gint or #guint", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "val", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the value to add", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TInt) -- throws : False -- Skip return : False foreign import ccall "g_atomic_int_add" g_atomic_int_add :: Int32 -> -- atomic : TBasicType TInt Int32 -> -- val : TBasicType TInt IO Int32 {- | Atomically adds /@val@/ to the value of /@atomic@/. Think of this operation as an atomic version of @{ tmp = *atomic; *atomic += val; return tmp; }@. This call acts as a full compiler and hardware memory barrier. Before version 2.30, this function did not return a value (but 'GI.GLib.Functions.atomicIntExchangeAndAdd' did, and had the same meaning). /Since: 2.4/ -} atomicIntAdd :: (B.CallStack.HasCallStack, MonadIO m) => Int32 {- ^ /@atomic@/: a pointer to a @/gint/@ or @/guint/@ -} -> Int32 {- ^ /@val@/: the value to add -} -> m Int32 {- ^ __Returns:__ the value of /@atomic@/ before the add, signed -} atomicIntAdd atomic val = liftIO $ do result <- g_atomic_int_add atomic val return result -- function g_atexit -- Args : [Arg {argCName = "func", argType = TInterface (Name {namespace = "GLib", name = "VoidFunc"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the function to call on normal program termination.", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_atexit" g_atexit :: FunPtr GLib.Callbacks.C_VoidFunc -> -- func : TInterface (Name {namespace = "GLib", name = "VoidFunc"}) IO () {-# DEPRECATED atexit ["(Since version 2.32)","It is best to avoid 'GI.GLib.Functions.atexit'."] #-} {- | Specifies a function to be called at normal program termination. Since GLib 2.8.2, on Windows 'GI.GLib.Functions.atexit' actually is a preprocessor macro that maps to a call to the @/atexit()/@ function in the C library. This means that in case the code that calls 'GI.GLib.Functions.atexit', i.e. @/atexit()/@, is in a DLL, the function will be called when the DLL is detached from the program. This typically makes more sense than that the function is called when the GLib DLL is detached, which happened earlier when 'GI.GLib.Functions.atexit' was a function in the GLib DLL. The behaviour of @/atexit()/@ in the context of dynamically loaded modules is not formally specified and varies wildly. On POSIX systems, calling 'GI.GLib.Functions.atexit' (or @/atexit()/@) in a dynamically loaded module which is unloaded before the program terminates might well cause a crash at program exit. Some POSIX systems implement @/atexit()/@ like Windows, and have each dynamically loaded module maintain an own atexit chain that is called when the module is unloaded. On other POSIX systems, before a dynamically loaded module is unloaded, the registered atexit functions (if any) residing in that module are called, regardless where the code that registered them resided. This is presumably the most robust approach. As can be seen from the above, for portability it\'s best to avoid calling 'GI.GLib.Functions.atexit' (or @/atexit()/@) except in the main executable of a program. -} atexit :: (B.CallStack.HasCallStack, MonadIO m) => GLib.Callbacks.VoidFunc {- ^ /@func@/: the function to call on normal program termination. -} -> m () atexit func = liftIO $ do ptrfunc <- callocMem :: IO (Ptr (FunPtr GLib.Callbacks.C_VoidFunc)) func' <- GLib.Callbacks.mk_VoidFunc (GLib.Callbacks.wrap_VoidFunc (Just ptrfunc) func) poke ptrfunc func' g_atexit func' return () -- function g_assertion_message_error -- Args : [Arg {argCName = "domain", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "file", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "line", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "func", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "expr", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "error", argType = TError, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "error_domain", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "error_code", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_assertion_message_error" g_assertion_message_error :: CString -> -- domain : TBasicType TUTF8 CString -> -- file : TBasicType TUTF8 Int32 -> -- line : TBasicType TInt CString -> -- func : TBasicType TUTF8 CString -> -- expr : TBasicType TUTF8 Ptr GError -> -- error : TError Word32 -> -- error_domain : TBasicType TUInt32 Int32 -> -- error_code : TBasicType TInt IO () {- | /No description available in the introspection data./ -} assertionMessageError :: (B.CallStack.HasCallStack, MonadIO m) => T.Text -> T.Text -> Int32 -> T.Text -> T.Text -> GError -> Word32 -> Int32 -> m () assertionMessageError domain file line func expr error_ errorDomain errorCode = liftIO $ do domain' <- textToCString domain file' <- textToCString file func' <- textToCString func expr' <- textToCString expr error_' <- unsafeManagedPtrGetPtr error_ g_assertion_message_error domain' file' line func' expr' error_' errorDomain errorCode touchManagedPtr error_ freeMem domain' freeMem file' freeMem func' freeMem expr' return () -- function g_assertion_message_cmpstr -- Args : [Arg {argCName = "domain", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "file", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "line", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "func", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "expr", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "arg1", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cmp", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "arg2", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_assertion_message_cmpstr" g_assertion_message_cmpstr :: CString -> -- domain : TBasicType TUTF8 CString -> -- file : TBasicType TUTF8 Int32 -> -- line : TBasicType TInt CString -> -- func : TBasicType TUTF8 CString -> -- expr : TBasicType TUTF8 CString -> -- arg1 : TBasicType TUTF8 CString -> -- cmp : TBasicType TUTF8 CString -> -- arg2 : TBasicType TUTF8 IO () {- | /No description available in the introspection data./ -} assertionMessageCmpstr :: (B.CallStack.HasCallStack, MonadIO m) => T.Text -> T.Text -> Int32 -> T.Text -> T.Text -> T.Text -> T.Text -> T.Text -> m () assertionMessageCmpstr domain file line func expr arg1 cmp arg2 = liftIO $ do domain' <- textToCString domain file' <- textToCString file func' <- textToCString func expr' <- textToCString expr arg1' <- textToCString arg1 cmp' <- textToCString cmp arg2' <- textToCString arg2 g_assertion_message_cmpstr domain' file' line func' expr' arg1' cmp' arg2' freeMem domain' freeMem file' freeMem func' freeMem expr' freeMem arg1' freeMem cmp' freeMem arg2' return () -- function g_assertion_message -- Args : [Arg {argCName = "domain", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "file", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "line", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "func", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "message", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_assertion_message" g_assertion_message :: CString -> -- domain : TBasicType TUTF8 CString -> -- file : TBasicType TUTF8 Int32 -> -- line : TBasicType TInt CString -> -- func : TBasicType TUTF8 CString -> -- message : TBasicType TUTF8 IO () {- | /No description available in the introspection data./ -} assertionMessage :: (B.CallStack.HasCallStack, MonadIO m) => T.Text -> T.Text -> Int32 -> T.Text -> T.Text -> m () assertionMessage domain file line func message = liftIO $ do domain' <- textToCString domain file' <- textToCString file func' <- textToCString func message' <- textToCString message g_assertion_message domain' file' line func' message' freeMem domain' freeMem file' freeMem func' freeMem message' return () -- function g_assert_warning -- Args : [Arg {argCName = "log_domain", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "file", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "line", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "pretty_function", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "expression", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_assert_warning" g_assert_warning :: CString -> -- log_domain : TBasicType TUTF8 CString -> -- file : TBasicType TUTF8 Int32 -> -- line : TBasicType TInt CString -> -- pretty_function : TBasicType TUTF8 CString -> -- expression : TBasicType TUTF8 IO () {- | /No description available in the introspection data./ -} assertWarning :: (B.CallStack.HasCallStack, MonadIO m) => T.Text -> T.Text -> Int32 -> T.Text -> T.Text -> m () assertWarning logDomain file line prettyFunction expression = liftIO $ do logDomain' <- textToCString logDomain file' <- textToCString file prettyFunction' <- textToCString prettyFunction expression' <- textToCString expression g_assert_warning logDomain' file' line prettyFunction' expression' freeMem logDomain' freeMem file' freeMem prettyFunction' freeMem expression' return () -- function g_ascii_xdigit_value -- Args : [Arg {argCName = "c", argType = TBasicType TInt8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an ASCII character.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TInt) -- throws : False -- Skip return : False foreign import ccall "g_ascii_xdigit_value" g_ascii_xdigit_value :: Int8 -> -- c : TBasicType TInt8 IO Int32 {- | Determines the numeric value of a character as a hexidecimal digit. Differs from 'GI.GLib.Functions.unicharXdigitValue' because it takes a char, so there\'s no worry about sign extension if characters are signed. -} asciiXdigitValue :: (B.CallStack.HasCallStack, MonadIO m) => Int8 {- ^ /@c@/: an ASCII character. -} -> m Int32 {- ^ __Returns:__ If /@c@/ is a hex digit (according to @/g_ascii_isxdigit()/@), its numeric value. Otherwise, -1. -} asciiXdigitValue c = liftIO $ do result <- g_ascii_xdigit_value c return result -- function g_ascii_toupper -- Args : [Arg {argCName = "c", argType = TBasicType TInt8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "any character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TInt8) -- throws : False -- Skip return : False foreign import ccall "g_ascii_toupper" g_ascii_toupper :: Int8 -> -- c : TBasicType TInt8 IO Int8 {- | Convert a character to ASCII upper case. Unlike the standard C library @/toupper()/@ function, this only recognizes standard ASCII letters and ignores the locale, returning all non-ASCII characters unchanged, even if they are upper case letters in a particular character set. Also unlike the standard library function, this takes and returns a char, not an int, so don\'t call it on @/EOF/@ but no need to worry about casting to @/guchar/@ before passing a possibly non-ASCII character in. -} asciiToupper :: (B.CallStack.HasCallStack, MonadIO m) => Int8 {- ^ /@c@/: any character -} -> m Int8 {- ^ __Returns:__ the result of converting /@c@/ to upper case. If /@c@/ is not an ASCII lower case letter, /@c@/ is returned unchanged. -} asciiToupper c = liftIO $ do result <- g_ascii_toupper c return result -- function g_ascii_tolower -- Args : [Arg {argCName = "c", argType = TBasicType TInt8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "any character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TInt8) -- throws : False -- Skip return : False foreign import ccall "g_ascii_tolower" g_ascii_tolower :: Int8 -> -- c : TBasicType TInt8 IO Int8 {- | Convert a character to ASCII lower case. Unlike the standard C library @/tolower()/@ function, this only recognizes standard ASCII letters and ignores the locale, returning all non-ASCII characters unchanged, even if they are lower case letters in a particular character set. Also unlike the standard library function, this takes and returns a char, not an int, so don\'t call it on @/EOF/@ but no need to worry about casting to @/guchar/@ before passing a possibly non-ASCII character in. -} asciiTolower :: (B.CallStack.HasCallStack, MonadIO m) => Int8 {- ^ /@c@/: any character -} -> m Int8 {- ^ __Returns:__ the result of converting /@c@/ to lower case. If /@c@/ is not an ASCII upper case letter, /@c@/ is returned unchanged. -} asciiTolower c = liftIO $ do result <- g_ascii_tolower c return result -- function g_ascii_strup -- Args : [Arg {argCName = "str", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "len", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "length of @str in bytes, or -1 if @str is nul-terminated", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_ascii_strup" g_ascii_strup :: CString -> -- str : TBasicType TUTF8 Int64 -> -- len : TBasicType TInt64 IO CString {- | Converts all lower case ASCII letters to upper case ASCII letters. -} asciiStrup :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@str@/: a string -} -> Int64 {- ^ /@len@/: length of /@str@/ in bytes, or -1 if /@str@/ is nul-terminated -} -> m T.Text {- ^ __Returns:__ a newly allocated string, with all the lower case characters in /@str@/ converted to upper case, with semantics that exactly match 'GI.GLib.Functions.asciiToupper'. (Note that this is unlike the old 'GI.GLib.Functions.strup', which modified the string in place.) -} asciiStrup str len = liftIO $ do str' <- textToCString str result <- g_ascii_strup str' len checkUnexpectedReturnNULL "asciiStrup" result result' <- cstringToText result freeMem result freeMem str' return result' -- function g_ascii_strtoull -- Args : [Arg {argCName = "nptr", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the string to convert to a numeric value.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "endptr", argType = TBasicType TUTF8, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "if non-%NULL, it returns the\n character after the last character used in the conversion.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "base", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "to be used for the conversion, 2..36 or 0", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUInt64) -- throws : False -- Skip return : False foreign import ccall "g_ascii_strtoull" g_ascii_strtoull :: CString -> -- nptr : TBasicType TUTF8 Ptr CString -> -- endptr : TBasicType TUTF8 Word32 -> -- base : TBasicType TUInt IO Word64 {- | Converts a string to a @/guint64/@ value. This function behaves like the standard @/strtoull()/@ function does in the C locale. It does this without actually changing the current locale, since that would not be thread-safe. Note that input with a leading minus sign (@-@) is accepted, and will return the negation of the parsed number, unless that would overflow a @/guint64/@. Critically, this means you cannot assume that a short fixed length input will never result in a low return value, as the input could have a leading @-@. This function is typically used when reading configuration files or other non-user input that should be locale independent. To handle input from the user you should normally use the locale-sensitive system @/strtoull()/@ function. If the correct value would cause overflow, 'GI.GLib.Constants.MAXUINT64' is returned, and @ERANGE@ is stored in @errno@. If the base is outside the valid range, zero is returned, and @EINVAL@ is stored in @errno@. If the string conversion fails, zero is returned, and /@endptr@/ returns /@nptr@/ (if /@endptr@/ is non-'Nothing'). /Since: 2.2/ -} asciiStrtoull :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@nptr@/: the string to convert to a numeric value. -} -> Word32 {- ^ /@base@/: to be used for the conversion, 2..36 or 0 -} -> m ((Word64, T.Text)) {- ^ __Returns:__ the @/guint64/@ value or zero on error. -} asciiStrtoull nptr base = liftIO $ do nptr' <- textToCString nptr endptr <- allocMem :: IO (Ptr CString) result <- g_ascii_strtoull nptr' endptr base endptr' <- peek endptr endptr'' <- cstringToText endptr' freeMem nptr' freeMem endptr return (result, endptr'') -- function g_ascii_strtoll -- Args : [Arg {argCName = "nptr", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the string to convert to a numeric value.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "endptr", argType = TBasicType TUTF8, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "if non-%NULL, it returns the\n character after the last character used in the conversion.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "base", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "to be used for the conversion, 2..36 or 0", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TInt64) -- throws : False -- Skip return : False foreign import ccall "g_ascii_strtoll" g_ascii_strtoll :: CString -> -- nptr : TBasicType TUTF8 Ptr CString -> -- endptr : TBasicType TUTF8 Word32 -> -- base : TBasicType TUInt IO Int64 {- | Converts a string to a @/gint64/@ value. This function behaves like the standard @/strtoll()/@ function does in the C locale. It does this without actually changing the current locale, since that would not be thread-safe. This function is typically used when reading configuration files or other non-user input that should be locale independent. To handle input from the user you should normally use the locale-sensitive system @/strtoll()/@ function. If the correct value would cause overflow, 'GI.GLib.Constants.MAXINT64' or 'GI.GLib.Constants.MININT64' is returned, and @ERANGE@ is stored in @errno@. If the base is outside the valid range, zero is returned, and @EINVAL@ is stored in @errno@. If the string conversion fails, zero is returned, and /@endptr@/ returns /@nptr@/ (if /@endptr@/ is non-'Nothing'). /Since: 2.12/ -} asciiStrtoll :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@nptr@/: the string to convert to a numeric value. -} -> Word32 {- ^ /@base@/: to be used for the conversion, 2..36 or 0 -} -> m ((Int64, T.Text)) {- ^ __Returns:__ the @/gint64/@ value or zero on error. -} asciiStrtoll nptr base = liftIO $ do nptr' <- textToCString nptr endptr <- allocMem :: IO (Ptr CString) result <- g_ascii_strtoll nptr' endptr base endptr' <- peek endptr endptr'' <- cstringToText endptr' freeMem nptr' freeMem endptr return (result, endptr'') -- function g_ascii_strtod -- Args : [Arg {argCName = "nptr", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the string to convert to a numeric value.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "endptr", argType = TBasicType TUTF8, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "if non-%NULL, it returns the\n character after the last character used in the conversion.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TDouble) -- throws : False -- Skip return : False foreign import ccall "g_ascii_strtod" g_ascii_strtod :: CString -> -- nptr : TBasicType TUTF8 Ptr CString -> -- endptr : TBasicType TUTF8 IO CDouble {- | Converts a string to a @/gdouble/@ value. This function behaves like the standard @/strtod()/@ function does in the C locale. It does this without actually changing the current locale, since that would not be thread-safe. A limitation of the implementation is that this function will still accept localized versions of infinities and NANs. This function is typically used when reading configuration files or other non-user input that should be locale independent. To handle input from the user you should normally use the locale-sensitive system @/strtod()/@ function. To convert from a @/gdouble/@ to a string in a locale-insensitive way, use 'GI.GLib.Functions.asciiDtostr'. If the correct value would cause overflow, plus or minus @/HUGE_VAL/@ is returned (according to the sign of the value), and @/ERANGE/@ is stored in @/errno/@. If the correct value would cause underflow, zero is returned and @/ERANGE/@ is stored in @/errno/@. This function resets @/errno/@ before calling @/strtod()/@ so that you can reliably detect overflow and underflow. -} asciiStrtod :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@nptr@/: the string to convert to a numeric value. -} -> m ((Double, T.Text)) {- ^ __Returns:__ the @/gdouble/@ value. -} asciiStrtod nptr = liftIO $ do nptr' <- textToCString nptr endptr <- allocMem :: IO (Ptr CString) result <- g_ascii_strtod nptr' endptr let result' = realToFrac result endptr' <- peek endptr endptr'' <- cstringToText endptr' freeMem nptr' freeMem endptr return (result', endptr'') -- function g_ascii_strncasecmp -- Args : [Arg {argCName = "s1", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "string to compare with @s2", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "s2", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "string to compare with @s1", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "n", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "number of characters to compare", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TInt) -- throws : False -- Skip return : False foreign import ccall "g_ascii_strncasecmp" g_ascii_strncasecmp :: CString -> -- s1 : TBasicType TUTF8 CString -> -- s2 : TBasicType TUTF8 Word64 -> -- n : TBasicType TUInt64 IO Int32 {- | Compare /@s1@/ and /@s2@/, ignoring the case of ASCII characters and any characters after the first /@n@/ in each string. Unlike the BSD @/strcasecmp()/@ function, this only recognizes standard ASCII letters and ignores the locale, treating all non-ASCII characters as if they are not letters. The same warning as in 'GI.GLib.Functions.asciiStrcasecmp' applies: Use this function only on strings known to be in encodings where bytes corresponding to ASCII letters always represent themselves. -} asciiStrncasecmp :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@s1@/: string to compare with /@s2@/ -} -> T.Text {- ^ /@s2@/: string to compare with /@s1@/ -} -> Word64 {- ^ /@n@/: number of characters to compare -} -> m Int32 {- ^ __Returns:__ 0 if the strings match, a negative value if /@s1@/ \< /@s2@/, or a positive value if /@s1@/ > /@s2@/. -} asciiStrncasecmp s1 s2 n = liftIO $ do s1' <- textToCString s1 s2' <- textToCString s2 result <- g_ascii_strncasecmp s1' s2' n freeMem s1' freeMem s2' return result -- function g_ascii_string_to_unsigned -- Args : [Arg {argCName = "str", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "base", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "base of a parsed number", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "min", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a lower bound (inclusive)", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "max", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an upper bound (inclusive)", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "out_num", argType = TBasicType TUInt64, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a return location for a number", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : True -- Skip return : False foreign import ccall "g_ascii_string_to_unsigned" g_ascii_string_to_unsigned :: CString -> -- str : TBasicType TUTF8 Word32 -> -- base : TBasicType TUInt Word64 -> -- min : TBasicType TUInt64 Word64 -> -- max : TBasicType TUInt64 Ptr Word64 -> -- out_num : TBasicType TUInt64 Ptr (Ptr GError) -> -- error IO CInt {- | A convenience function for converting a string to an unsigned number. This function assumes that /@str@/ contains only a number of the given /@base@/ that is within inclusive bounds limited by /@min@/ and /@max@/. If this is true, then the converted number is stored in /@outNum@/. An empty string is not a valid input. A string with leading or trailing whitespace is also an invalid input. A string with a leading sign (@-@ or @+@) is not a valid input for the unsigned parser. /@base@/ can be between 2 and 36 inclusive. Hexadecimal numbers must not be prefixed with \"0x\" or \"0X\". Such a problem does not exist for octal numbers, since they were usually prefixed with a zero which does not change the value of the parsed number. Parsing failures result in an error with the @/G_NUMBER_PARSER_ERROR/@ domain. If the input is invalid, the error code will be 'GI.GLib.Enums.NumberParserErrorInvalid'. If the parsed number is out of bounds - 'GI.GLib.Enums.NumberParserErrorOutOfBounds'. See 'GI.GLib.Functions.asciiStrtoull' if you have more complex needs such as parsing a string which starts with a number, but then has other characters. /Since: 2.54/ -} asciiStringToUnsigned :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@str@/: a string -} -> Word32 {- ^ /@base@/: base of a parsed number -} -> Word64 {- ^ /@min@/: a lower bound (inclusive) -} -> Word64 {- ^ /@max@/: an upper bound (inclusive) -} -> m (Word64) {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -} asciiStringToUnsigned str base min max = liftIO $ do str' <- textToCString str outNum <- allocMem :: IO (Ptr Word64) onException (do _ <- propagateGError $ g_ascii_string_to_unsigned str' base min max outNum outNum' <- peek outNum freeMem str' freeMem outNum return outNum' ) (do freeMem str' freeMem outNum ) -- function g_ascii_string_to_signed -- Args : [Arg {argCName = "str", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "base", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "base of a parsed number", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "min", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a lower bound (inclusive)", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "max", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an upper bound (inclusive)", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "out_num", argType = TBasicType TInt64, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a return location for a number", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : True -- Skip return : False foreign import ccall "g_ascii_string_to_signed" g_ascii_string_to_signed :: CString -> -- str : TBasicType TUTF8 Word32 -> -- base : TBasicType TUInt Int64 -> -- min : TBasicType TInt64 Int64 -> -- max : TBasicType TInt64 Ptr Int64 -> -- out_num : TBasicType TInt64 Ptr (Ptr GError) -> -- error IO CInt {- | A convenience function for converting a string to a signed number. This function assumes that /@str@/ contains only a number of the given /@base@/ that is within inclusive bounds limited by /@min@/ and /@max@/. If this is true, then the converted number is stored in /@outNum@/. An empty string is not a valid input. A string with leading or trailing whitespace is also an invalid input. /@base@/ can be between 2 and 36 inclusive. Hexadecimal numbers must not be prefixed with \"0x\" or \"0X\". Such a problem does not exist for octal numbers, since they were usually prefixed with a zero which does not change the value of the parsed number. Parsing failures result in an error with the @/G_NUMBER_PARSER_ERROR/@ domain. If the input is invalid, the error code will be 'GI.GLib.Enums.NumberParserErrorInvalid'. If the parsed number is out of bounds - 'GI.GLib.Enums.NumberParserErrorOutOfBounds'. See 'GI.GLib.Functions.asciiStrtoll' if you have more complex needs such as parsing a string which starts with a number, but then has other characters. /Since: 2.54/ -} asciiStringToSigned :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@str@/: a string -} -> Word32 {- ^ /@base@/: base of a parsed number -} -> Int64 {- ^ /@min@/: a lower bound (inclusive) -} -> Int64 {- ^ /@max@/: an upper bound (inclusive) -} -> m (Int64) {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -} asciiStringToSigned str base min max = liftIO $ do str' <- textToCString str outNum <- allocMem :: IO (Ptr Int64) onException (do _ <- propagateGError $ g_ascii_string_to_signed str' base min max outNum outNum' <- peek outNum freeMem str' freeMem outNum return outNum' ) (do freeMem str' freeMem outNum ) -- function g_ascii_strdown -- Args : [Arg {argCName = "str", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "len", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "length of @str in bytes, or -1 if @str is nul-terminated", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_ascii_strdown" g_ascii_strdown :: CString -> -- str : TBasicType TUTF8 Int64 -> -- len : TBasicType TInt64 IO CString {- | Converts all upper case ASCII letters to lower case ASCII letters. -} asciiStrdown :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@str@/: a string -} -> Int64 {- ^ /@len@/: length of /@str@/ in bytes, or -1 if /@str@/ is nul-terminated -} -> m T.Text {- ^ __Returns:__ a newly-allocated string, with all the upper case characters in /@str@/ converted to lower case, with semantics that exactly match 'GI.GLib.Functions.asciiTolower'. (Note that this is unlike the old 'GI.GLib.Functions.strdown', which modified the string in place.) -} asciiStrdown str len = liftIO $ do str' <- textToCString str result <- g_ascii_strdown str' len checkUnexpectedReturnNULL "asciiStrdown" result result' <- cstringToText result freeMem result freeMem str' return result' -- function g_ascii_strcasecmp -- Args : [Arg {argCName = "s1", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "string to compare with @s2", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "s2", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "string to compare with @s1", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TInt) -- throws : False -- Skip return : False foreign import ccall "g_ascii_strcasecmp" g_ascii_strcasecmp :: CString -> -- s1 : TBasicType TUTF8 CString -> -- s2 : TBasicType TUTF8 IO Int32 {- | Compare two strings, ignoring the case of ASCII characters. Unlike the BSD @/strcasecmp()/@ function, this only recognizes standard ASCII letters and ignores the locale, treating all non-ASCII bytes as if they are not letters. This function should be used only on strings that are known to be in encodings where the bytes corresponding to ASCII letters always represent themselves. This includes UTF-8 and the ISO-8859-* charsets, but not for instance double-byte encodings like the Windows Codepage 932, where the trailing bytes of double-byte characters include all ASCII letters. If you compare two CP932 strings using this function, you will get false matches. Both /@s1@/ and /@s2@/ must be non-'Nothing'. -} asciiStrcasecmp :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@s1@/: string to compare with /@s2@/ -} -> T.Text {- ^ /@s2@/: string to compare with /@s1@/ -} -> m Int32 {- ^ __Returns:__ 0 if the strings match, a negative value if /@s1@/ \< /@s2@/, or a positive value if /@s1@/ > /@s2@/. -} asciiStrcasecmp s1 s2 = liftIO $ do s1' <- textToCString s1 s2' <- textToCString s2 result <- g_ascii_strcasecmp s1' s2' freeMem s1' freeMem s2' return result -- function g_ascii_formatd -- Args : [Arg {argCName = "buffer", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A buffer to place the resulting string in", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "buf_len", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The length of the buffer.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "format", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The printf()-style format to use for the\n code to use for converting.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "d", argType = TBasicType TDouble, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The #gdouble to convert", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_ascii_formatd" g_ascii_formatd :: CString -> -- buffer : TBasicType TUTF8 Int32 -> -- buf_len : TBasicType TInt CString -> -- format : TBasicType TUTF8 CDouble -> -- d : TBasicType TDouble IO CString {- | Converts a @/gdouble/@ to a string, using the \'.\' as decimal point. To format the number you pass in a @/printf()/@-style format string. Allowed conversion specifiers are \'e\', \'E\', \'f\', \'F\', \'g\' and \'G\'. The returned buffer is guaranteed to be nul-terminated. If you just want to want to serialize the value into a string, use 'GI.GLib.Functions.asciiDtostr'. -} asciiFormatd :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@buffer@/: A buffer to place the resulting string in -} -> Int32 {- ^ /@bufLen@/: The length of the buffer. -} -> T.Text {- ^ /@format@/: The @/printf()/@-style format to use for the code to use for converting. -} -> Double {- ^ /@d@/: The @/gdouble/@ to convert -} -> m T.Text {- ^ __Returns:__ The pointer to the buffer with the converted string. -} asciiFormatd buffer bufLen format d = liftIO $ do buffer' <- textToCString buffer format' <- textToCString format let d' = realToFrac d result <- g_ascii_formatd buffer' bufLen format' d' checkUnexpectedReturnNULL "asciiFormatd" result result' <- cstringToText result freeMem result freeMem buffer' freeMem format' return result' -- function g_ascii_dtostr -- Args : [Arg {argCName = "buffer", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A buffer to place the resulting string in", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "buf_len", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The length of the buffer.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "d", argType = TBasicType TDouble, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The #gdouble to convert", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_ascii_dtostr" g_ascii_dtostr :: CString -> -- buffer : TBasicType TUTF8 Int32 -> -- buf_len : TBasicType TInt CDouble -> -- d : TBasicType TDouble IO CString {- | Converts a @/gdouble/@ to a string, using the \'.\' as decimal point. This function generates enough precision that converting the string back using 'GI.GLib.Functions.asciiStrtod' gives the same machine-number (on machines with IEEE compatible 64bit doubles). It is guaranteed that the size of the resulting string will never be larger than /@gASCIIDTOSTRBUFSIZE@/ bytes, including the terminating nul character, which is always added. -} asciiDtostr :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@buffer@/: A buffer to place the resulting string in -} -> Int32 {- ^ /@bufLen@/: The length of the buffer. -} -> Double {- ^ /@d@/: The @/gdouble/@ to convert -} -> m T.Text {- ^ __Returns:__ The pointer to the buffer with the converted string. -} asciiDtostr buffer bufLen d = liftIO $ do buffer' <- textToCString buffer let d' = realToFrac d result <- g_ascii_dtostr buffer' bufLen d' checkUnexpectedReturnNULL "asciiDtostr" result result' <- cstringToText result freeMem result freeMem buffer' return result' -- function g_ascii_digit_value -- Args : [Arg {argCName = "c", argType = TBasicType TInt8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an ASCII character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TInt) -- throws : False -- Skip return : False foreign import ccall "g_ascii_digit_value" g_ascii_digit_value :: Int8 -> -- c : TBasicType TInt8 IO Int32 {- | Determines the numeric value of a character as a decimal digit. Differs from 'GI.GLib.Functions.unicharDigitValue' because it takes a char, so there\'s no worry about sign extension if characters are signed. -} asciiDigitValue :: (B.CallStack.HasCallStack, MonadIO m) => Int8 {- ^ /@c@/: an ASCII character -} -> m Int32 {- ^ __Returns:__ If /@c@/ is a decimal digit (according to @/g_ascii_isdigit()/@), its numeric value. Otherwise, -1. -} asciiDigitValue c = liftIO $ do result <- g_ascii_digit_value c return result -- function g_access -- Args : [Arg {argCName = "filename", argType = TBasicType TFileName, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a pathname in the GLib file name encoding\n (UTF-8 on Windows)", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "mode", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "as in access()", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TInt) -- throws : False -- Skip return : False foreign import ccall "g_access" g_access :: CString -> -- filename : TBasicType TFileName Int32 -> -- mode : TBasicType TInt IO Int32 {- | A wrapper for the POSIX @/access()/@ function. This function is used to test a pathname for one or several of read, write or execute permissions, or just existence. On Windows, the file protection mechanism is not at all POSIX-like, and the underlying function in the C library only checks the FAT-style READONLY attribute, and does not look at the ACL of a file at all. This function is this in practise almost useless on Windows. Software that needs to handle file permissions on Windows more exactly should use the Win32 API. See your C library manual for more details about @/access()/@. /Since: 2.8/ -} access :: (B.CallStack.HasCallStack, MonadIO m) => [Char] {- ^ /@filename@/: a pathname in the GLib file name encoding (UTF-8 on Windows) -} -> Int32 {- ^ /@mode@/: as in @/access()/@ -} -> m Int32 {- ^ __Returns:__ zero if the pathname refers to an existing file system object that has all the tested permissions, or -1 otherwise or on error. -} access filename mode = liftIO $ do filename' <- stringToCString filename result <- g_access filename' mode freeMem filename' return result