{- |
Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License    : LGPL-2.1
Maintainer : Iñaki García Etxebarria (garetxe@gmail.com)
-}

#define ENABLE_OVERLOADING \
       (!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                              ,


-- ** getConsoleCharset #method:getConsoleCharset#

    getConsoleCharset                       ,


-- ** 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                        ,


-- ** getOsInfo #method:getOsInfo#

    getOsInfo                               ,


-- ** 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                          ,


-- ** testSummary #method:testSummary#

    testSummary                             ,


-- ** 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                         ,


-- ** unixGetPasswdEntry #method:unixGetPasswdEntry#

    unixGetPasswdEntry                      ,


-- ** 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.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.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP

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 :: m GType
variantGetGtype  = IO GType -> m GType
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO GType -> m GType) -> IO GType -> m GType
forall a b. (a -> b) -> a -> b
$ do
    CGType
result <- IO CGType
g_variant_get_gtype
    let result' :: GType
result' = CGType -> GType
GType CGType
result
    GType -> IO GType
forall (m :: * -> *) a. Monad m => a -> m a
return GType
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. It has the same
randomness guarantees as 'GI.GLib.Structs.Rand.Rand', so must not be used for cryptographic
purposes such as key generation, nonces, salts or one-time pads.

/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 :: m Text
uuidStringRandom  = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
result <- IO CString
g_uuid_string_random
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "uuidStringRandom" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
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 :: Text -> m Bool
uuidStringIsValid str :: Text
str = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    CString
str' <- Text -> IO CString
textToCString Text
str
    CInt
result <- CString -> IO CInt
g_uuid_string_is_valid CString
str'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
str'
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
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 :: ByteString -> m (Bool, Text)
utf8ValidateLen str :: ByteString
str = IO (Bool, Text) -> m (Bool, Text)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Bool, Text) -> m (Bool, Text))
-> IO (Bool, Text) -> m (Bool, Text)
forall a b. (a -> b) -> a -> b
$ do
    let maxLen :: CGType
maxLen = Int -> CGType
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CGType) -> Int -> CGType
forall a b. (a -> b) -> a -> b
$ ByteString -> Int
B.length ByteString
str
    Ptr Word8
str' <- ByteString -> IO (Ptr Word8)
packByteString ByteString
str
    Ptr CString
end <- IO (Ptr CString)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr CString)
    CInt
result <- Ptr Word8 -> CGType -> Ptr CString -> IO CInt
g_utf8_validate_len Ptr Word8
str' CGType
maxLen Ptr CString
end
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    CString
end' <- Ptr CString -> IO CString
forall a. Storable a => Ptr a -> IO a
peek Ptr CString
end
    Text
end'' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
end'
    Ptr Word8 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word8
str'
    Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
end
    (Bool, Text) -> IO (Bool, Text)
forall (m :: * -> *) a. Monad m => a -> m a
return (Bool
result', Text
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 :: ByteString -> m (Bool, Text)
utf8Validate str :: ByteString
str = IO (Bool, Text) -> m (Bool, Text)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Bool, Text) -> m (Bool, Text))
-> IO (Bool, Text) -> m (Bool, Text)
forall a b. (a -> b) -> a -> b
$ do
    let maxLen :: Int64
maxLen = Int -> Int64
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> Int64) -> Int -> Int64
forall a b. (a -> b) -> a -> b
$ ByteString -> Int
B.length ByteString
str
    Ptr Word8
str' <- ByteString -> IO (Ptr Word8)
packByteString ByteString
str
    Ptr CString
end <- IO (Ptr CString)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr CString)
    CInt
result <- Ptr Word8 -> Int64 -> Ptr CString -> IO CInt
g_utf8_validate Ptr Word8
str' Int64
maxLen Ptr CString
end
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    CString
end' <- Ptr CString -> IO CString
forall a. Storable a => Ptr a -> IO a
peek Ptr CString
end
    Text
end'' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
end'
    Ptr Word8 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word8
str'
    Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
end
    (Bool, Text) -> IO (Bool, Text)
forall (m :: * -> *) a. Monad m => a -> m a
return (Bool
result', Text
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 :: Text -> CLong -> CLong -> m Text
utf8Substring str :: Text
str startPos :: CLong
startPos endPos :: CLong
endPos = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
str' <- Text -> IO CString
textToCString Text
str
    CString
result <- CString -> CLong -> CLong -> IO CString
g_utf8_substring CString
str' CLong
startPos CLong
endPos
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "utf8Substring" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
str'
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
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 :: Text -> Int64 -> m Text
utf8Strup str :: Text
str len :: Int64
len = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
str' <- Text -> IO CString
textToCString Text
str
    CString
result <- CString -> Int64 -> IO CString
g_utf8_strup CString
str' Int64
len
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "utf8Strup" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
str'
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
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 :: Text -> Int64 -> m Text
utf8Strreverse str :: Text
str len :: Int64
len = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
str' <- Text -> IO CString
textToCString Text
str
    CString
result <- CString -> Int64 -> IO CString
g_utf8_strreverse CString
str' Int64
len
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "utf8Strreverse" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
str'
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
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 (Maybe 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 :: Text -> Int64 -> Char -> m (Maybe Text)
utf8Strrchr p :: Text
p len :: Int64
len c :: Char
c = IO (Maybe Text) -> m (Maybe Text)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Text) -> m (Maybe Text))
-> IO (Maybe Text) -> m (Maybe Text)
forall a b. (a -> b) -> a -> b
$ do
    CString
p' <- Text -> IO CString
textToCString Text
p
    let c' :: CInt
c' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Char -> Int) -> Char -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Int
ord) Char
c
    CString
result <- CString -> Int64 -> CInt -> IO CString
g_utf8_strrchr CString
p' Int64
len CInt
c'
    Maybe Text
maybeResult <- CString -> (CString -> IO Text) -> IO (Maybe Text)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull CString
result ((CString -> IO Text) -> IO (Maybe Text))
-> (CString -> IO Text) -> IO (Maybe Text)
forall a b. (a -> b) -> a -> b
$ \result' :: CString
result' -> do
        Text
result'' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result'
        Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result''
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
p'
    Maybe Text -> IO (Maybe Text)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Text
maybeResult


-- 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 :: Text -> Text -> CGType -> m Text
utf8Strncpy dest :: Text
dest src :: Text
src n :: CGType
n = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
dest' <- Text -> IO CString
textToCString Text
dest
    CString
src' <- Text -> IO CString
textToCString Text
src
    CString
result <- CString -> CString -> CGType -> IO CString
g_utf8_strncpy CString
dest' CString
src' CGType
n
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "utf8Strncpy" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
dest'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
src'
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
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 :: Text -> Int64 -> m CLong
utf8Strlen p :: Text
p max :: Int64
max = IO CLong -> m CLong
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO CLong -> m CLong) -> IO CLong -> m CLong
forall a b. (a -> b) -> a -> b
$ do
    CString
p' <- Text -> IO CString
textToCString Text
p
    CLong
result <- CString -> Int64 -> IO CLong
g_utf8_strlen CString
p' Int64
max
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
p'
    CLong -> IO CLong
forall (m :: * -> *) a. Monad m => a -> m a
return CLong
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 :: Text -> Int64 -> m Text
utf8Strdown str :: Text
str len :: Int64
len = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
str' <- Text -> IO CString
textToCString Text
str
    CString
result <- CString -> Int64 -> IO CString
g_utf8_strdown CString
str' Int64
len
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "utf8Strdown" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
str'
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
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 (Maybe 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 :: Text -> Int64 -> Char -> m (Maybe Text)
utf8Strchr p :: Text
p len :: Int64
len c :: Char
c = IO (Maybe Text) -> m (Maybe Text)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Text) -> m (Maybe Text))
-> IO (Maybe Text) -> m (Maybe Text)
forall a b. (a -> b) -> a -> b
$ do
    CString
p' <- Text -> IO CString
textToCString Text
p
    let c' :: CInt
c' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Char -> Int) -> Char -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Int
ord) Char
c
    CString
result <- CString -> Int64 -> CInt -> IO CString
g_utf8_strchr CString
p' Int64
len CInt
c'
    Maybe Text
maybeResult <- CString -> (CString -> IO Text) -> IO (Maybe Text)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull CString
result ((CString -> IO Text) -> IO (Maybe Text))
-> (CString -> IO Text) -> IO (Maybe Text)
forall a b. (a -> b) -> a -> b
$ \result' :: CString
result' -> do
        Text
result'' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result'
        Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result''
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
p'
    Maybe Text -> IO (Maybe Text)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Text
maybeResult


-- 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 :: Text -> m Text
utf8PrevChar p :: Text
p = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
p' <- Text -> IO CString
textToCString Text
p
    CString
result <- CString -> IO CString
g_utf8_prev_char CString
p'
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "utf8PrevChar" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
p'
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
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 an 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 :: Text -> Text -> m CLong
utf8PointerToOffset str :: Text
str pos :: Text
pos = IO CLong -> m CLong
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO CLong -> m CLong) -> IO CLong -> m CLong
forall a b. (a -> b) -> a -> b
$ do
    CString
str' <- Text -> IO CString
textToCString Text
str
    CString
pos' <- Text -> IO CString
textToCString Text
pos
    CLong
result <- CString -> CString -> IO CLong
g_utf8_pointer_to_offset CString
str' CString
pos'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
str'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
pos'
    CLong -> IO CLong
forall (m :: * -> *) a. Monad m => a -> m a
return CLong
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 :: Text -> CLong -> m Text
utf8OffsetToPointer str :: Text
str offset :: CLong
offset = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
str' <- Text -> IO CString
textToCString Text
str
    CString
result <- CString -> CLong -> IO CString
g_utf8_offset_to_pointer CString
str' CLong
offset
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "utf8OffsetToPointer" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
str'
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
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 (Maybe T.Text)
    {- ^ __Returns:__ a newly allocated string, that
  is the normalized form of /@str@/, or 'Nothing' if /@str@/
  is not valid UTF-8. -}
utf8Normalize :: Text -> Int64 -> NormalizeMode -> m (Maybe Text)
utf8Normalize str :: Text
str len :: Int64
len mode :: NormalizeMode
mode = IO (Maybe Text) -> m (Maybe Text)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Text) -> m (Maybe Text))
-> IO (Maybe Text) -> m (Maybe Text)
forall a b. (a -> b) -> a -> b
$ do
    CString
str' <- Text -> IO CString
textToCString Text
str
    let mode' :: CUInt
mode' = (Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CUInt) -> (NormalizeMode -> Int) -> NormalizeMode -> CUInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. NormalizeMode -> Int
forall a. Enum a => a -> Int
fromEnum) NormalizeMode
mode
    CString
result <- CString -> Int64 -> CUInt -> IO CString
g_utf8_normalize CString
str' Int64
len CUInt
mode'
    Maybe Text
maybeResult <- CString -> (CString -> IO Text) -> IO (Maybe Text)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull CString
result ((CString -> IO Text) -> IO (Maybe Text))
-> (CString -> IO Text) -> IO (Maybe Text)
forall a b. (a -> b) -> a -> b
$ \result' :: CString
result' -> do
        Text
result'' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result'
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result'
        Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result''
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
str'
    Maybe Text -> IO (Maybe Text)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Text
maybeResult


-- 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 :: Text -> Int64 -> m Text
utf8MakeValid str :: Text
str len :: Int64
len = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
str' <- Text -> IO CString
textToCString Text
str
    CString
result <- CString -> Int64 -> IO CString
g_utf8_make_valid CString
str' Int64
len
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "utf8MakeValid" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
str'
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
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 :: Text -> Int64 -> m Char
utf8GetCharValidated p :: Text
p maxLen :: Int64
maxLen = IO Char -> m Char
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Char -> m Char) -> IO Char -> m Char
forall a b. (a -> b) -> a -> b
$ do
    CString
p' <- Text -> IO CString
textToCString Text
p
    CInt
result <- CString -> Int64 -> IO CInt
g_utf8_get_char_validated CString
p' Int64
maxLen
    let result' :: Char
result' = (Int -> Char
chr (Int -> Char) -> (CInt -> Int) -> CInt -> Char
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral) CInt
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
p'
    Char -> IO Char
forall (m :: * -> *) a. Monad m => a -> m a
return Char
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 :: Text -> m Char
utf8GetChar p :: Text
p = IO Char -> m Char
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Char -> m Char) -> IO Char -> m Char
forall a b. (a -> b) -> a -> b
$ do
    CString
p' <- Text -> IO CString
textToCString Text
p
    CInt
result <- CString -> IO CInt
g_utf8_get_char CString
p'
    let result' :: Char
result' = (Int -> Char
chr (Int -> Char) -> (CInt -> Int) -> CInt -> Char
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral) CInt
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
p'
    Char -> IO Char
forall (m :: * -> *) a. Monad m => a -> m a
return Char
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 (Maybe T.Text)
    {- ^ __Returns:__ a pointer to the found character or 'Nothing'. -}
utf8FindPrevChar :: Text -> Text -> m (Maybe Text)
utf8FindPrevChar str :: Text
str p :: Text
p = IO (Maybe Text) -> m (Maybe Text)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Text) -> m (Maybe Text))
-> IO (Maybe Text) -> m (Maybe Text)
forall a b. (a -> b) -> a -> b
$ do
    CString
str' <- Text -> IO CString
textToCString Text
str
    CString
p' <- Text -> IO CString
textToCString Text
p
    CString
result <- CString -> CString -> IO CString
g_utf8_find_prev_char CString
str' CString
p'
    Maybe Text
maybeResult <- CString -> (CString -> IO Text) -> IO (Maybe Text)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull CString
result ((CString -> IO Text) -> IO (Maybe Text))
-> (CString -> IO Text) -> IO (Maybe Text)
forall a b. (a -> b) -> a -> b
$ \result' :: CString
result' -> do
        Text
result'' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result'
        Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result''
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
str'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
p'
    Maybe Text -> IO (Maybe Text)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Text
maybeResult


-- 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 :: Text -> Maybe Text -> m (Maybe Text)
utf8FindNextChar p :: Text
p end :: Maybe Text
end = IO (Maybe Text) -> m (Maybe Text)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Text) -> m (Maybe Text))
-> IO (Maybe Text) -> m (Maybe Text)
forall a b. (a -> b) -> a -> b
$ do
    CString
p' <- Text -> IO CString
textToCString Text
p
    CString
maybeEnd <- case Maybe Text
end of
        Nothing -> CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
forall a. Ptr a
nullPtr
        Just jEnd :: Text
jEnd -> do
            CString
jEnd' <- Text -> IO CString
textToCString Text
jEnd
            CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
jEnd'
    CString
result <- CString -> CString -> IO CString
g_utf8_find_next_char CString
p' CString
maybeEnd
    Maybe Text
maybeResult <- CString -> (CString -> IO Text) -> IO (Maybe Text)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull CString
result ((CString -> IO Text) -> IO (Maybe Text))
-> (CString -> IO Text) -> IO (Maybe Text)
forall a b. (a -> b) -> a -> b
$ \result' :: CString
result' -> do
        Text
result'' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result'
        Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result''
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
p'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeEnd
    Maybe Text -> IO (Maybe Text)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Text
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 :: Text -> Int64 -> m Text
utf8CollateKeyForFilename str :: Text
str len :: Int64
len = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
str' <- Text -> IO CString
textToCString Text
str
    CString
result <- CString -> Int64 -> IO CString
g_utf8_collate_key_for_filename CString
str' Int64
len
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "utf8CollateKeyForFilename" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
str'
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
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 :: Text -> Int64 -> m Text
utf8CollateKey str :: Text
str len :: Int64
len = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
str' <- Text -> IO CString
textToCString Text
str
    CString
result <- CString -> Int64 -> IO CString
g_utf8_collate_key CString
str' Int64
len
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "utf8CollateKey" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
str'
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
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 :: Text -> Text -> m Int32
utf8Collate str1 :: Text
str1 str2 :: Text
str2 = IO Int32 -> m Int32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int32 -> m Int32) -> IO Int32 -> m Int32
forall a b. (a -> b) -> a -> b
$ do
    CString
str1' <- Text -> IO CString
textToCString Text
str1
    CString
str2' <- Text -> IO CString
textToCString Text
str2
    Int32
result <- CString -> CString -> IO Int32
g_utf8_collate CString
str1' CString
str2'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
str1'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
str2'
    Int32 -> IO Int32
forall (m :: * -> *) a. Monad m => a -> m a
return Int32
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 :: Text -> Int64 -> m Text
utf8Casefold str :: Text
str len :: Int64
len = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
str' <- Text -> IO CString
textToCString Text
str
    CString
result <- CString -> Int64 -> IO CString
g_utf8_casefold CString
str' Int64
len
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "utf8Casefold" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
str'
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
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 :: CULong -> m ()
usleep microseconds :: CULong
microseconds = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    CULong -> IO ()
g_usleep CULong
microseconds
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
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 :: Text -> Maybe Text -> m Text
uriUnescapeString escapedString :: Text
escapedString illegalCharacters :: Maybe Text
illegalCharacters = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
escapedString' <- Text -> IO CString
textToCString Text
escapedString
    CString
maybeIllegalCharacters <- case Maybe Text
illegalCharacters of
        Nothing -> CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
forall a. Ptr a
nullPtr
        Just jIllegalCharacters :: Text
jIllegalCharacters -> do
            CString
jIllegalCharacters' <- Text -> IO CString
textToCString Text
jIllegalCharacters
            CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
jIllegalCharacters'
    CString
result <- CString -> CString -> IO CString
g_uri_unescape_string CString
escapedString' CString
maybeIllegalCharacters
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "uriUnescapeString" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
escapedString'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeIllegalCharacters
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
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 :: Maybe Text -> Maybe Text -> Maybe Text -> m Text
uriUnescapeSegment escapedString :: Maybe Text
escapedString escapedStringEnd :: Maybe Text
escapedStringEnd illegalCharacters :: Maybe Text
illegalCharacters = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
maybeEscapedString <- case Maybe Text
escapedString of
        Nothing -> CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
forall a. Ptr a
nullPtr
        Just jEscapedString :: Text
jEscapedString -> do
            CString
jEscapedString' <- Text -> IO CString
textToCString Text
jEscapedString
            CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
jEscapedString'
    CString
maybeEscapedStringEnd <- case Maybe Text
escapedStringEnd of
        Nothing -> CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
forall a. Ptr a
nullPtr
        Just jEscapedStringEnd :: Text
jEscapedStringEnd -> do
            CString
jEscapedStringEnd' <- Text -> IO CString
textToCString Text
jEscapedStringEnd
            CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
jEscapedStringEnd'
    CString
maybeIllegalCharacters <- case Maybe Text
illegalCharacters of
        Nothing -> CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
forall a. Ptr a
nullPtr
        Just jIllegalCharacters :: Text
jIllegalCharacters -> do
            CString
jIllegalCharacters' <- Text -> IO CString
textToCString Text
jIllegalCharacters
            CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
jIllegalCharacters'
    CString
result <- CString -> CString -> CString -> IO CString
g_uri_unescape_segment CString
maybeEscapedString CString
maybeEscapedStringEnd CString
maybeIllegalCharacters
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "uriUnescapeSegment" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeEscapedString
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeEscapedStringEnd
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeIllegalCharacters
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
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 :: Text -> m Text
uriParseScheme uri :: Text
uri = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
uri' <- Text -> IO CString
textToCString Text
uri
    CString
result <- CString -> IO CString
g_uri_parse_scheme CString
uri'
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "uriParseScheme" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
uri'
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
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 :: Text -> m [Text]
uriListExtractUris uriList :: Text
uriList = IO [Text] -> m [Text]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [Text] -> m [Text]) -> IO [Text] -> m [Text]
forall a b. (a -> b) -> a -> b
$ do
    CString
uriList' <- Text -> IO CString
textToCString Text
uriList
    Ptr CString
result <- CString -> IO (Ptr CString)
g_uri_list_extract_uris CString
uriList'
    Text -> Ptr CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "uriListExtractUris" Ptr CString
result
    [Text]
result' <- HasCallStack => Ptr CString -> IO [Text]
Ptr CString -> IO [Text]
unpackZeroTerminatedUTF8CArray Ptr CString
result
    (CString -> IO ()) -> Ptr CString -> IO ()
forall a b. (Ptr a -> IO b) -> Ptr (Ptr a) -> IO ()
mapZeroTerminatedCArray CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
result
    Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
uriList'
    [Text] -> IO [Text]
forall (m :: * -> *) a. Monad m => a -> m a
return [Text]
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 :: Text -> Maybe Text -> Bool -> m Text
uriEscapeString unescaped :: Text
unescaped reservedCharsAllowed :: Maybe Text
reservedCharsAllowed allowUtf8 :: Bool
allowUtf8 = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
unescaped' <- Text -> IO CString
textToCString Text
unescaped
    CString
maybeReservedCharsAllowed <- case Maybe Text
reservedCharsAllowed of
        Nothing -> CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
forall a. Ptr a
nullPtr
        Just jReservedCharsAllowed :: Text
jReservedCharsAllowed -> do
            CString
jReservedCharsAllowed' <- Text -> IO CString
textToCString Text
jReservedCharsAllowed
            CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
jReservedCharsAllowed'
    let allowUtf8' :: CInt
allowUtf8' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Bool -> Int) -> Bool -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> Int
forall a. Enum a => a -> Int
fromEnum) Bool
allowUtf8
    CString
result <- CString -> CString -> CInt -> IO CString
g_uri_escape_string CString
unescaped' CString
maybeReservedCharsAllowed CInt
allowUtf8'
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "uriEscapeString" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
unescaped'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeReservedCharsAllowed
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
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 :: [Char] -> m ()
unsetenv variable :: [Char]
variable = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    CString
variable' <- [Char] -> IO CString
stringToCString [Char]
variable
    CString -> IO ()
g_unsetenv CString
variable'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
variable'
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
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 :: [Char] -> m Int32
unlink filename :: [Char]
filename = IO Int32 -> m Int32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int32 -> m Int32) -> IO Int32 -> m Int32
forall a b. (a -> b) -> a -> b
$ do
    CString
filename' <- [Char] -> IO CString
stringToCString [Char]
filename
    Int32
result <- CString -> IO Int32
g_unlink CString
filename'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
filename'
    Int32 -> IO Int32
forall (m :: * -> *) a. Monad m => a -> m a
return Int32
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 :: Int32 -> m Source
unixSignalSourceNew signum :: Int32
signum = IO Source -> m Source
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Source -> m Source) -> IO Source -> m Source
forall a b. (a -> b) -> a -> b
$ do
    Ptr Source
result <- Int32 -> IO (Ptr Source)
g_unix_signal_source_new Int32
signum
    Text -> Ptr Source -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "unixSignalSourceNew" Ptr Source
result
    Source
result' <- ((ManagedPtr Source -> Source) -> Ptr Source -> IO Source
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Source -> Source
GLib.Source.Source) Ptr Source
result
    Source -> IO Source
forall (m :: * -> *) a. Monad m => a -> m a
return Source
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 :: Int32 -> Int32 -> IO Bool -> m Word32
unixSignalAdd priority :: Int32
priority signum :: Int32
signum handler :: IO Bool
handler = IO Word32 -> m Word32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ do
    FunPtr C_SourceFunc
handler' <- C_SourceFunc -> IO (FunPtr C_SourceFunc)
GLib.Callbacks.mk_SourceFunc (Maybe (Ptr (FunPtr C_SourceFunc))
-> SourceFunc_WithClosures -> C_SourceFunc
GLib.Callbacks.wrap_SourceFunc Maybe (Ptr (FunPtr C_SourceFunc))
forall a. Maybe a
Nothing (IO Bool -> SourceFunc_WithClosures
GLib.Callbacks.drop_closures_SourceFunc IO Bool
handler))
    let userData :: Ptr ()
userData = FunPtr C_SourceFunc -> Ptr ()
forall a b. FunPtr a -> Ptr b
castFunPtrToPtr FunPtr C_SourceFunc
handler'
    let notify :: FunPtr (Ptr a -> IO ())
notify = FunPtr (Ptr a -> IO ())
forall a. FunPtr (Ptr a -> IO ())
safeFreeFunPtrPtr
    Word32
result <- Int32
-> Int32
-> FunPtr C_SourceFunc
-> Ptr ()
-> FunPtr C_DestroyNotify
-> IO Word32
g_unix_signal_add_full Int32
priority Int32
signum FunPtr C_SourceFunc
handler' Ptr ()
userData FunPtr C_DestroyNotify
forall a. FunPtr (Ptr a -> IO ())
notify
    Word32 -> IO Word32
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
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 :: Int32 -> Bool -> m ()
unixSetFdNonblocking fd :: Int32
fd nonblock :: Bool
nonblock = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    let nonblock' :: CInt
nonblock' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Bool -> Int) -> Bool -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> Int
forall a. Enum a => a -> Int
fromEnum) Bool
nonblock
    IO () -> IO () -> IO ()
forall a b. IO a -> IO b -> IO a
onException (do
        CInt
_ <- (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ Int32 -> CInt -> Ptr (Ptr GError) -> IO CInt
g_unix_set_fd_nonblocking Int32
fd CInt
nonblock'
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     ) (do
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
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 :: Int32 -> Int32 -> m ()
unixOpenPipe fds :: Int32
fds flags :: Int32
flags = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    IO () -> IO () -> IO ()
forall a b. IO a -> IO b -> IO a
onException (do
        CInt
_ <- (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ Int32 -> Int32 -> Ptr (Ptr GError) -> IO CInt
g_unix_open_pipe Int32
fds Int32
flags
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     ) (do
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     )


-- function g_unix_get_passwd_entry
-- Args : [Arg {argCName = "user_name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the username to get the passwd file entry for", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TPtr)
-- throws : True
-- Skip return : False

foreign import ccall "g_unix_get_passwd_entry" g_unix_get_passwd_entry :: 
    CString ->                              -- user_name : TBasicType TUTF8
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr ())

{- |
Get the @passwd@ file entry for the given /@userName@/ using @getpwnam_r()@.
This can fail if the given /@userName@/ doesn’t exist.

The returned @struct passwd@ has been allocated using 'GI.GLib.Functions.malloc' and should
be freed using 'GI.GLib.Functions.free'. The strings referenced by the returned struct are
included in the same allocation, so are valid until the @struct passwd@ is
freed.

This function is safe to call from multiple threads concurrently.

You will need to include @pwd.h@ to get the definition of @struct passwd@.

/Since: 2.64/
-}
unixGetPasswdEntry ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@userName@/: the username to get the passwd file entry for -}
    -> m (Ptr ())
    {- ^ __Returns:__ passwd entry, or 'Nothing' on error; free the returned
   value with 'GI.GLib.Functions.free' /(Can throw 'Data.GI.Base.GError.GError')/ -}
unixGetPasswdEntry :: Text -> m (Ptr ())
unixGetPasswdEntry userName :: Text
userName = IO (Ptr ()) -> m (Ptr ())
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Ptr ()) -> m (Ptr ())) -> IO (Ptr ()) -> m (Ptr ())
forall a b. (a -> b) -> a -> b
$ do
    CString
userName' <- Text -> IO CString
textToCString Text
userName
    IO (Ptr ()) -> IO () -> IO (Ptr ())
forall a b. IO a -> IO b -> IO a
onException (do
        Ptr ()
result <- (Ptr (Ptr GError) -> IO (Ptr ())) -> IO (Ptr ())
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO (Ptr ())) -> IO (Ptr ()))
-> (Ptr (Ptr GError) -> IO (Ptr ())) -> IO (Ptr ())
forall a b. (a -> b) -> a -> b
$ CString -> Ptr (Ptr GError) -> IO (Ptr ())
g_unix_get_passwd_entry CString
userName'
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
userName'
        Ptr () -> IO (Ptr ())
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr ()
result
     ) (do
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
userName'
     )


-- 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 :: Int32 -> [IOCondition] -> m Source
unixFdSourceNew fd :: Int32
fd condition :: [IOCondition]
condition = IO Source -> m Source
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Source -> m Source) -> IO Source -> m Source
forall a b. (a -> b) -> a -> b
$ do
    let condition' :: CUInt
condition' = [IOCondition] -> CUInt
forall b a. (Num b, IsGFlag a) => [a] -> b
gflagsToWord [IOCondition]
condition
    Ptr Source
result <- Int32 -> CUInt -> IO (Ptr Source)
g_unix_fd_source_new Int32
fd CUInt
condition'
    Text -> Ptr Source -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "unixFdSourceNew" Ptr Source
result
    Source
result' <- ((ManagedPtr Source -> Source) -> Ptr Source -> IO Source
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Source -> Source
GLib.Source.Source) Ptr Source
result
    Source -> IO Source
forall (m :: * -> *) a. Monad m => a -> m a
return Source
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 :: Int32 -> Int32 -> [IOCondition] -> UnixFDSourceFunc -> m Word32
unixFdAddFull priority :: Int32
priority fd :: Int32
fd condition :: [IOCondition]
condition function :: UnixFDSourceFunc
function = IO Word32 -> m Word32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ do
    let condition' :: CUInt
condition' = [IOCondition] -> CUInt
forall b a. (Num b, IsGFlag a) => [a] -> b
gflagsToWord [IOCondition]
condition
    FunPtr C_UnixFDSourceFunc
function' <- C_UnixFDSourceFunc -> IO (FunPtr C_UnixFDSourceFunc)
GLib.Callbacks.mk_UnixFDSourceFunc (Maybe (Ptr (FunPtr C_UnixFDSourceFunc))
-> UnixFDSourceFunc_WithClosures -> C_UnixFDSourceFunc
GLib.Callbacks.wrap_UnixFDSourceFunc Maybe (Ptr (FunPtr C_UnixFDSourceFunc))
forall a. Maybe a
Nothing (UnixFDSourceFunc -> UnixFDSourceFunc_WithClosures
GLib.Callbacks.drop_closures_UnixFDSourceFunc UnixFDSourceFunc
function))
    let userData :: Ptr ()
userData = FunPtr C_UnixFDSourceFunc -> Ptr ()
forall a b. FunPtr a -> Ptr b
castFunPtrToPtr FunPtr C_UnixFDSourceFunc
function'
    let notify :: FunPtr (Ptr a -> IO ())
notify = FunPtr (Ptr a -> IO ())
forall a. FunPtr (Ptr a -> IO ())
safeFreeFunPtrPtr
    Word32
result <- Int32
-> Int32
-> CUInt
-> FunPtr C_UnixFDSourceFunc
-> Ptr ()
-> FunPtr C_DestroyNotify
-> IO Word32
g_unix_fd_add_full Int32
priority Int32
fd CUInt
condition' FunPtr C_UnixFDSourceFunc
function' Ptr ()
userData FunPtr C_DestroyNotify
forall a. FunPtr (Ptr a -> IO ())
notify
    Word32 -> IO Word32
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
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 :: m Word32
unixErrorQuark  = IO Word32 -> m Word32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ do
    Word32
result <- IO Word32
g_unix_error_quark
    Word32 -> IO Word32
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
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 :: UnicodeScript -> m Word32
unicodeScriptToIso15924 script :: UnicodeScript
script = IO Word32 -> m Word32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ do
    let script' :: CInt
script' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (UnicodeScript -> Int) -> UnicodeScript -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. UnicodeScript -> Int
forall a. Enum a => a -> Int
fromEnum) UnicodeScript
script
    Word32
result <- CInt -> IO Word32
g_unicode_script_to_iso15924 CInt
script'
    Word32 -> IO Word32
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
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 :: Word32 -> m UnicodeScript
unicodeScriptFromIso15924 iso15924 :: Word32
iso15924 = IO UnicodeScript -> m UnicodeScript
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO UnicodeScript -> m UnicodeScript)
-> IO UnicodeScript -> m UnicodeScript
forall a b. (a -> b) -> a -> b
$ do
    CInt
result <- Word32 -> IO CInt
g_unicode_script_from_iso15924 Word32
iso15924
    let result' :: UnicodeScript
result' = (Int -> UnicodeScript
forall a. Enum a => Int -> a
toEnum (Int -> UnicodeScript) -> (CInt -> Int) -> CInt -> UnicodeScript
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral) CInt
result
    UnicodeScript -> IO UnicodeScript
forall (m :: * -> *) a. Monad m => a -> m a
return UnicodeScript
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 :: Char -> CGType -> m ()
unicodeCanonicalOrdering string :: Char
string len :: CGType
len = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    let string' :: CInt
string' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Char -> Int) -> Char -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Int
ord) Char
string
    CInt -> CGType -> IO ()
g_unicode_canonical_ordering CInt
string' CGType
len
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
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 :: Char -> CGType -> m Char
unicodeCanonicalDecomposition ch :: Char
ch resultLen :: CGType
resultLen = IO Char -> m Char
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Char -> m Char) -> IO Char -> m Char
forall a b. (a -> b) -> a -> b
$ do
    let ch' :: CInt
ch' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Char -> Int) -> Char -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Int
ord) Char
ch
    CInt
result <- CInt -> CGType -> IO CInt
g_unicode_canonical_decomposition CInt
ch' CGType
resultLen
    let result' :: Char
result' = (Int -> Char
chr (Int -> Char) -> (CInt -> Int) -> CInt -> Char
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral) CInt
result
    Char -> IO Char
forall (m :: * -> *) a. Monad m => a -> m a
return Char
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 :: Char -> m Int32
unicharXdigitValue c :: Char
c = IO Int32 -> m Int32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int32 -> m Int32) -> IO Int32 -> m Int32
forall a b. (a -> b) -> a -> b
$ do
    let c' :: CInt
c' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Char -> Int) -> Char -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Int
ord) Char
c
    Int32
result <- CInt -> IO Int32
g_unichar_xdigit_value CInt
c'
    Int32 -> IO Int32
forall (m :: * -> *) a. Monad m => a -> m a
return Int32
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 :: Char -> m Bool
unicharValidate ch :: Char
ch = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    let ch' :: CInt
ch' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Char -> Int) -> Char -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Int
ord) Char
ch
    CInt
result <- CInt -> IO CInt
g_unichar_validate CInt
ch'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
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 :: Char -> m UnicodeType
unicharType c :: Char
c = IO UnicodeType -> m UnicodeType
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO UnicodeType -> m UnicodeType)
-> IO UnicodeType -> m UnicodeType
forall a b. (a -> b) -> a -> b
$ do
    let c' :: CInt
c' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Char -> Int) -> Char -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Int
ord) Char
c
    CUInt
result <- CInt -> IO CUInt
g_unichar_type CInt
c'
    let result' :: UnicodeType
result' = (Int -> UnicodeType
forall a. Enum a => Int -> a
toEnum (Int -> UnicodeType) -> (CUInt -> Int) -> CUInt -> UnicodeType
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CUInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral) CUInt
result
    UnicodeType -> IO UnicodeType
forall (m :: * -> *) a. Monad m => a -> m a
return UnicodeType
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 a lowercase or titlecase character,
              or has no upper case equivalent /@c@/ is returned unchanged. -}
unicharToupper :: Char -> m Char
unicharToupper c :: Char
c = IO Char -> m Char
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Char -> m Char) -> IO Char -> m Char
forall a b. (a -> b) -> a -> b
$ do
    let c' :: CInt
c' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Char -> Int) -> Char -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Int
ord) Char
c
    CInt
result <- CInt -> IO CInt
g_unichar_toupper CInt
c'
    let result' :: Char
result' = (Int -> Char
chr (Int -> Char) -> (CInt -> Int) -> CInt -> Char
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral) CInt
result
    Char -> IO Char
forall (m :: * -> *) a. Monad m => a -> m a
return Char
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 :: Char -> m Char
unicharTotitle c :: Char
c = IO Char -> m Char
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Char -> m Char) -> IO Char -> m Char
forall a b. (a -> b) -> a -> b
$ do
    let c' :: CInt
c' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Char -> Int) -> Char -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Int
ord) Char
c
    CInt
result <- CInt -> IO CInt
g_unichar_totitle CInt
c'
    let result' :: Char
result' = (Int -> Char
chr (Int -> Char) -> (CInt -> Int) -> CInt -> Char
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral) CInt
result
    Char -> IO Char
forall (m :: * -> *) a. Monad m => a -> m a
return Char
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 :: Char -> m Char
unicharTolower c :: Char
c = IO Char -> m Char
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Char -> m Char) -> IO Char -> m Char
forall a b. (a -> b) -> a -> b
$ do
    let c' :: CInt
c' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Char -> Int) -> Char -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Int
ord) Char
c
    CInt
result <- CInt -> IO CInt
g_unichar_tolower CInt
c'
    let result' :: Char
result' = (Int -> Char
chr (Int -> Char) -> (CInt -> Int) -> CInt -> Char
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral) CInt
result
    Char -> IO Char
forall (m :: * -> *) a. Monad m => a -> m a
return Char
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 :: Char -> m Bool
unicharIszerowidth c :: Char
c = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    let c' :: CInt
c' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Char -> Int) -> Char -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Int
ord) Char
c
    CInt
result <- CInt -> IO CInt
g_unichar_iszerowidth CInt
c'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
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 :: Char -> m Bool
unicharIsxdigit c :: Char
c = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    let c' :: CInt
c' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Char -> Int) -> Char -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Int
ord) Char
c
    CInt
result <- CInt -> IO CInt
g_unichar_isxdigit CInt
c'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
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 :: Char -> m Bool
unicharIswideCjk c :: Char
c = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    let c' :: CInt
c' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Char -> Int) -> Char -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Int
ord) Char
c
    CInt
result <- CInt -> IO CInt
g_unichar_iswide_cjk CInt
c'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
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 :: Char -> m Bool
unicharIswide c :: Char
c = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    let c' :: CInt
c' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Char -> Int) -> Char -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Int
ord) Char
c
    CInt
result <- CInt -> IO CInt
g_unichar_iswide CInt
c'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
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 :: Char -> m Bool
unicharIsupper c :: Char
c = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    let c' :: CInt
c' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Char -> Int) -> Char -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Int
ord) Char
c
    CInt
result <- CInt -> IO CInt
g_unichar_isupper CInt
c'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
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 :: Char -> m Bool
unicharIstitle c :: Char
c = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    let c' :: CInt
c' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Char -> Int) -> Char -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Int
ord) Char
c
    CInt
result <- CInt -> IO CInt
g_unichar_istitle CInt
c'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
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 :: Char -> m Bool
unicharIsspace c :: Char
c = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    let c' :: CInt
c' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Char -> Int) -> Char -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Int
ord) Char
c
    CInt
result <- CInt -> IO CInt
g_unichar_isspace CInt
c'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
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 :: Char -> m Bool
unicharIspunct c :: Char
c = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    let c' :: CInt
c' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Char -> Int) -> Char -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Int
ord) Char
c
    CInt
result <- CInt -> IO CInt
g_unichar_ispunct CInt
c'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
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 :: Char -> m Bool
unicharIsprint c :: Char
c = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    let c' :: CInt
c' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Char -> Int) -> Char -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Int
ord) Char
c
    CInt
result <- CInt -> IO CInt
g_unichar_isprint CInt
c'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
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 :: Char -> m Bool
unicharIsmark c :: Char
c = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    let c' :: CInt
c' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Char -> Int) -> Char -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Int
ord) Char
c
    CInt
result <- CInt -> IO CInt
g_unichar_ismark CInt
c'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
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 :: Char -> m Bool
unicharIslower c :: Char
c = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    let c' :: CInt
c' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Char -> Int) -> Char -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Int
ord) Char
c
    CInt
result <- CInt -> IO CInt
g_unichar_islower CInt
c'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
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 :: Char -> m Bool
unicharIsgraph c :: Char
c = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    let c' :: CInt
c' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Char -> Int) -> Char -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Int
ord) Char
c
    CInt
result <- CInt -> IO CInt
g_unichar_isgraph CInt
c'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
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 :: Char -> m Bool
unicharIsdigit c :: Char
c = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    let c' :: CInt
c' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Char -> Int) -> Char -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Int
ord) Char
c
    CInt
result <- CInt -> IO CInt
g_unichar_isdigit CInt
c'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
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 :: Char -> m Bool
unicharIsdefined c :: Char
c = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    let c' :: CInt
c' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Char -> Int) -> Char -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Int
ord) Char
c
    CInt
result <- CInt -> IO CInt
g_unichar_isdefined CInt
c'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
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 :: Char -> m Bool
unicharIscntrl c :: Char
c = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    let c' :: CInt
c' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Char -> Int) -> Char -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Int
ord) Char
c
    CInt
result <- CInt -> IO CInt
g_unichar_iscntrl CInt
c'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
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 :: Char -> m Bool
unicharIsalpha c :: Char
c = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    let c' :: CInt
c' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Char -> Int) -> Char -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Int
ord) Char
c
    CInt
result <- CInt -> IO CInt
g_unichar_isalpha CInt
c'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
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 :: Char -> m Bool
unicharIsalnum c :: Char
c = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    let c' :: CInt
c' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Char -> Int) -> Char -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Int
ord) Char
c
    CInt
result <- CInt -> IO CInt
g_unichar_isalnum CInt
c'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
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 :: Char -> m UnicodeScript
unicharGetScript ch :: Char
ch = IO UnicodeScript -> m UnicodeScript
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO UnicodeScript -> m UnicodeScript)
-> IO UnicodeScript -> m UnicodeScript
forall a b. (a -> b) -> a -> b
$ do
    let ch' :: CInt
ch' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Char -> Int) -> Char -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Int
ord) Char
ch
    CInt
result <- CInt -> IO CInt
g_unichar_get_script CInt
ch'
    let result' :: UnicodeScript
result' = (Int -> UnicodeScript
forall a. Enum a => Int -> a
toEnum (Int -> UnicodeScript) -> (CInt -> Int) -> CInt -> UnicodeScript
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral) CInt
result
    UnicodeScript -> IO UnicodeScript
forall (m :: * -> *) a. Monad m => a -> m a
return UnicodeScript
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 :: Char -> Char -> m Bool
unicharGetMirrorChar ch :: Char
ch mirroredCh :: Char
mirroredCh = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    let ch' :: CInt
ch' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Char -> Int) -> Char -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Int
ord) Char
ch
    let mirroredCh' :: CInt
mirroredCh' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Char -> Int) -> Char -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Int
ord) Char
mirroredCh
    CInt
result <- CInt -> CInt -> IO CInt
g_unichar_get_mirror_char CInt
ch' CInt
mirroredCh'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
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 :: Char -> m Int32
unicharDigitValue c :: Char
c = IO Int32 -> m Int32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int32 -> m Int32) -> IO Int32 -> m Int32
forall a b. (a -> b) -> a -> b
$ do
    let c' :: CInt
c' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Char -> Int) -> Char -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Int
ord) Char
c
    Int32
result <- CInt -> IO Int32
g_unichar_digit_value CInt
c'
    Int32 -> IO Int32
forall (m :: * -> *) a. Monad m => a -> m a
return Int32
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 = DirectionOut, 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 = TransferEverything},Arg {argCName = "b", argType = TBasicType TUniChar, direction = DirectionOut, 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 = TransferEverything}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_unichar_decompose" g_unichar_decompose :: 
    CInt ->                                 -- ch : TBasicType TUniChar
    Ptr CInt ->                             -- a : TBasicType TUniChar
    Ptr 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 -}
    -> m ((Bool, Char, Char))
    {- ^ __Returns:__ 'True' if the character could be decomposed -}
unicharDecompose :: Char -> m (Bool, Char, Char)
unicharDecompose ch :: Char
ch = IO (Bool, Char, Char) -> m (Bool, Char, Char)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Bool, Char, Char) -> m (Bool, Char, Char))
-> IO (Bool, Char, Char) -> m (Bool, Char, Char)
forall a b. (a -> b) -> a -> b
$ do
    let ch' :: CInt
ch' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Char -> Int) -> Char -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Int
ord) Char
ch
    Ptr CInt
a <- IO (Ptr CInt)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr CInt)
    Ptr CInt
b <- IO (Ptr CInt)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr CInt)
    CInt
result <- CInt -> Ptr CInt -> Ptr CInt -> IO CInt
g_unichar_decompose CInt
ch' Ptr CInt
a Ptr CInt
b
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    CInt
a' <- Ptr CInt -> IO CInt
forall a. Storable a => Ptr a -> IO a
peek Ptr CInt
a
    let a'' :: Char
a'' = (Int -> Char
chr (Int -> Char) -> (CInt -> Int) -> CInt -> Char
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral) CInt
a'
    CInt
b' <- Ptr CInt -> IO CInt
forall a. Storable a => Ptr a -> IO a
peek Ptr CInt
b
    let b'' :: Char
b'' = (Int -> Char
chr (Int -> Char) -> (CInt -> Int) -> CInt -> Char
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral) CInt
b'
    Ptr CInt -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CInt
a
    Ptr CInt -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CInt
b
    (Bool, Char, Char) -> IO (Bool, Char, Char)
forall (m :: * -> *) a. Monad m => a -> m a
return (Bool
result', Char
a'', Char
b'')


-- 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 = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "return location for the composed character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- 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
    Ptr 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 -}
    -> m ((Bool, Char))
    {- ^ __Returns:__ 'True' if the characters could be composed -}
unicharCompose :: Char -> Char -> m (Bool, Char)
unicharCompose a :: Char
a b :: Char
b = IO (Bool, Char) -> m (Bool, Char)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Bool, Char) -> m (Bool, Char))
-> IO (Bool, Char) -> m (Bool, Char)
forall a b. (a -> b) -> a -> b
$ do
    let a' :: CInt
a' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Char -> Int) -> Char -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Int
ord) Char
a
    let b' :: CInt
b' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Char -> Int) -> Char -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Int
ord) Char
b
    Ptr CInt
ch <- IO (Ptr CInt)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr CInt)
    CInt
result <- CInt -> CInt -> Ptr CInt -> IO CInt
g_unichar_compose CInt
a' CInt
b' Ptr CInt
ch
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    CInt
ch' <- Ptr CInt -> IO CInt
forall a. Storable a => Ptr a -> IO a
peek Ptr CInt
ch
    let ch'' :: Char
ch'' = (Int -> Char
chr (Int -> Char) -> (CInt -> Int) -> CInt -> Char
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral) CInt
ch'
    Ptr CInt -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CInt
ch
    (Bool, Char) -> IO (Bool, Char)
forall (m :: * -> *) a. Monad m => a -> m a
return (Bool
result', Char
ch'')


-- 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 :: Char -> m Int32
unicharCombiningClass uc :: Char
uc = IO Int32 -> m Int32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int32 -> m Int32) -> IO Int32 -> m Int32
forall a b. (a -> b) -> a -> b
$ do
    let uc' :: CInt
uc' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Char -> Int) -> Char -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Int
ord) Char
uc
    Int32
result <- CInt -> IO Int32
g_unichar_combining_class CInt
uc'
    Int32 -> IO Int32
forall (m :: * -> *) a. Monad m => a -> m a
return Int32
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 :: Char -> m UnicodeBreakType
unicharBreakType c :: Char
c = IO UnicodeBreakType -> m UnicodeBreakType
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO UnicodeBreakType -> m UnicodeBreakType)
-> IO UnicodeBreakType -> m UnicodeBreakType
forall a b. (a -> b) -> a -> b
$ do
    let c' :: CInt
c' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Char -> Int) -> Char -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Int
ord) Char
c
    CUInt
result <- CInt -> IO CUInt
g_unichar_break_type CInt
c'
    let result' :: UnicodeBreakType
result' = (Int -> UnicodeBreakType
forall a. Enum a => Int -> a
toEnum (Int -> UnicodeBreakType)
-> (CUInt -> Int) -> CUInt -> UnicodeBreakType
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CUInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral) CUInt
result
    UnicodeBreakType -> IO UnicodeBreakType
forall (m :: * -> *) a. Monad m => a -> m a
return UnicodeBreakType
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 :: Ptr () -> CGType -> CGType -> m (Ptr ())
tryReallocN mem :: Ptr ()
mem nBlocks :: CGType
nBlocks nBlockBytes :: CGType
nBlockBytes = IO (Ptr ()) -> m (Ptr ())
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Ptr ()) -> m (Ptr ())) -> IO (Ptr ()) -> m (Ptr ())
forall a b. (a -> b) -> a -> b
$ do
    Ptr ()
result <- Ptr () -> CGType -> CGType -> IO (Ptr ())
g_try_realloc_n Ptr ()
mem CGType
nBlocks CGType
nBlockBytes
    Ptr () -> IO (Ptr ())
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr ()
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 :: Ptr () -> CGType -> m (Ptr ())
tryRealloc mem :: Ptr ()
mem nBytes :: CGType
nBytes = IO (Ptr ()) -> m (Ptr ())
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Ptr ()) -> m (Ptr ())) -> IO (Ptr ()) -> m (Ptr ())
forall a b. (a -> b) -> a -> b
$ do
    Ptr ()
result <- Ptr () -> CGType -> IO (Ptr ())
g_try_realloc Ptr ()
mem CGType
nBytes
    Ptr () -> IO (Ptr ())
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr ()
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 :: CGType -> CGType -> m (Ptr ())
tryMallocN nBlocks :: CGType
nBlocks nBlockBytes :: CGType
nBlockBytes = IO (Ptr ()) -> m (Ptr ())
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Ptr ()) -> m (Ptr ())) -> IO (Ptr ()) -> m (Ptr ())
forall a b. (a -> b) -> a -> b
$ do
    Ptr ()
result <- CGType -> CGType -> IO (Ptr ())
g_try_malloc_n CGType
nBlocks CGType
nBlockBytes
    Ptr () -> IO (Ptr ())
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr ()
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 :: CGType -> CGType -> m (Ptr ())
tryMalloc0N nBlocks :: CGType
nBlocks nBlockBytes :: CGType
nBlockBytes = IO (Ptr ()) -> m (Ptr ())
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Ptr ()) -> m (Ptr ())) -> IO (Ptr ()) -> m (Ptr ())
forall a b. (a -> b) -> a -> b
$ do
    Ptr ()
result <- CGType -> CGType -> IO (Ptr ())
g_try_malloc0_n CGType
nBlocks CGType
nBlockBytes
    Ptr () -> IO (Ptr ())
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr ()
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 :: CGType -> m (Ptr ())
tryMalloc0 nBytes :: CGType
nBytes = IO (Ptr ()) -> m (Ptr ())
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Ptr ()) -> m (Ptr ())) -> IO (Ptr ()) -> m (Ptr ())
forall a b. (a -> b) -> a -> b
$ do
    Ptr ()
result <- CGType -> IO (Ptr ())
g_try_malloc0 CGType
nBytes
    Ptr () -> IO (Ptr ())
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr ()
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 :: CGType -> m (Ptr ())
tryMalloc nBytes :: CGType
nBytes = IO (Ptr ()) -> m (Ptr ())
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Ptr ()) -> m (Ptr ())) -> IO (Ptr ()) -> m (Ptr ())
forall a b. (a -> b) -> a -> b
$ do
    Ptr ()
result <- CGType -> IO (Ptr ())
g_try_malloc CGType
nBytes
    Ptr () -> IO (Ptr ())
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr ()
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 :: Word32 -> m Source
timeoutSourceNewSeconds interval :: Word32
interval = IO Source -> m Source
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Source -> m Source) -> IO Source -> m Source
forall a b. (a -> b) -> a -> b
$ do
    Ptr Source
result <- Word32 -> IO (Ptr Source)
g_timeout_source_new_seconds Word32
interval
    Text -> Ptr Source -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "timeoutSourceNewSeconds" Ptr Source
result
    Source
result' <- ((ManagedPtr Source -> Source) -> Ptr Source -> IO Source
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Source -> Source
GLib.Source.Source) Ptr Source
result
    Source -> IO Source
forall (m :: * -> *) a. Monad m => a -> m a
return Source
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 :: Word32 -> m Source
timeoutSourceNew interval :: Word32
interval = IO Source -> m Source
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Source -> m Source) -> IO Source -> m Source
forall a b. (a -> b) -> a -> b
$ do
    Ptr Source
result <- Word32 -> IO (Ptr Source)
g_timeout_source_new Word32
interval
    Text -> Ptr Source -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "timeoutSourceNew" Ptr Source
result
    Source
result' <- ((ManagedPtr Source -> Source) -> Ptr Source -> IO Source
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Source -> Source
GLib.Source.Source) Ptr Source
result
    Source -> IO Source
forall (m :: * -> *) a. Monad m => a -> m a
return Source
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.

It is safe to call this function from any thread.

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 :: Int32 -> Word32 -> IO Bool -> m Word32
timeoutAddSeconds priority :: Int32
priority interval :: Word32
interval function :: IO Bool
function = IO Word32 -> m Word32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ do
    FunPtr C_SourceFunc
function' <- C_SourceFunc -> IO (FunPtr C_SourceFunc)
GLib.Callbacks.mk_SourceFunc (Maybe (Ptr (FunPtr C_SourceFunc))
-> SourceFunc_WithClosures -> C_SourceFunc
GLib.Callbacks.wrap_SourceFunc Maybe (Ptr (FunPtr C_SourceFunc))
forall a. Maybe a
Nothing (IO Bool -> SourceFunc_WithClosures
GLib.Callbacks.drop_closures_SourceFunc IO Bool
function))
    let data_ :: Ptr ()
data_ = FunPtr C_SourceFunc -> Ptr ()
forall a b. FunPtr a -> Ptr b
castFunPtrToPtr FunPtr C_SourceFunc
function'
    let notify :: FunPtr (Ptr a -> IO ())
notify = FunPtr (Ptr a -> IO ())
forall a. FunPtr (Ptr a -> IO ())
safeFreeFunPtrPtr
    Word32
result <- Int32
-> Word32
-> FunPtr C_SourceFunc
-> Ptr ()
-> FunPtr C_DestroyNotify
-> IO Word32
g_timeout_add_seconds_full Int32
priority Word32
interval FunPtr C_SourceFunc
function' Ptr ()
data_ FunPtr C_DestroyNotify
forall a. FunPtr (Ptr a -> IO ())
notify
    Word32 -> IO Word32
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
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 :: Int32 -> Word32 -> IO Bool -> m Word32
timeoutAdd priority :: Int32
priority interval :: Word32
interval function :: IO Bool
function = IO Word32 -> m Word32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ do
    FunPtr C_SourceFunc
function' <- C_SourceFunc -> IO (FunPtr C_SourceFunc)
GLib.Callbacks.mk_SourceFunc (Maybe (Ptr (FunPtr C_SourceFunc))
-> SourceFunc_WithClosures -> C_SourceFunc
GLib.Callbacks.wrap_SourceFunc Maybe (Ptr (FunPtr C_SourceFunc))
forall a. Maybe a
Nothing (IO Bool -> SourceFunc_WithClosures
GLib.Callbacks.drop_closures_SourceFunc IO Bool
function))
    let data_ :: Ptr ()
data_ = FunPtr C_SourceFunc -> Ptr ()
forall a b. FunPtr a -> Ptr b
castFunPtrToPtr FunPtr C_SourceFunc
function'
    let notify :: FunPtr (Ptr a -> IO ())
notify = FunPtr (Ptr a -> IO ())
forall a. FunPtr (Ptr a -> IO ())
safeFreeFunPtrPtr
    Word32
result <- Int32
-> Word32
-> FunPtr C_SourceFunc
-> Ptr ()
-> FunPtr C_DestroyNotify
-> IO Word32
g_timeout_add_full Int32
priority Word32
interval FunPtr C_SourceFunc
function' Ptr ()
data_ FunPtr C_DestroyNotify
forall a. FunPtr (Ptr a -> IO ())
notify
    Word32 -> IO Word32
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
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 :: Maybe Text -> CGType -> [TestSubprocessFlags] -> m ()
testTrapSubprocess testPath :: Maybe Text
testPath usecTimeout :: CGType
usecTimeout testFlags :: [TestSubprocessFlags]
testFlags = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    CString
maybeTestPath <- case Maybe Text
testPath of
        Nothing -> CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
forall a. Ptr a
nullPtr
        Just jTestPath :: Text
jTestPath -> do
            CString
jTestPath' <- Text -> IO CString
textToCString Text
jTestPath
            CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
jTestPath'
    let testFlags' :: CUInt
testFlags' = [TestSubprocessFlags] -> CUInt
forall b a. (Num b, IsGFlag a) => [a] -> b
gflagsToWord [TestSubprocessFlags]
testFlags
    CString -> CGType -> CUInt -> IO ()
g_test_trap_subprocess CString
maybeTestPath CGType
usecTimeout CUInt
testFlags'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeTestPath
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
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 :: m Bool
testTrapReachedTimeout  = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    CInt
result <- IO CInt
g_test_trap_reached_timeout
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
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 :: m Bool
testTrapHasPassed  = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    CInt
result <- IO CInt
g_test_trap_has_passed
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
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 :: CGType -> [TestTrapFlags] -> m Bool
testTrapFork usecTimeout :: CGType
usecTimeout testTrapFlags :: [TestTrapFlags]
testTrapFlags = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    let testTrapFlags' :: CUInt
testTrapFlags' = [TestTrapFlags] -> CUInt
forall b a. (Num b, IsGFlag a) => [a] -> b
gflagsToWord [TestTrapFlags]
testTrapFlags
    CInt
result <- CGType -> CUInt -> IO CInt
g_test_trap_fork CGType
usecTimeout CUInt
testTrapFlags'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
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 :: Text -> Text -> Int32 -> Text -> CGType -> Text -> m ()
testTrapAssertions domain :: Text
domain file :: Text
file line :: Int32
line func :: Text
func assertionFlags :: CGType
assertionFlags pattern :: Text
pattern = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    CString
domain' <- Text -> IO CString
textToCString Text
domain
    CString
file' <- Text -> IO CString
textToCString Text
file
    CString
func' <- Text -> IO CString
textToCString Text
func
    CString
pattern' <- Text -> IO CString
textToCString Text
pattern
    CString
-> CString -> Int32 -> CString -> CGType -> CString -> IO ()
g_test_trap_assertions CString
domain' CString
file' Int32
line CString
func' CGType
assertionFlags CString
pattern'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
domain'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
file'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
func'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
pattern'
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
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 :: m ()
testTimerStart  = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    IO ()
g_test_timer_start
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
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 :: m Double
testTimerLast  = IO Double -> m Double
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Double -> m Double) -> IO Double -> m Double
forall a b. (a -> b) -> a -> b
$ do
    CDouble
result <- IO CDouble
g_test_timer_last
    let result' :: Double
result' = CDouble -> Double
forall a b. (Real a, Fractional b) => a -> b
realToFrac CDouble
result
    Double -> IO Double
forall (m :: * -> *) a. Monad m => a -> m a
return Double
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 :: m Double
testTimerElapsed  = IO Double -> m Double
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Double -> m Double) -> IO Double -> m Double
forall a b. (a -> b) -> a -> b
$ do
    CDouble
result <- IO CDouble
g_test_timer_elapsed
    let result' :: Double
result' = CDouble -> Double
forall a b. (Real a, Fractional b) => a -> b
realToFrac CDouble
result
    Double -> IO Double
forall (m :: * -> *) a. Monad m => a -> m a
return Double
result'


-- function g_test_summary
-- Args : [Arg {argCName = "summary", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "One or two sentences summarising what the test checks, and how it\n   checks it.", 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_summary" g_test_summary :: 
    CString ->                              -- summary : TBasicType TUTF8
    IO ()

{- |
Set the summary for a test, which describes what the test checks, and how it
goes about checking it. This may be included in test report output, and is
useful documentation for anyone reading the source code or modifying a test
in future. It must be a single line.

This should be called at the top of a test function.

For example:

=== /C code/
>
>static void
>test_array_sort (void)
>{
>  g_test_summary ("Test my_array_sort() sorts the array correctly and stably, "
>                  "including testing zero length and one-element arrays.");
>
>  …
>}


/Since: 2.62/
-}
testSummary ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@summary@/: One or two sentences summarising what the test checks, and how it
   checks it. -}
    -> m ()
testSummary :: Text -> m ()
testSummary summary :: Text
summary = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    CString
summary' <- Text -> IO CString
textToCString Text
summary
    CString -> IO ()
g_test_summary CString
summary'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
summary'
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()


-- 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 :: m Bool
testSubprocess  = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    CInt
result <- IO CInt
g_test_subprocess
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
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 :: Maybe Text -> m ()
testSkip msg :: Maybe Text
msg = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    CString
maybeMsg <- case Maybe Text
msg of
        Nothing -> CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
forall a. Ptr a
nullPtr
        Just jMsg :: Text
jMsg -> do
            CString
jMsg' <- Text -> IO CString
textToCString Text
jMsg
            CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
jMsg'
    CString -> IO ()
g_test_skip CString
maybeMsg
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeMsg
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
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 :: m ()
testSetNonfatalAssertions  = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    IO ()
g_test_set_nonfatal_assertions
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
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 :: TestSuite -> m Int32
testRunSuite suite :: TestSuite
suite = IO Int32 -> m Int32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int32 -> m Int32) -> IO Int32 -> m Int32
forall a b. (a -> b) -> a -> b
$ do
    Ptr TestSuite
suite' <- TestSuite -> IO (Ptr TestSuite)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr TestSuite
suite
    Int32
result <- Ptr TestSuite -> IO Int32
g_test_run_suite Ptr TestSuite
suite'
    TestSuite -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr TestSuite
suite
    Int32 -> IO Int32
forall (m :: * -> *) a. Monad m => a -> m a
return Int32
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 :: m Int32
testRun  = IO Int32 -> m Int32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int32 -> m Int32) -> IO Int32 -> m Int32
forall a b. (a -> b) -> a -> b
$ do
    Int32
result <- IO Int32
g_test_run
    Int32 -> IO Int32
forall (m :: * -> *) a. Monad m => a -> m a
return Int32
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 :: Int32 -> Int32 -> m Int32
testRandIntRange begin :: Int32
begin end :: Int32
end = IO Int32 -> m Int32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int32 -> m Int32) -> IO Int32 -> m Int32
forall a b. (a -> b) -> a -> b
$ do
    Int32
result <- Int32 -> Int32 -> IO Int32
g_test_rand_int_range Int32
begin Int32
end
    Int32 -> IO Int32
forall (m :: * -> *) a. Monad m => a -> m a
return Int32
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 :: m Int32
testRandInt  = IO Int32 -> m Int32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int32 -> m Int32) -> IO Int32 -> m Int32
forall a b. (a -> b) -> a -> b
$ do
    Int32
result <- IO Int32
g_test_rand_int
    Int32 -> IO Int32
forall (m :: * -> *) a. Monad m => a -> m a
return Int32
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 :: Double -> Double -> m Double
testRandDoubleRange rangeStart :: Double
rangeStart rangeEnd :: Double
rangeEnd = IO Double -> m Double
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Double -> m Double) -> IO Double -> m Double
forall a b. (a -> b) -> a -> b
$ do
    let rangeStart' :: CDouble
rangeStart' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
rangeStart
    let rangeEnd' :: CDouble
rangeEnd' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
rangeEnd
    CDouble
result <- CDouble -> CDouble -> IO CDouble
g_test_rand_double_range CDouble
rangeStart' CDouble
rangeEnd'
    let result' :: Double
result' = CDouble -> Double
forall a b. (Real a, Fractional b) => a -> b
realToFrac CDouble
result
    Double -> IO Double
forall (m :: * -> *) a. Monad m => a -> m a
return Double
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 :: m Double
testRandDouble  = IO Double -> m Double
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Double -> m Double) -> IO Double -> m Double
forall a b. (a -> b) -> a -> b
$ do
    CDouble
result <- IO CDouble
g_test_rand_double
    let result' :: Double
result' = CDouble -> Double
forall a b. (Real a, Fractional b) => a -> b
realToFrac CDouble
result
    Double -> IO Double
forall (m :: * -> *) a. Monad m => a -> m a
return Double
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 :: Ptr () -> m ()
testQueueFree gfreePointer :: Ptr ()
gfreePointer = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    C_DestroyNotify
g_test_queue_free Ptr ()
gfreePointer
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
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 :: C_DestroyNotify -> Ptr () -> m ()
testQueueDestroy destroyFunc :: C_DestroyNotify
destroyFunc destroyData :: Ptr ()
destroyData = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr (FunPtr C_DestroyNotify)
ptrdestroyFunc <- IO (Ptr (FunPtr C_DestroyNotify))
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr (FunPtr GLib.Callbacks.C_DestroyNotify))
    FunPtr C_DestroyNotify
destroyFunc' <- C_DestroyNotify -> IO (FunPtr C_DestroyNotify)
GLib.Callbacks.mk_DestroyNotify (Maybe (Ptr (FunPtr C_DestroyNotify))
-> C_DestroyNotify -> C_DestroyNotify
GLib.Callbacks.wrap_DestroyNotify (Ptr (FunPtr C_DestroyNotify)
-> Maybe (Ptr (FunPtr C_DestroyNotify))
forall a. a -> Maybe a
Just Ptr (FunPtr C_DestroyNotify)
ptrdestroyFunc) C_DestroyNotify
destroyFunc)
    Ptr (FunPtr C_DestroyNotify) -> FunPtr C_DestroyNotify -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke Ptr (FunPtr C_DestroyNotify)
ptrdestroyFunc FunPtr C_DestroyNotify
destroyFunc'
    FunPtr C_DestroyNotify -> C_DestroyNotify
g_test_queue_destroy FunPtr C_DestroyNotify
destroyFunc' Ptr ()
destroyData
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
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 :: TestLogType -> m Text
testLogTypeName logType :: TestLogType
logType = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    let logType' :: CUInt
logType' = (Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CUInt) -> (TestLogType -> Int) -> TestLogType -> CUInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TestLogType -> Int
forall a. Enum a => a -> Int
fromEnum) TestLogType
logType
    CString
result <- CUInt -> IO CString
g_test_log_type_name CUInt
logType'
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "testLogTypeName" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
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 :: Maybe Text -> m ()
testIncomplete msg :: Maybe Text
msg = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    CString
maybeMsg <- case Maybe Text
msg of
        Nothing -> CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
forall a. Ptr a
nullPtr
        Just jMsg :: Text
jMsg -> do
            CString
jMsg' <- Text -> IO CString
textToCString Text
jMsg
            CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
jMsg'
    CString -> IO ()
g_test_incomplete CString
maybeMsg
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeMsg
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
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 :: TestFileType -> m [Char]
testGetDir fileType :: TestFileType
fileType = IO [Char] -> m [Char]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [Char] -> m [Char]) -> IO [Char] -> m [Char]
forall a b. (a -> b) -> a -> b
$ do
    let fileType' :: CUInt
fileType' = (Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CUInt) -> (TestFileType -> Int) -> TestFileType -> CUInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TestFileType -> Int
forall a. Enum a => a -> Int
fromEnum) TestFileType
fileType
    CString
result <- CUInt -> IO CString
g_test_get_dir CUInt
fileType'
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "testGetDir" CString
result
    [Char]
result' <- HasCallStack => CString -> IO [Char]
CString -> IO [Char]
cstringToString CString
result
    [Char] -> IO [Char]
forall (m :: * -> *) a. Monad m => a -> m a
return [Char]
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 :: m Bool
testFailed  = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    CInt
result <- IO CInt
g_test_failed
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
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 :: m ()
testFail  = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    IO ()
g_test_fail
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
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 :: Maybe Text -> [LogLevelFlags] -> Text -> m ()
testExpectMessage logDomain :: Maybe Text
logDomain logLevel :: [LogLevelFlags]
logLevel pattern :: Text
pattern = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    CString
maybeLogDomain <- case Maybe Text
logDomain of
        Nothing -> CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
forall a. Ptr a
nullPtr
        Just jLogDomain :: Text
jLogDomain -> do
            CString
jLogDomain' <- Text -> IO CString
textToCString Text
jLogDomain
            CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
jLogDomain'
    let logLevel' :: CInt
logLevel' = [LogLevelFlags] -> CInt
forall b a. (Num b, IsGFlag a) => [a] -> b
gflagsToWord [LogLevelFlags]
logLevel
    CString
pattern' <- Text -> IO CString
textToCString Text
pattern
    CString -> CInt -> CString -> IO ()
g_test_expect_message CString
maybeLogDomain CInt
logLevel' CString
pattern'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeLogDomain
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
pattern'
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
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.

If 'GI.GLib.Functions.testBugBase' is not called, bug URIs are formed solely
from the value provided by 'GI.GLib.Functions.testBug'.

/Since: 2.16/
-}
testBugBase ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@uriPattern@/: the base pattern for bug URIs -}
    -> m ()
testBugBase :: Text -> m ()
testBugBase uriPattern :: Text
uriPattern = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    CString
uriPattern' <- Text -> IO CString
textToCString Text
uriPattern
    CString -> IO ()
g_test_bug_base CString
uriPattern'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
uriPattern'
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
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@/. If 'GI.GLib.Functions.testBugBase' has not been called, it is
assumed to be the empty string, so a full URI can be provided to
'GI.GLib.Functions.testBug' instead.

/Since: 2.16/
-}
testBug ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@bugUriSnippet@/: Bug specific bug tracker URI portion. -}
    -> m ()
testBug :: Text -> m ()
testBug bugUriSnippet :: Text
bugUriSnippet = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    CString
bugUriSnippet' <- Text -> IO CString
textToCString Text
bugUriSnippet
    CString -> IO ()
g_test_bug CString
bugUriSnippet'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
bugUriSnippet'
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
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 :: Text -> Text -> Int32 -> Text -> m ()
testAssertExpectedMessagesInternal domain :: Text
domain file :: Text
file line :: Int32
line func :: Text
func = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    CString
domain' <- Text -> IO CString
textToCString Text
domain
    CString
file' <- Text -> IO CString
textToCString Text
file
    CString
func' <- Text -> IO CString
textToCString Text
func
    CString -> CString -> Int32 -> CString -> IO ()
g_test_assert_expected_messages_internal CString
domain' CString
file' Int32
line CString
func'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
domain'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
file'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
func'
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
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 :: Text -> IO () -> m ()
testAddFunc testpath :: Text
testpath testFunc :: IO ()
testFunc = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    CString
testpath' <- Text -> IO CString
textToCString Text
testpath
    Ptr (FunPtr (IO ()))
ptrtestFunc <- IO (Ptr (FunPtr (IO ())))
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr (FunPtr GLib.Callbacks.C_TestFunc))
    FunPtr (IO ())
testFunc' <- IO () -> IO (FunPtr (IO ()))
GLib.Callbacks.mk_TestFunc (Maybe (Ptr (FunPtr (IO ()))) -> IO () -> IO ()
GLib.Callbacks.wrap_TestFunc (Ptr (FunPtr (IO ())) -> Maybe (Ptr (FunPtr (IO ())))
forall a. a -> Maybe a
Just Ptr (FunPtr (IO ()))
ptrtestFunc) IO ()
testFunc)
    Ptr (FunPtr (IO ())) -> FunPtr (IO ()) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke Ptr (FunPtr (IO ()))
ptrtestFunc FunPtr (IO ())
testFunc'
    CString -> FunPtr (IO ()) -> IO ()
g_test_add_func CString
testpath' FunPtr (IO ())
testFunc'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
testpath'
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
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 :: Text -> Ptr () -> IO () -> m ()
testAddDataFunc testpath :: Text
testpath testData :: Ptr ()
testData testFunc :: IO ()
testFunc = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    CString
testpath' <- Text -> IO CString
textToCString Text
testpath
    Ptr (FunPtr C_DestroyNotify)
ptrtestFunc <- IO (Ptr (FunPtr C_DestroyNotify))
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr (FunPtr GLib.Callbacks.C_TestDataFunc))
    FunPtr C_DestroyNotify
testFunc' <- C_DestroyNotify -> IO (FunPtr C_DestroyNotify)
GLib.Callbacks.mk_TestDataFunc (Maybe (Ptr (FunPtr C_DestroyNotify))
-> C_DestroyNotify -> C_DestroyNotify
GLib.Callbacks.wrap_TestDataFunc (Ptr (FunPtr C_DestroyNotify)
-> Maybe (Ptr (FunPtr C_DestroyNotify))
forall a. a -> Maybe a
Just Ptr (FunPtr C_DestroyNotify)
ptrtestFunc) (IO () -> C_DestroyNotify
GLib.Callbacks.drop_closures_TestDataFunc IO ()
testFunc))
    Ptr (FunPtr C_DestroyNotify) -> FunPtr C_DestroyNotify -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke Ptr (FunPtr C_DestroyNotify)
ptrtestFunc FunPtr C_DestroyNotify
testFunc'
    CString -> Ptr () -> FunPtr C_DestroyNotify -> IO ()
g_test_add_data_func CString
testpath' Ptr ()
testData FunPtr C_DestroyNotify
testFunc'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
testpath'
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
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 :: Text -> m Word32
strvLength strArray :: Text
strArray = IO Word32 -> m Word32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ do
    CString
strArray' <- Text -> IO CString
textToCString Text
strArray
    Word32
result <- CString -> IO Word32
g_strv_length CString
strArray'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
strArray'
    Word32 -> IO Word32
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
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 :: m GType
strvGetType  = IO GType -> m GType
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO GType -> m GType) -> IO GType -> m GType
forall a b. (a -> b) -> a -> b
$ do
    CGType
result <- IO CGType
g_strv_get_type
    let result' :: GType
result' = CGType -> GType
GType CGType
result
    GType -> IO GType
forall (m :: * -> *) a. Monad m => a -> m a
return GType
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 :: Text -> Text -> m Bool
strvEqual strv1 :: Text
strv1 strv2 :: Text
strv2 = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    CString
strv1' <- Text -> IO CString
textToCString Text
strv1
    CString
strv2' <- Text -> IO CString
textToCString Text
strv2
    CInt
result <- CString -> CString -> IO CInt
g_strv_equal CString
strv1' CString
strv2'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
strv1'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
strv2'
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
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 :: Text -> Text -> m Bool
strvContains strv :: Text
strv str :: Text
str = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    CString
strv' <- Text -> IO CString
textToCString Text
strv
    CString
str' <- Text -> IO CString
textToCString Text
str
    CInt
result <- CString -> CString -> IO CInt
g_strv_contains CString
strv' CString
str'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
strv'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
str'
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
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 :: Text -> m Text
strup string :: Text
string = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
string' <- Text -> IO CString
textToCString Text
string
    CString
result <- CString -> IO CString
g_strup CString
string'
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "strup" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
string'
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
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 :: Text -> m (Double, Text)
strtod nptr :: Text
nptr = IO (Double, Text) -> m (Double, Text)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Double, Text) -> m (Double, Text))
-> IO (Double, Text) -> m (Double, Text)
forall a b. (a -> b) -> a -> b
$ do
    CString
nptr' <- Text -> IO CString
textToCString Text
nptr
    Ptr CString
endptr <- IO (Ptr CString)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr CString)
    CDouble
result <- CString -> Ptr CString -> IO CDouble
g_strtod CString
nptr' Ptr CString
endptr
    let result' :: Double
result' = CDouble -> Double
forall a b. (Real a, Fractional b) => a -> b
realToFrac CDouble
result
    CString
endptr' <- Ptr CString -> IO CString
forall a. Storable a => Ptr a -> IO a
peek Ptr CString
endptr
    Text
endptr'' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
endptr'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
nptr'
    Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
endptr
    (Double, Text) -> IO (Double, Text)
forall (m :: * -> *) a. Monad m => a -> m a
return (Double
result', Text
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 :: Text -> Int64 -> Text -> m Text
strstrLen haystack :: Text
haystack haystackLen :: Int64
haystackLen needle :: Text
needle = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
haystack' <- Text -> IO CString
textToCString Text
haystack
    CString
needle' <- Text -> IO CString
textToCString Text
needle
    CString
result <- CString -> Int64 -> CString -> IO CString
g_strstr_len CString
haystack' Int64
haystackLen CString
needle'
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "strstrLen" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
haystack'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
needle'
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
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 :: Int32 -> m Text
strsignal signum :: Int32
signum = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
result <- Int32 -> IO CString
g_strsignal Int32
signum
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "strsignal" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
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 :: Text -> Int64 -> Text -> m Text
strrstrLen haystack :: Text
haystack haystackLen :: Int64
haystackLen needle :: Text
needle = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
haystack' <- Text -> IO CString
textToCString Text
haystack
    CString
needle' <- Text -> IO CString
textToCString Text
needle
    CString
result <- CString -> Int64 -> CString -> IO CString
g_strrstr_len CString
haystack' Int64
haystackLen CString
needle'
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "strrstrLen" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
haystack'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
needle'
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
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 :: Text -> Text -> m Text
strrstr haystack :: Text
haystack needle :: Text
needle = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
haystack' <- Text -> IO CString
textToCString Text
haystack
    CString
needle' <- Text -> IO CString
textToCString Text
needle
    CString
result <- CString -> CString -> IO CString
g_strrstr CString
haystack' CString
needle'
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "strrstr" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
haystack'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
needle'
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
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 :: Text -> m Text
strreverse string :: Text
string = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
string' <- Text -> IO CString
textToCString Text
string
    CString
result <- CString -> IO CString
g_strreverse CString
string'
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "strreverse" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
string'
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
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 :: CGType -> Int8 -> m Text
strnfill length_ :: CGType
length_ fillChar :: Int8
fillChar = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
result <- CGType -> Int8 -> IO CString
g_strnfill CGType
length_ Int8
fillChar
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "strnfill" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
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 :: Text -> CGType -> m Text
strndup str :: Text
str n :: CGType
n = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
str' <- Text -> IO CString
textToCString Text
str
    CString
result <- CString -> CGType -> IO CString
g_strndup CString
str' CGType
n
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "strndup" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
str'
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
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 :: Text -> Text -> Word32 -> m Int32
strncasecmp s1 :: Text
s1 s2 :: Text
s2 n :: Word32
n = IO Int32 -> m Int32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int32 -> m Int32) -> IO Int32 -> m Int32
forall a b. (a -> b) -> a -> b
$ do
    CString
s1' <- Text -> IO CString
textToCString Text
s1
    CString
s2' <- Text -> IO CString
textToCString Text
s2
    Int32
result <- CString -> CString -> Word32 -> IO Int32
g_strncasecmp CString
s1' CString
s2' Word32
n
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
s1'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
s2'
    Int32 -> IO Int32
forall (m :: * -> *) a. Monad m => a -> m a
return Int32
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 :: Text -> Text -> CGType -> m CGType
strlcpy dest :: Text
dest src :: Text
src destSize :: CGType
destSize = IO CGType -> m CGType
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO CGType -> m CGType) -> IO CGType -> m CGType
forall a b. (a -> b) -> a -> b
$ do
    CString
dest' <- Text -> IO CString
textToCString Text
dest
    CString
src' <- Text -> IO CString
textToCString Text
src
    CGType
result <- CString -> CString -> CGType -> IO CGType
g_strlcpy CString
dest' CString
src' CGType
destSize
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
dest'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
src'
    CGType -> IO CGType
forall (m :: * -> *) a. Monad m => a -> m a
return CGType
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 :: Text -> Text -> CGType -> m CGType
strlcat dest :: Text
dest src :: Text
src destSize :: CGType
destSize = IO CGType -> m CGType
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO CGType -> m CGType) -> IO CGType -> m CGType
forall a b. (a -> b) -> a -> b
$ do
    CString
dest' <- Text -> IO CString
textToCString Text
dest
    CString
src' <- Text -> IO CString
textToCString Text
src
    CGType
result <- CString -> CString -> CGType -> IO CGType
g_strlcat CString
dest' CString
src' CGType
destSize
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
dest'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
src'
    CGType -> IO CGType
forall (m :: * -> *) a. Monad m => a -> m a
return CGType
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 :: Maybe Text -> Text -> m Text
strjoinv separator :: Maybe Text
separator strArray :: Text
strArray = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
maybeSeparator <- case Maybe Text
separator of
        Nothing -> CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
forall a. Ptr a
nullPtr
        Just jSeparator :: Text
jSeparator -> do
            CString
jSeparator' <- Text -> IO CString
textToCString Text
jSeparator
            CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
jSeparator'
    CString
strArray' <- Text -> IO CString
textToCString Text
strArray
    CString
result <- CString -> CString -> IO CString
g_strjoinv CString
maybeSeparator CString
strArray'
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "strjoinv" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeSeparator
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
strArray'
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
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 :: Text -> Text -> m Text
stripContext msgid :: Text
msgid msgval :: Text
msgval = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
msgid' <- Text -> IO CString
textToCString Text
msgid
    CString
msgval' <- Text -> IO CString
textToCString Text
msgval
    CString
result <- CString -> CString -> IO CString
g_strip_context CString
msgid' CString
msgval'
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "stripContext" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
msgid'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
msgval'
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
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 :: CGType -> m String
stringSizedNew dflSize :: CGType
dflSize = IO String -> m String
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO String -> m String) -> IO String -> m String
forall a b. (a -> b) -> a -> b
$ do
    Ptr String
result <- CGType -> IO (Ptr String)
g_string_sized_new CGType
dflSize
    Text -> Ptr String -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "stringSizedNew" Ptr String
result
    String
result' <- ((ManagedPtr String -> String) -> Ptr String -> IO String
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr String -> String
GLib.String.String) Ptr String
result
    String -> IO String
forall (m :: * -> *) a. Monad m => a -> m a
return String
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 :: Text -> Int64 -> m String
stringNewLen init :: Text
init len :: Int64
len = IO String -> m String
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO String -> m String) -> IO String -> m String
forall a b. (a -> b) -> a -> b
$ do
    CString
init' <- Text -> IO CString
textToCString Text
init
    Ptr String
result <- CString -> Int64 -> IO (Ptr String)
g_string_new_len CString
init' Int64
len
    Text -> Ptr String -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "stringNewLen" Ptr String
result
    String
result' <- ((ManagedPtr String -> String) -> Ptr String -> IO String
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr String -> String
GLib.String.String) Ptr String
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
init'
    String -> IO String
forall (m :: * -> *) a. Monad m => a -> m a
return String
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 :: Maybe Text -> m String
stringNew init :: Maybe Text
init = IO String -> m String
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO String -> m String) -> IO String -> m String
forall a b. (a -> b) -> a -> b
$ do
    CString
maybeInit <- case Maybe Text
init of
        Nothing -> CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
forall a. Ptr a
nullPtr
        Just jInit :: Text
jInit -> do
            CString
jInit' <- Text -> IO CString
textToCString Text
jInit
            CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
jInit'
    Ptr String
result <- CString -> IO (Ptr String)
g_string_new CString
maybeInit
    Text -> Ptr String -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "stringNew" Ptr String
result
    String
result' <- ((ManagedPtr String -> String) -> Ptr String -> IO String
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr String -> String
GLib.String.String) Ptr String
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeInit
    String -> IO String
forall (m :: * -> *) a. Monad m => a -> m a
return String
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 :: Maybe Text -> m ()
strfreev strArray :: Maybe Text
strArray = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    CString
maybeStrArray <- case Maybe Text
strArray of
        Nothing -> CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
forall a. Ptr a
nullPtr
        Just jStrArray :: Text
jStrArray -> do
            CString
jStrArray' <- Text -> IO CString
textToCString Text
jStrArray
            CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
jStrArray'
    CString -> IO ()
g_strfreev CString
maybeStrArray
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeStrArray
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
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 :: Text -> Maybe Text -> m Text
strescape source :: Text
source exceptions :: Maybe Text
exceptions = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
source' <- Text -> IO CString
textToCString Text
source
    CString
maybeExceptions <- case Maybe Text
exceptions of
        Nothing -> CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
forall a. Ptr a
nullPtr
        Just jExceptions :: Text
jExceptions -> do
            CString
jExceptions' <- Text -> IO CString
textToCString Text
jExceptions
            CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
jExceptions'
    CString
result <- CString -> CString -> IO CString
g_strescape CString
source' CString
maybeExceptions
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "strescape" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
source'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeExceptions
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
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 :: Int32 -> m Text
strerror errnum :: Int32
errnum = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
result <- Int32 -> IO CString
g_strerror Int32
errnum
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "strerror" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
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 :: Maybe Text -> m Text
strdup str :: Maybe Text
str = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
maybeStr <- case Maybe Text
str of
        Nothing -> CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
forall a. Ptr a
nullPtr
        Just jStr :: Text
jStr -> do
            CString
jStr' <- Text -> IO CString
textToCString Text
jStr
            CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
jStr'
    CString
result <- CString -> IO CString
g_strdup CString
maybeStr
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "strdup" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeStr
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
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 :: Text -> m Text
strdown string :: Text
string = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
string' <- Text -> IO CString
textToCString Text
string
    CString
result <- CString -> IO CString
g_strdown CString
string'
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "strdown" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
string'
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
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", '?'))


In order to modify a copy, you may use @g_strdup()@:

=== /C code/
>
>  reformatted = g_strdelimit (g_strdup (const_str), "abc", '?');
>  ...
>  g_free (reformatted);
-}
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 :: Text -> Maybe Text -> Int8 -> m Text
strdelimit string :: Text
string delimiters :: Maybe Text
delimiters newDelimiter :: Int8
newDelimiter = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
string' <- Text -> IO CString
textToCString Text
string
    CString
maybeDelimiters <- case Maybe Text
delimiters of
        Nothing -> CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
forall a. Ptr a
nullPtr
        Just jDelimiters :: Text
jDelimiters -> do
            CString
jDelimiters' <- Text -> IO CString
textToCString Text
jDelimiters
            CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
jDelimiters'
    CString
result <- CString -> CString -> Int8 -> IO CString
g_strdelimit CString
string' CString
maybeDelimiters Int8
newDelimiter
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "strdelimit" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
string'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeDelimiters
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
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 :: Text -> m Text
strcompress source :: Text
source = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
source' <- Text -> IO CString
textToCString Text
source
    CString
result <- CString -> IO CString
g_strcompress CString
source'
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "strcompress" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
source'
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
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 :: Maybe Text -> Maybe Text -> m Int32
strcmp0 str1 :: Maybe Text
str1 str2 :: Maybe Text
str2 = IO Int32 -> m Int32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int32 -> m Int32) -> IO Int32 -> m Int32
forall a b. (a -> b) -> a -> b
$ do
    CString
maybeStr1 <- case Maybe Text
str1 of
        Nothing -> CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
forall a. Ptr a
nullPtr
        Just jStr1 :: Text
jStr1 -> do
            CString
jStr1' <- Text -> IO CString
textToCString Text
jStr1
            CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
jStr1'
    CString
maybeStr2 <- case Maybe Text
str2 of
        Nothing -> CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
forall a. Ptr a
nullPtr
        Just jStr2 :: Text
jStr2 -> do
            CString
jStr2' <- Text -> IO CString
textToCString Text
jStr2
            CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
jStr2'
    Int32
result <- CString -> CString -> IO Int32
g_strcmp0 CString
maybeStr1 CString
maybeStr2
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeStr1
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeStr2
    Int32 -> IO Int32
forall (m :: * -> *) a. Monad m => a -> m a
return Int32
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 :: Text -> m Text
strchug string :: Text
string = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
string' <- Text -> IO CString
textToCString Text
string
    CString
result <- CString -> IO CString
g_strchug CString
string'
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "strchug" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
string'
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
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 :: Text -> m Text
strchomp string :: Text
string = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
string' <- Text -> IO CString
textToCString Text
string
    CString
result <- CString -> IO CString
g_strchomp CString
string'
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "strchomp" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
string'
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
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 :: Text -> Text -> m Int32
strcasecmp s1 :: Text
s1 s2 :: Text
s2 = IO Int32 -> m Int32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int32 -> m Int32) -> IO Int32 -> m Int32
forall a b. (a -> b) -> a -> b
$ do
    CString
s1' <- Text -> IO CString
textToCString Text
s1
    CString
s2' <- Text -> IO CString
textToCString Text
s2
    Int32
result <- CString -> CString -> IO Int32
g_strcasecmp CString
s1' CString
s2'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
s1'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
s2'
    Int32 -> IO Int32
forall (m :: * -> *) a. Monad m => a -> m a
return Int32
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", '?'))


In order to modify a copy, you may use @g_strdup()@:

=== /C code/
>
>  reformatted = g_strcanon (g_strdup (const_str), "abc", '?');
>  ...
>  g_free (reformatted);
-}
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 :: Text -> Text -> Int8 -> m Text
strcanon string :: Text
string validChars :: Text
validChars substitutor :: Int8
substitutor = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
string' <- Text -> IO CString
textToCString Text
string
    CString
validChars' <- Text -> IO CString
textToCString Text
validChars
    CString
result <- CString -> CString -> Int8 -> IO CString
g_strcanon CString
string' CString
validChars' Int8
substitutor
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "strcanon" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
string'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
validChars'
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
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 :: Text -> Maybe Text -> m ([Text], [Text])
strTokenizeAndFold string :: Text
string translitLocale :: Maybe Text
translitLocale = IO ([Text], [Text]) -> m ([Text], [Text])
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO ([Text], [Text]) -> m ([Text], [Text]))
-> IO ([Text], [Text]) -> m ([Text], [Text])
forall a b. (a -> b) -> a -> b
$ do
    CString
string' <- Text -> IO CString
textToCString Text
string
    CString
maybeTranslitLocale <- case Maybe Text
translitLocale of
        Nothing -> CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
forall a. Ptr a
nullPtr
        Just jTranslitLocale :: Text
jTranslitLocale -> do
            CString
jTranslitLocale' <- Text -> IO CString
textToCString Text
jTranslitLocale
            CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
jTranslitLocale'
    Ptr (Ptr CString)
asciiAlternates <- IO (Ptr (Ptr CString))
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr (Ptr CString))
    Ptr CString
result <- CString -> CString -> Ptr (Ptr CString) -> IO (Ptr CString)
g_str_tokenize_and_fold CString
string' CString
maybeTranslitLocale Ptr (Ptr CString)
asciiAlternates
    Text -> Ptr CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "strTokenizeAndFold" Ptr CString
result
    [Text]
result' <- HasCallStack => Ptr CString -> IO [Text]
Ptr CString -> IO [Text]
unpackZeroTerminatedUTF8CArray Ptr CString
result
    (CString -> IO ()) -> Ptr CString -> IO ()
forall a b. (Ptr a -> IO b) -> Ptr (Ptr a) -> IO ()
mapZeroTerminatedCArray CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
result
    Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
result
    Ptr CString
asciiAlternates' <- Ptr (Ptr CString) -> IO (Ptr CString)
forall a. Storable a => Ptr a -> IO a
peek Ptr (Ptr CString)
asciiAlternates
    [Text]
asciiAlternates'' <- HasCallStack => Ptr CString -> IO [Text]
Ptr CString -> IO [Text]
unpackZeroTerminatedUTF8CArray Ptr CString
asciiAlternates'
    (CString -> IO ()) -> Ptr CString -> IO ()
forall a b. (Ptr a -> IO b) -> Ptr (Ptr a) -> IO ()
mapZeroTerminatedCArray CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
asciiAlternates'
    Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
asciiAlternates'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
string'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeTranslitLocale
    Ptr (Ptr CString) -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr (Ptr CString)
asciiAlternates
    ([Text], [Text]) -> IO ([Text], [Text])
forall (m :: * -> *) a. Monad m => a -> m a
return ([Text]
result', [Text]
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 :: Text -> Maybe Text -> m Text
strToAscii str :: Text
str fromLocale :: Maybe Text
fromLocale = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
str' <- Text -> IO CString
textToCString Text
str
    CString
maybeFromLocale <- case Maybe Text
fromLocale of
        Nothing -> CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
forall a. Ptr a
nullPtr
        Just jFromLocale :: Text
jFromLocale -> do
            CString
jFromLocale' <- Text -> IO CString
textToCString Text
jFromLocale
            CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
jFromLocale'
    CString
result <- CString -> CString -> IO CString
g_str_to_ascii CString
str' CString
maybeFromLocale
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "strToAscii" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
str'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeFromLocale
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
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 :: Text -> Text -> Bool -> m Bool
strMatchString searchTerm :: Text
searchTerm potentialHit :: Text
potentialHit acceptAlternates :: Bool
acceptAlternates = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    CString
searchTerm' <- Text -> IO CString
textToCString Text
searchTerm
    CString
potentialHit' <- Text -> IO CString
textToCString Text
potentialHit
    let acceptAlternates' :: CInt
acceptAlternates' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Bool -> Int) -> Bool -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> Int
forall a. Enum a => a -> Int
fromEnum) Bool
acceptAlternates
    CInt
result <- CString -> CString -> CInt -> IO CInt
g_str_match_string CString
searchTerm' CString
potentialHit' CInt
acceptAlternates'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
searchTerm'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
potentialHit'
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
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 :: Text -> m Bool
strIsAscii str :: Text
str = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    CString
str' <- Text -> IO CString
textToCString Text
str
    CInt
result <- CString -> IO CInt
g_str_is_ascii CString
str'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
str'
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
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 :: Ptr () -> m Word32
strHash v :: Ptr ()
v = IO Word32 -> m Word32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ do
    Word32
result <- Ptr () -> IO Word32
g_str_hash Ptr ()
v
    Word32 -> IO Word32
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
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 :: Text -> Text -> m Bool
strHasSuffix str :: Text
str suffix :: Text
suffix = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    CString
str' <- Text -> IO CString
textToCString Text
str
    CString
suffix' <- Text -> IO CString
textToCString Text
suffix
    CInt
result <- CString -> CString -> IO CInt
g_str_has_suffix CString
str' CString
suffix'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
str'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
suffix'
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
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 :: Text -> Text -> m Bool
strHasPrefix str :: Text
str prefix :: Text
prefix = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    CString
str' <- Text -> IO CString
textToCString Text
str
    CString
prefix' <- Text -> IO CString
textToCString Text
prefix
    CInt
result <- CString -> CString -> IO CInt
g_str_has_prefix CString
str' CString
prefix'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
str'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
prefix'
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
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 :: Ptr () -> Ptr () -> m Bool
strEqual v1 :: Ptr ()
v1 v2 :: Ptr ()
v2 = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    CInt
result <- Ptr () -> C_SourceFunc
g_str_equal Ptr ()
v1 Ptr ()
v2
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
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 :: Text -> Text -> m Text
stpcpy dest :: Text
dest src :: Text
src = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
dest' <- Text -> IO CString
textToCString Text
dest
    CString
src' <- Text -> IO CString
textToCString Text
src
    CString
result <- CString -> CString -> IO CString
g_stpcpy CString
dest' CString
src'
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "stpcpy" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
dest'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
src'
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
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 :: Maybe [Char]
-> [[Char]]
-> Maybe [[Char]]
-> [SpawnFlags]
-> Maybe (IO ())
-> m (ByteString, ByteString, Int32)
spawnSync workingDirectory :: Maybe [Char]
workingDirectory argv :: [[Char]]
argv envp :: Maybe [[Char]]
envp flags :: [SpawnFlags]
flags childSetup :: Maybe (IO ())
childSetup = IO (ByteString, ByteString, Int32)
-> m (ByteString, ByteString, Int32)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (ByteString, ByteString, Int32)
 -> m (ByteString, ByteString, Int32))
-> IO (ByteString, ByteString, Int32)
-> m (ByteString, ByteString, Int32)
forall a b. (a -> b) -> a -> b
$ do
    CString
maybeWorkingDirectory <- case Maybe [Char]
workingDirectory of
        Nothing -> CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
forall a. Ptr a
nullPtr
        Just jWorkingDirectory :: [Char]
jWorkingDirectory -> do
            CString
jWorkingDirectory' <- [Char] -> IO CString
stringToCString [Char]
jWorkingDirectory
            CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
jWorkingDirectory'
    Ptr CString
argv' <- [[Char]] -> IO (Ptr CString)
packZeroTerminatedFileNameArray [[Char]]
argv
    Ptr CString
maybeEnvp <- case Maybe [[Char]]
envp of
        Nothing -> Ptr CString -> IO (Ptr CString)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CString
forall a. Ptr a
nullPtr
        Just jEnvp :: [[Char]]
jEnvp -> do
            Ptr CString
jEnvp' <- [[Char]] -> IO (Ptr CString)
packZeroTerminatedFileNameArray [[Char]]
jEnvp
            Ptr CString -> IO (Ptr CString)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CString
jEnvp'
    let flags' :: CUInt
flags' = [SpawnFlags] -> CUInt
forall b a. (Num b, IsGFlag a) => [a] -> b
gflagsToWord [SpawnFlags]
flags
    FunPtr C_DestroyNotify
maybeChildSetup <- case Maybe (IO ())
childSetup of
        Nothing -> FunPtr C_DestroyNotify -> IO (FunPtr C_DestroyNotify)
forall (m :: * -> *) a. Monad m => a -> m a
return (Ptr Any -> FunPtr C_DestroyNotify
forall a b. Ptr a -> FunPtr b
castPtrToFunPtr Ptr Any
forall a. Ptr a
nullPtr)
        Just jChildSetup :: IO ()
jChildSetup -> do
            Ptr (FunPtr C_DestroyNotify)
ptrchildSetup <- IO (Ptr (FunPtr C_DestroyNotify))
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr (FunPtr GLib.Callbacks.C_SpawnChildSetupFunc))
            FunPtr C_DestroyNotify
jChildSetup' <- C_DestroyNotify -> IO (FunPtr C_DestroyNotify)
GLib.Callbacks.mk_SpawnChildSetupFunc (Maybe (Ptr (FunPtr C_DestroyNotify))
-> C_DestroyNotify -> C_DestroyNotify
GLib.Callbacks.wrap_SpawnChildSetupFunc (Ptr (FunPtr C_DestroyNotify)
-> Maybe (Ptr (FunPtr C_DestroyNotify))
forall a. a -> Maybe a
Just Ptr (FunPtr C_DestroyNotify)
ptrchildSetup) (IO () -> C_DestroyNotify
GLib.Callbacks.drop_closures_SpawnChildSetupFunc IO ()
jChildSetup))
            Ptr (FunPtr C_DestroyNotify) -> FunPtr C_DestroyNotify -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke Ptr (FunPtr C_DestroyNotify)
ptrchildSetup FunPtr C_DestroyNotify
jChildSetup'
            FunPtr C_DestroyNotify -> IO (FunPtr C_DestroyNotify)
forall (m :: * -> *) a. Monad m => a -> m a
return FunPtr C_DestroyNotify
jChildSetup'
    Ptr (Ptr Word8)
standardOutput <- IO (Ptr (Ptr Word8))
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr (Ptr Word8))
    Ptr (Ptr Word8)
standardError <- IO (Ptr (Ptr Word8))
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr (Ptr Word8))
    Ptr Int32
exitStatus <- IO (Ptr Int32)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Int32)
    let userData :: Ptr a
userData = Ptr a
forall a. Ptr a
nullPtr
    IO (ByteString, ByteString, Int32)
-> IO () -> IO (ByteString, ByteString, Int32)
forall a b. IO a -> IO b -> IO a
onException (do
        CInt
_ <- (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ CString
-> Ptr CString
-> Ptr CString
-> CUInt
-> FunPtr C_DestroyNotify
-> Ptr ()
-> Ptr (Ptr Word8)
-> Ptr (Ptr Word8)
-> Ptr Int32
-> Ptr (Ptr GError)
-> IO CInt
g_spawn_sync CString
maybeWorkingDirectory Ptr CString
argv' Ptr CString
maybeEnvp CUInt
flags' FunPtr C_DestroyNotify
maybeChildSetup Ptr ()
forall a. Ptr a
userData Ptr (Ptr Word8)
standardOutput Ptr (Ptr Word8)
standardError Ptr Int32
exitStatus
        Ptr Word8
standardOutput' <- Ptr (Ptr Word8) -> IO (Ptr Word8)
forall a. Storable a => Ptr a -> IO a
peek Ptr (Ptr Word8)
standardOutput
        ByteString
standardOutput'' <- Ptr Word8 -> IO ByteString
unpackZeroTerminatedByteString Ptr Word8
standardOutput'
        Ptr Word8 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word8
standardOutput'
        Ptr Word8
standardError' <- Ptr (Ptr Word8) -> IO (Ptr Word8)
forall a. Storable a => Ptr a -> IO a
peek Ptr (Ptr Word8)
standardError
        ByteString
standardError'' <- Ptr Word8 -> IO ByteString
unpackZeroTerminatedByteString Ptr Word8
standardError'
        Ptr Word8 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word8
standardError'
        Int32
exitStatus' <- Ptr Int32 -> IO Int32
forall a. Storable a => Ptr a -> IO a
peek Ptr Int32
exitStatus
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeWorkingDirectory
        (CString -> IO ()) -> Ptr CString -> IO ()
forall a b. (Ptr a -> IO b) -> Ptr (Ptr a) -> IO ()
mapZeroTerminatedCArray CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
argv'
        Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
argv'
        (CString -> IO ()) -> Ptr CString -> IO ()
forall a b. (Ptr a -> IO b) -> Ptr (Ptr a) -> IO ()
mapZeroTerminatedCArray CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
maybeEnvp
        Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
maybeEnvp
        Ptr (Ptr Word8) -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr (Ptr Word8)
standardOutput
        Ptr (Ptr Word8) -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr (Ptr Word8)
standardError
        Ptr Int32 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Int32
exitStatus
        (ByteString, ByteString, Int32)
-> IO (ByteString, ByteString, Int32)
forall (m :: * -> *) a. Monad m => a -> m a
return (ByteString
standardOutput'', ByteString
standardError'', Int32
exitStatus')
     ) (do
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeWorkingDirectory
        (CString -> IO ()) -> Ptr CString -> IO ()
forall a b. (Ptr a -> IO b) -> Ptr (Ptr a) -> IO ()
mapZeroTerminatedCArray CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
argv'
        Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
argv'
        (CString -> IO ()) -> Ptr CString -> IO ()
forall a b. (Ptr a -> IO b) -> Ptr (Ptr a) -> IO ()
mapZeroTerminatedCArray CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
maybeEnvp
        Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
maybeEnvp
        Ptr (Ptr Word8) -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr (Ptr Word8)
standardOutput
        Ptr (Ptr Word8) -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr (Ptr Word8)
standardError
        Ptr Int32 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Int32
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 :: m Word32
spawnExitErrorQuark  = IO Word32 -> m Word32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ do
    Word32
result <- IO Word32
g_spawn_exit_error_quark
    Word32 -> IO Word32
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
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 :: m Word32
spawnErrorQuark  = IO Word32 -> m Word32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ do
    Word32
result <- IO Word32
g_spawn_error_quark
    Word32 -> IO Word32
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
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 :: [Char] -> m (ByteString, ByteString, Int32)
spawnCommandLineSync commandLine :: [Char]
commandLine = IO (ByteString, ByteString, Int32)
-> m (ByteString, ByteString, Int32)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (ByteString, ByteString, Int32)
 -> m (ByteString, ByteString, Int32))
-> IO (ByteString, ByteString, Int32)
-> m (ByteString, ByteString, Int32)
forall a b. (a -> b) -> a -> b
$ do
    CString
commandLine' <- [Char] -> IO CString
stringToCString [Char]
commandLine
    Ptr (Ptr Word8)
standardOutput <- IO (Ptr (Ptr Word8))
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr (Ptr Word8))
    Ptr (Ptr Word8)
standardError <- IO (Ptr (Ptr Word8))
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr (Ptr Word8))
    Ptr Int32
exitStatus <- IO (Ptr Int32)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Int32)
    IO (ByteString, ByteString, Int32)
-> IO () -> IO (ByteString, ByteString, Int32)
forall a b. IO a -> IO b -> IO a
onException (do
        CInt
_ <- (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ CString
-> Ptr (Ptr Word8)
-> Ptr (Ptr Word8)
-> Ptr Int32
-> Ptr (Ptr GError)
-> IO CInt
g_spawn_command_line_sync CString
commandLine' Ptr (Ptr Word8)
standardOutput Ptr (Ptr Word8)
standardError Ptr Int32
exitStatus
        Ptr Word8
standardOutput' <- Ptr (Ptr Word8) -> IO (Ptr Word8)
forall a. Storable a => Ptr a -> IO a
peek Ptr (Ptr Word8)
standardOutput
        ByteString
standardOutput'' <- Ptr Word8 -> IO ByteString
unpackZeroTerminatedByteString Ptr Word8
standardOutput'
        Ptr Word8 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word8
standardOutput'
        Ptr Word8
standardError' <- Ptr (Ptr Word8) -> IO (Ptr Word8)
forall a. Storable a => Ptr a -> IO a
peek Ptr (Ptr Word8)
standardError
        ByteString
standardError'' <- Ptr Word8 -> IO ByteString
unpackZeroTerminatedByteString Ptr Word8
standardError'
        Ptr Word8 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word8
standardError'
        Int32
exitStatus' <- Ptr Int32 -> IO Int32
forall a. Storable a => Ptr a -> IO a
peek Ptr Int32
exitStatus
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
commandLine'
        Ptr (Ptr Word8) -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr (Ptr Word8)
standardOutput
        Ptr (Ptr Word8) -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr (Ptr Word8)
standardError
        Ptr Int32 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Int32
exitStatus
        (ByteString, ByteString, Int32)
-> IO (ByteString, ByteString, Int32)
forall (m :: * -> *) a. Monad m => a -> m a
return (ByteString
standardOutput'', ByteString
standardError'', Int32
exitStatus')
     ) (do
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
commandLine'
        Ptr (Ptr Word8) -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr (Ptr Word8)
standardOutput
        Ptr (Ptr Word8) -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr (Ptr Word8)
standardError
        Ptr Int32 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Int32
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 :: [Char] -> m ()
spawnCommandLineAsync commandLine :: [Char]
commandLine = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    CString
commandLine' <- [Char] -> IO CString
stringToCString [Char]
commandLine
    IO () -> IO () -> IO ()
forall a b. IO a -> IO b -> IO a
onException (do
        CInt
_ <- (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ CString -> Ptr (Ptr GError) -> IO CInt
g_spawn_command_line_async CString
commandLine'
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
commandLine'
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     ) (do
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
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 :: Int32 -> m ()
spawnClosePid pid :: Int32
pid = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Int32 -> IO ()
g_spawn_close_pid Int32
pid
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
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 :: Int32 -> m ()
spawnCheckExitStatus exitStatus :: Int32
exitStatus = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    IO () -> IO () -> IO ()
forall a b. IO a -> IO b -> IO a
onException (do
        CInt
_ <- (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ Int32 -> Ptr (Ptr GError) -> IO CInt
g_spawn_check_exit_status Int32
exitStatus
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     ) (do
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
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 :: Maybe [Char]
-> [[Char]]
-> Maybe [[Char]]
-> [SpawnFlags]
-> Maybe (IO ())
-> m (Int32, Int32, Int32, Int32)
spawnAsyncWithPipes workingDirectory :: Maybe [Char]
workingDirectory argv :: [[Char]]
argv envp :: Maybe [[Char]]
envp flags :: [SpawnFlags]
flags childSetup :: Maybe (IO ())
childSetup = IO (Int32, Int32, Int32, Int32) -> m (Int32, Int32, Int32, Int32)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Int32, Int32, Int32, Int32) -> m (Int32, Int32, Int32, Int32))
-> IO (Int32, Int32, Int32, Int32)
-> m (Int32, Int32, Int32, Int32)
forall a b. (a -> b) -> a -> b
$ do
    CString
maybeWorkingDirectory <- case Maybe [Char]
workingDirectory of
        Nothing -> CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
forall a. Ptr a
nullPtr
        Just jWorkingDirectory :: [Char]
jWorkingDirectory -> do
            CString
jWorkingDirectory' <- [Char] -> IO CString
stringToCString [Char]
jWorkingDirectory
            CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
jWorkingDirectory'
    Ptr CString
argv' <- [[Char]] -> IO (Ptr CString)
packZeroTerminatedFileNameArray [[Char]]
argv
    Ptr CString
maybeEnvp <- case Maybe [[Char]]
envp of
        Nothing -> Ptr CString -> IO (Ptr CString)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CString
forall a. Ptr a
nullPtr
        Just jEnvp :: [[Char]]
jEnvp -> do
            Ptr CString
jEnvp' <- [[Char]] -> IO (Ptr CString)
packZeroTerminatedFileNameArray [[Char]]
jEnvp
            Ptr CString -> IO (Ptr CString)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CString
jEnvp'
    let flags' :: CUInt
flags' = [SpawnFlags] -> CUInt
forall b a. (Num b, IsGFlag a) => [a] -> b
gflagsToWord [SpawnFlags]
flags
    FunPtr C_DestroyNotify
maybeChildSetup <- case Maybe (IO ())
childSetup of
        Nothing -> FunPtr C_DestroyNotify -> IO (FunPtr C_DestroyNotify)
forall (m :: * -> *) a. Monad m => a -> m a
return (Ptr Any -> FunPtr C_DestroyNotify
forall a b. Ptr a -> FunPtr b
castPtrToFunPtr Ptr Any
forall a. Ptr a
nullPtr)
        Just jChildSetup :: IO ()
jChildSetup -> do
            Ptr (FunPtr C_DestroyNotify)
ptrchildSetup <- IO (Ptr (FunPtr C_DestroyNotify))
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr (FunPtr GLib.Callbacks.C_SpawnChildSetupFunc))
            FunPtr C_DestroyNotify
jChildSetup' <- C_DestroyNotify -> IO (FunPtr C_DestroyNotify)
GLib.Callbacks.mk_SpawnChildSetupFunc (Maybe (Ptr (FunPtr C_DestroyNotify))
-> C_DestroyNotify -> C_DestroyNotify
GLib.Callbacks.wrap_SpawnChildSetupFunc (Ptr (FunPtr C_DestroyNotify)
-> Maybe (Ptr (FunPtr C_DestroyNotify))
forall a. a -> Maybe a
Just Ptr (FunPtr C_DestroyNotify)
ptrchildSetup) (IO () -> C_DestroyNotify
GLib.Callbacks.drop_closures_SpawnChildSetupFunc IO ()
jChildSetup))
            Ptr (FunPtr C_DestroyNotify) -> FunPtr C_DestroyNotify -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke Ptr (FunPtr C_DestroyNotify)
ptrchildSetup FunPtr C_DestroyNotify
jChildSetup'
            FunPtr C_DestroyNotify -> IO (FunPtr C_DestroyNotify)
forall (m :: * -> *) a. Monad m => a -> m a
return FunPtr C_DestroyNotify
jChildSetup'
    Ptr Int32
childPid <- IO (Ptr Int32)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Int32)
    Ptr Int32
standardInput <- IO (Ptr Int32)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Int32)
    Ptr Int32
standardOutput <- IO (Ptr Int32)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Int32)
    Ptr Int32
standardError <- IO (Ptr Int32)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Int32)
    let userData :: Ptr a
userData = Ptr a
forall a. Ptr a
nullPtr
    IO (Int32, Int32, Int32, Int32)
-> IO () -> IO (Int32, Int32, Int32, Int32)
forall a b. IO a -> IO b -> IO a
onException (do
        CInt
_ <- (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ CString
-> Ptr CString
-> Ptr CString
-> CUInt
-> FunPtr C_DestroyNotify
-> Ptr ()
-> Ptr Int32
-> Ptr Int32
-> Ptr Int32
-> Ptr Int32
-> Ptr (Ptr GError)
-> IO CInt
g_spawn_async_with_pipes CString
maybeWorkingDirectory Ptr CString
argv' Ptr CString
maybeEnvp CUInt
flags' FunPtr C_DestroyNotify
maybeChildSetup Ptr ()
forall a. Ptr a
userData Ptr Int32
childPid Ptr Int32
standardInput Ptr Int32
standardOutput Ptr Int32
standardError
        Int32
childPid' <- Ptr Int32 -> IO Int32
forall a. Storable a => Ptr a -> IO a
peek Ptr Int32
childPid
        Int32
standardInput' <- Ptr Int32 -> IO Int32
forall a. Storable a => Ptr a -> IO a
peek Ptr Int32
standardInput
        Int32
standardOutput' <- Ptr Int32 -> IO Int32
forall a. Storable a => Ptr a -> IO a
peek Ptr Int32
standardOutput
        Int32
standardError' <- Ptr Int32 -> IO Int32
forall a. Storable a => Ptr a -> IO a
peek Ptr Int32
standardError
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeWorkingDirectory
        (CString -> IO ()) -> Ptr CString -> IO ()
forall a b. (Ptr a -> IO b) -> Ptr (Ptr a) -> IO ()
mapZeroTerminatedCArray CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
argv'
        Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
argv'
        (CString -> IO ()) -> Ptr CString -> IO ()
forall a b. (Ptr a -> IO b) -> Ptr (Ptr a) -> IO ()
mapZeroTerminatedCArray CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
maybeEnvp
        Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
maybeEnvp
        Ptr Int32 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Int32
childPid
        Ptr Int32 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Int32
standardInput
        Ptr Int32 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Int32
standardOutput
        Ptr Int32 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Int32
standardError
        (Int32, Int32, Int32, Int32) -> IO (Int32, Int32, Int32, Int32)
forall (m :: * -> *) a. Monad m => a -> m a
return (Int32
childPid', Int32
standardInput', Int32
standardOutput', Int32
standardError')
     ) (do
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeWorkingDirectory
        (CString -> IO ()) -> Ptr CString -> IO ()
forall a b. (Ptr a -> IO b) -> Ptr (Ptr a) -> IO ()
mapZeroTerminatedCArray CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
argv'
        Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
argv'
        (CString -> IO ()) -> Ptr CString -> IO ()
forall a b. (Ptr a -> IO b) -> Ptr (Ptr a) -> IO ()
mapZeroTerminatedCArray CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
maybeEnvp
        Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
maybeEnvp
        Ptr Int32 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Int32
childPid
        Ptr Int32 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Int32
standardInput
        Ptr Int32 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Int32
standardOutput
        Ptr Int32 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Int32
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 :: Maybe [Char]
-> [Text]
-> Maybe [Text]
-> [SpawnFlags]
-> Maybe (IO ())
-> Int32
-> Int32
-> Int32
-> m Int32
spawnAsyncWithFds workingDirectory :: Maybe [Char]
workingDirectory argv :: [Text]
argv envp :: Maybe [Text]
envp flags :: [SpawnFlags]
flags childSetup :: Maybe (IO ())
childSetup stdinFd :: Int32
stdinFd stdoutFd :: Int32
stdoutFd stderrFd :: Int32
stderrFd = IO Int32 -> m Int32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int32 -> m Int32) -> IO Int32 -> m Int32
forall a b. (a -> b) -> a -> b
$ do
    CString
maybeWorkingDirectory <- case Maybe [Char]
workingDirectory of
        Nothing -> CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
forall a. Ptr a
nullPtr
        Just jWorkingDirectory :: [Char]
jWorkingDirectory -> do
            CString
jWorkingDirectory' <- [Char] -> IO CString
stringToCString [Char]
jWorkingDirectory
            CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
jWorkingDirectory'
    Ptr CString
argv' <- [Text] -> IO (Ptr CString)
packZeroTerminatedUTF8CArray [Text]
argv
    Ptr CString
maybeEnvp <- case Maybe [Text]
envp of
        Nothing -> Ptr CString -> IO (Ptr CString)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CString
forall a. Ptr a
nullPtr
        Just jEnvp :: [Text]
jEnvp -> do
            Ptr CString
jEnvp' <- [Text] -> IO (Ptr CString)
packZeroTerminatedUTF8CArray [Text]
jEnvp
            Ptr CString -> IO (Ptr CString)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CString
jEnvp'
    let flags' :: CUInt
flags' = [SpawnFlags] -> CUInt
forall b a. (Num b, IsGFlag a) => [a] -> b
gflagsToWord [SpawnFlags]
flags
    FunPtr C_DestroyNotify
maybeChildSetup <- case Maybe (IO ())
childSetup of
        Nothing -> FunPtr C_DestroyNotify -> IO (FunPtr C_DestroyNotify)
forall (m :: * -> *) a. Monad m => a -> m a
return (Ptr Any -> FunPtr C_DestroyNotify
forall a b. Ptr a -> FunPtr b
castPtrToFunPtr Ptr Any
forall a. Ptr a
nullPtr)
        Just jChildSetup :: IO ()
jChildSetup -> do
            Ptr (FunPtr C_DestroyNotify)
ptrchildSetup <- IO (Ptr (FunPtr C_DestroyNotify))
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr (FunPtr GLib.Callbacks.C_SpawnChildSetupFunc))
            FunPtr C_DestroyNotify
jChildSetup' <- C_DestroyNotify -> IO (FunPtr C_DestroyNotify)
GLib.Callbacks.mk_SpawnChildSetupFunc (Maybe (Ptr (FunPtr C_DestroyNotify))
-> C_DestroyNotify -> C_DestroyNotify
GLib.Callbacks.wrap_SpawnChildSetupFunc (Ptr (FunPtr C_DestroyNotify)
-> Maybe (Ptr (FunPtr C_DestroyNotify))
forall a. a -> Maybe a
Just Ptr (FunPtr C_DestroyNotify)
ptrchildSetup) (IO () -> C_DestroyNotify
GLib.Callbacks.drop_closures_SpawnChildSetupFunc IO ()
jChildSetup))
            Ptr (FunPtr C_DestroyNotify) -> FunPtr C_DestroyNotify -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke Ptr (FunPtr C_DestroyNotify)
ptrchildSetup FunPtr C_DestroyNotify
jChildSetup'
            FunPtr C_DestroyNotify -> IO (FunPtr C_DestroyNotify)
forall (m :: * -> *) a. Monad m => a -> m a
return FunPtr C_DestroyNotify
jChildSetup'
    Ptr Int32
childPid <- IO (Ptr Int32)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Int32)
    let userData :: Ptr a
userData = Ptr a
forall a. Ptr a
nullPtr
    IO Int32 -> IO () -> IO Int32
forall a b. IO a -> IO b -> IO a
onException (do
        CInt
_ <- (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ CString
-> Ptr CString
-> Ptr CString
-> CUInt
-> FunPtr C_DestroyNotify
-> Ptr ()
-> Ptr Int32
-> Int32
-> Int32
-> Int32
-> Ptr (Ptr GError)
-> IO CInt
g_spawn_async_with_fds CString
maybeWorkingDirectory Ptr CString
argv' Ptr CString
maybeEnvp CUInt
flags' FunPtr C_DestroyNotify
maybeChildSetup Ptr ()
forall a. Ptr a
userData Ptr Int32
childPid Int32
stdinFd Int32
stdoutFd Int32
stderrFd
        Int32
childPid' <- Ptr Int32 -> IO Int32
forall a. Storable a => Ptr a -> IO a
peek Ptr Int32
childPid
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeWorkingDirectory
        (CString -> IO ()) -> Ptr CString -> IO ()
forall a b. (Ptr a -> IO b) -> Ptr (Ptr a) -> IO ()
mapZeroTerminatedCArray CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
argv'
        Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
argv'
        (CString -> IO ()) -> Ptr CString -> IO ()
forall a b. (Ptr a -> IO b) -> Ptr (Ptr a) -> IO ()
mapZeroTerminatedCArray CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
maybeEnvp
        Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
maybeEnvp
        Ptr Int32 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Int32
childPid
        Int32 -> IO Int32
forall (m :: * -> *) a. Monad m => a -> m a
return Int32
childPid'
     ) (do
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeWorkingDirectory
        (CString -> IO ()) -> Ptr CString -> IO ()
forall a b. (Ptr a -> IO b) -> Ptr (Ptr a) -> IO ()
mapZeroTerminatedCArray CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
argv'
        Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
argv'
        (CString -> IO ()) -> Ptr CString -> IO ()
forall a b. (Ptr a -> IO b) -> Ptr (Ptr a) -> IO ()
mapZeroTerminatedCArray CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
maybeEnvp
        Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
maybeEnvp
        Ptr Int32 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Int32
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 :: Maybe [Char]
-> [[Char]]
-> Maybe [[Char]]
-> [SpawnFlags]
-> Maybe (IO ())
-> m Int32
spawnAsync workingDirectory :: Maybe [Char]
workingDirectory argv :: [[Char]]
argv envp :: Maybe [[Char]]
envp flags :: [SpawnFlags]
flags childSetup :: Maybe (IO ())
childSetup = IO Int32 -> m Int32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int32 -> m Int32) -> IO Int32 -> m Int32
forall a b. (a -> b) -> a -> b
$ do
    CString
maybeWorkingDirectory <- case Maybe [Char]
workingDirectory of
        Nothing -> CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
forall a. Ptr a
nullPtr
        Just jWorkingDirectory :: [Char]
jWorkingDirectory -> do
            CString
jWorkingDirectory' <- [Char] -> IO CString
stringToCString [Char]
jWorkingDirectory
            CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
jWorkingDirectory'
    Ptr CString
argv' <- [[Char]] -> IO (Ptr CString)
packZeroTerminatedFileNameArray [[Char]]
argv
    Ptr CString
maybeEnvp <- case Maybe [[Char]]
envp of
        Nothing -> Ptr CString -> IO (Ptr CString)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CString
forall a. Ptr a
nullPtr
        Just jEnvp :: [[Char]]
jEnvp -> do
            Ptr CString
jEnvp' <- [[Char]] -> IO (Ptr CString)
packZeroTerminatedFileNameArray [[Char]]
jEnvp
            Ptr CString -> IO (Ptr CString)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CString
jEnvp'
    let flags' :: CUInt
flags' = [SpawnFlags] -> CUInt
forall b a. (Num b, IsGFlag a) => [a] -> b
gflagsToWord [SpawnFlags]
flags
    FunPtr C_DestroyNotify
maybeChildSetup <- case Maybe (IO ())
childSetup of
        Nothing -> FunPtr C_DestroyNotify -> IO (FunPtr C_DestroyNotify)
forall (m :: * -> *) a. Monad m => a -> m a
return (Ptr Any -> FunPtr C_DestroyNotify
forall a b. Ptr a -> FunPtr b
castPtrToFunPtr Ptr Any
forall a. Ptr a
nullPtr)
        Just jChildSetup :: IO ()
jChildSetup -> do
            Ptr (FunPtr C_DestroyNotify)
ptrchildSetup <- IO (Ptr (FunPtr C_DestroyNotify))
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr (FunPtr GLib.Callbacks.C_SpawnChildSetupFunc))
            FunPtr C_DestroyNotify
jChildSetup' <- C_DestroyNotify -> IO (FunPtr C_DestroyNotify)
GLib.Callbacks.mk_SpawnChildSetupFunc (Maybe (Ptr (FunPtr C_DestroyNotify))
-> C_DestroyNotify -> C_DestroyNotify
GLib.Callbacks.wrap_SpawnChildSetupFunc (Ptr (FunPtr C_DestroyNotify)
-> Maybe (Ptr (FunPtr C_DestroyNotify))
forall a. a -> Maybe a
Just Ptr (FunPtr C_DestroyNotify)
ptrchildSetup) (IO () -> C_DestroyNotify
GLib.Callbacks.drop_closures_SpawnChildSetupFunc IO ()
jChildSetup))
            Ptr (FunPtr C_DestroyNotify) -> FunPtr C_DestroyNotify -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke Ptr (FunPtr C_DestroyNotify)
ptrchildSetup FunPtr C_DestroyNotify
jChildSetup'
            FunPtr C_DestroyNotify -> IO (FunPtr C_DestroyNotify)
forall (m :: * -> *) a. Monad m => a -> m a
return FunPtr C_DestroyNotify
jChildSetup'
    Ptr Int32
childPid <- IO (Ptr Int32)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Int32)
    let userData :: Ptr a
userData = Ptr a
forall a. Ptr a
nullPtr
    IO Int32 -> IO () -> IO Int32
forall a b. IO a -> IO b -> IO a
onException (do
        CInt
_ <- (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ CString
-> Ptr CString
-> Ptr CString
-> CUInt
-> FunPtr C_DestroyNotify
-> Ptr ()
-> Ptr Int32
-> Ptr (Ptr GError)
-> IO CInt
g_spawn_async CString
maybeWorkingDirectory Ptr CString
argv' Ptr CString
maybeEnvp CUInt
flags' FunPtr C_DestroyNotify
maybeChildSetup Ptr ()
forall a. Ptr a
userData Ptr Int32
childPid
        Int32
childPid' <- Ptr Int32 -> IO Int32
forall a. Storable a => Ptr a -> IO a
peek Ptr Int32
childPid
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeWorkingDirectory
        (CString -> IO ()) -> Ptr CString -> IO ()
forall a b. (Ptr a -> IO b) -> Ptr (Ptr a) -> IO ()
mapZeroTerminatedCArray CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
argv'
        Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
argv'
        (CString -> IO ()) -> Ptr CString -> IO ()
forall a b. (Ptr a -> IO b) -> Ptr (Ptr a) -> IO ()
mapZeroTerminatedCArray CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
maybeEnvp
        Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
maybeEnvp
        Ptr Int32 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Int32
childPid
        Int32 -> IO Int32
forall (m :: * -> *) a. Monad m => a -> m a
return Int32
childPid'
     ) (do
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeWorkingDirectory
        (CString -> IO ()) -> Ptr CString -> IO ()
forall a b. (Ptr a -> IO b) -> Ptr (Ptr a) -> IO ()
mapZeroTerminatedCArray CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
argv'
        Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
argv'
        (CString -> IO ()) -> Ptr CString -> IO ()
forall a b. (Ptr a -> IO b) -> Ptr (Ptr a) -> IO ()
mapZeroTerminatedCArray CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
maybeEnvp
        Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
maybeEnvp
        Ptr Int32 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Int32
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 :: Word32 -> m Word32
spacedPrimesClosest num :: Word32
num = IO Word32 -> m Word32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ do
    Word32
result <- Word32 -> IO Word32
g_spaced_primes_closest Word32
num
    Word32 -> IO Word32
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
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 :: SliceConfig -> Int64 -> m ()
sliceSetConfig ckey :: SliceConfig
ckey value :: Int64
value = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    let ckey' :: CUInt
ckey' = (Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CUInt) -> (SliceConfig -> Int) -> SliceConfig -> CUInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SliceConfig -> Int
forall a. Enum a => a -> Int
fromEnum) SliceConfig
ckey
    CUInt -> Int64 -> IO ()
g_slice_set_config CUInt
ckey' Int64
value
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
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 :: SliceConfig -> Int64 -> Word32 -> m Int64
sliceGetConfigState ckey :: SliceConfig
ckey address :: Int64
address nValues :: Word32
nValues = IO Int64 -> m Int64
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int64 -> m Int64) -> IO Int64 -> m Int64
forall a b. (a -> b) -> a -> b
$ do
    let ckey' :: CUInt
ckey' = (Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CUInt) -> (SliceConfig -> Int) -> SliceConfig -> CUInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SliceConfig -> Int
forall a. Enum a => a -> Int
fromEnum) SliceConfig
ckey
    Int64
result <- CUInt -> Int64 -> Word32 -> IO Int64
g_slice_get_config_state CUInt
ckey' Int64
address Word32
nValues
    Int64 -> IO Int64
forall (m :: * -> *) a. Monad m => a -> m a
return Int64
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 :: SliceConfig -> m Int64
sliceGetConfig ckey :: SliceConfig
ckey = IO Int64 -> m Int64
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int64 -> m Int64) -> IO Int64 -> m Int64
forall a b. (a -> b) -> a -> b
$ do
    let ckey' :: CUInt
ckey' = (Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CUInt) -> (SliceConfig -> Int) -> SliceConfig -> CUInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SliceConfig -> Int
forall a. Enum a => a -> Int
fromEnum) SliceConfig
ckey
    Int64
result <- CUInt -> IO Int64
g_slice_get_config CUInt
ckey'
    Int64 -> IO Int64
forall (m :: * -> *) a. Monad m => a -> m a
return Int64
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 :: CGType -> Ptr () -> CGType -> m ()
sliceFreeChainWithOffset blockSize :: CGType
blockSize memChain :: Ptr ()
memChain nextOffset :: CGType
nextOffset = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    CGType -> Ptr () -> CGType -> IO ()
g_slice_free_chain_with_offset CGType
blockSize Ptr ()
memChain CGType
nextOffset
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
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 :: CGType -> Ptr () -> m ()
sliceFree1 blockSize :: CGType
blockSize memBlock :: Ptr ()
memBlock = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    CGType -> C_DestroyNotify
g_slice_free1 CGType
blockSize Ptr ()
memBlock
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
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 :: CGType -> Ptr () -> m (Ptr ())
sliceCopy blockSize :: CGType
blockSize memBlock :: Ptr ()
memBlock = IO (Ptr ()) -> m (Ptr ())
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Ptr ()) -> m (Ptr ())) -> IO (Ptr ()) -> m (Ptr ())
forall a b. (a -> b) -> a -> b
$ do
    Ptr ()
result <- CGType -> Ptr () -> IO (Ptr ())
g_slice_copy CGType
blockSize Ptr ()
memBlock
    Ptr () -> IO (Ptr ())
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr ()
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 :: CGType -> m (Ptr ())
sliceAlloc0 blockSize :: CGType
blockSize = IO (Ptr ()) -> m (Ptr ())
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Ptr ()) -> m (Ptr ())) -> IO (Ptr ()) -> m (Ptr ())
forall a b. (a -> b) -> a -> b
$ do
    Ptr ()
result <- CGType -> IO (Ptr ())
g_slice_alloc0 CGType
blockSize
    Ptr () -> IO (Ptr ())
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr ()
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 :: CGType -> m (Ptr ())
sliceAlloc blockSize :: CGType
blockSize = IO (Ptr ()) -> m (Ptr ())
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Ptr ()) -> m (Ptr ())) -> IO (Ptr ()) -> m (Ptr ())
forall a b. (a -> b) -> a -> b
$ do
    Ptr ()
result <- CGType -> IO (Ptr ())
g_slice_alloc CGType
blockSize
    Ptr () -> IO (Ptr ())
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr ()
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 :: [Char] -> m [Char]
shellUnquote quotedString :: [Char]
quotedString = IO [Char] -> m [Char]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [Char] -> m [Char]) -> IO [Char] -> m [Char]
forall a b. (a -> b) -> a -> b
$ do
    CString
quotedString' <- [Char] -> IO CString
stringToCString [Char]
quotedString
    IO [Char] -> IO () -> IO [Char]
forall a b. IO a -> IO b -> IO a
onException (do
        CString
result <- (Ptr (Ptr GError) -> IO CString) -> IO CString
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CString) -> IO CString)
-> (Ptr (Ptr GError) -> IO CString) -> IO CString
forall a b. (a -> b) -> a -> b
$ CString -> Ptr (Ptr GError) -> IO CString
g_shell_unquote CString
quotedString'
        Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "shellUnquote" CString
result
        [Char]
result' <- HasCallStack => CString -> IO [Char]
CString -> IO [Char]
cstringToString CString
result
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
quotedString'
        [Char] -> IO [Char]
forall (m :: * -> *) a. Monad m => a -> m a
return [Char]
result'
     ) (do
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
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 :: [Char] -> m [Char]
shellQuote unquotedString :: [Char]
unquotedString = IO [Char] -> m [Char]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [Char] -> m [Char]) -> IO [Char] -> m [Char]
forall a b. (a -> b) -> a -> b
$ do
    CString
unquotedString' <- [Char] -> IO CString
stringToCString [Char]
unquotedString
    CString
result <- CString -> IO CString
g_shell_quote CString
unquotedString'
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "shellQuote" CString
result
    [Char]
result' <- HasCallStack => CString -> IO [Char]
CString -> IO [Char]
cstringToString CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
unquotedString'
    [Char] -> IO [Char]
forall (m :: * -> *) a. Monad m => a -> m a
return [Char]
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 :: [Char] -> m (Int32, [[Char]])
shellParseArgv commandLine :: [Char]
commandLine = IO (Int32, [[Char]]) -> m (Int32, [[Char]])
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Int32, [[Char]]) -> m (Int32, [[Char]]))
-> IO (Int32, [[Char]]) -> m (Int32, [[Char]])
forall a b. (a -> b) -> a -> b
$ do
    CString
commandLine' <- [Char] -> IO CString
stringToCString [Char]
commandLine
    Ptr Int32
argcp <- IO (Ptr Int32)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Int32)
    Ptr (Ptr CString)
argvp <- IO (Ptr (Ptr CString))
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr (Ptr CString))
    IO (Int32, [[Char]]) -> IO () -> IO (Int32, [[Char]])
forall a b. IO a -> IO b -> IO a
onException (do
        CInt
_ <- (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ CString
-> Ptr Int32 -> Ptr (Ptr CString) -> Ptr (Ptr GError) -> IO CInt
g_shell_parse_argv CString
commandLine' Ptr Int32
argcp Ptr (Ptr CString)
argvp
        Int32
argcp' <- Ptr Int32 -> IO Int32
forall a. Storable a => Ptr a -> IO a
peek Ptr Int32
argcp
        Ptr CString
argvp' <- Ptr (Ptr CString) -> IO (Ptr CString)
forall a. Storable a => Ptr a -> IO a
peek Ptr (Ptr CString)
argvp
        [[Char]]
argvp'' <- HasCallStack => Ptr CString -> IO [[Char]]
Ptr CString -> IO [[Char]]
unpackZeroTerminatedFileNameArray Ptr CString
argvp'
        (CString -> IO ()) -> Ptr CString -> IO ()
forall a b. (Ptr a -> IO b) -> Ptr (Ptr a) -> IO ()
mapZeroTerminatedCArray CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
argvp'
        Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
argvp'
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
commandLine'
        Ptr Int32 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Int32
argcp
        Ptr (Ptr CString) -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr (Ptr CString)
argvp
        (Int32, [[Char]]) -> IO (Int32, [[Char]])
forall (m :: * -> *) a. Monad m => a -> m a
return (Int32
argcp', [[Char]]
argvp'')
     ) (do
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
commandLine'
        Ptr Int32 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Int32
argcp
        Ptr (Ptr CString) -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr (Ptr CString)
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 :: m Word32
shellErrorQuark  = IO Word32 -> m Word32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ do
    Word32
result <- IO Word32
g_shell_error_quark
    Word32 -> IO Word32
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
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 :: [Char] -> [Char] -> Bool -> m Bool
setenv variable :: [Char]
variable value :: [Char]
value overwrite :: Bool
overwrite = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    CString
variable' <- [Char] -> IO CString
stringToCString [Char]
variable
    CString
value' <- [Char] -> IO CString
stringToCString [Char]
value
    let overwrite' :: CInt
overwrite' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Bool -> Int) -> Bool -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> Int
forall a. Enum a => a -> Int
fromEnum) Bool
overwrite
    CInt
result <- CString -> CString -> CInt -> IO CInt
g_setenv CString
variable' CString
value' CInt
overwrite'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
variable'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
value'
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
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 :: Text -> m ()
setPrgname prgname :: Text
prgname = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    CString
prgname' <- Text -> IO CString
textToCString Text
prgname
    CString -> IO ()
g_set_prgname CString
prgname'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
prgname'
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
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 :: Word32 -> Int32 -> Text -> m GError
setErrorLiteral domain :: Word32
domain code :: Int32
code message :: Text
message = IO GError -> m GError
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO GError -> m GError) -> IO GError -> m GError
forall a b. (a -> b) -> a -> b
$ do
    Ptr (Ptr GError)
err <- IO (Ptr (Ptr GError))
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr (Ptr GError))
    CString
message' <- Text -> IO CString
textToCString Text
message
    Ptr (Ptr GError) -> Word32 -> Int32 -> CString -> IO ()
g_set_error_literal Ptr (Ptr GError)
err Word32
domain Int32
code CString
message'
    Ptr GError
err' <- Ptr (Ptr GError) -> IO (Ptr GError)
forall a. Storable a => Ptr a -> IO a
peek Ptr (Ptr GError)
err
    GError
err'' <- ((ManagedPtr GError -> GError) -> Ptr GError -> IO GError
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr GError -> GError
GError) Ptr GError
err'
    Ptr (Ptr GError) -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr (Ptr GError)
err
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
message'
    GError -> IO GError
forall (m :: * -> *) a. Monad m => a -> m a
return GError
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 :: Text -> m ()
setApplicationName applicationName :: Text
applicationName = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    CString
applicationName' <- Text -> IO CString
textToCString Text
applicationName
    CString -> IO ()
g_set_application_name CString
applicationName'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
applicationName'
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
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 :: [Char] -> m Int32
rmdir filename :: [Char]
filename = IO Int32 -> m Int32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int32 -> m Int32) -> IO Int32 -> m Int32
forall a b. (a -> b) -> a -> b
$ do
    CString
filename' <- [Char] -> IO CString
stringToCString [Char]
filename
    Int32
result <- CString -> IO Int32
g_rmdir CString
filename'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
filename'
    Int32 -> IO Int32
forall (m :: * -> *) a. Monad m => a -> m a
return Int32
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 :: m ()
reloadUserSpecialDirsCache  = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    IO ()
g_reload_user_special_dirs_cache
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
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 :: Text -> m ()
refStringRelease str :: Text
str = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    CString
str' <- Text -> IO CString
textToCString Text
str
    CString -> IO ()
g_ref_string_release CString
str'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
str'
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
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 :: Text -> Int64 -> m Text
refStringNewLen str :: Text
str len :: Int64
len = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
str' <- Text -> IO CString
textToCString Text
str
    CString
result <- CString -> Int64 -> IO CString
g_ref_string_new_len CString
str' Int64
len
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "refStringNewLen" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
str'
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
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 :: Text -> m Text
refStringNewIntern str :: Text
str = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
str' <- Text -> IO CString
textToCString Text
str
    CString
result <- CString -> IO CString
g_ref_string_new_intern CString
str'
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "refStringNewIntern" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
str'
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
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 :: Text -> m Text
refStringNew str :: Text
str = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
str' <- Text -> IO CString
textToCString Text
str
    CString
result <- CString -> IO CString
g_ref_string_new CString
str'
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "refStringNew" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
str'
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
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 :: Text -> m CGType
refStringLength str :: Text
str = IO CGType -> m CGType
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO CGType -> m CGType) -> IO CGType -> m CGType
forall a b. (a -> b) -> a -> b
$ do
    CString
str' <- Text -> IO CString
textToCString Text
str
    CGType
result <- CString -> IO CGType
g_ref_string_length CString
str'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
str'
    CGType -> IO CGType
forall (m :: * -> *) a. Monad m => a -> m a
return CGType
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 :: Text -> m Text
refStringAcquire str :: Text
str = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
str' <- Text -> IO CString
textToCString Text
str
    CString
result <- CString -> IO CString
g_ref_string_acquire CString
str'
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "refStringAcquire" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
str'
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
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 :: Int32 -> m ()
refCountInit rc :: Int32
rc = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Int32 -> IO ()
g_ref_count_init Int32
rc
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
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 :: Int32 -> m ()
refCountInc rc :: Int32
rc = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Int32 -> IO ()
g_ref_count_inc Int32
rc
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
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 :: Int32 -> m Bool
refCountDec rc :: Int32
rc = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    CInt
result <- Int32 -> IO CInt
g_ref_count_dec Int32
rc
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
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 :: Int32 -> Int32 -> m Bool
refCountCompare rc :: Int32
rc val :: Int32
val = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    CInt
result <- Int32 -> Int32 -> IO CInt
g_ref_count_compare Int32
rc Int32
val
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
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 :: Ptr () -> CGType -> CGType -> m (Ptr ())
reallocN mem :: Ptr ()
mem nBlocks :: CGType
nBlocks nBlockBytes :: CGType
nBlockBytes = IO (Ptr ()) -> m (Ptr ())
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Ptr ()) -> m (Ptr ())) -> IO (Ptr ()) -> m (Ptr ())
forall a b. (a -> b) -> a -> b
$ do
    Ptr ()
result <- Ptr () -> CGType -> CGType -> IO (Ptr ())
g_realloc_n Ptr ()
mem CGType
nBlocks CGType
nBlockBytes
    Ptr () -> IO (Ptr ())
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr ()
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 :: Ptr () -> CGType -> m (Ptr ())
realloc mem :: Ptr ()
mem nBytes :: CGType
nBytes = IO (Ptr ()) -> m (Ptr ())
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Ptr ()) -> m (Ptr ())) -> IO (Ptr ()) -> m (Ptr ())
forall a b. (a -> b) -> a -> b
$ do
    Ptr ()
result <- Ptr () -> CGType -> IO (Ptr ())
g_realloc Ptr ()
mem CGType
nBytes
    Ptr () -> IO (Ptr ())
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr ()
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 :: Ptr () -> C_DestroyNotify -> m ()
rcBoxReleaseFull memBlock :: Ptr ()
memBlock clearFunc :: C_DestroyNotify
clearFunc = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr (FunPtr C_DestroyNotify)
ptrclearFunc <- IO (Ptr (FunPtr C_DestroyNotify))
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr (FunPtr GLib.Callbacks.C_DestroyNotify))
    FunPtr C_DestroyNotify
clearFunc' <- C_DestroyNotify -> IO (FunPtr C_DestroyNotify)
GLib.Callbacks.mk_DestroyNotify (Maybe (Ptr (FunPtr C_DestroyNotify))
-> C_DestroyNotify -> C_DestroyNotify
GLib.Callbacks.wrap_DestroyNotify (Ptr (FunPtr C_DestroyNotify)
-> Maybe (Ptr (FunPtr C_DestroyNotify))
forall a. a -> Maybe a
Just Ptr (FunPtr C_DestroyNotify)
ptrclearFunc) C_DestroyNotify
clearFunc)
    Ptr (FunPtr C_DestroyNotify) -> FunPtr C_DestroyNotify -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke Ptr (FunPtr C_DestroyNotify)
ptrclearFunc FunPtr C_DestroyNotify
clearFunc'
    Ptr () -> FunPtr C_DestroyNotify -> IO ()
g_rc_box_release_full Ptr ()
memBlock FunPtr C_DestroyNotify
clearFunc'
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
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 :: Ptr () -> m ()
rcBoxRelease memBlock :: Ptr ()
memBlock = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    C_DestroyNotify
g_rc_box_release Ptr ()
memBlock
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
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 :: Ptr () -> m CGType
rcBoxGetSize memBlock :: Ptr ()
memBlock = IO CGType -> m CGType
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO CGType -> m CGType) -> IO CGType -> m CGType
forall a b. (a -> b) -> a -> b
$ do
    CGType
result <- Ptr () -> IO CGType
g_rc_box_get_size Ptr ()
memBlock
    CGType -> IO CGType
forall (m :: * -> *) a. Monad m => a -> m a
return CGType
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 :: CGType -> Ptr () -> m (Ptr ())
rcBoxDup blockSize :: CGType
blockSize memBlock :: Ptr ()
memBlock = IO (Ptr ()) -> m (Ptr ())
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Ptr ()) -> m (Ptr ())) -> IO (Ptr ()) -> m (Ptr ())
forall a b. (a -> b) -> a -> b
$ do
    Ptr ()
result <- CGType -> Ptr () -> IO (Ptr ())
g_rc_box_dup CGType
blockSize Ptr ()
memBlock
    Ptr () -> IO (Ptr ())
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr ()
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 :: CGType -> m (Ptr ())
rcBoxAlloc0 blockSize :: CGType
blockSize = IO (Ptr ()) -> m (Ptr ())
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Ptr ()) -> m (Ptr ())) -> IO (Ptr ()) -> m (Ptr ())
forall a b. (a -> b) -> a -> b
$ do
    Ptr ()
result <- CGType -> IO (Ptr ())
g_rc_box_alloc0 CGType
blockSize
    Ptr () -> IO (Ptr ())
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr ()
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 :: CGType -> m (Ptr ())
rcBoxAlloc blockSize :: CGType
blockSize = IO (Ptr ()) -> m (Ptr ())
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Ptr ()) -> m (Ptr ())) -> IO (Ptr ()) -> m (Ptr ())
forall a b. (a -> b) -> a -> b
$ do
    Ptr ()
result <- CGType -> IO (Ptr ())
g_rc_box_alloc CGType
blockSize
    Ptr () -> IO (Ptr ())
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr ()
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 :: Ptr () -> m (Ptr ())
rcBoxAcquire memBlock :: Ptr ()
memBlock = IO (Ptr ()) -> m (Ptr ())
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Ptr ()) -> m (Ptr ())) -> IO (Ptr ()) -> m (Ptr ())
forall a b. (a -> b) -> a -> b
$ do
    Ptr ()
result <- Ptr () -> IO (Ptr ())
g_rc_box_acquire Ptr ()
memBlock
    Ptr () -> IO (Ptr ())
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr ()
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 :: Word32 -> m ()
randomSetSeed seed :: Word32
seed = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Word32 -> IO ()
g_random_set_seed Word32
seed
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
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 :: Int32 -> Int32 -> m Int32
randomIntRange begin :: Int32
begin end :: Int32
end = IO Int32 -> m Int32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int32 -> m Int32) -> IO Int32 -> m Int32
forall a b. (a -> b) -> a -> b
$ do
    Int32
result <- Int32 -> Int32 -> IO Int32
g_random_int_range Int32
begin Int32
end
    Int32 -> IO Int32
forall (m :: * -> *) a. Monad m => a -> m a
return Int32
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 :: m Word32
randomInt  = IO Word32 -> m Word32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ do
    Word32
result <- IO Word32
g_random_int
    Word32 -> IO Word32
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
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 :: Double -> Double -> m Double
randomDoubleRange begin :: Double
begin end :: Double
end = IO Double -> m Double
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Double -> m Double) -> IO Double -> m Double
forall a b. (a -> b) -> a -> b
$ do
    let begin' :: CDouble
begin' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
begin
    let end' :: CDouble
end' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
end
    CDouble
result <- CDouble -> CDouble -> IO CDouble
g_random_double_range CDouble
begin' CDouble
end'
    let result' :: Double
result' = CDouble -> Double
forall a b. (Real a, Fractional b) => a -> b
realToFrac CDouble
result
    Double -> IO Double
forall (m :: * -> *) a. Monad m => a -> m a
return Double
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 :: m Double
randomDouble  = IO Double -> m Double
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Double -> m Double) -> IO Double -> m Double
forall a b. (a -> b) -> a -> b
$ do
    CDouble
result <- IO CDouble
g_random_double
    let result' :: Double
result' = CDouble -> Double
forall a b. (Real a, Fractional b) => a -> b
realToFrac CDouble
result
    Double -> IO Double
forall (m :: * -> *) a. Monad m => a -> m a
return Double
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'.

This function must not be used before library constructors have finished
running.
-}
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 :: Maybe Text -> m Word32
quarkTryString string :: Maybe Text
string = IO Word32 -> m Word32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ do
    CString
maybeString <- case Maybe Text
string of
        Nothing -> CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
forall a. Ptr a
nullPtr
        Just jString :: Text
jString -> do
            CString
jString' <- Text -> IO CString
textToCString Text
jString
            CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
jString'
    Word32
result <- CString -> IO Word32
g_quark_try_string CString
maybeString
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeString
    Word32 -> IO Word32
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
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 :: Word32 -> m Text
quarkToString quark :: Word32
quark = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
result <- Word32 -> IO CString
g_quark_to_string Word32
quark
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "quarkToString" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
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.

This function must not be used before library constructors have finished
running. In particular, this means it cannot be used to initialize global
variables in C++.
-}
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 :: Maybe Text -> m Word32
quarkFromString string :: Maybe Text
string = IO Word32 -> m Word32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ do
    CString
maybeString <- case Maybe Text
string of
        Nothing -> CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
forall a. Ptr a
nullPtr
        Just jString :: Text
jString -> do
            CString
jString' <- Text -> IO CString
textToCString Text
jString
            CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
jString'
    Word32
result <- CString -> IO Word32
g_quark_from_string CString
maybeString
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeString
    Word32 -> IO Word32
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
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).

This function must not be used before library constructors have finished
running. In particular, this means it cannot be used to initialize global
variables in C++.
-}
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 :: Maybe Text -> m Word32
quarkFromStaticString string :: Maybe Text
string = IO Word32 -> m Word32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ do
    CString
maybeString <- case Maybe Text
string of
        Nothing -> CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
forall a. Ptr a
nullPtr
        Just jString :: Text
jString -> do
            CString
jString' <- Text -> IO CString
textToCString Text
jString
            CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
jString'
    Word32
result <- CString -> IO Word32
g_quark_from_static_string CString
maybeString
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeString
    Word32 -> IO Word32
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
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 :: GError -> m (Maybe GError)
propagateError src :: GError
src = IO (Maybe GError) -> m (Maybe GError)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe GError) -> m (Maybe GError))
-> IO (Maybe GError) -> m (Maybe GError)
forall a b. (a -> b) -> a -> b
$ do
    Ptr (Ptr GError)
dest <- IO (Ptr (Ptr GError))
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr (Ptr GError))
    Ptr GError
src' <- GError -> IO (Ptr GError)
forall a. (HasCallStack, BoxedObject a) => a -> IO (Ptr a)
B.ManagedPtr.disownBoxed GError
src
    Ptr (Ptr GError) -> Ptr GError -> IO ()
g_propagate_error Ptr (Ptr GError)
dest Ptr GError
src'
    Ptr GError
dest' <- Ptr (Ptr GError) -> IO (Ptr GError)
forall a. Storable a => Ptr a -> IO a
peek Ptr (Ptr GError)
dest
    Maybe GError
maybeDest' <- Ptr GError -> (Ptr GError -> IO GError) -> IO (Maybe GError)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull Ptr GError
dest' ((Ptr GError -> IO GError) -> IO (Maybe GError))
-> (Ptr GError -> IO GError) -> IO (Maybe GError)
forall a b. (a -> b) -> a -> b
$ \dest'' :: Ptr GError
dest'' -> do
        GError
dest''' <- ((ManagedPtr GError -> GError) -> Ptr GError -> IO GError
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr GError -> GError
GError) Ptr GError
dest''
        GError -> IO GError
forall (m :: * -> *) a. Monad m => a -> m a
return GError
dest'''
    GError -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr GError
src
    Ptr (Ptr GError) -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr (Ptr GError)
dest
    Maybe GError -> IO (Maybe GError)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe GError
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 :: PollFD -> Word32 -> Int32 -> m Int32
poll fds :: PollFD
fds nfds :: Word32
nfds timeout :: Int32
timeout = IO Int32 -> m Int32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int32 -> m Int32) -> IO Int32 -> m Int32
forall a b. (a -> b) -> a -> b
$ do
    Ptr PollFD
fds' <- PollFD -> IO (Ptr PollFD)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr PollFD
fds
    Int32
result <- Ptr PollFD -> Word32 -> Int32 -> IO Int32
g_poll Ptr PollFD
fds' Word32
nfds Int32
timeout
    PollFD -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr PollFD
fds
    Int32 -> IO Int32
forall (m :: * -> *) a. Monad m => a -> m a
return Int32
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 :: Ptr () -> Int32 -> m ()
pointerBitUnlock address :: Ptr ()
address lockBit :: Int32
lockBit = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr () -> Int32 -> IO ()
g_pointer_bit_unlock Ptr ()
address Int32
lockBit
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
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 :: Ptr () -> Int32 -> m Bool
pointerBitTrylock address :: Ptr ()
address lockBit :: Int32
lockBit = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    CInt
result <- Ptr () -> Int32 -> IO CInt
g_pointer_bit_trylock Ptr ()
address Int32
lockBit
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
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 :: Ptr () -> Int32 -> m ()
pointerBitLock address :: Ptr ()
address lockBit :: Int32
lockBit = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr () -> Int32 -> IO ()
g_pointer_bit_lock Ptr ()
address Int32
lockBit
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
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 :: PatternSpec -> Text -> m Bool
patternMatchString pspec :: PatternSpec
pspec string :: Text
string = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    Ptr PatternSpec
pspec' <- PatternSpec -> IO (Ptr PatternSpec)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr PatternSpec
pspec
    CString
string' <- Text -> IO CString
textToCString Text
string
    CInt
result <- Ptr PatternSpec -> CString -> IO CInt
g_pattern_match_string Ptr PatternSpec
pspec' CString
string'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    PatternSpec -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr PatternSpec
pspec
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
string'
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
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 :: Text -> Text -> m Bool
patternMatchSimple pattern :: Text
pattern string :: Text
string = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    CString
pattern' <- Text -> IO CString
textToCString Text
pattern
    CString
string' <- Text -> IO CString
textToCString Text
string
    CInt
result <- CString -> CString -> IO CInt
g_pattern_match_simple CString
pattern' CString
string'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
pattern'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
string'
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
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 :: PatternSpec -> Word32 -> Text -> Maybe Text -> m Bool
patternMatch pspec :: PatternSpec
pspec stringLength :: Word32
stringLength string :: Text
string stringReversed :: Maybe Text
stringReversed = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    Ptr PatternSpec
pspec' <- PatternSpec -> IO (Ptr PatternSpec)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr PatternSpec
pspec
    CString
string' <- Text -> IO CString
textToCString Text
string
    CString
maybeStringReversed <- case Maybe Text
stringReversed of
        Nothing -> CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
forall a. Ptr a
nullPtr
        Just jStringReversed :: Text
jStringReversed -> do
            CString
jStringReversed' <- Text -> IO CString
textToCString Text
jStringReversed
            CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
jStringReversed'
    CInt
result <- Ptr PatternSpec -> Word32 -> CString -> CString -> IO CInt
g_pattern_match Ptr PatternSpec
pspec' Word32
stringLength CString
string' CString
maybeStringReversed
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    PatternSpec -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr PatternSpec
pspec
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
string'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeStringReversed
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
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 :: [Char] -> m (Maybe [Char])
pathSkipRoot fileName :: [Char]
fileName = IO (Maybe [Char]) -> m (Maybe [Char])
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe [Char]) -> m (Maybe [Char]))
-> IO (Maybe [Char]) -> m (Maybe [Char])
forall a b. (a -> b) -> a -> b
$ do
    CString
fileName' <- [Char] -> IO CString
stringToCString [Char]
fileName
    CString
result <- CString -> IO CString
g_path_skip_root CString
fileName'
    Maybe [Char]
maybeResult <- CString -> (CString -> IO [Char]) -> IO (Maybe [Char])
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull CString
result ((CString -> IO [Char]) -> IO (Maybe [Char]))
-> (CString -> IO [Char]) -> IO (Maybe [Char])
forall a b. (a -> b) -> a -> b
$ \result' :: CString
result' -> do
        [Char]
result'' <- HasCallStack => CString -> IO [Char]
CString -> IO [Char]
cstringToString CString
result'
        [Char] -> IO [Char]
forall (m :: * -> *) a. Monad m => a -> m a
return [Char]
result''
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
fileName'
    Maybe [Char] -> IO (Maybe [Char])
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe [Char]
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 :: [Char] -> m Bool
pathIsAbsolute fileName :: [Char]
fileName = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    CString
fileName' <- [Char] -> IO CString
stringToCString [Char]
fileName
    CInt
result <- CString -> IO CInt
g_path_is_absolute CString
fileName'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
fileName'
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
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 :: [Char] -> m [Char]
pathGetDirname fileName :: [Char]
fileName = IO [Char] -> m [Char]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [Char] -> m [Char]) -> IO [Char] -> m [Char]
forall a b. (a -> b) -> a -> b
$ do
    CString
fileName' <- [Char] -> IO CString
stringToCString [Char]
fileName
    CString
result <- CString -> IO CString
g_path_get_dirname CString
fileName'
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "pathGetDirname" CString
result
    [Char]
result' <- HasCallStack => CString -> IO [Char]
CString -> IO [Char]
cstringToString CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
fileName'
    [Char] -> IO [Char]
forall (m :: * -> *) a. Monad m => a -> m a
return [Char]
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 :: [Char] -> m [Char]
pathGetBasename fileName :: [Char]
fileName = IO [Char] -> m [Char]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [Char] -> m [Char]) -> IO [Char] -> m [Char]
forall a b. (a -> b) -> a -> b
$ do
    CString
fileName' <- [Char] -> IO CString
stringToCString [Char]
fileName
    CString
result <- CString -> IO CString
g_path_get_basename CString
fileName'
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "pathGetBasename" CString
result
    [Char]
result' <- HasCallStack => CString -> IO [Char]
CString -> IO [Char]
cstringToString CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
fileName'
    [Char] -> IO [Char]
forall (m :: * -> *) a. Monad m => a -> m a
return [Char]
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 :: Maybe Text -> [DebugKey] -> m Word32
parseDebugString string :: Maybe Text
string keys :: [DebugKey]
keys = IO Word32 -> m Word32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ do
    let nkeys :: Word32
nkeys = Int -> Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> Word32) -> Int -> Word32
forall a b. (a -> b) -> a -> b
$ [DebugKey] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [DebugKey]
keys
    CString
maybeString <- case Maybe Text
string of
        Nothing -> CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
forall a. Ptr a
nullPtr
        Just jString :: Text
jString -> do
            CString
jString' <- Text -> IO CString
textToCString Text
jString
            CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
jString'
    [Ptr DebugKey]
keys' <- (DebugKey -> IO (Ptr DebugKey)) -> [DebugKey] -> IO [Ptr DebugKey]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM DebugKey -> IO (Ptr DebugKey)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr [DebugKey]
keys
    Ptr DebugKey
keys'' <- Int -> [Ptr DebugKey] -> IO (Ptr DebugKey)
forall a. Int -> [Ptr a] -> IO (Ptr a)
packBlockArray 16 [Ptr DebugKey]
keys'
    Word32
result <- CString -> Ptr DebugKey -> Word32 -> IO Word32
g_parse_debug_string CString
maybeString Ptr DebugKey
keys'' Word32
nkeys
    (DebugKey -> IO ()) -> [DebugKey] -> IO ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ DebugKey -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr [DebugKey]
keys
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeString
    Ptr DebugKey -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr DebugKey
keys''
    Word32 -> IO Word32
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
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 :: m Word32
optionErrorQuark  = IO Word32 -> m Word32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ do
    Word32
result <- IO Word32
g_option_error_quark
    Word32 -> IO Word32
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
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.

When running on Windows, this function is *not* called by
'GI.GLib.Functions.onErrorQuery'. If called directly, it will raise an
exception, which will crash the program. If the @G_DEBUGGER@ environment
variable is set, a debugger will be invoked to attach and
handle that exception (see <http://developer.gnome.org/glib/stable/glib-running.html Running GLib Applications>).
-}
onErrorStackTrace ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@prgName@/: the program name, needed by gdb for the \"[S]tack trace\"
    option -}
    -> m ()
onErrorStackTrace :: Text -> m ()
onErrorStackTrace prgName :: Text
prgName = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    CString
prgName' <- Text -> IO CString
textToCString Text
prgName
    CString -> IO ()
g_on_error_stack_trace CString
prgName'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
prgName'
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
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.

On Windows consider using the @G_DEBUGGER@ environment
variable (see <http://developer.gnome.org/glib/stable/glib-running.html Running GLib Applications>) and
calling 'GI.GLib.Functions.onErrorStackTrace' instead.
-}
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 :: Text -> m ()
onErrorQuery prgName :: Text
prgName = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    CString
prgName' <- Text -> IO CString
textToCString Text
prgName
    CString -> IO ()
g_on_error_query CString
prgName'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
prgName'
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
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 :: m Word32
numberParserErrorQuark  = IO Word32 -> m Word32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ do
    Word32
result <- IO Word32
g_number_parser_error_quark
    Word32 -> IO Word32
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
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 :: Ptr () -> m ()
nullifyPointer nullifyLocation :: Ptr ()
nullifyLocation = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    C_DestroyNotify
g_nullify_pointer Ptr ()
nullifyLocation
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
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 :: [Char] -> Int32 -> m Int32
mkdirWithParents pathname :: [Char]
pathname mode :: Int32
mode = IO Int32 -> m Int32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int32 -> m Int32) -> IO Int32 -> m Int32
forall a b. (a -> b) -> a -> b
$ do
    CString
pathname' <- [Char] -> IO CString
stringToCString [Char]
pathname
    Int32
result <- CString -> Int32 -> IO Int32
g_mkdir_with_parents CString
pathname' Int32
mode
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
pathname'
    Int32 -> IO Int32
forall (m :: * -> *) a. Monad m => a -> m a
return Int32
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 :: Ptr () -> Word32 -> m (Ptr ())
memdup mem :: Ptr ()
mem byteSize :: Word32
byteSize = IO (Ptr ()) -> m (Ptr ())
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Ptr ()) -> m (Ptr ())) -> IO (Ptr ()) -> m (Ptr ())
forall a b. (a -> b) -> a -> b
$ do
    Ptr ()
result <- Ptr () -> Word32 -> IO (Ptr ())
g_memdup Ptr ()
mem Word32
byteSize
    Ptr () -> IO (Ptr ())
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr ()
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 :: MemVTable -> m ()
memSetVtable vtable :: MemVTable
vtable = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr MemVTable
vtable' <- MemVTable -> IO (Ptr MemVTable)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr MemVTable
vtable
    Ptr MemVTable -> IO ()
g_mem_set_vtable Ptr MemVTable
vtable'
    MemVTable -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr MemVTable
vtable
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
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 :: m ()
memProfile  = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    IO ()
g_mem_profile
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
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 interchangeably 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 :: m Bool
memIsSystemMalloc  = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    CInt
result <- IO CInt
g_mem_is_system_malloc
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
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 -> Int64 -> m Text
markupEscapeText text :: Text
text length_ :: Int64
length_ = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
text' <- Text -> IO CString
textToCString Text
text
    CString
result <- CString -> Int64 -> IO CString
g_markup_escape_text CString
text' Int64
length_
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "markupEscapeText" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
text'
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
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 :: m Word32
markupErrorQuark  = IO Word32 -> m Word32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ do
    Word32
result <- IO Word32
g_markup_error_quark
    Word32 -> IO Word32
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
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 :: CGType -> CGType -> m (Ptr ())
mallocN nBlocks :: CGType
nBlocks nBlockBytes :: CGType
nBlockBytes = IO (Ptr ()) -> m (Ptr ())
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Ptr ()) -> m (Ptr ())) -> IO (Ptr ()) -> m (Ptr ())
forall a b. (a -> b) -> a -> b
$ do
    Ptr ()
result <- CGType -> CGType -> IO (Ptr ())
g_malloc_n CGType
nBlocks CGType
nBlockBytes
    Ptr () -> IO (Ptr ())
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr ()
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 :: CGType -> CGType -> m (Ptr ())
malloc0N nBlocks :: CGType
nBlocks nBlockBytes :: CGType
nBlockBytes = IO (Ptr ()) -> m (Ptr ())
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Ptr ()) -> m (Ptr ())) -> IO (Ptr ()) -> m (Ptr ())
forall a b. (a -> b) -> a -> b
$ do
    Ptr ()
result <- CGType -> CGType -> IO (Ptr ())
g_malloc0_n CGType
nBlocks CGType
nBlockBytes
    Ptr () -> IO (Ptr ())
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr ()
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 :: CGType -> m (Ptr ())
malloc0 nBytes :: CGType
nBytes = IO (Ptr ()) -> m (Ptr ())
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Ptr ()) -> m (Ptr ())) -> IO (Ptr ()) -> m (Ptr ())
forall a b. (a -> b) -> a -> b
$ do
    Ptr ()
result <- CGType -> IO (Ptr ())
g_malloc0 CGType
nBytes
    Ptr () -> IO (Ptr ())
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr ()
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 :: CGType -> m (Ptr ())
malloc nBytes :: CGType
nBytes = IO (Ptr ()) -> m (Ptr ())
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Ptr ()) -> m (Ptr ())) -> IO (Ptr ()) -> m (Ptr ())
forall a b. (a -> b) -> a -> b
$ do
    Ptr ()
result <- CGType -> IO (Ptr ())
g_malloc CGType
nBytes
    Ptr () -> IO (Ptr ())
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr ()
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 :: m Int32
mainDepth  = IO Int32 -> m Int32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int32 -> m Int32) -> IO Int32 -> m Int32
forall a b. (a -> b) -> a -> b
$ do
    Int32
result <- IO Int32
g_main_depth
    Int32 -> IO Int32
forall (m :: * -> *) a. Monad m => a -> m a
return Int32
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 :: m Source
mainCurrentSource  = IO Source -> m Source
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Source -> m Source) -> IO Source -> m Source
forall a b. (a -> b) -> a -> b
$ do
    Ptr Source
result <- IO (Ptr Source)
g_main_current_source
    Text -> Ptr Source -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "mainCurrentSource" Ptr Source
result
    Source
result' <- ((ManagedPtr Source -> Source) -> Ptr Source -> IO Source
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
newBoxed ManagedPtr Source -> Source
GLib.Source.Source) Ptr Source
result
    Source -> IO Source
forall (m :: * -> *) a. Monad m => a -> m a
return Source
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 :: Int32 -> m Bool
logWriterSupportsColor outputFd :: Int32
outputFd = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    CInt
result <- Int32 -> IO CInt
g_log_writer_supports_color Int32
outputFd
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
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 :: [LogLevelFlags] -> [LogField] -> Ptr () -> m LogWriterOutput
logWriterStandardStreams logLevel :: [LogLevelFlags]
logLevel fields :: [LogField]
fields userData :: Ptr ()
userData = IO LogWriterOutput -> m LogWriterOutput
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO LogWriterOutput -> m LogWriterOutput)
-> IO LogWriterOutput -> m LogWriterOutput
forall a b. (a -> b) -> a -> b
$ do
    let nFields :: CGType
nFields = Int -> CGType
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CGType) -> Int -> CGType
forall a b. (a -> b) -> a -> b
$ [LogField] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [LogField]
fields
    let logLevel' :: CInt
logLevel' = [LogLevelFlags] -> CInt
forall b a. (Num b, IsGFlag a) => [a] -> b
gflagsToWord [LogLevelFlags]
logLevel
    [Ptr LogField]
fields' <- (LogField -> IO (Ptr LogField)) -> [LogField] -> IO [Ptr LogField]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM LogField -> IO (Ptr LogField)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr [LogField]
fields
    Ptr LogField
fields'' <- Int -> [Ptr LogField] -> IO (Ptr LogField)
forall a. Int -> [Ptr a] -> IO (Ptr a)
packBlockArray 24 [Ptr LogField]
fields'
    CUInt
result <- CInt -> Ptr LogField -> CGType -> Ptr () -> IO CUInt
g_log_writer_standard_streams CInt
logLevel' Ptr LogField
fields'' CGType
nFields Ptr ()
userData
    let result' :: LogWriterOutput
result' = (Int -> LogWriterOutput
forall a. Enum a => Int -> a
toEnum (Int -> LogWriterOutput)
-> (CUInt -> Int) -> CUInt -> LogWriterOutput
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CUInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral) CUInt
result
    (LogField -> IO ()) -> [LogField] -> IO ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ LogField -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr [LogField]
fields
    Ptr LogField -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr LogField
fields''
    LogWriterOutput -> IO LogWriterOutput
forall (m :: * -> *) a. Monad m => a -> m a
return LogWriterOutput
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 :: [LogLevelFlags] -> [LogField] -> Ptr () -> m LogWriterOutput
logWriterJournald logLevel :: [LogLevelFlags]
logLevel fields :: [LogField]
fields userData :: Ptr ()
userData = IO LogWriterOutput -> m LogWriterOutput
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO LogWriterOutput -> m LogWriterOutput)
-> IO LogWriterOutput -> m LogWriterOutput
forall a b. (a -> b) -> a -> b
$ do
    let nFields :: CGType
nFields = Int -> CGType
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CGType) -> Int -> CGType
forall a b. (a -> b) -> a -> b
$ [LogField] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [LogField]
fields
    let logLevel' :: CInt
logLevel' = [LogLevelFlags] -> CInt
forall b a. (Num b, IsGFlag a) => [a] -> b
gflagsToWord [LogLevelFlags]
logLevel
    [Ptr LogField]
fields' <- (LogField -> IO (Ptr LogField)) -> [LogField] -> IO [Ptr LogField]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM LogField -> IO (Ptr LogField)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr [LogField]
fields
    Ptr LogField
fields'' <- Int -> [Ptr LogField] -> IO (Ptr LogField)
forall a. Int -> [Ptr a] -> IO (Ptr a)
packBlockArray 24 [Ptr LogField]
fields'
    CUInt
result <- CInt -> Ptr LogField -> CGType -> Ptr () -> IO CUInt
g_log_writer_journald CInt
logLevel' Ptr LogField
fields'' CGType
nFields Ptr ()
userData
    let result' :: LogWriterOutput
result' = (Int -> LogWriterOutput
forall a. Enum a => Int -> a
toEnum (Int -> LogWriterOutput)
-> (CUInt -> Int) -> CUInt -> LogWriterOutput
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CUInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral) CUInt
result
    (LogField -> IO ()) -> [LogField] -> IO ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ LogField -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr [LogField]
fields
    Ptr LogField -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr LogField
fields''
    LogWriterOutput -> IO LogWriterOutput
forall (m :: * -> *) a. Monad m => a -> m a
return LogWriterOutput
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 :: Int32 -> m Bool
logWriterIsJournald outputFd :: Int32
outputFd = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    CInt
result <- Int32 -> IO CInt
g_log_writer_is_journald Int32
outputFd
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
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 :: [LogLevelFlags] -> [LogField] -> Bool -> m Text
logWriterFormatFields logLevel :: [LogLevelFlags]
logLevel fields :: [LogField]
fields useColor :: Bool
useColor = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    let nFields :: CGType
nFields = Int -> CGType
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CGType) -> Int -> CGType
forall a b. (a -> b) -> a -> b
$ [LogField] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [LogField]
fields
    let logLevel' :: CInt
logLevel' = [LogLevelFlags] -> CInt
forall b a. (Num b, IsGFlag a) => [a] -> b
gflagsToWord [LogLevelFlags]
logLevel
    [Ptr LogField]
fields' <- (LogField -> IO (Ptr LogField)) -> [LogField] -> IO [Ptr LogField]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM LogField -> IO (Ptr LogField)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr [LogField]
fields
    Ptr LogField
fields'' <- Int -> [Ptr LogField] -> IO (Ptr LogField)
forall a. Int -> [Ptr a] -> IO (Ptr a)
packBlockArray 24 [Ptr LogField]
fields'
    let useColor' :: CInt
useColor' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Bool -> Int) -> Bool -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> Int
forall a. Enum a => a -> Int
fromEnum) Bool
useColor
    CString
result <- CInt -> Ptr LogField -> CGType -> CInt -> IO CString
g_log_writer_format_fields CInt
logLevel' Ptr LogField
fields'' CGType
nFields CInt
useColor'
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "logWriterFormatFields" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    (LogField -> IO ()) -> [LogField] -> IO ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ LogField -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr [LogField]
fields
    Ptr LogField -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr LogField
fields''
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
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 :: [LogLevelFlags] -> [LogField] -> Ptr () -> m LogWriterOutput
logWriterDefault logLevel :: [LogLevelFlags]
logLevel fields :: [LogField]
fields userData :: Ptr ()
userData = IO LogWriterOutput -> m LogWriterOutput
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO LogWriterOutput -> m LogWriterOutput)
-> IO LogWriterOutput -> m LogWriterOutput
forall a b. (a -> b) -> a -> b
$ do
    let nFields :: CGType
nFields = Int -> CGType
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CGType) -> Int -> CGType
forall a b. (a -> b) -> a -> b
$ [LogField] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [LogField]
fields
    let logLevel' :: CInt
logLevel' = [LogLevelFlags] -> CInt
forall b a. (Num b, IsGFlag a) => [a] -> b
gflagsToWord [LogLevelFlags]
logLevel
    [Ptr LogField]
fields' <- (LogField -> IO (Ptr LogField)) -> [LogField] -> IO [Ptr LogField]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM LogField -> IO (Ptr LogField)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr [LogField]
fields
    Ptr LogField
fields'' <- Int -> [Ptr LogField] -> IO (Ptr LogField)
forall a. Int -> [Ptr a] -> IO (Ptr a)
packBlockArray 24 [Ptr LogField]
fields'
    CUInt
result <- CInt -> Ptr LogField -> CGType -> Ptr () -> IO CUInt
g_log_writer_default CInt
logLevel' Ptr LogField
fields'' CGType
nFields Ptr ()
userData
    let result' :: LogWriterOutput
result' = (Int -> LogWriterOutput
forall a. Enum a => Int -> a
toEnum (Int -> LogWriterOutput)
-> (CUInt -> Int) -> CUInt -> LogWriterOutput
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CUInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral) CUInt
result
    (LogField -> IO ()) -> [LogField] -> IO ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ LogField -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr [LogField]
fields
    Ptr LogField -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr LogField
fields''
    LogWriterOutput -> IO LogWriterOutput
forall (m :: * -> *) a. Monad m => a -> m a
return LogWriterOutput
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 :: Maybe Text -> [LogLevelFlags] -> GVariant -> m ()
logVariant logDomain :: Maybe Text
logDomain logLevel :: [LogLevelFlags]
logLevel fields :: GVariant
fields = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    CString
maybeLogDomain <- case Maybe Text
logDomain of
        Nothing -> CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
forall a. Ptr a
nullPtr
        Just jLogDomain :: Text
jLogDomain -> do
            CString
jLogDomain' <- Text -> IO CString
textToCString Text
jLogDomain
            CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
jLogDomain'
    let logLevel' :: CInt
logLevel' = [LogLevelFlags] -> CInt
forall b a. (Num b, IsGFlag a) => [a] -> b
gflagsToWord [LogLevelFlags]
logLevel
    Ptr GVariant
fields' <- GVariant -> IO (Ptr GVariant)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr GVariant
fields
    CString -> CInt -> Ptr GVariant -> IO ()
g_log_variant CString
maybeLogDomain CInt
logLevel' Ptr GVariant
fields'
    GVariant -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr GVariant
fields
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeLogDomain
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
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 :: [LogLevelFlags] -> [LogField] -> m ()
logStructuredArray logLevel :: [LogLevelFlags]
logLevel fields :: [LogField]
fields = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    let nFields :: CGType
nFields = Int -> CGType
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CGType) -> Int -> CGType
forall a b. (a -> b) -> a -> b
$ [LogField] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [LogField]
fields
    let logLevel' :: CInt
logLevel' = [LogLevelFlags] -> CInt
forall b a. (Num b, IsGFlag a) => [a] -> b
gflagsToWord [LogLevelFlags]
logLevel
    [Ptr LogField]
fields' <- (LogField -> IO (Ptr LogField)) -> [LogField] -> IO [Ptr LogField]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM LogField -> IO (Ptr LogField)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr [LogField]
fields
    Ptr LogField
fields'' <- Int -> [Ptr LogField] -> IO (Ptr LogField)
forall a. Int -> [Ptr a] -> IO (Ptr a)
packBlockArray 24 [Ptr LogField]
fields'
    CInt -> Ptr LogField -> CGType -> IO ()
g_log_structured_array CInt
logLevel' Ptr LogField
fields'' CGType
nFields
    (LogField -> IO ()) -> [LogField] -> IO ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ LogField -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr [LogField]
fields
    Ptr LogField -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr LogField
fields''
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
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 :: Maybe Text -> [LogLevelFlags] -> LogFunc -> m Word32
logSetHandler logDomain :: Maybe Text
logDomain logLevels :: [LogLevelFlags]
logLevels logFunc :: LogFunc
logFunc = IO Word32 -> m Word32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ do
    CString
maybeLogDomain <- case Maybe Text
logDomain of
        Nothing -> CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
forall a. Ptr a
nullPtr
        Just jLogDomain :: Text
jLogDomain -> do
            CString
jLogDomain' <- Text -> IO CString
textToCString Text
jLogDomain
            CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
jLogDomain'
    let logLevels' :: CInt
logLevels' = [LogLevelFlags] -> CInt
forall b a. (Num b, IsGFlag a) => [a] -> b
gflagsToWord [LogLevelFlags]
logLevels
    FunPtr C_LogFunc
logFunc' <- C_LogFunc -> IO (FunPtr C_LogFunc)
GLib.Callbacks.mk_LogFunc (Maybe (Ptr (FunPtr C_LogFunc)) -> LogFunc_WithClosures -> C_LogFunc
GLib.Callbacks.wrap_LogFunc Maybe (Ptr (FunPtr C_LogFunc))
forall a. Maybe a
Nothing (LogFunc -> LogFunc_WithClosures
GLib.Callbacks.drop_closures_LogFunc LogFunc
logFunc))
    let userData :: Ptr ()
userData = FunPtr C_LogFunc -> Ptr ()
forall a b. FunPtr a -> Ptr b
castFunPtrToPtr FunPtr C_LogFunc
logFunc'
    let destroy :: FunPtr (Ptr a -> IO ())
destroy = FunPtr (Ptr a -> IO ())
forall a. FunPtr (Ptr a -> IO ())
safeFreeFunPtrPtr
    Word32
result <- CString
-> CInt
-> FunPtr C_LogFunc
-> Ptr ()
-> FunPtr C_DestroyNotify
-> IO Word32
g_log_set_handler_full CString
maybeLogDomain CInt
logLevels' FunPtr C_LogFunc
logFunc' Ptr ()
userData FunPtr C_DestroyNotify
forall a. FunPtr (Ptr a -> IO ())
destroy
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeLogDomain
    Word32 -> IO Word32
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
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 :: Text -> [LogLevelFlags] -> m [LogLevelFlags]
logSetFatalMask logDomain :: Text
logDomain fatalMask :: [LogLevelFlags]
fatalMask = IO [LogLevelFlags] -> m [LogLevelFlags]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [LogLevelFlags] -> m [LogLevelFlags])
-> IO [LogLevelFlags] -> m [LogLevelFlags]
forall a b. (a -> b) -> a -> b
$ do
    CString
logDomain' <- Text -> IO CString
textToCString Text
logDomain
    let fatalMask' :: CInt
fatalMask' = [LogLevelFlags] -> CInt
forall b a. (Num b, IsGFlag a) => [a] -> b
gflagsToWord [LogLevelFlags]
fatalMask
    CInt
result <- CString -> CInt -> IO CInt
g_log_set_fatal_mask CString
logDomain' CInt
fatalMask'
    let result' :: [LogLevelFlags]
result' = CInt -> [LogLevelFlags]
forall a b. (Storable a, Integral a, Bits a, IsGFlag b) => a -> [b]
wordToGFlags CInt
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
logDomain'
    [LogLevelFlags] -> IO [LogLevelFlags]
forall (m :: * -> *) a. Monad m => a -> m a
return [LogLevelFlags]
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 :: [LogLevelFlags] -> m [LogLevelFlags]
logSetAlwaysFatal fatalMask :: [LogLevelFlags]
fatalMask = IO [LogLevelFlags] -> m [LogLevelFlags]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [LogLevelFlags] -> m [LogLevelFlags])
-> IO [LogLevelFlags] -> m [LogLevelFlags]
forall a b. (a -> b) -> a -> b
$ do
    let fatalMask' :: CInt
fatalMask' = [LogLevelFlags] -> CInt
forall b a. (Num b, IsGFlag a) => [a] -> b
gflagsToWord [LogLevelFlags]
fatalMask
    CInt
result <- CInt -> IO CInt
g_log_set_always_fatal CInt
fatalMask'
    let result' :: [LogLevelFlags]
result' = CInt -> [LogLevelFlags]
forall a b. (Storable a, Integral a, Bits a, IsGFlag b) => a -> [b]
wordToGFlags CInt
result
    [LogLevelFlags] -> IO [LogLevelFlags]
forall (m :: * -> *) a. Monad m => a -> m a
return [LogLevelFlags]
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 :: Text -> Word32 -> m ()
logRemoveHandler logDomain :: Text
logDomain handlerId :: Word32
handlerId = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    CString
logDomain' <- Text -> IO CString
textToCString Text
logDomain
    CString -> Word32 -> IO ()
g_log_remove_handler CString
logDomain' Word32
handlerId
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
logDomain'
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
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 :: Maybe Text -> [LogLevelFlags] -> Maybe Text -> Ptr () -> m ()
logDefaultHandler logDomain :: Maybe Text
logDomain logLevel :: [LogLevelFlags]
logLevel message :: Maybe Text
message unusedData :: Ptr ()
unusedData = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    CString
maybeLogDomain <- case Maybe Text
logDomain of
        Nothing -> CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
forall a. Ptr a
nullPtr
        Just jLogDomain :: Text
jLogDomain -> do
            CString
jLogDomain' <- Text -> IO CString
textToCString Text
jLogDomain
            CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
jLogDomain'
    let logLevel' :: CInt
logLevel' = [LogLevelFlags] -> CInt
forall b a. (Num b, IsGFlag a) => [a] -> b
gflagsToWord [LogLevelFlags]
logLevel
    CString
maybeMessage <- case Maybe Text
message of
        Nothing -> CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
forall a. Ptr a
nullPtr
        Just jMessage :: Text
jMessage -> do
            CString
jMessage' <- Text -> IO CString
textToCString Text
jMessage
            CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
jMessage'
    C_LogFunc
g_log_default_handler CString
maybeLogDomain CInt
logLevel' CString
maybeMessage Ptr ()
unusedData
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeLogDomain
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeMessage
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
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 :: ByteString -> m (Text, CGType, CGType)
localeToUtf8 opsysstring :: ByteString
opsysstring = IO (Text, CGType, CGType) -> m (Text, CGType, CGType)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Text, CGType, CGType) -> m (Text, CGType, CGType))
-> IO (Text, CGType, CGType) -> m (Text, CGType, CGType)
forall a b. (a -> b) -> a -> b
$ do
    let len :: Int64
len = Int -> Int64
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> Int64) -> Int -> Int64
forall a b. (a -> b) -> a -> b
$ ByteString -> Int
B.length ByteString
opsysstring
    Ptr Word8
opsysstring' <- ByteString -> IO (Ptr Word8)
packByteString ByteString
opsysstring
    Ptr CGType
bytesRead <- IO (Ptr CGType)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Word64)
    Ptr CGType
bytesWritten <- IO (Ptr CGType)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Word64)
    IO (Text, CGType, CGType) -> IO () -> IO (Text, CGType, CGType)
forall a b. IO a -> IO b -> IO a
onException (do
        CString
result <- (Ptr (Ptr GError) -> IO CString) -> IO CString
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CString) -> IO CString)
-> (Ptr (Ptr GError) -> IO CString) -> IO CString
forall a b. (a -> b) -> a -> b
$ Ptr Word8
-> Int64
-> Ptr CGType
-> Ptr CGType
-> Ptr (Ptr GError)
-> IO CString
g_locale_to_utf8 Ptr Word8
opsysstring' Int64
len Ptr CGType
bytesRead Ptr CGType
bytesWritten
        Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "localeToUtf8" CString
result
        Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
        CGType
bytesRead' <- Ptr CGType -> IO CGType
forall a. Storable a => Ptr a -> IO a
peek Ptr CGType
bytesRead
        CGType
bytesWritten' <- Ptr CGType -> IO CGType
forall a. Storable a => Ptr a -> IO a
peek Ptr CGType
bytesWritten
        Ptr Word8 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word8
opsysstring'
        Ptr CGType -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CGType
bytesRead
        Ptr CGType -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CGType
bytesWritten
        (Text, CGType, CGType) -> IO (Text, CGType, CGType)
forall (m :: * -> *) a. Monad m => a -> m a
return (Text
result', CGType
bytesRead', CGType
bytesWritten')
     ) (do
        Ptr Word8 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word8
opsysstring'
        Ptr CGType -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CGType
bytesRead
        Ptr CGType -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CGType
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 :: Text -> Int64 -> m (ByteString, CGType)
localeFromUtf8 utf8string :: Text
utf8string len :: Int64
len = IO (ByteString, CGType) -> m (ByteString, CGType)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (ByteString, CGType) -> m (ByteString, CGType))
-> IO (ByteString, CGType) -> m (ByteString, CGType)
forall a b. (a -> b) -> a -> b
$ do
    CString
utf8string' <- Text -> IO CString
textToCString Text
utf8string
    Ptr CGType
bytesRead <- IO (Ptr CGType)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Word64)
    Ptr CGType
bytesWritten <- IO (Ptr CGType)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Word64)
    IO (ByteString, CGType) -> IO () -> IO (ByteString, CGType)
forall a b. IO a -> IO b -> IO a
onException (do
        Ptr Word8
result <- (Ptr (Ptr GError) -> IO (Ptr Word8)) -> IO (Ptr Word8)
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO (Ptr Word8)) -> IO (Ptr Word8))
-> (Ptr (Ptr GError) -> IO (Ptr Word8)) -> IO (Ptr Word8)
forall a b. (a -> b) -> a -> b
$ CString
-> Int64
-> Ptr CGType
-> Ptr CGType
-> Ptr (Ptr GError)
-> IO (Ptr Word8)
g_locale_from_utf8 CString
utf8string' Int64
len Ptr CGType
bytesRead Ptr CGType
bytesWritten
        CGType
bytesWritten' <- Ptr CGType -> IO CGType
forall a. Storable a => Ptr a -> IO a
peek Ptr CGType
bytesWritten
        Text -> Ptr Word8 -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "localeFromUtf8" Ptr Word8
result
        ByteString
result' <- (CGType -> Ptr Word8 -> IO ByteString
forall a. Integral a => a -> Ptr Word8 -> IO ByteString
unpackByteStringWithLength CGType
bytesWritten') Ptr Word8
result
        Ptr Word8 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word8
result
        CGType
bytesRead' <- Ptr CGType -> IO CGType
forall a. Storable a => Ptr a -> IO a
peek Ptr CGType
bytesRead
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
utf8string'
        Ptr CGType -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CGType
bytesRead
        Ptr CGType -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CGType
bytesWritten
        (ByteString, CGType) -> IO (ByteString, CGType)
forall (m :: * -> *) a. Monad m => a -> m a
return (ByteString
result', CGType
bytesRead')
     ) (do
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
utf8string'
        Ptr CGType -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CGType
bytesRead
        Ptr CGType -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CGType
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 :: m [[Char]]
listenv  = IO [[Char]] -> m [[Char]]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [[Char]] -> m [[Char]]) -> IO [[Char]] -> m [[Char]]
forall a b. (a -> b) -> a -> b
$ do
    Ptr CString
result <- IO (Ptr CString)
g_listenv
    Text -> Ptr CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "listenv" Ptr CString
result
    [[Char]]
result' <- HasCallStack => Ptr CString -> IO [[Char]]
Ptr CString -> IO [[Char]]
unpackZeroTerminatedFileNameArray Ptr CString
result
    (CString -> IO ()) -> Ptr CString -> IO ()
forall a b. (Ptr a -> IO b) -> Ptr (Ptr a) -> IO ()
mapZeroTerminatedCArray CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
result
    Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
result
    [[Char]] -> IO [[Char]]
forall (m :: * -> *) a. Monad m => a -> m a
return [[Char]]
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.

The callback function invoked by the 'GI.GLib.Structs.Source.Source' should be added with
'GI.GLib.Structs.Source.sourceSetCallback', but it has type 'GI.GLib.Callbacks.IOFunc' (not 'GI.GLib.Callbacks.SourceFunc').

@/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 :: IOChannel -> [IOCondition] -> m Source
ioCreateWatch channel :: IOChannel
channel condition :: [IOCondition]
condition = IO Source -> m Source
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Source -> m Source) -> IO Source -> m Source
forall a b. (a -> b) -> a -> b
$ do
    Ptr IOChannel
channel' <- IOChannel -> IO (Ptr IOChannel)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr IOChannel
channel
    let condition' :: CUInt
condition' = [IOCondition] -> CUInt
forall b a. (Num b, IsGFlag a) => [a] -> b
gflagsToWord [IOCondition]
condition
    Ptr Source
result <- Ptr IOChannel -> CUInt -> IO (Ptr Source)
g_io_create_watch Ptr IOChannel
channel' CUInt
condition'
    Text -> Ptr Source -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "ioCreateWatch" Ptr Source
result
    Source
result' <- ((ManagedPtr Source -> Source) -> Ptr Source -> IO Source
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Source -> Source
GLib.Source.Source) Ptr Source
result
    IOChannel -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr IOChannel
channel
    Source -> IO Source
forall (m :: * -> *) a. Monad m => a -> m a
return Source
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 :: IOChannel -> Int32 -> [IOCondition] -> IOFunc -> m Word32
ioAddWatch channel :: IOChannel
channel priority :: Int32
priority condition :: [IOCondition]
condition func :: IOFunc
func = IO Word32 -> m Word32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ do
    Ptr IOChannel
channel' <- IOChannel -> IO (Ptr IOChannel)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr IOChannel
channel
    let condition' :: CUInt
condition' = [IOCondition] -> CUInt
forall b a. (Num b, IsGFlag a) => [a] -> b
gflagsToWord [IOCondition]
condition
    FunPtr C_IOFunc
func' <- C_IOFunc -> IO (FunPtr C_IOFunc)
GLib.Callbacks.mk_IOFunc (Maybe (Ptr (FunPtr C_IOFunc)) -> IOFunc -> C_IOFunc
GLib.Callbacks.wrap_IOFunc Maybe (Ptr (FunPtr C_IOFunc))
forall a. Maybe a
Nothing IOFunc
func)
    let userData :: Ptr ()
userData = FunPtr C_IOFunc -> Ptr ()
forall a b. FunPtr a -> Ptr b
castFunPtrToPtr FunPtr C_IOFunc
func'
    let notify :: FunPtr (Ptr a -> IO ())
notify = FunPtr (Ptr a -> IO ())
forall a. FunPtr (Ptr a -> IO ())
safeFreeFunPtrPtr
    Word32
result <- Ptr IOChannel
-> Int32
-> CUInt
-> FunPtr C_IOFunc
-> Ptr ()
-> FunPtr C_DestroyNotify
-> IO Word32
g_io_add_watch_full Ptr IOChannel
channel' Int32
priority CUInt
condition' FunPtr C_IOFunc
func' Ptr ()
userData FunPtr C_DestroyNotify
forall a. FunPtr (Ptr a -> IO ())
notify
    IOChannel -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr IOChannel
channel
    Word32 -> IO Word32
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
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()/@.

This function must not be used before library constructors have finished
running. In particular, this means it cannot be used to initialize global
variables in C++.

/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 :: Maybe Text -> m Text
internString string :: Maybe Text
string = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
maybeString <- case Maybe Text
string of
        Nothing -> CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
forall a. Ptr a
nullPtr
        Just jString :: Text
jString -> do
            CString
jString' <- Text -> IO CString
textToCString Text
jString
            CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
jString'
    CString
result <- CString -> IO CString
g_intern_string CString
maybeString
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "internString" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeString
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
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.

This function must not be used before library constructors have finished
running. In particular, this means it cannot be used to initialize global
variables in C++.

/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 :: Maybe Text -> m Text
internStaticString string :: Maybe Text
string = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
maybeString <- case Maybe Text
string of
        Nothing -> CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
forall a. Ptr a
nullPtr
        Just jString :: Text
jString -> do
            CString
jString' <- Text -> IO CString
textToCString Text
jString
            CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
jString'
    CString
result <- CString -> IO CString
g_intern_static_string CString
maybeString
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "internStaticString" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeString
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
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 :: Ptr () -> m Word32
intHash v :: Ptr ()
v = IO Word32 -> m Word32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ do
    Word32
result <- Ptr () -> IO Word32
g_int_hash Ptr ()
v
    Word32 -> IO Word32
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
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 :: Ptr () -> Ptr () -> m Bool
intEqual v1 :: Ptr ()
v1 v2 :: Ptr ()
v2 = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    CInt
result <- Ptr () -> C_SourceFunc
g_int_equal Ptr ()
v1 Ptr ()
v2
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
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 :: Ptr () -> m Word32
int64Hash v :: Ptr ()
v = IO Word32 -> m Word32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ do
    Word32
result <- Ptr () -> IO Word32
g_int64_hash Ptr ()
v
    Word32 -> IO Word32
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
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 :: Ptr () -> Ptr () -> m Bool
int64Equal v1 :: Ptr ()
v1 v2 :: Ptr ()
v2 = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    CInt
result <- Ptr () -> C_SourceFunc
g_int64_equal Ptr ()
v1 Ptr ()
v2
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
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 :: m Source
idleSourceNew  = IO Source -> m Source
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Source -> m Source) -> IO Source -> m Source
forall a b. (a -> b) -> a -> b
$ do
    Ptr Source
result <- IO (Ptr Source)
g_idle_source_new
    Text -> Ptr Source -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "idleSourceNew" Ptr Source
result
    Source
result' <- ((ManagedPtr Source -> Source) -> Ptr Source -> IO Source
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Source -> Source
GLib.Source.Source) Ptr Source
result
    Source -> IO Source
forall (m :: * -> *) a. Monad m => a -> m a
return Source
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 :: Ptr () -> m Bool
idleRemoveByData data_ :: Ptr ()
data_ = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    CInt
result <- C_SourceFunc
g_idle_remove_by_data Ptr ()
data_
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
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 :: Int32 -> IO Bool -> m Word32
idleAdd priority :: Int32
priority function :: IO Bool
function = IO Word32 -> m Word32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ do
    FunPtr C_SourceFunc
function' <- C_SourceFunc -> IO (FunPtr C_SourceFunc)
GLib.Callbacks.mk_SourceFunc (Maybe (Ptr (FunPtr C_SourceFunc))
-> SourceFunc_WithClosures -> C_SourceFunc
GLib.Callbacks.wrap_SourceFunc Maybe (Ptr (FunPtr C_SourceFunc))
forall a. Maybe a
Nothing (IO Bool -> SourceFunc_WithClosures
GLib.Callbacks.drop_closures_SourceFunc IO Bool
function))
    let data_ :: Ptr ()
data_ = FunPtr C_SourceFunc -> Ptr ()
forall a b. FunPtr a -> Ptr b
castFunPtrToPtr FunPtr C_SourceFunc
function'
    let notify :: FunPtr (Ptr a -> IO ())
notify = FunPtr (Ptr a -> IO ())
forall a. FunPtr (Ptr a -> IO ())
safeFreeFunPtrPtr
    Word32
result <- Int32
-> FunPtr C_SourceFunc
-> Ptr ()
-> FunPtr C_DestroyNotify
-> IO Word32
g_idle_add_full Int32
priority FunPtr C_SourceFunc
function' Ptr ()
data_ FunPtr C_DestroyNotify
forall a. FunPtr (Ptr a -> IO ())
notify
    Word32 -> IO Word32
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
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 :: Text -> m Text
hostnameToUnicode hostname :: Text
hostname = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
hostname' <- Text -> IO CString
textToCString Text
hostname
    CString
result <- CString -> IO CString
g_hostname_to_unicode CString
hostname'
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "hostnameToUnicode" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
hostname'
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
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 :: Text -> m Text
hostnameToAscii hostname :: Text
hostname = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
hostname' <- Text -> IO CString
textToCString Text
hostname
    CString
result <- CString -> IO CString
g_hostname_to_ascii CString
hostname'
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "hostnameToAscii" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
hostname'
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
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 :: Text -> m Bool
hostnameIsNonAscii hostname :: Text
hostname = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    CString
hostname' <- Text -> IO CString
textToCString Text
hostname
    CInt
result <- CString -> IO CInt
g_hostname_is_non_ascii CString
hostname'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
hostname'
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
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 :: Text -> m Bool
hostnameIsIpAddress hostname :: Text
hostname = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    CString
hostname' <- Text -> IO CString
textToCString Text
hostname
    CInt
result <- CString -> IO CInt
g_hostname_is_ip_address CString
hostname'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
hostname'
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
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 :: Text -> m Bool
hostnameIsAsciiEncoded hostname :: Text
hostname = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    CString
hostname' <- Text -> IO CString
textToCString Text
hostname
    CInt
result <- CString -> IO CInt
g_hostname_is_ascii_encoded CString
hostname'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
hostname'
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
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 :: [Char] -> m [Char]
getenv variable :: [Char]
variable = IO [Char] -> m [Char]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [Char] -> m [Char]) -> IO [Char] -> m [Char]
forall a b. (a -> b) -> a -> b
$ do
    CString
variable' <- [Char] -> IO CString
stringToCString [Char]
variable
    CString
result <- CString -> IO CString
g_getenv CString
variable'
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "getenv" CString
result
    [Char]
result' <- HasCallStack => CString -> IO [Char]
CString -> IO [Char]
cstringToString CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
variable'
    [Char] -> IO [Char]
forall (m :: * -> *) a. Monad m => a -> m a
return [Char]
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 :: UserDirectory -> m [Char]
getUserSpecialDir directory :: UserDirectory
directory = IO [Char] -> m [Char]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [Char] -> m [Char]) -> IO [Char] -> m [Char]
forall a b. (a -> b) -> a -> b
$ do
    let directory' :: CUInt
directory' = (Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CUInt) -> (UserDirectory -> Int) -> UserDirectory -> CUInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. UserDirectory -> Int
forall a. Enum a => a -> Int
fromEnum) UserDirectory
directory
    CString
result <- CUInt -> IO CString
g_get_user_special_dir CUInt
directory'
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "getUserSpecialDir" CString
result
    [Char]
result' <- HasCallStack => CString -> IO [Char]
CString -> IO [Char]
cstringToString CString
result
    [Char] -> IO [Char]
forall (m :: * -> *) a. Monad m => a -> m a
return [Char]
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 :: m [Char]
getUserRuntimeDir  = IO [Char] -> m [Char]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [Char] -> m [Char]) -> IO [Char] -> m [Char]
forall a b. (a -> b) -> a -> b
$ do
    CString
result <- IO CString
g_get_user_runtime_dir
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "getUserRuntimeDir" CString
result
    [Char]
result' <- HasCallStack => CString -> IO [Char]
CString -> IO [Char]
cstringToString CString
result
    [Char] -> IO [Char]
forall (m :: * -> *) a. Monad m => a -> m a
return [Char]
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 :: m [Char]
getUserName  = IO [Char] -> m [Char]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [Char] -> m [Char]) -> IO [Char] -> m [Char]
forall a b. (a -> b) -> a -> b
$ do
    CString
result <- IO CString
g_get_user_name
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "getUserName" CString
result
    [Char]
result' <- HasCallStack => CString -> IO [Char]
CString -> IO [Char]
cstringToString CString
result
    [Char] -> IO [Char]
forall (m :: * -> *) a. Monad m => a -> m a
return [Char]
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 :: m [Char]
getUserDataDir  = IO [Char] -> m [Char]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [Char] -> m [Char]) -> IO [Char] -> m [Char]
forall a b. (a -> b) -> a -> b
$ do
    CString
result <- IO CString
g_get_user_data_dir
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "getUserDataDir" CString
result
    [Char]
result' <- HasCallStack => CString -> IO [Char]
CString -> IO [Char]
cstringToString CString
result
    [Char] -> IO [Char]
forall (m :: * -> *) a. Monad m => a -> m a
return [Char]
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 :: m [Char]
getUserConfigDir  = IO [Char] -> m [Char]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [Char] -> m [Char]) -> IO [Char] -> m [Char]
forall a b. (a -> b) -> a -> b
$ do
    CString
result <- IO CString
g_get_user_config_dir
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "getUserConfigDir" CString
result
    [Char]
result' <- HasCallStack => CString -> IO [Char]
CString -> IO [Char]
cstringToString CString
result
    [Char] -> IO [Char]
forall (m :: * -> *) a. Monad m => a -> m a
return [Char]
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 :: m [Char]
getUserCacheDir  = IO [Char] -> m [Char]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [Char] -> m [Char]) -> IO [Char] -> m [Char]
forall a b. (a -> b) -> a -> b
$ do
    CString
result <- IO CString
g_get_user_cache_dir
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "getUserCacheDir" CString
result
    [Char]
result' <- HasCallStack => CString -> IO [Char]
CString -> IO [Char]
cstringToString CString
result
    [Char] -> IO [Char]
forall (m :: * -> *) a. Monad m => a -> m a
return [Char]
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 :: m [Char]
getTmpDir  = IO [Char] -> m [Char]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [Char] -> m [Char]) -> IO [Char] -> m [Char]
forall a b. (a -> b) -> a -> b
$ do
    CString
result <- IO CString
g_get_tmp_dir
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "getTmpDir" CString
result
    [Char]
result' <- HasCallStack => CString -> IO [Char]
CString -> IO [Char]
cstringToString CString
result
    [Char] -> IO [Char]
forall (m :: * -> *) a. Monad m => a -> m a
return [Char]
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 :: m [[Char]]
getSystemDataDirs  = IO [[Char]] -> m [[Char]]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [[Char]] -> m [[Char]]) -> IO [[Char]] -> m [[Char]]
forall a b. (a -> b) -> a -> b
$ do
    Ptr CString
result <- IO (Ptr CString)
g_get_system_data_dirs
    Text -> Ptr CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "getSystemDataDirs" Ptr CString
result
    [[Char]]
result' <- HasCallStack => Ptr CString -> IO [[Char]]
Ptr CString -> IO [[Char]]
unpackZeroTerminatedFileNameArray Ptr CString
result
    [[Char]] -> IO [[Char]]
forall (m :: * -> *) a. Monad m => a -> m a
return [[Char]]
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 :: m [[Char]]
getSystemConfigDirs  = IO [[Char]] -> m [[Char]]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [[Char]] -> m [[Char]]) -> IO [[Char]] -> m [[Char]]
forall a b. (a -> b) -> a -> b
$ do
    Ptr CString
result <- IO (Ptr CString)
g_get_system_config_dirs
    Text -> Ptr CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "getSystemConfigDirs" Ptr CString
result
    [[Char]]
result' <- HasCallStack => Ptr CString -> IO [[Char]]
Ptr CString -> IO [[Char]]
unpackZeroTerminatedFileNameArray Ptr CString
result
    [[Char]] -> IO [[Char]]
forall (m :: * -> *) a. Monad m => a -> m a
return [[Char]]
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 :: m Int64
getRealTime  = IO Int64 -> m Int64
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int64 -> m Int64) -> IO Int64 -> m Int64
forall a b. (a -> b) -> a -> b
$ do
    Int64
result <- IO Int64
g_get_real_time
    Int64 -> IO Int64
forall (m :: * -> *) a. Monad m => a -> m a
return Int64
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 :: m [Char]
getRealName  = IO [Char] -> m [Char]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [Char] -> m [Char]) -> IO [Char] -> m [Char]
forall a b. (a -> b) -> a -> b
$ do
    CString
result <- IO CString
g_get_real_name
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "getRealName" CString
result
    [Char]
result' <- HasCallStack => CString -> IO [Char]
CString -> IO [Char]
cstringToString CString
result
    [Char] -> IO [Char]
forall (m :: * -> *) a. Monad m => a -> m a
return [Char]
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 (Maybe T.Text)
    {- ^ __Returns:__ the name of the program,
  or 'Nothing' if it has not been set yet. The returned string belongs
  to GLib and must not be modified or freed. -}
getPrgname :: m (Maybe Text)
getPrgname  = IO (Maybe Text) -> m (Maybe Text)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Text) -> m (Maybe Text))
-> IO (Maybe Text) -> m (Maybe Text)
forall a b. (a -> b) -> a -> b
$ do
    CString
result <- IO CString
g_get_prgname
    Maybe Text
maybeResult <- CString -> (CString -> IO Text) -> IO (Maybe Text)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull CString
result ((CString -> IO Text) -> IO (Maybe Text))
-> (CString -> IO Text) -> IO (Maybe Text)
forall a b. (a -> b) -> a -> b
$ \result' :: CString
result' -> do
        Text
result'' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result'
        Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result''
    Maybe Text -> IO (Maybe Text)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Text
maybeResult


-- function g_get_os_info
-- Args : [Arg {argCName = "key_name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a key for the OS info being requested, for example %G_OS_INFO_KEY_NAME.", 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_get_os_info" g_get_os_info :: 
    CString ->                              -- key_name : TBasicType TUTF8
    IO CString

{- |
Get information about the operating system.

On Linux this comes from the @\/etc\/os-release@ file. On other systems, it may
come from a variety of sources. You can either use the standard key names
like @/G_OS_INFO_KEY_NAME/@ or pass any UTF-8 string key name. For example,
@\/etc\/os-release@ provides a number of other less commonly used values that may
be useful. No key is guaranteed to be provided, so the caller should always
check if the result is 'Nothing'.

/Since: 2.64/
-}
getOsInfo ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@keyName@/: a key for the OS info being requested, for example @/G_OS_INFO_KEY_NAME/@. -}
    -> m (Maybe T.Text)
    {- ^ __Returns:__ The associated value for the requested key or 'Nothing' if
  this information is not provided. -}
getOsInfo :: Text -> m (Maybe Text)
getOsInfo keyName :: Text
keyName = IO (Maybe Text) -> m (Maybe Text)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Text) -> m (Maybe Text))
-> IO (Maybe Text) -> m (Maybe Text)
forall a b. (a -> b) -> a -> b
$ do
    CString
keyName' <- Text -> IO CString
textToCString Text
keyName
    CString
result <- CString -> IO CString
g_get_os_info CString
keyName'
    Maybe Text
maybeResult <- CString -> (CString -> IO Text) -> IO (Maybe Text)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull CString
result ((CString -> IO Text) -> IO (Maybe Text))
-> (CString -> IO Text) -> IO (Maybe Text)
forall a b. (a -> b) -> a -> b
$ \result' :: CString
result' -> do
        Text
result'' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result'
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result'
        Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result''
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
keyName'
    Maybe Text -> IO (Maybe Text)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Text
maybeResult


-- 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 :: m Word32
getNumProcessors  = IO Word32 -> m Word32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ do
    Word32
result <- IO Word32
g_get_num_processors
    Word32 -> IO Word32
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
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 :: m Int64
getMonotonicTime  = IO Int64 -> m Int64
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int64 -> m Int64) -> IO Int64 -> m Int64
forall a b. (a -> b) -> a -> b
$ do
    Int64
result <- IO Int64
g_get_monotonic_time
    Int64 -> IO Int64
forall (m :: * -> *) a. Monad m => a -> m a
return Int64
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. See
<http://developer.gnome.org/glib/stable/man:setlocale `setlocale(3)`> for information about locales and their format.

/@locale@/ itself is guaranteed to be returned in the output.

For example, if /@locale@/ is @fr_BE@, then the returned list
is @fr_BE@, @fr@. If /@locale@/ is @en_GB.UTF-8\@euro@, then the returned list
is @en_GB.UTF-8\@euro@, @en_GB.UTF-8@, @en_GB\@euro@, @en_GB@, @en.UTF-8\@euro@,
@en.UTF-8@, @en\@euro@, @en@.

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 :: Text -> m [Text]
getLocaleVariants locale :: Text
locale = IO [Text] -> m [Text]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [Text] -> m [Text]) -> IO [Text] -> m [Text]
forall a b. (a -> b) -> a -> b
$ do
    CString
locale' <- Text -> IO CString
textToCString Text
locale
    Ptr CString
result <- CString -> IO (Ptr CString)
g_get_locale_variants CString
locale'
    Text -> Ptr CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "getLocaleVariants" Ptr CString
result
    [Text]
result' <- HasCallStack => Ptr CString -> IO [Text]
Ptr CString -> IO [Text]
unpackZeroTerminatedUTF8CArray Ptr CString
result
    (CString -> IO ()) -> Ptr CString -> IO ()
forall a b. (Ptr a -> IO b) -> Ptr (Ptr a) -> IO ()
mapZeroTerminatedCArray CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
result
    Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
locale'
    [Text] -> IO [Text]
forall (m :: * -> *) a. Monad m => a -> m a
return [Text]
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 :: Text -> m [Text]
getLanguageNamesWithCategory categoryName :: Text
categoryName = IO [Text] -> m [Text]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [Text] -> m [Text]) -> IO [Text] -> m [Text]
forall a b. (a -> b) -> a -> b
$ do
    CString
categoryName' <- Text -> IO CString
textToCString Text
categoryName
    Ptr CString
result <- CString -> IO (Ptr CString)
g_get_language_names_with_category CString
categoryName'
    Text -> Ptr CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "getLanguageNamesWithCategory" Ptr CString
result
    [Text]
result' <- HasCallStack => Ptr CString -> IO [Text]
Ptr CString -> IO [Text]
unpackZeroTerminatedUTF8CArray Ptr CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
categoryName'
    [Text] -> IO [Text]
forall (m :: * -> *) a. Monad m => a -> m a
return [Text]
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 :: m [Text]
getLanguageNames  = IO [Text] -> m [Text]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [Text] -> m [Text]) -> IO [Text] -> m [Text]
forall a b. (a -> b) -> a -> b
$ do
    Ptr CString
result <- IO (Ptr CString)
g_get_language_names
    Text -> Ptr CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "getLanguageNames" Ptr CString
result
    [Text]
result' <- HasCallStack => Ptr CString -> IO [Text]
Ptr CString -> IO [Text]
unpackZeroTerminatedUTF8CArray Ptr CString
result
    [Text] -> IO [Text]
forall (m :: * -> *) a. Monad m => a -> m a
return [Text]
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 :: m Text
getHostName  = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
result <- IO CString
g_get_host_name
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "getHostName" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
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 :: m [Char]
getHomeDir  = IO [Char] -> m [Char]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [Char] -> m [Char]) -> IO [Char] -> m [Char]
forall a b. (a -> b) -> a -> b
$ do
    CString
result <- IO CString
g_get_home_dir
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "getHomeDir" CString
result
    [Char]
result' <- HasCallStack => CString -> IO [Char]
CString -> IO [Char]
cstringToString CString
result
    [Char] -> IO [Char]
forall (m :: * -> *) a. Monad m => a -> m a
return [Char]
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 :: m (Bool, [Text])
getFilenameCharsets  = IO (Bool, [Text]) -> m (Bool, [Text])
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Bool, [Text]) -> m (Bool, [Text]))
-> IO (Bool, [Text]) -> m (Bool, [Text])
forall a b. (a -> b) -> a -> b
$ do
    Ptr (Ptr CString)
filenameCharsets <- IO (Ptr (Ptr CString))
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr (Ptr CString))
    CInt
result <- Ptr (Ptr CString) -> IO CInt
g_get_filename_charsets Ptr (Ptr CString)
filenameCharsets
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    Ptr CString
filenameCharsets' <- Ptr (Ptr CString) -> IO (Ptr CString)
forall a. Storable a => Ptr a -> IO a
peek Ptr (Ptr CString)
filenameCharsets
    [Text]
filenameCharsets'' <- HasCallStack => Ptr CString -> IO [Text]
Ptr CString -> IO [Text]
unpackZeroTerminatedUTF8CArray Ptr CString
filenameCharsets'
    Ptr (Ptr CString) -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr (Ptr CString)
filenameCharsets
    (Bool, [Text]) -> IO (Bool, [Text])
forall (m :: * -> *) a. Monad m => a -> m a
return (Bool
result', [Text]
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 :: m [[Char]]
getEnviron  = IO [[Char]] -> m [[Char]]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [[Char]] -> m [[Char]]) -> IO [[Char]] -> m [[Char]]
forall a b. (a -> b) -> a -> b
$ do
    Ptr CString
result <- IO (Ptr CString)
g_get_environ
    Text -> Ptr CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "getEnviron" Ptr CString
result
    [[Char]]
result' <- HasCallStack => Ptr CString -> IO [[Char]]
Ptr CString -> IO [[Char]]
unpackZeroTerminatedFileNameArray Ptr CString
result
    (CString -> IO ()) -> Ptr CString -> IO ()
forall a b. (Ptr a -> IO b) -> Ptr (Ptr a) -> IO ()
mapZeroTerminatedCArray CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
result
    Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
result
    [[Char]] -> IO [[Char]]
forall (m :: * -> *) a. Monad m => a -> m a
return [[Char]]
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 ()

{-# DEPRECATED getCurrentTime ["(Since version 2.62)","'GI.GLib.Structs.TimeVal.TimeVal' is not year-2038-safe. Use 'GI.GLib.Functions.getRealTime'","   instead."] #-}
{- |
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 :: TimeVal -> m ()
getCurrentTime result_ :: TimeVal
result_ = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr TimeVal
result_' <- TimeVal -> IO (Ptr TimeVal)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr TimeVal
result_
    Ptr TimeVal -> IO ()
g_get_current_time Ptr TimeVal
result_'
    TimeVal -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr TimeVal
result_
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
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 :: m [Char]
getCurrentDir  = IO [Char] -> m [Char]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [Char] -> m [Char]) -> IO [Char] -> m [Char]
forall a b. (a -> b) -> a -> b
$ do
    CString
result <- IO CString
g_get_current_dir
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "getCurrentDir" CString
result
    [Char]
result' <- HasCallStack => CString -> IO [Char]
CString -> IO [Char]
cstringToString CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    [Char] -> IO [Char]
forall (m :: * -> *) a. Monad m => a -> m a
return [Char]
result'


-- function g_get_console_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_console_charset" g_get_console_charset :: 
    Ptr CString ->                          -- charset : TBasicType TUTF8
    IO CInt

{- |
Obtains the character set used by the console attached to the process,
which is suitable for printing output to the terminal.

Usually this matches the result returned by 'GI.GLib.Functions.getCharset', but in
environments where the locale\'s character set does not match the encoding
of the console this function tries to guess a more suitable value instead.

On Windows the character set returned by this function is the
output code page used by the console associated with the calling process.
If the codepage can\'t be determined (for example because there is no
console attached) UTF-8 is assumed.

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.

/Since: 2.62/
-}
getConsoleCharset ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m ((Bool, T.Text))
    {- ^ __Returns:__ 'True' if the returned charset is UTF-8 -}
getConsoleCharset :: m (Bool, Text)
getConsoleCharset  = IO (Bool, Text) -> m (Bool, Text)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Bool, Text) -> m (Bool, Text))
-> IO (Bool, Text) -> m (Bool, Text)
forall a b. (a -> b) -> a -> b
$ do
    Ptr CString
charset <- IO (Ptr CString)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr CString)
    CInt
result <- Ptr CString -> IO CInt
g_get_console_charset Ptr CString
charset
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    CString
charset' <- Ptr CString -> IO CString
forall a. Storable a => Ptr a -> IO a
peek Ptr CString
charset
    Text
charset'' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
charset'
    Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
charset
    (Bool, Text) -> IO (Bool, Text)
forall (m :: * -> *) a. Monad m => a -> m a
return (Bool
result', Text
charset'')


-- 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 :: m Text
getCodeset  = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
result <- IO CString
g_get_codeset
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "getCodeset" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
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 :: m (Bool, Text)
getCharset  = IO (Bool, Text) -> m (Bool, Text)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Bool, Text) -> m (Bool, Text))
-> IO (Bool, Text) -> m (Bool, Text)
forall a b. (a -> b) -> a -> b
$ do
    Ptr CString
charset <- IO (Ptr CString)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr CString)
    CInt
result <- Ptr CString -> IO CInt
g_get_charset Ptr CString
charset
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    CString
charset' <- Ptr CString -> IO CString
forall a. Storable a => Ptr a -> IO a
peek Ptr CString
charset
    Text
charset'' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
charset'
    Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
charset
    (Bool, Text) -> IO (Bool, Text)
forall (m :: * -> *) a. Monad m => a -> m a
return (Bool
result', Text
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 (Maybe T.Text)
    {- ^ __Returns:__ human-readable application
  name. May return 'Nothing' -}
getApplicationName :: m (Maybe Text)
getApplicationName  = IO (Maybe Text) -> m (Maybe Text)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Text) -> m (Maybe Text))
-> IO (Maybe Text) -> m (Maybe Text)
forall a b. (a -> b) -> a -> b
$ do
    CString
result <- IO CString
g_get_application_name
    Maybe Text
maybeResult <- CString -> (CString -> IO Text) -> IO (Maybe Text)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull CString
result ((CString -> IO Text) -> IO (Maybe Text))
-> (CString -> IO Text) -> IO (Maybe Text)
forall a b. (a -> b) -> a -> b
$ \result' :: CString
result' -> do
        Text
result'' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result'
        Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result''
    Maybe Text -> IO (Maybe Text)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Text
maybeResult


-- 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 :: Ptr () -> m ()
free mem :: Ptr ()
mem = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    C_DestroyNotify
g_free Ptr ()
mem
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
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 :: CGType -> [FormatSizeFlags] -> m Text
formatSizeFull size :: CGType
size flags :: [FormatSizeFlags]
flags = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    let flags' :: CUInt
flags' = [FormatSizeFlags] -> CUInt
forall b a. (Num b, IsGFlag a) => [a] -> b
gflagsToWord [FormatSizeFlags]
flags
    CString
result <- CGType -> CUInt -> IO CString
g_format_size_full CGType
size CUInt
flags'
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "formatSizeFull" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
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 :: Int64 -> m Text
formatSizeForDisplay size :: Int64
size = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
result <- Int64 -> IO CString
g_format_size_for_display Int64
size
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "formatSizeForDisplay" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
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 :: CGType -> m Text
formatSize size :: CGType
size = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
result <- CGType -> IO CString
g_format_size CGType
size
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "formatSize" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
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 (Maybe [Char])
    {- ^ __Returns:__ a newly-allocated
  string with the absolute path, or 'Nothing' -}
findProgramInPath :: [Char] -> m (Maybe [Char])
findProgramInPath program :: [Char]
program = IO (Maybe [Char]) -> m (Maybe [Char])
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe [Char]) -> m (Maybe [Char]))
-> IO (Maybe [Char]) -> m (Maybe [Char])
forall a b. (a -> b) -> a -> b
$ do
    CString
program' <- [Char] -> IO CString
stringToCString [Char]
program
    CString
result <- CString -> IO CString
g_find_program_in_path CString
program'
    Maybe [Char]
maybeResult <- CString -> (CString -> IO [Char]) -> IO (Maybe [Char])
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull CString
result ((CString -> IO [Char]) -> IO (Maybe [Char]))
-> (CString -> IO [Char]) -> IO (Maybe [Char])
forall a b. (a -> b) -> a -> b
$ \result' :: CString
result' -> do
        [Char]
result'' <- HasCallStack => CString -> IO [Char]
CString -> IO [Char]
cstringToString CString
result'
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result'
        [Char] -> IO [Char]
forall (m :: * -> *) a. Monad m => a -> m a
return [Char]
result''
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
program'
    Maybe [Char] -> IO (Maybe [Char])
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe [Char]
maybeResult


-- 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 :: [Char] -> Int64 -> m (Text, CGType, CGType)
filenameToUtf8 opsysstring :: [Char]
opsysstring len :: Int64
len = IO (Text, CGType, CGType) -> m (Text, CGType, CGType)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Text, CGType, CGType) -> m (Text, CGType, CGType))
-> IO (Text, CGType, CGType) -> m (Text, CGType, CGType)
forall a b. (a -> b) -> a -> b
$ do
    CString
opsysstring' <- [Char] -> IO CString
stringToCString [Char]
opsysstring
    Ptr CGType
bytesRead <- IO (Ptr CGType)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Word64)
    Ptr CGType
bytesWritten <- IO (Ptr CGType)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Word64)
    IO (Text, CGType, CGType) -> IO () -> IO (Text, CGType, CGType)
forall a b. IO a -> IO b -> IO a
onException (do
        CString
result <- (Ptr (Ptr GError) -> IO CString) -> IO CString
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CString) -> IO CString)
-> (Ptr (Ptr GError) -> IO CString) -> IO CString
forall a b. (a -> b) -> a -> b
$ CString
-> Int64
-> Ptr CGType
-> Ptr CGType
-> Ptr (Ptr GError)
-> IO CString
g_filename_to_utf8 CString
opsysstring' Int64
len Ptr CGType
bytesRead Ptr CGType
bytesWritten
        Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "filenameToUtf8" CString
result
        Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
        CGType
bytesRead' <- Ptr CGType -> IO CGType
forall a. Storable a => Ptr a -> IO a
peek Ptr CGType
bytesRead
        CGType
bytesWritten' <- Ptr CGType -> IO CGType
forall a. Storable a => Ptr a -> IO a
peek Ptr CGType
bytesWritten
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
opsysstring'
        Ptr CGType -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CGType
bytesRead
        Ptr CGType -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CGType
bytesWritten
        (Text, CGType, CGType) -> IO (Text, CGType, CGType)
forall (m :: * -> *) a. Monad m => a -> m a
return (Text
result', CGType
bytesRead', CGType
bytesWritten')
     ) (do
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
opsysstring'
        Ptr CGType -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CGType
bytesRead
        Ptr CGType -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CGType
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 :: [Char] -> Maybe Text -> m Text
filenameToUri filename :: [Char]
filename hostname :: Maybe Text
hostname = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
filename' <- [Char] -> IO CString
stringToCString [Char]
filename
    CString
maybeHostname <- case Maybe Text
hostname of
        Nothing -> CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
forall a. Ptr a
nullPtr
        Just jHostname :: Text
jHostname -> do
            CString
jHostname' <- Text -> IO CString
textToCString Text
jHostname
            CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
jHostname'
    IO Text -> IO () -> IO Text
forall a b. IO a -> IO b -> IO a
onException (do
        CString
result <- (Ptr (Ptr GError) -> IO CString) -> IO CString
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CString) -> IO CString)
-> (Ptr (Ptr GError) -> IO CString) -> IO CString
forall a b. (a -> b) -> a -> b
$ CString -> CString -> Ptr (Ptr GError) -> IO CString
g_filename_to_uri CString
filename' CString
maybeHostname
        Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "filenameToUri" CString
result
        Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
filename'
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeHostname
        Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'
     ) (do
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
filename'
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
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 :: Text -> Int64 -> m ([Char], CGType, CGType)
filenameFromUtf8 utf8string :: Text
utf8string len :: Int64
len = IO ([Char], CGType, CGType) -> m ([Char], CGType, CGType)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO ([Char], CGType, CGType) -> m ([Char], CGType, CGType))
-> IO ([Char], CGType, CGType) -> m ([Char], CGType, CGType)
forall a b. (a -> b) -> a -> b
$ do
    CString
utf8string' <- Text -> IO CString
textToCString Text
utf8string
    Ptr CGType
bytesRead <- IO (Ptr CGType)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Word64)
    Ptr CGType
bytesWritten <- IO (Ptr CGType)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Word64)
    IO ([Char], CGType, CGType) -> IO () -> IO ([Char], CGType, CGType)
forall a b. IO a -> IO b -> IO a
onException (do
        CString
result <- (Ptr (Ptr GError) -> IO CString) -> IO CString
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CString) -> IO CString)
-> (Ptr (Ptr GError) -> IO CString) -> IO CString
forall a b. (a -> b) -> a -> b
$ CString
-> Int64
-> Ptr CGType
-> Ptr CGType
-> Ptr (Ptr GError)
-> IO CString
g_filename_from_utf8 CString
utf8string' Int64
len Ptr CGType
bytesRead Ptr CGType
bytesWritten
        Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "filenameFromUtf8" CString
result
        [Char]
result' <- HasCallStack => CString -> IO [Char]
CString -> IO [Char]
cstringToString CString
result
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
        CGType
bytesRead' <- Ptr CGType -> IO CGType
forall a. Storable a => Ptr a -> IO a
peek Ptr CGType
bytesRead
        CGType
bytesWritten' <- Ptr CGType -> IO CGType
forall a. Storable a => Ptr a -> IO a
peek Ptr CGType
bytesWritten
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
utf8string'
        Ptr CGType -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CGType
bytesRead
        Ptr CGType -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CGType
bytesWritten
        ([Char], CGType, CGType) -> IO ([Char], CGType, CGType)
forall (m :: * -> *) a. Monad m => a -> m a
return ([Char]
result', CGType
bytesRead', CGType
bytesWritten')
     ) (do
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
utf8string'
        Ptr CGType -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CGType
bytesRead
        Ptr CGType -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CGType
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 :: Text -> m ([Char], Maybe Text)
filenameFromUri uri :: Text
uri = IO ([Char], Maybe Text) -> m ([Char], Maybe Text)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO ([Char], Maybe Text) -> m ([Char], Maybe Text))
-> IO ([Char], Maybe Text) -> m ([Char], Maybe Text)
forall a b. (a -> b) -> a -> b
$ do
    CString
uri' <- Text -> IO CString
textToCString Text
uri
    Ptr CString
hostname <- IO (Ptr CString)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr CString)
    IO ([Char], Maybe Text) -> IO () -> IO ([Char], Maybe Text)
forall a b. IO a -> IO b -> IO a
onException (do
        CString
result <- (Ptr (Ptr GError) -> IO CString) -> IO CString
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CString) -> IO CString)
-> (Ptr (Ptr GError) -> IO CString) -> IO CString
forall a b. (a -> b) -> a -> b
$ CString -> Ptr CString -> Ptr (Ptr GError) -> IO CString
g_filename_from_uri CString
uri' Ptr CString
hostname
        Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "filenameFromUri" CString
result
        [Char]
result' <- HasCallStack => CString -> IO [Char]
CString -> IO [Char]
cstringToString CString
result
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
        CString
hostname' <- Ptr CString -> IO CString
forall a. Storable a => Ptr a -> IO a
peek Ptr CString
hostname
        Maybe Text
maybeHostname' <- CString -> (CString -> IO Text) -> IO (Maybe Text)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull CString
hostname' ((CString -> IO Text) -> IO (Maybe Text))
-> (CString -> IO Text) -> IO (Maybe Text)
forall a b. (a -> b) -> a -> b
$ \hostname'' :: CString
hostname'' -> do
            Text
hostname''' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
hostname''
            Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
hostname'''
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
hostname'
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
uri'
        Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
hostname
        ([Char], Maybe Text) -> IO ([Char], Maybe Text)
forall (m :: * -> *) a. Monad m => a -> m a
return ([Char]
result', Maybe Text
maybeHostname')
     ) (do
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
uri'
        Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
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 :: [Char] -> m Text
filenameDisplayName filename :: [Char]
filename = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
filename' <- [Char] -> IO CString
stringToCString [Char]
filename
    CString
result <- CString -> IO CString
g_filename_display_name CString
filename'
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "filenameDisplayName" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
filename'
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
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 :: [Char] -> m Text
filenameDisplayBasename filename :: [Char]
filename = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
filename' <- [Char] -> IO CString
stringToCString [Char]
filename
    CString
result <- CString -> IO CString
g_filename_display_basename CString
filename'
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "filenameDisplayBasename" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
filename'
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
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 :: [Char] -> [FileTest] -> m Bool
fileTest filename :: [Char]
filename test :: [FileTest]
test = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    CString
filename' <- [Char] -> IO CString
stringToCString [Char]
filename
    let test' :: CUInt
test' = [FileTest] -> CUInt
forall b a. (Num b, IsGFlag a) => [a] -> b
gflagsToWord [FileTest]
test
    CInt
result <- CString -> CUInt -> IO CInt
g_file_test CString
filename' CUInt
test'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
filename'
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
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 :: [Char] -> ByteString -> m ()
fileSetContents filename :: [Char]
filename contents :: ByteString
contents = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    let length_ :: Int64
length_ = Int -> Int64
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> Int64) -> Int -> Int64
forall a b. (a -> b) -> a -> b
$ ByteString -> Int
B.length ByteString
contents
    CString
filename' <- [Char] -> IO CString
stringToCString [Char]
filename
    Ptr Word8
contents' <- ByteString -> IO (Ptr Word8)
packByteString ByteString
contents
    IO () -> IO () -> IO ()
forall a b. IO a -> IO b -> IO a
onException (do
        CInt
_ <- (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ CString -> Ptr Word8 -> Int64 -> Ptr (Ptr GError) -> IO CInt
g_file_set_contents CString
filename' Ptr Word8
contents' Int64
length_
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
filename'
        Ptr Word8 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word8
contents'
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     ) (do
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
filename'
        Ptr Word8 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word8
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 :: [Char] -> m [Char]
fileReadLink filename :: [Char]
filename = IO [Char] -> m [Char]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [Char] -> m [Char]) -> IO [Char] -> m [Char]
forall a b. (a -> b) -> a -> b
$ do
    CString
filename' <- [Char] -> IO CString
stringToCString [Char]
filename
    IO [Char] -> IO () -> IO [Char]
forall a b. IO a -> IO b -> IO a
onException (do
        CString
result <- (Ptr (Ptr GError) -> IO CString) -> IO CString
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CString) -> IO CString)
-> (Ptr (Ptr GError) -> IO CString) -> IO CString
forall a b. (a -> b) -> a -> b
$ CString -> Ptr (Ptr GError) -> IO CString
g_file_read_link CString
filename'
        Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "fileReadLink" CString
result
        [Char]
result' <- HasCallStack => CString -> IO [Char]
CString -> IO [Char]
cstringToString CString
result
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
filename'
        [Char] -> IO [Char]
forall (m :: * -> *) a. Monad m => a -> m a
return [Char]
result'
     ) (do
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
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 :: Maybe [Char] -> m (Int32, [Char])
fileOpenTmp tmpl :: Maybe [Char]
tmpl = IO (Int32, [Char]) -> m (Int32, [Char])
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Int32, [Char]) -> m (Int32, [Char]))
-> IO (Int32, [Char]) -> m (Int32, [Char])
forall a b. (a -> b) -> a -> b
$ do
    CString
maybeTmpl <- case Maybe [Char]
tmpl of
        Nothing -> CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
forall a. Ptr a
nullPtr
        Just jTmpl :: [Char]
jTmpl -> do
            CString
jTmpl' <- [Char] -> IO CString
stringToCString [Char]
jTmpl
            CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
jTmpl'
    Ptr CString
nameUsed <- IO (Ptr CString)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr CString)
    IO (Int32, [Char]) -> IO () -> IO (Int32, [Char])
forall a b. IO a -> IO b -> IO a
onException (do
        Int32
result <- (Ptr (Ptr GError) -> IO Int32) -> IO Int32
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO Int32) -> IO Int32)
-> (Ptr (Ptr GError) -> IO Int32) -> IO Int32
forall a b. (a -> b) -> a -> b
$ CString -> Ptr CString -> Ptr (Ptr GError) -> IO Int32
g_file_open_tmp CString
maybeTmpl Ptr CString
nameUsed
        CString
nameUsed' <- Ptr CString -> IO CString
forall a. Storable a => Ptr a -> IO a
peek Ptr CString
nameUsed
        [Char]
nameUsed'' <- HasCallStack => CString -> IO [Char]
CString -> IO [Char]
cstringToString CString
nameUsed'
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
nameUsed'
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeTmpl
        Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
nameUsed
        (Int32, [Char]) -> IO (Int32, [Char])
forall (m :: * -> *) a. Monad m => a -> m a
return (Int32
result, [Char]
nameUsed'')
     ) (do
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeTmpl
        Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
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 :: [Char] -> m ByteString
fileGetContents filename :: [Char]
filename = IO ByteString -> m ByteString
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO ByteString -> m ByteString) -> IO ByteString -> m ByteString
forall a b. (a -> b) -> a -> b
$ do
    CString
filename' <- [Char] -> IO CString
stringToCString [Char]
filename
    Ptr (Ptr Word8)
contents <- IO (Ptr (Ptr Word8))
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr (Ptr Word8))
    Ptr CGType
length_ <- IO (Ptr CGType)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Word64)
    IO ByteString -> IO () -> IO ByteString
forall a b. IO a -> IO b -> IO a
onException (do
        CInt
_ <- (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ CString
-> Ptr (Ptr Word8) -> Ptr CGType -> Ptr (Ptr GError) -> IO CInt
g_file_get_contents CString
filename' Ptr (Ptr Word8)
contents Ptr CGType
length_
        CGType
length_' <- Ptr CGType -> IO CGType
forall a. Storable a => Ptr a -> IO a
peek Ptr CGType
length_
        Ptr Word8
contents' <- Ptr (Ptr Word8) -> IO (Ptr Word8)
forall a. Storable a => Ptr a -> IO a
peek Ptr (Ptr Word8)
contents
        ByteString
contents'' <- (CGType -> Ptr Word8 -> IO ByteString
forall a. Integral a => a -> Ptr Word8 -> IO ByteString
unpackByteStringWithLength CGType
length_') Ptr Word8
contents'
        Ptr Word8 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word8
contents'
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
filename'
        Ptr (Ptr Word8) -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr (Ptr Word8)
contents
        Ptr CGType -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CGType
length_
        ByteString -> IO ByteString
forall (m :: * -> *) a. Monad m => a -> m a
return ByteString
contents''
     ) (do
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
filename'
        Ptr (Ptr Word8) -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr (Ptr Word8)
contents
        Ptr CGType -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CGType
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 :: m Word32
fileErrorQuark  = IO Word32 -> m Word32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ do
    Word32
result <- IO Word32
g_file_error_quark
    Word32 -> IO Word32
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
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 :: Int32 -> m FileError
fileErrorFromErrno errNo :: Int32
errNo = IO FileError -> m FileError
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO FileError -> m FileError) -> IO FileError -> m FileError
forall a b. (a -> b) -> a -> b
$ do
    CUInt
result <- Int32 -> IO CUInt
g_file_error_from_errno Int32
errNo
    let result' :: FileError
result' = (Int -> FileError
forall a. Enum a => Int -> a
toEnum (Int -> FileError) -> (CUInt -> Int) -> CUInt -> FileError
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CUInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral) CUInt
result
    FileError -> IO FileError
forall (m :: * -> *) a. Monad m => a -> m a
return FileError
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 :: Maybe [[Char]] -> [Char] -> m [[Char]]
environUnsetenv envp :: Maybe [[Char]]
envp variable :: [Char]
variable = IO [[Char]] -> m [[Char]]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [[Char]] -> m [[Char]]) -> IO [[Char]] -> m [[Char]]
forall a b. (a -> b) -> a -> b
$ do
    Ptr CString
maybeEnvp <- case Maybe [[Char]]
envp of
        Nothing -> Ptr CString -> IO (Ptr CString)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CString
forall a. Ptr a
nullPtr
        Just jEnvp :: [[Char]]
jEnvp -> do
            Ptr CString
jEnvp' <- [[Char]] -> IO (Ptr CString)
packZeroTerminatedFileNameArray [[Char]]
jEnvp
            Ptr CString -> IO (Ptr CString)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CString
jEnvp'
    CString
variable' <- [Char] -> IO CString
stringToCString [Char]
variable
    Ptr CString
result <- Ptr CString -> CString -> IO (Ptr CString)
g_environ_unsetenv Ptr CString
maybeEnvp CString
variable'
    Text -> Ptr CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "environUnsetenv" Ptr CString
result
    [[Char]]
result' <- HasCallStack => Ptr CString -> IO [[Char]]
Ptr CString -> IO [[Char]]
unpackZeroTerminatedFileNameArray Ptr CString
result
    (CString -> IO ()) -> Ptr CString -> IO ()
forall a b. (Ptr a -> IO b) -> Ptr (Ptr a) -> IO ()
mapZeroTerminatedCArray CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
result
    Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
variable'
    [[Char]] -> IO [[Char]]
forall (m :: * -> *) a. Monad m => a -> m a
return [[Char]]
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 :: Maybe [[Char]] -> [Char] -> [Char] -> Bool -> m [[Char]]
environSetenv envp :: Maybe [[Char]]
envp variable :: [Char]
variable value :: [Char]
value overwrite :: Bool
overwrite = IO [[Char]] -> m [[Char]]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [[Char]] -> m [[Char]]) -> IO [[Char]] -> m [[Char]]
forall a b. (a -> b) -> a -> b
$ do
    Ptr CString
maybeEnvp <- case Maybe [[Char]]
envp of
        Nothing -> Ptr CString -> IO (Ptr CString)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CString
forall a. Ptr a
nullPtr
        Just jEnvp :: [[Char]]
jEnvp -> do
            Ptr CString
jEnvp' <- [[Char]] -> IO (Ptr CString)
packZeroTerminatedFileNameArray [[Char]]
jEnvp
            Ptr CString -> IO (Ptr CString)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CString
jEnvp'
    CString
variable' <- [Char] -> IO CString
stringToCString [Char]
variable
    CString
value' <- [Char] -> IO CString
stringToCString [Char]
value
    let overwrite' :: CInt
overwrite' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Bool -> Int) -> Bool -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> Int
forall a. Enum a => a -> Int
fromEnum) Bool
overwrite
    Ptr CString
result <- Ptr CString -> CString -> CString -> CInt -> IO (Ptr CString)
g_environ_setenv Ptr CString
maybeEnvp CString
variable' CString
value' CInt
overwrite'
    Text -> Ptr CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "environSetenv" Ptr CString
result
    [[Char]]
result' <- HasCallStack => Ptr CString -> IO [[Char]]
Ptr CString -> IO [[Char]]
unpackZeroTerminatedFileNameArray Ptr CString
result
    (CString -> IO ()) -> Ptr CString -> IO ()
forall a b. (Ptr a -> IO b) -> Ptr (Ptr a) -> IO ()
mapZeroTerminatedCArray CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
result
    Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
variable'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
value'
    [[Char]] -> IO [[Char]]
forall (m :: * -> *) a. Monad m => a -> m a
return [[Char]]
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 :: Maybe [[Char]] -> [Char] -> m [Char]
environGetenv envp :: Maybe [[Char]]
envp variable :: [Char]
variable = IO [Char] -> m [Char]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [Char] -> m [Char]) -> IO [Char] -> m [Char]
forall a b. (a -> b) -> a -> b
$ do
    Ptr CString
maybeEnvp <- case Maybe [[Char]]
envp of
        Nothing -> Ptr CString -> IO (Ptr CString)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CString
forall a. Ptr a
nullPtr
        Just jEnvp :: [[Char]]
jEnvp -> do
            Ptr CString
jEnvp' <- [[Char]] -> IO (Ptr CString)
packZeroTerminatedFileNameArray [[Char]]
jEnvp
            Ptr CString -> IO (Ptr CString)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CString
jEnvp'
    CString
variable' <- [Char] -> IO CString
stringToCString [Char]
variable
    CString
result <- Ptr CString -> CString -> IO CString
g_environ_getenv Ptr CString
maybeEnvp CString
variable'
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "environGetenv" CString
result
    [Char]
result' <- HasCallStack => CString -> IO [Char]
CString -> IO [Char]
cstringToString CString
result
    (CString -> IO ()) -> Ptr CString -> IO ()
forall a b. (Ptr a -> IO b) -> Ptr (Ptr a) -> IO ()
mapZeroTerminatedCArray CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
maybeEnvp
    Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
maybeEnvp
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
variable'
    [Char] -> IO [Char]
forall (m :: * -> *) a. Monad m => a -> m a
return [Char]
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 :: Maybe Text -> Text -> Text -> m Text
dpgettext2 domain :: Maybe Text
domain context :: Text
context msgid :: Text
msgid = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
maybeDomain <- case Maybe Text
domain of
        Nothing -> CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
forall a. Ptr a
nullPtr
        Just jDomain :: Text
jDomain -> do
            CString
jDomain' <- Text -> IO CString
textToCString Text
jDomain
            CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
jDomain'
    CString
context' <- Text -> IO CString
textToCString Text
context
    CString
msgid' <- Text -> IO CString
textToCString Text
msgid
    CString
result <- CString -> CString -> CString -> IO CString
g_dpgettext2 CString
maybeDomain CString
context' CString
msgid'
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "dpgettext2" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeDomain
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
context'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
msgid'
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
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 :: Maybe Text -> Text -> CGType -> m Text
dpgettext domain :: Maybe Text
domain msgctxtid :: Text
msgctxtid msgidoffset :: CGType
msgidoffset = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
maybeDomain <- case Maybe Text
domain of
        Nothing -> CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
forall a. Ptr a
nullPtr
        Just jDomain :: Text
jDomain -> do
            CString
jDomain' <- Text -> IO CString
textToCString Text
jDomain
            CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
jDomain'
    CString
msgctxtid' <- Text -> IO CString
textToCString Text
msgctxtid
    CString
result <- CString -> CString -> CGType -> IO CString
g_dpgettext CString
maybeDomain CString
msgctxtid' CGType
msgidoffset
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "dpgettext" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeDomain
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
msgctxtid'
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
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 :: Ptr () -> m Word32
doubleHash v :: Ptr ()
v = IO Word32 -> m Word32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ do
    Word32
result <- Ptr () -> IO Word32
g_double_hash Ptr ()
v
    Word32 -> IO Word32
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
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 :: Ptr () -> Ptr () -> m Bool
doubleEqual v1 :: Ptr ()
v1 v2 :: Ptr ()
v2 = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    CInt
result <- Ptr () -> C_SourceFunc
g_double_equal Ptr ()
v1 Ptr ()
v2
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
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 :: Maybe Text -> Text -> Text -> CULong -> m Text
dngettext domain :: Maybe Text
domain msgid :: Text
msgid msgidPlural :: Text
msgidPlural n :: CULong
n = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
maybeDomain <- case Maybe Text
domain of
        Nothing -> CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
forall a. Ptr a
nullPtr
        Just jDomain :: Text
jDomain -> do
            CString
jDomain' <- Text -> IO CString
textToCString Text
jDomain
            CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
jDomain'
    CString
msgid' <- Text -> IO CString
textToCString Text
msgid
    CString
msgidPlural' <- Text -> IO CString
textToCString Text
msgidPlural
    CString
result <- CString -> CString -> CString -> CULong -> IO CString
g_dngettext CString
maybeDomain CString
msgid' CString
msgidPlural' CULong
n
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "dngettext" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeDomain
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
msgid'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
msgidPlural'
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
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 :: Ptr () -> m Word32
directHash v :: Ptr ()
v = IO Word32 -> m Word32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ do
    Word32
result <- Ptr () -> IO Word32
g_direct_hash Ptr ()
v
    Word32 -> IO Word32
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
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 :: Ptr () -> Ptr () -> m Bool
directEqual v1 :: Ptr ()
v1 v2 :: Ptr ()
v2 = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    CInt
result <- Ptr () -> C_SourceFunc
g_direct_equal Ptr ()
v1 Ptr ()
v2
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
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 :: Maybe Text -> Text -> m Text
dgettext domain :: Maybe Text
domain msgid :: Text
msgid = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
maybeDomain <- case Maybe Text
domain of
        Nothing -> CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
forall a. Ptr a
nullPtr
        Just jDomain :: Text
jDomain -> do
            CString
jDomain' <- Text -> IO CString
textToCString Text
jDomain
            CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
jDomain'
    CString
msgid' <- Text -> IO CString
textToCString Text
msgid
    CString
result <- CString -> CString -> IO CString
g_dgettext CString
maybeDomain CString
msgid'
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "dgettext" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeDomain
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
msgid'
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
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 :: Maybe Text -> Text -> Int32 -> m Text
dcgettext domain :: Maybe Text
domain msgid :: Text
msgid category :: Int32
category = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
maybeDomain <- case Maybe Text
domain of
        Nothing -> CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
forall a. Ptr a
nullPtr
        Just jDomain :: Text
jDomain -> do
            CString
jDomain' <- Text -> IO CString
textToCString Text
jDomain
            CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
jDomain'
    CString
msgid' <- Text -> IO CString
textToCString Text
msgid
    CString
result <- CString -> CString -> Int32 -> IO CString
g_dcgettext CString
maybeDomain CString
msgid' Int32
category
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "dcgettext" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeDomain
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
msgid'
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
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 :: Ptr () -> Word32 -> m (Ptr ())
datasetIdGetData datasetLocation :: Ptr ()
datasetLocation keyId :: Word32
keyId = IO (Ptr ()) -> m (Ptr ())
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Ptr ()) -> m (Ptr ())) -> IO (Ptr ()) -> m (Ptr ())
forall a b. (a -> b) -> a -> b
$ do
    Ptr ()
result <- Ptr () -> Word32 -> IO (Ptr ())
g_dataset_id_get_data Ptr ()
datasetLocation Word32
keyId
    Ptr () -> IO (Ptr ())
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr ()
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 :: Ptr () -> DataForeachFunc -> m ()
datasetForeach datasetLocation :: Ptr ()
datasetLocation func :: DataForeachFunc
func = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    FunPtr C_DataForeachFunc
func' <- C_DataForeachFunc -> IO (FunPtr C_DataForeachFunc)
GLib.Callbacks.mk_DataForeachFunc (Maybe (Ptr (FunPtr C_DataForeachFunc))
-> C_DataForeachFunc -> C_DataForeachFunc
GLib.Callbacks.wrap_DataForeachFunc Maybe (Ptr (FunPtr C_DataForeachFunc))
forall a. Maybe a
Nothing (DataForeachFunc -> C_DataForeachFunc
GLib.Callbacks.drop_closures_DataForeachFunc DataForeachFunc
func))
    let userData :: Ptr a
userData = Ptr a
forall a. Ptr a
nullPtr
    Ptr () -> FunPtr C_DataForeachFunc -> C_DestroyNotify
g_dataset_foreach Ptr ()
datasetLocation FunPtr C_DataForeachFunc
func' Ptr ()
forall a. Ptr a
userData
    Ptr Any -> IO ()
forall a. Ptr a -> IO ()
safeFreeFunPtr (Ptr Any -> IO ()) -> Ptr Any -> IO ()
forall a b. (a -> b) -> a -> b
$ FunPtr C_DataForeachFunc -> Ptr Any
forall a b. FunPtr a -> Ptr b
castFunPtrToPtr FunPtr C_DataForeachFunc
func'
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
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 :: Ptr () -> m ()
datasetDestroy datasetLocation :: Ptr ()
datasetLocation = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    C_DestroyNotify
g_dataset_destroy Ptr ()
datasetLocation
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
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 :: Data -> Word32 -> m ()
datalistUnsetFlags datalist :: Data
datalist flags :: Word32
flags = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr Data
datalist' <- Data -> IO (Ptr Data)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Data
datalist
    Ptr Data -> Word32 -> IO ()
g_datalist_unset_flags Ptr Data
datalist' Word32
flags
    Data -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Data
datalist
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
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 :: Data -> Word32 -> m ()
datalistSetFlags datalist :: Data
datalist flags :: Word32
flags = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr Data
datalist' <- Data -> IO (Ptr Data)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Data
datalist
    Ptr Data -> Word32 -> IO ()
g_datalist_set_flags Ptr Data
datalist' Word32
flags
    Data -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Data
datalist
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
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 :: Data -> Word32 -> m (Ptr ())
datalistIdGetData datalist :: Data
datalist keyId :: Word32
keyId = IO (Ptr ()) -> m (Ptr ())
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Ptr ()) -> m (Ptr ())) -> IO (Ptr ()) -> m (Ptr ())
forall a b. (a -> b) -> a -> b
$ do
    Ptr Data
datalist' <- Data -> IO (Ptr Data)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Data
datalist
    Ptr ()
result <- Ptr Data -> Word32 -> IO (Ptr ())
g_datalist_id_get_data Ptr Data
datalist' Word32
keyId
    Data -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Data
datalist
    Ptr () -> IO (Ptr ())
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr ()
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 :: Data -> m Word32
datalistGetFlags datalist :: Data
datalist = IO Word32 -> m Word32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ do
    Ptr Data
datalist' <- Data -> IO (Ptr Data)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Data
datalist
    Word32
result <- Ptr Data -> IO Word32
g_datalist_get_flags Ptr Data
datalist'
    Data -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Data
datalist
    Word32 -> IO Word32
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
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 :: Data -> Text -> m (Ptr ())
datalistGetData datalist :: Data
datalist key :: Text
key = IO (Ptr ()) -> m (Ptr ())
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Ptr ()) -> m (Ptr ())) -> IO (Ptr ()) -> m (Ptr ())
forall a b. (a -> b) -> a -> b
$ do
    Ptr Data
datalist' <- Data -> IO (Ptr Data)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Data
datalist
    CString
key' <- Text -> IO CString
textToCString Text
key
    Ptr ()
result <- Ptr Data -> CString -> IO (Ptr ())
g_datalist_get_data Ptr Data
datalist' CString
key'
    Data -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Data
datalist
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
key'
    Ptr () -> IO (Ptr ())
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr ()
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 :: Data -> DataForeachFunc -> m ()
datalistForeach datalist :: Data
datalist func :: DataForeachFunc
func = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr Data
datalist' <- Data -> IO (Ptr Data)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Data
datalist
    FunPtr C_DataForeachFunc
func' <- C_DataForeachFunc -> IO (FunPtr C_DataForeachFunc)
GLib.Callbacks.mk_DataForeachFunc (Maybe (Ptr (FunPtr C_DataForeachFunc))
-> C_DataForeachFunc -> C_DataForeachFunc
GLib.Callbacks.wrap_DataForeachFunc Maybe (Ptr (FunPtr C_DataForeachFunc))
forall a. Maybe a
Nothing (DataForeachFunc -> C_DataForeachFunc
GLib.Callbacks.drop_closures_DataForeachFunc DataForeachFunc
func))
    let userData :: Ptr a
userData = Ptr a
forall a. Ptr a
nullPtr
    Ptr Data -> FunPtr C_DataForeachFunc -> C_DestroyNotify
g_datalist_foreach Ptr Data
datalist' FunPtr C_DataForeachFunc
func' Ptr ()
forall a. Ptr a
userData
    Ptr Any -> IO ()
forall a. Ptr a -> IO ()
safeFreeFunPtr (Ptr Any -> IO ()) -> Ptr Any -> IO ()
forall a b. (a -> b) -> a -> b
$ FunPtr C_DataForeachFunc -> Ptr Any
forall a b. FunPtr a -> Ptr b
castFunPtrToPtr FunPtr C_DataForeachFunc
func'
    Data -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Data
datalist
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
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 :: ByteString -> Text -> Text -> Text -> m (ByteString, CGType)
convertWithFallback str :: ByteString
str toCodeset :: Text
toCodeset fromCodeset :: Text
fromCodeset fallback :: Text
fallback = IO (ByteString, CGType) -> m (ByteString, CGType)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (ByteString, CGType) -> m (ByteString, CGType))
-> IO (ByteString, CGType) -> m (ByteString, CGType)
forall a b. (a -> b) -> a -> b
$ do
    let len :: Int64
len = Int -> Int64
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> Int64) -> Int -> Int64
forall a b. (a -> b) -> a -> b
$ ByteString -> Int
B.length ByteString
str
    Ptr Word8
str' <- ByteString -> IO (Ptr Word8)
packByteString ByteString
str
    CString
toCodeset' <- Text -> IO CString
textToCString Text
toCodeset
    CString
fromCodeset' <- Text -> IO CString
textToCString Text
fromCodeset
    CString
fallback' <- Text -> IO CString
textToCString Text
fallback
    Ptr CGType
bytesRead <- IO (Ptr CGType)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Word64)
    Ptr CGType
bytesWritten <- IO (Ptr CGType)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Word64)
    IO (ByteString, CGType) -> IO () -> IO (ByteString, CGType)
forall a b. IO a -> IO b -> IO a
onException (do
        Ptr Word8
result <- (Ptr (Ptr GError) -> IO (Ptr Word8)) -> IO (Ptr Word8)
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO (Ptr Word8)) -> IO (Ptr Word8))
-> (Ptr (Ptr GError) -> IO (Ptr Word8)) -> IO (Ptr Word8)
forall a b. (a -> b) -> a -> b
$ Ptr Word8
-> Int64
-> CString
-> CString
-> CString
-> Ptr CGType
-> Ptr CGType
-> Ptr (Ptr GError)
-> IO (Ptr Word8)
g_convert_with_fallback Ptr Word8
str' Int64
len CString
toCodeset' CString
fromCodeset' CString
fallback' Ptr CGType
bytesRead Ptr CGType
bytesWritten
        CGType
bytesWritten' <- Ptr CGType -> IO CGType
forall a. Storable a => Ptr a -> IO a
peek Ptr CGType
bytesWritten
        Text -> Ptr Word8 -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "convertWithFallback" Ptr Word8
result
        ByteString
result' <- (CGType -> Ptr Word8 -> IO ByteString
forall a. Integral a => a -> Ptr Word8 -> IO ByteString
unpackByteStringWithLength CGType
bytesWritten') Ptr Word8
result
        Ptr Word8 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word8
result
        CGType
bytesRead' <- Ptr CGType -> IO CGType
forall a. Storable a => Ptr a -> IO a
peek Ptr CGType
bytesRead
        Ptr Word8 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word8
str'
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
toCodeset'
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
fromCodeset'
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
fallback'
        Ptr CGType -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CGType
bytesRead
        Ptr CGType -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CGType
bytesWritten
        (ByteString, CGType) -> IO (ByteString, CGType)
forall (m :: * -> *) a. Monad m => a -> m a
return (ByteString
result', CGType
bytesRead')
     ) (do
        Ptr Word8 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word8
str'
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
toCodeset'
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
fromCodeset'
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
fallback'
        Ptr CGType -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CGType
bytesRead
        Ptr CGType -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CGType
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 :: m Word32
convertErrorQuark  = IO Word32 -> m Word32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ do
    Word32
result <- IO Word32
g_convert_error_quark
    Word32 -> IO Word32
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
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 :: ByteString -> Text -> Text -> m (ByteString, CGType)
convert str :: ByteString
str toCodeset :: Text
toCodeset fromCodeset :: Text
fromCodeset = IO (ByteString, CGType) -> m (ByteString, CGType)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (ByteString, CGType) -> m (ByteString, CGType))
-> IO (ByteString, CGType) -> m (ByteString, CGType)
forall a b. (a -> b) -> a -> b
$ do
    let len :: Int64
len = Int -> Int64
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> Int64) -> Int -> Int64
forall a b. (a -> b) -> a -> b
$ ByteString -> Int
B.length ByteString
str
    Ptr Word8
str' <- ByteString -> IO (Ptr Word8)
packByteString ByteString
str
    CString
toCodeset' <- Text -> IO CString
textToCString Text
toCodeset
    CString
fromCodeset' <- Text -> IO CString
textToCString Text
fromCodeset
    Ptr CGType
bytesRead <- IO (Ptr CGType)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Word64)
    Ptr CGType
bytesWritten <- IO (Ptr CGType)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Word64)
    IO (ByteString, CGType) -> IO () -> IO (ByteString, CGType)
forall a b. IO a -> IO b -> IO a
onException (do
        Ptr Word8
result <- (Ptr (Ptr GError) -> IO (Ptr Word8)) -> IO (Ptr Word8)
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO (Ptr Word8)) -> IO (Ptr Word8))
-> (Ptr (Ptr GError) -> IO (Ptr Word8)) -> IO (Ptr Word8)
forall a b. (a -> b) -> a -> b
$ Ptr Word8
-> Int64
-> CString
-> CString
-> Ptr CGType
-> Ptr CGType
-> Ptr (Ptr GError)
-> IO (Ptr Word8)
g_convert Ptr Word8
str' Int64
len CString
toCodeset' CString
fromCodeset' Ptr CGType
bytesRead Ptr CGType
bytesWritten
        CGType
bytesWritten' <- Ptr CGType -> IO CGType
forall a. Storable a => Ptr a -> IO a
peek Ptr CGType
bytesWritten
        Text -> Ptr Word8 -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "convert" Ptr Word8
result
        ByteString
result' <- (CGType -> Ptr Word8 -> IO ByteString
forall a. Integral a => a -> Ptr Word8 -> IO ByteString
unpackByteStringWithLength CGType
bytesWritten') Ptr Word8
result
        Ptr Word8 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word8
result
        CGType
bytesRead' <- Ptr CGType -> IO CGType
forall a. Storable a => Ptr a -> IO a
peek Ptr CGType
bytesRead
        Ptr Word8 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word8
str'
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
toCodeset'
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
fromCodeset'
        Ptr CGType -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CGType
bytesRead
        Ptr CGType -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CGType
bytesWritten
        (ByteString, CGType) -> IO (ByteString, CGType)
forall (m :: * -> *) a. Monad m => a -> m a
return (ByteString
result', CGType
bytesRead')
     ) (do
        Ptr Word8 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word8
str'
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
toCodeset'
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
fromCodeset'
        Ptr CGType -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CGType
bytesRead
        Ptr CGType -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CGType
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 :: ChecksumType -> ByteString -> Text -> Int64 -> m Text
computeHmacForString digestType :: ChecksumType
digestType key :: ByteString
key str :: Text
str length_ :: Int64
length_ = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    let keyLen :: CGType
keyLen = Int -> CGType
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CGType) -> Int -> CGType
forall a b. (a -> b) -> a -> b
$ ByteString -> Int
B.length ByteString
key
    let digestType' :: CUInt
digestType' = (Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CUInt) -> (ChecksumType -> Int) -> ChecksumType -> CUInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ChecksumType -> Int
forall a. Enum a => a -> Int
fromEnum) ChecksumType
digestType
    Ptr Word8
key' <- ByteString -> IO (Ptr Word8)
packByteString ByteString
key
    CString
str' <- Text -> IO CString
textToCString Text
str
    CString
result <- CUInt -> Ptr Word8 -> CGType -> CString -> Int64 -> IO CString
g_compute_hmac_for_string CUInt
digestType' Ptr Word8
key' CGType
keyLen CString
str' Int64
length_
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "computeHmacForString" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    Ptr Word8 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word8
key'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
str'
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
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 :: ChecksumType -> ByteString -> ByteString -> m Text
computeHmacForData digestType :: ChecksumType
digestType key :: ByteString
key data_ :: ByteString
data_ = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    let length_ :: CGType
length_ = Int -> CGType
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CGType) -> Int -> CGType
forall a b. (a -> b) -> a -> b
$ ByteString -> Int
B.length ByteString
data_
    let keyLen :: CGType
keyLen = Int -> CGType
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CGType) -> Int -> CGType
forall a b. (a -> b) -> a -> b
$ ByteString -> Int
B.length ByteString
key
    let digestType' :: CUInt
digestType' = (Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CUInt) -> (ChecksumType -> Int) -> ChecksumType -> CUInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ChecksumType -> Int
forall a. Enum a => a -> Int
fromEnum) ChecksumType
digestType
    Ptr Word8
key' <- ByteString -> IO (Ptr Word8)
packByteString ByteString
key
    Ptr Word8
data_' <- ByteString -> IO (Ptr Word8)
packByteString ByteString
data_
    CString
result <- CUInt -> Ptr Word8 -> CGType -> Ptr Word8 -> CGType -> IO CString
g_compute_hmac_for_data CUInt
digestType' Ptr Word8
key' CGType
keyLen Ptr Word8
data_' CGType
length_
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "computeHmacForData" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    Ptr Word8 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word8
key'
    Ptr Word8 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word8
data_'
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
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 :: ChecksumType -> Bytes -> Bytes -> m Text
computeHmacForBytes digestType :: ChecksumType
digestType key :: Bytes
key data_ :: Bytes
data_ = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    let digestType' :: CUInt
digestType' = (Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CUInt) -> (ChecksumType -> Int) -> ChecksumType -> CUInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ChecksumType -> Int
forall a. Enum a => a -> Int
fromEnum) ChecksumType
digestType
    Ptr Bytes
key' <- Bytes -> IO (Ptr Bytes)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Bytes
key
    Ptr Bytes
data_' <- Bytes -> IO (Ptr Bytes)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Bytes
data_
    CString
result <- CUInt -> Ptr Bytes -> Ptr Bytes -> IO CString
g_compute_hmac_for_bytes CUInt
digestType' Ptr Bytes
key' Ptr Bytes
data_'
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "computeHmacForBytes" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    Bytes -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Bytes
key
    Bytes -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Bytes
data_
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
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 -> Text -> Int64 -> m Text
computeChecksumForString checksumType :: ChecksumType
checksumType str :: Text
str length_ :: Int64
length_ = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    let checksumType' :: CUInt
checksumType' = (Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CUInt) -> (ChecksumType -> Int) -> ChecksumType -> CUInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ChecksumType -> Int
forall a. Enum a => a -> Int
fromEnum) ChecksumType
checksumType
    CString
str' <- Text -> IO CString
textToCString Text
str
    CString
result <- CUInt -> CString -> Int64 -> IO CString
g_compute_checksum_for_string CUInt
checksumType' CString
str' Int64
length_
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "computeChecksumForString" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
str'
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
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 -> ByteString -> m Text
computeChecksumForData checksumType :: ChecksumType
checksumType data_ :: ByteString
data_ = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    let length_ :: CGType
length_ = Int -> CGType
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CGType) -> Int -> CGType
forall a b. (a -> b) -> a -> b
$ ByteString -> Int
B.length ByteString
data_
    let checksumType' :: CUInt
checksumType' = (Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CUInt) -> (ChecksumType -> Int) -> ChecksumType -> CUInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ChecksumType -> Int
forall a. Enum a => a -> Int
fromEnum) ChecksumType
checksumType
    Ptr Word8
data_' <- ByteString -> IO (Ptr Word8)
packByteString ByteString
data_
    CString
result <- CUInt -> Ptr Word8 -> CGType -> IO CString
g_compute_checksum_for_data CUInt
checksumType' Ptr Word8
data_' CGType
length_
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "computeChecksumForData" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    Ptr Word8 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word8
data_'
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
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 -> Bytes -> m Text
computeChecksumForBytes checksumType :: ChecksumType
checksumType data_ :: Bytes
data_ = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    let checksumType' :: CUInt
checksumType' = (Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CUInt) -> (ChecksumType -> Int) -> ChecksumType -> CUInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ChecksumType -> Int
forall a. Enum a => a -> Int
fromEnum) ChecksumType
checksumType
    Ptr Bytes
data_' <- Bytes -> IO (Ptr Bytes)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Bytes
data_
    CString
result <- CUInt -> Ptr Bytes -> IO CString
g_compute_checksum_for_bytes CUInt
checksumType' Ptr Bytes
data_'
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "computeChecksumForBytes" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    Bytes -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Bytes
data_
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
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 :: Int32 -> m ()
close fd :: Int32
fd = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    IO () -> IO () -> IO ()
forall a b. IO a -> IO b -> IO a
onException (do
        CInt
_ <- (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ Int32 -> Ptr (Ptr GError) -> IO CInt
g_close Int32
fd
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     ) (do
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
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 :: m ()
clearError  = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    IO () -> IO () -> IO ()
forall a b. IO a -> IO b -> IO a
onException (do
        (Ptr (Ptr GError) -> IO ()) -> IO ()
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO ()) -> IO ())
-> (Ptr (Ptr GError) -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ Ptr (Ptr GError) -> IO ()
g_clear_error
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     ) (do
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
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 :: Int32 -> m Source
childWatchSourceNew pid :: Int32
pid = IO Source -> m Source
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Source -> m Source) -> IO Source -> m Source
forall a b. (a -> b) -> a -> b
$ do
    Ptr Source
result <- Int32 -> IO (Ptr Source)
g_child_watch_source_new Int32
pid
    Text -> Ptr Source -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "childWatchSourceNew" Ptr Source
result
    Source
result' <- ((ManagedPtr Source -> Source) -> Ptr Source -> IO Source
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Source -> Source
GLib.Source.Source) Ptr Source
result
    Source -> IO Source
forall (m :: * -> *) a. Monad m => a -> m a
return Source
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 :: Int32 -> Int32 -> ChildWatchFunc -> m Word32
childWatchAdd priority :: Int32
priority pid :: Int32
pid function :: ChildWatchFunc
function = IO Word32 -> m Word32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ do
    FunPtr C_ChildWatchFunc
function' <- C_ChildWatchFunc -> IO (FunPtr C_ChildWatchFunc)
GLib.Callbacks.mk_ChildWatchFunc (Maybe (Ptr (FunPtr C_ChildWatchFunc))
-> C_ChildWatchFunc -> C_ChildWatchFunc
GLib.Callbacks.wrap_ChildWatchFunc Maybe (Ptr (FunPtr C_ChildWatchFunc))
forall a. Maybe a
Nothing (ChildWatchFunc -> C_ChildWatchFunc
GLib.Callbacks.drop_closures_ChildWatchFunc ChildWatchFunc
function))
    let data_ :: Ptr ()
data_ = FunPtr C_ChildWatchFunc -> Ptr ()
forall a b. FunPtr a -> Ptr b
castFunPtrToPtr FunPtr C_ChildWatchFunc
function'
    let notify :: FunPtr (Ptr a -> IO ())
notify = FunPtr (Ptr a -> IO ())
forall a. FunPtr (Ptr a -> IO ())
safeFreeFunPtrPtr
    Word32
result <- Int32
-> Int32
-> FunPtr C_ChildWatchFunc
-> Ptr ()
-> FunPtr C_DestroyNotify
-> IO Word32
g_child_watch_add_full Int32
priority Int32
pid FunPtr C_ChildWatchFunc
function' Ptr ()
data_ FunPtr C_DestroyNotify
forall a. FunPtr (Ptr a -> IO ())
notify
    Word32 -> IO Word32
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
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 :: Word32 -> Word32 -> Word32 -> m Text
checkVersion requiredMajor :: Word32
requiredMajor requiredMinor :: Word32
requiredMinor requiredMicro :: Word32
requiredMicro = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
result <- Word32 -> Word32 -> Word32 -> IO CString
glib_check_version Word32
requiredMajor Word32
requiredMinor Word32
requiredMicro
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "checkVersion" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
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 :: [Char] -> m Int32
chdir path :: [Char]
path = IO Int32 -> m Int32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int32 -> m Int32) -> IO Int32 -> m Int32
forall a b. (a -> b) -> a -> b
$ do
    CString
path' <- [Char] -> IO CString
stringToCString [Char]
path
    Int32
result <- CString -> IO Int32
g_chdir CString
path'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
path'
    Int32 -> IO Int32
forall (m :: * -> *) a. Monad m => a -> m a
return Int32
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 :: [Char] -> Maybe [Char] -> m [Char]
canonicalizeFilename filename :: [Char]
filename relativeTo :: Maybe [Char]
relativeTo = IO [Char] -> m [Char]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [Char] -> m [Char]) -> IO [Char] -> m [Char]
forall a b. (a -> b) -> a -> b
$ do
    CString
filename' <- [Char] -> IO CString
stringToCString [Char]
filename
    CString
maybeRelativeTo <- case Maybe [Char]
relativeTo of
        Nothing -> CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
forall a. Ptr a
nullPtr
        Just jRelativeTo :: [Char]
jRelativeTo -> do
            CString
jRelativeTo' <- [Char] -> IO CString
stringToCString [Char]
jRelativeTo
            CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
jRelativeTo'
    CString
result <- CString -> CString -> IO CString
g_canonicalize_filename CString
filename' CString
maybeRelativeTo
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "canonicalizeFilename" CString
result
    [Char]
result' <- HasCallStack => CString -> IO [Char]
CString -> IO [Char]
cstringToString CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
filename'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeRelativeTo
    [Char] -> IO [Char]
forall (m :: * -> *) a. Monad m => a -> m a
return [Char]
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 :: Text -> [[Char]] -> m [Char]
buildPathv separator :: Text
separator args :: [[Char]]
args = IO [Char] -> m [Char]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [Char] -> m [Char]) -> IO [Char] -> m [Char]
forall a b. (a -> b) -> a -> b
$ do
    CString
separator' <- Text -> IO CString
textToCString Text
separator
    Ptr CString
args' <- [[Char]] -> IO (Ptr CString)
packZeroTerminatedFileNameArray [[Char]]
args
    CString
result <- CString -> Ptr CString -> IO CString
g_build_pathv CString
separator' Ptr CString
args'
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "buildPathv" CString
result
    [Char]
result' <- HasCallStack => CString -> IO [Char]
CString -> IO [Char]
cstringToString CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
separator'
    (CString -> IO ()) -> Ptr CString -> IO ()
forall a b. (Ptr a -> IO b) -> Ptr (Ptr a) -> IO ()
mapZeroTerminatedCArray CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
args'
    Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
args'
    [Char] -> IO [Char]
forall (m :: * -> *) a. Monad m => a -> m a
return [Char]
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 :: [[Char]] -> m [Char]
buildFilenamev args :: [[Char]]
args = IO [Char] -> m [Char]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [Char] -> m [Char]) -> IO [Char] -> m [Char]
forall a b. (a -> b) -> a -> b
$ do
    Ptr CString
args' <- [[Char]] -> IO (Ptr CString)
packZeroTerminatedFileNameArray [[Char]]
args
    CString
result <- Ptr CString -> IO CString
g_build_filenamev Ptr CString
args'
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "buildFilenamev" CString
result
    [Char]
result' <- HasCallStack => CString -> IO [Char]
CString -> IO [Char]
cstringToString CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    (CString -> IO ()) -> Ptr CString -> IO ()
forall a b. (Ptr a -> IO b) -> Ptr (Ptr a) -> IO ()
mapZeroTerminatedCArray CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
args'
    Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
args'
    [Char] -> IO [Char]
forall (m :: * -> *) a. Monad m => a -> m a
return [Char]
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 :: Int32 -> Int32 -> m ()
bitUnlock address :: Int32
address lockBit :: Int32
lockBit = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    ChildWatchFunc
g_bit_unlock Int32
address Int32
lockBit
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
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 :: Int32 -> Int32 -> m Bool
bitTrylock address :: Int32
address lockBit :: Int32
lockBit = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    CInt
result <- Int32 -> Int32 -> IO CInt
g_bit_trylock Int32
address Int32
lockBit
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
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 :: CULong -> m Word32
bitStorage number :: CULong
number = IO Word32 -> m Word32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ do
    Word32
result <- CULong -> IO Word32
g_bit_storage CULong
number
    Word32 -> IO Word32
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
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 :: CULong -> Int32 -> m Int32
bitNthMsf mask :: CULong
mask nthBit :: Int32
nthBit = IO Int32 -> m Int32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int32 -> m Int32) -> IO Int32 -> m Int32
forall a b. (a -> b) -> a -> b
$ do
    Int32
result <- CULong -> Int32 -> IO Int32
g_bit_nth_msf CULong
mask Int32
nthBit
    Int32 -> IO Int32
forall (m :: * -> *) a. Monad m => a -> m a
return Int32
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 :: CULong -> Int32 -> m Int32
bitNthLsf mask :: CULong
mask nthBit :: Int32
nthBit = IO Int32 -> m Int32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int32 -> m Int32) -> IO Int32 -> m Int32
forall a b. (a -> b) -> a -> b
$ do
    Int32
result <- CULong -> Int32 -> IO Int32
g_bit_nth_lsf CULong
mask Int32
nthBit
    Int32 -> IO Int32
forall (m :: * -> *) a. Monad m => a -> m a
return Int32
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 :: Int32 -> Int32 -> m ()
bitLock address :: Int32
address lockBit :: Int32
lockBit = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    ChildWatchFunc
g_bit_lock Int32
address Int32
lockBit
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
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 :: [Char] -> m [Char]
basename fileName :: [Char]
fileName = IO [Char] -> m [Char]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [Char] -> m [Char]) -> IO [Char] -> m [Char]
forall a b. (a -> b) -> a -> b
$ do
    CString
fileName' <- [Char] -> IO CString
stringToCString [Char]
fileName
    CString
result <- CString -> IO CString
g_basename CString
fileName'
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "basename" CString
result
    [Char]
result' <- HasCallStack => CString -> IO [Char]
CString -> IO [Char]
cstringToString CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
fileName'
    [Char] -> IO [Char]
forall (m :: * -> *) a. Monad m => a -> m a
return [Char]
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 :: Maybe ByteString -> m Text
base64Encode data_ :: Maybe ByteString
data_ = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    let len :: CGType
len = case Maybe ByteString
data_ of
            Nothing -> 0
            Just jData_ :: ByteString
jData_ -> Int -> CGType
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CGType) -> Int -> CGType
forall a b. (a -> b) -> a -> b
$ ByteString -> Int
B.length ByteString
jData_
    Ptr Word8
maybeData_ <- case Maybe ByteString
data_ of
        Nothing -> Ptr Word8 -> IO (Ptr Word8)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Word8
forall a. Ptr a
nullPtr
        Just jData_ :: ByteString
jData_ -> do
            Ptr Word8
jData_' <- ByteString -> IO (Ptr Word8)
packByteString ByteString
jData_
            Ptr Word8 -> IO (Ptr Word8)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Word8
jData_'
    CString
result <- Ptr Word8 -> CGType -> IO CString
g_base64_encode Ptr Word8
maybeData_ CGType
len
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "base64Encode" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    Ptr Word8 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word8
maybeData_
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
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 :: ByteString -> m (Word8, ByteString)
base64DecodeInplace text :: ByteString
text = IO (Word8, ByteString) -> m (Word8, ByteString)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Word8, ByteString) -> m (Word8, ByteString))
-> IO (Word8, ByteString) -> m (Word8, ByteString)
forall a b. (a -> b) -> a -> b
$ do
    let outLen :: CGType
outLen = Int -> CGType
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CGType) -> Int -> CGType
forall a b. (a -> b) -> a -> b
$ ByteString -> Int
B.length ByteString
text
    Ptr Word8
text' <- ByteString -> IO (Ptr Word8)
packByteString ByteString
text
    Ptr (Ptr Word8)
text'' <- IO (Ptr (Ptr Word8))
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr (Ptr Word8))
    Ptr (Ptr Word8) -> Ptr Word8 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke Ptr (Ptr Word8)
text'' Ptr Word8
text'
    Ptr CGType
outLen' <- IO (Ptr CGType)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Word64)
    Ptr CGType -> CGType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke Ptr CGType
outLen' CGType
outLen
    Word8
result <- Ptr (Ptr Word8) -> Ptr CGType -> IO Word8
g_base64_decode_inplace Ptr (Ptr Word8)
text'' Ptr CGType
outLen'
    CGType
outLen'' <- Ptr CGType -> IO CGType
forall a. Storable a => Ptr a -> IO a
peek Ptr CGType
outLen'
    Ptr Word8
text''' <- Ptr (Ptr Word8) -> IO (Ptr Word8)
forall a. Storable a => Ptr a -> IO a
peek Ptr (Ptr Word8)
text''
    ByteString
text'''' <- (CGType -> Ptr Word8 -> IO ByteString
forall a. Integral a => a -> Ptr Word8 -> IO ByteString
unpackByteStringWithLength CGType
outLen'') Ptr Word8
text'''
    Ptr Word8 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word8
text'''
    Ptr (Ptr Word8) -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr (Ptr Word8)
text''
    Ptr CGType -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CGType
outLen'
    (Word8, ByteString) -> IO (Word8, ByteString)
forall (m :: * -> *) a. Monad m => a -> m a
return (Word8
result, ByteString
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 -> m ByteString
base64Decode text :: Text
text = IO ByteString -> m ByteString
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO ByteString -> m ByteString) -> IO ByteString -> m ByteString
forall a b. (a -> b) -> a -> b
$ do
    CString
text' <- Text -> IO CString
textToCString Text
text
    Ptr CGType
outLen <- IO (Ptr CGType)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Word64)
    Ptr Word8
result <- CString -> Ptr CGType -> IO (Ptr Word8)
g_base64_decode CString
text' Ptr CGType
outLen
    CGType
outLen' <- Ptr CGType -> IO CGType
forall a. Storable a => Ptr a -> IO a
peek Ptr CGType
outLen
    Text -> Ptr Word8 -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "base64Decode" Ptr Word8
result
    ByteString
result' <- (CGType -> Ptr Word8 -> IO ByteString
forall a. Integral a => a -> Ptr Word8 -> IO ByteString
unpackByteStringWithLength CGType
outLen') Ptr Word8
result
    Ptr Word8 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word8
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
text'
    Ptr CGType -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CGType
outLen
    ByteString -> IO ByteString
forall (m :: * -> *) a. Monad m => a -> m a
return ByteString
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 :: Int32 -> m ()
atomicRefCountInit arc :: Int32
arc = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Int32 -> IO ()
g_atomic_ref_count_init Int32
arc
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
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 :: Int32 -> m ()
atomicRefCountInc arc :: Int32
arc = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Int32 -> IO ()
g_atomic_ref_count_inc Int32
arc
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
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 :: Int32 -> m Bool
atomicRefCountDec arc :: Int32
arc = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    CInt
result <- Int32 -> IO CInt
g_atomic_ref_count_dec Int32
arc
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
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 :: Int32 -> Int32 -> m Bool
atomicRefCountCompare arc :: Int32
arc val :: Int32
val = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    CInt
result <- Int32 -> Int32 -> IO CInt
g_atomic_ref_count_compare Int32
arc Int32
val
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
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 :: Ptr () -> C_DestroyNotify -> m ()
atomicRcBoxReleaseFull memBlock :: Ptr ()
memBlock clearFunc :: C_DestroyNotify
clearFunc = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr (FunPtr C_DestroyNotify)
ptrclearFunc <- IO (Ptr (FunPtr C_DestroyNotify))
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr (FunPtr GLib.Callbacks.C_DestroyNotify))
    FunPtr C_DestroyNotify
clearFunc' <- C_DestroyNotify -> IO (FunPtr C_DestroyNotify)
GLib.Callbacks.mk_DestroyNotify (Maybe (Ptr (FunPtr C_DestroyNotify))
-> C_DestroyNotify -> C_DestroyNotify
GLib.Callbacks.wrap_DestroyNotify (Ptr (FunPtr C_DestroyNotify)
-> Maybe (Ptr (FunPtr C_DestroyNotify))
forall a. a -> Maybe a
Just Ptr (FunPtr C_DestroyNotify)
ptrclearFunc) C_DestroyNotify
clearFunc)
    Ptr (FunPtr C_DestroyNotify) -> FunPtr C_DestroyNotify -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke Ptr (FunPtr C_DestroyNotify)
ptrclearFunc FunPtr C_DestroyNotify
clearFunc'
    Ptr () -> FunPtr C_DestroyNotify -> IO ()
g_atomic_rc_box_release_full Ptr ()
memBlock FunPtr C_DestroyNotify
clearFunc'
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
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 :: Ptr () -> m ()
atomicRcBoxRelease memBlock :: Ptr ()
memBlock = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    C_DestroyNotify
g_atomic_rc_box_release Ptr ()
memBlock
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
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 :: Ptr () -> m CGType
atomicRcBoxGetSize memBlock :: Ptr ()
memBlock = IO CGType -> m CGType
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO CGType -> m CGType) -> IO CGType -> m CGType
forall a b. (a -> b) -> a -> b
$ do
    CGType
result <- Ptr () -> IO CGType
g_atomic_rc_box_get_size Ptr ()
memBlock
    CGType -> IO CGType
forall (m :: * -> *) a. Monad m => a -> m a
return CGType
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 atomic 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 :: CGType -> Ptr () -> m (Ptr ())
atomicRcBoxDup blockSize :: CGType
blockSize memBlock :: Ptr ()
memBlock = IO (Ptr ()) -> m (Ptr ())
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Ptr ()) -> m (Ptr ())) -> IO (Ptr ()) -> m (Ptr ())
forall a b. (a -> b) -> a -> b
$ do
    Ptr ()
result <- CGType -> Ptr () -> IO (Ptr ())
g_atomic_rc_box_dup CGType
blockSize Ptr ()
memBlock
    Ptr () -> IO (Ptr ())
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr ()
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 :: CGType -> m (Ptr ())
atomicRcBoxAlloc0 blockSize :: CGType
blockSize = IO (Ptr ()) -> m (Ptr ())
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Ptr ()) -> m (Ptr ())) -> IO (Ptr ()) -> m (Ptr ())
forall a b. (a -> b) -> a -> b
$ do
    Ptr ()
result <- CGType -> IO (Ptr ())
g_atomic_rc_box_alloc0 CGType
blockSize
    Ptr () -> IO (Ptr ())
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr ()
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 :: CGType -> m (Ptr ())
atomicRcBoxAlloc blockSize :: CGType
blockSize = IO (Ptr ()) -> m (Ptr ())
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Ptr ()) -> m (Ptr ())) -> IO (Ptr ()) -> m (Ptr ())
forall a b. (a -> b) -> a -> b
$ do
    Ptr ()
result <- CGType -> IO (Ptr ())
g_atomic_rc_box_alloc CGType
blockSize
    Ptr () -> IO (Ptr ())
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr ()
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 :: Ptr () -> m (Ptr ())
atomicRcBoxAcquire memBlock :: Ptr ()
memBlock = IO (Ptr ()) -> m (Ptr ())
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Ptr ()) -> m (Ptr ())) -> IO (Ptr ()) -> m (Ptr ())
forall a b. (a -> b) -> a -> b
$ do
    Ptr ()
result <- Ptr () -> IO (Ptr ())
g_atomic_rc_box_acquire Ptr ()
memBlock
    Ptr () -> IO (Ptr ())
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr ()
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 :: Ptr () -> CGType -> m CGType
atomicPointerXor atomic :: Ptr ()
atomic val :: CGType
val = IO CGType -> m CGType
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO CGType -> m CGType) -> IO CGType -> m CGType
forall a b. (a -> b) -> a -> b
$ do
    CGType
result <- Ptr () -> CGType -> IO CGType
g_atomic_pointer_xor Ptr ()
atomic CGType
val
    CGType -> IO CGType
forall (m :: * -> *) a. Monad m => a -> m a
return CGType
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 :: Ptr () -> Ptr () -> m ()
atomicPointerSet atomic :: Ptr ()
atomic newval :: Ptr ()
newval = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr () -> C_DestroyNotify
g_atomic_pointer_set Ptr ()
atomic Ptr ()
newval
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
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 :: Ptr () -> CGType -> m CGType
atomicPointerOr atomic :: Ptr ()
atomic val :: CGType
val = IO CGType -> m CGType
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO CGType -> m CGType) -> IO CGType -> m CGType
forall a b. (a -> b) -> a -> b
$ do
    CGType
result <- Ptr () -> CGType -> IO CGType
g_atomic_pointer_or Ptr ()
atomic CGType
val
    CGType -> IO CGType
forall (m :: * -> *) a. Monad m => a -> m a
return CGType
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 :: Ptr () -> m (Ptr ())
atomicPointerGet atomic :: Ptr ()
atomic = IO (Ptr ()) -> m (Ptr ())
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Ptr ()) -> m (Ptr ())) -> IO (Ptr ()) -> m (Ptr ())
forall a b. (a -> b) -> a -> b
$ do
    Ptr ()
result <- Ptr () -> IO (Ptr ())
g_atomic_pointer_get Ptr ()
atomic
    Ptr () -> IO (Ptr ())
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr ()
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 :: Ptr () -> Ptr () -> Ptr () -> m Bool
atomicPointerCompareAndExchange atomic :: Ptr ()
atomic oldval :: Ptr ()
oldval newval :: Ptr ()
newval = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    CInt
result <- Ptr () -> Ptr () -> C_SourceFunc
g_atomic_pointer_compare_and_exchange Ptr ()
atomic Ptr ()
oldval Ptr ()
newval
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
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 :: Ptr () -> CGType -> m CGType
atomicPointerAnd atomic :: Ptr ()
atomic val :: CGType
val = IO CGType -> m CGType
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO CGType -> m CGType) -> IO CGType -> m CGType
forall a b. (a -> b) -> a -> b
$ do
    CGType
result <- Ptr () -> CGType -> IO CGType
g_atomic_pointer_and Ptr ()
atomic CGType
val
    CGType -> IO CGType
forall (m :: * -> *) a. Monad m => a -> m a
return CGType
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 :: Ptr () -> Int64 -> m Int64
atomicPointerAdd atomic :: Ptr ()
atomic val :: Int64
val = IO Int64 -> m Int64
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int64 -> m Int64) -> IO Int64 -> m Int64
forall a b. (a -> b) -> a -> b
$ do
    Int64
result <- Ptr () -> Int64 -> IO Int64
g_atomic_pointer_add Ptr ()
atomic Int64
val
    Int64 -> IO Int64
forall (m :: * -> *) a. Monad m => a -> m a
return Int64
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 :: Word32 -> Word32 -> m Word32
atomicIntXor atomic :: Word32
atomic val :: Word32
val = IO Word32 -> m Word32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ do
    Word32
result <- Word32 -> Word32 -> IO Word32
g_atomic_int_xor Word32
atomic Word32
val
    Word32 -> IO Word32
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
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 :: Int32 -> Int32 -> m ()
atomicIntSet atomic :: Int32
atomic newval :: Int32
newval = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    ChildWatchFunc
g_atomic_int_set Int32
atomic Int32
newval
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
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 :: Word32 -> Word32 -> m Word32
atomicIntOr atomic :: Word32
atomic val :: Word32
val = IO Word32 -> m Word32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ do
    Word32
result <- Word32 -> Word32 -> IO Word32
g_atomic_int_or Word32
atomic Word32
val
    Word32 -> IO Word32
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
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 :: Int32 -> m ()
atomicIntInc atomic :: Int32
atomic = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Int32 -> IO ()
g_atomic_int_inc Int32
atomic
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
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 :: Int32 -> m Int32
atomicIntGet atomic :: Int32
atomic = IO Int32 -> m Int32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int32 -> m Int32) -> IO Int32 -> m Int32
forall a b. (a -> b) -> a -> b
$ do
    Int32
result <- Int32 -> IO Int32
g_atomic_int_get Int32
atomic
    Int32 -> IO Int32
forall (m :: * -> *) a. Monad m => a -> m a
return Int32
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 :: Int32 -> Int32 -> m Int32
atomicIntExchangeAndAdd atomic :: Int32
atomic val :: Int32
val = IO Int32 -> m Int32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int32 -> m Int32) -> IO Int32 -> m Int32
forall a b. (a -> b) -> a -> b
$ do
    Int32
result <- Int32 -> Int32 -> IO Int32
g_atomic_int_exchange_and_add Int32
atomic Int32
val
    Int32 -> IO Int32
forall (m :: * -> *) a. Monad m => a -> m a
return Int32
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 :: Int32 -> m Bool
atomicIntDecAndTest atomic :: Int32
atomic = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    CInt
result <- Int32 -> IO CInt
g_atomic_int_dec_and_test Int32
atomic
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
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 :: Int32 -> Int32 -> Int32 -> m Bool
atomicIntCompareAndExchange atomic :: Int32
atomic oldval :: Int32
oldval newval :: Int32
newval = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    CInt
result <- Int32 -> Int32 -> Int32 -> IO CInt
g_atomic_int_compare_and_exchange Int32
atomic Int32
oldval Int32
newval
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
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 :: Word32 -> Word32 -> m Word32
atomicIntAnd atomic :: Word32
atomic val :: Word32
val = IO Word32 -> m Word32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ do
    Word32
result <- Word32 -> Word32 -> IO Word32
g_atomic_int_and Word32
atomic Word32
val
    Word32 -> IO Word32
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
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 :: Int32 -> Int32 -> m Int32
atomicIntAdd atomic :: Int32
atomic val :: Int32
val = IO Int32 -> m Int32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int32 -> m Int32) -> IO Int32 -> m Int32
forall a b. (a -> b) -> a -> b
$ do
    Int32
result <- Int32 -> Int32 -> IO Int32
g_atomic_int_add Int32
atomic Int32
val
    Int32 -> IO Int32
forall (m :: * -> *) a. Monad m => a -> m a
return Int32
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 :: IO () -> m ()
atexit func :: IO ()
func = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr (FunPtr (IO ()))
ptrfunc <- IO (Ptr (FunPtr (IO ())))
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr (FunPtr GLib.Callbacks.C_VoidFunc))
    FunPtr (IO ())
func' <- IO () -> IO (FunPtr (IO ()))
GLib.Callbacks.mk_VoidFunc (Maybe (Ptr (FunPtr (IO ()))) -> IO () -> IO ()
GLib.Callbacks.wrap_VoidFunc (Ptr (FunPtr (IO ())) -> Maybe (Ptr (FunPtr (IO ())))
forall a. a -> Maybe a
Just Ptr (FunPtr (IO ()))
ptrfunc) IO ()
func)
    Ptr (FunPtr (IO ())) -> FunPtr (IO ()) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke Ptr (FunPtr (IO ()))
ptrfunc FunPtr (IO ())
func'
    FunPtr (IO ()) -> IO ()
g_atexit FunPtr (IO ())
func'
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
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 :: Text
-> Text
-> Int32
-> Text
-> Text
-> GError
-> Word32
-> Int32
-> m ()
assertionMessageError domain :: Text
domain file :: Text
file line :: Int32
line func :: Text
func expr :: Text
expr error_ :: GError
error_ errorDomain :: Word32
errorDomain errorCode :: Int32
errorCode = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    CString
domain' <- Text -> IO CString
textToCString Text
domain
    CString
file' <- Text -> IO CString
textToCString Text
file
    CString
func' <- Text -> IO CString
textToCString Text
func
    CString
expr' <- Text -> IO CString
textToCString Text
expr
    Ptr GError
error_' <- GError -> IO (Ptr GError)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr GError
error_
    CString
-> CString
-> Int32
-> CString
-> CString
-> Ptr GError
-> Word32
-> Int32
-> IO ()
g_assertion_message_error CString
domain' CString
file' Int32
line CString
func' CString
expr' Ptr GError
error_' Word32
errorDomain Int32
errorCode
    GError -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr GError
error_
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
domain'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
file'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
func'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
expr'
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
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 :: Text
-> Text -> Int32 -> Text -> Text -> Text -> Text -> Text -> m ()
assertionMessageCmpstr domain :: Text
domain file :: Text
file line :: Int32
line func :: Text
func expr :: Text
expr arg1 :: Text
arg1 cmp :: Text
cmp arg2 :: Text
arg2 = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    CString
domain' <- Text -> IO CString
textToCString Text
domain
    CString
file' <- Text -> IO CString
textToCString Text
file
    CString
func' <- Text -> IO CString
textToCString Text
func
    CString
expr' <- Text -> IO CString
textToCString Text
expr
    CString
arg1' <- Text -> IO CString
textToCString Text
arg1
    CString
cmp' <- Text -> IO CString
textToCString Text
cmp
    CString
arg2' <- Text -> IO CString
textToCString Text
arg2
    CString
-> CString
-> Int32
-> CString
-> CString
-> CString
-> CString
-> CString
-> IO ()
g_assertion_message_cmpstr CString
domain' CString
file' Int32
line CString
func' CString
expr' CString
arg1' CString
cmp' CString
arg2'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
domain'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
file'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
func'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
expr'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
arg1'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
cmp'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
arg2'
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
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 :: Text -> Text -> Int32 -> Text -> Text -> m ()
assertionMessage domain :: Text
domain file :: Text
file line :: Int32
line func :: Text
func message :: Text
message = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    CString
domain' <- Text -> IO CString
textToCString Text
domain
    CString
file' <- Text -> IO CString
textToCString Text
file
    CString
func' <- Text -> IO CString
textToCString Text
func
    CString
message' <- Text -> IO CString
textToCString Text
message
    CString -> CString -> Int32 -> CString -> CString -> IO ()
g_assertion_message CString
domain' CString
file' Int32
line CString
func' CString
message'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
domain'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
file'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
func'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
message'
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
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 :: Text -> Text -> Int32 -> Text -> Text -> m ()
assertWarning logDomain :: Text
logDomain file :: Text
file line :: Int32
line prettyFunction :: Text
prettyFunction expression :: Text
expression = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    CString
logDomain' <- Text -> IO CString
textToCString Text
logDomain
    CString
file' <- Text -> IO CString
textToCString Text
file
    CString
prettyFunction' <- Text -> IO CString
textToCString Text
prettyFunction
    CString
expression' <- Text -> IO CString
textToCString Text
expression
    CString -> CString -> Int32 -> CString -> CString -> IO ()
g_assert_warning CString
logDomain' CString
file' Int32
line CString
prettyFunction' CString
expression'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
logDomain'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
file'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
prettyFunction'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
expression'
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
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 :: Int8 -> m Int32
asciiXdigitValue c :: Int8
c = IO Int32 -> m Int32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int32 -> m Int32) -> IO Int32 -> m Int32
forall a b. (a -> b) -> a -> b
$ do
    Int32
result <- Int8 -> IO Int32
g_ascii_xdigit_value Int8
c
    Int32 -> IO Int32
forall (m :: * -> *) a. Monad m => a -> m a
return Int32
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 :: Int8 -> m Int8
asciiToupper c :: Int8
c = IO Int8 -> m Int8
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int8 -> m Int8) -> IO Int8 -> m Int8
forall a b. (a -> b) -> a -> b
$ do
    Int8
result <- Int8 -> IO Int8
g_ascii_toupper Int8
c
    Int8 -> IO Int8
forall (m :: * -> *) a. Monad m => a -> m a
return Int8
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 :: Int8 -> m Int8
asciiTolower c :: Int8
c = IO Int8 -> m Int8
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int8 -> m Int8) -> IO Int8 -> m Int8
forall a b. (a -> b) -> a -> b
$ do
    Int8
result <- Int8 -> IO Int8
g_ascii_tolower Int8
c
    Int8 -> IO Int8
forall (m :: * -> *) a. Monad m => a -> m a
return Int8
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 :: Text -> Int64 -> m Text
asciiStrup str :: Text
str len :: Int64
len = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
str' <- Text -> IO CString
textToCString Text
str
    CString
result <- CString -> Int64 -> IO CString
g_ascii_strup CString
str' Int64
len
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "asciiStrup" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
str'
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
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 :: Text -> Word32 -> m (CGType, Text)
asciiStrtoull nptr :: Text
nptr base :: Word32
base = IO (CGType, Text) -> m (CGType, Text)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (CGType, Text) -> m (CGType, Text))
-> IO (CGType, Text) -> m (CGType, Text)
forall a b. (a -> b) -> a -> b
$ do
    CString
nptr' <- Text -> IO CString
textToCString Text
nptr
    Ptr CString
endptr <- IO (Ptr CString)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr CString)
    CGType
result <- CString -> Ptr CString -> Word32 -> IO CGType
g_ascii_strtoull CString
nptr' Ptr CString
endptr Word32
base
    CString
endptr' <- Ptr CString -> IO CString
forall a. Storable a => Ptr a -> IO a
peek Ptr CString
endptr
    Text
endptr'' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
endptr'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
nptr'
    Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
endptr
    (CGType, Text) -> IO (CGType, Text)
forall (m :: * -> *) a. Monad m => a -> m a
return (CGType
result, Text
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 :: Text -> Word32 -> m (Int64, Text)
asciiStrtoll nptr :: Text
nptr base :: Word32
base = IO (Int64, Text) -> m (Int64, Text)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Int64, Text) -> m (Int64, Text))
-> IO (Int64, Text) -> m (Int64, Text)
forall a b. (a -> b) -> a -> b
$ do
    CString
nptr' <- Text -> IO CString
textToCString Text
nptr
    Ptr CString
endptr <- IO (Ptr CString)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr CString)
    Int64
result <- CString -> Ptr CString -> Word32 -> IO Int64
g_ascii_strtoll CString
nptr' Ptr CString
endptr Word32
base
    CString
endptr' <- Ptr CString -> IO CString
forall a. Storable a => Ptr a -> IO a
peek Ptr CString
endptr
    Text
endptr'' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
endptr'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
nptr'
    Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
endptr
    (Int64, Text) -> IO (Int64, Text)
forall (m :: * -> *) a. Monad m => a -> m a
return (Int64
result, Text
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 :: Text -> m (Double, Text)
asciiStrtod nptr :: Text
nptr = IO (Double, Text) -> m (Double, Text)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Double, Text) -> m (Double, Text))
-> IO (Double, Text) -> m (Double, Text)
forall a b. (a -> b) -> a -> b
$ do
    CString
nptr' <- Text -> IO CString
textToCString Text
nptr
    Ptr CString
endptr <- IO (Ptr CString)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr CString)
    CDouble
result <- CString -> Ptr CString -> IO CDouble
g_ascii_strtod CString
nptr' Ptr CString
endptr
    let result' :: Double
result' = CDouble -> Double
forall a b. (Real a, Fractional b) => a -> b
realToFrac CDouble
result
    CString
endptr' <- Ptr CString -> IO CString
forall a. Storable a => Ptr a -> IO a
peek Ptr CString
endptr
    Text
endptr'' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
endptr'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
nptr'
    Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
endptr
    (Double, Text) -> IO (Double, Text)
forall (m :: * -> *) a. Monad m => a -> m a
return (Double
result', Text
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 :: Text -> Text -> CGType -> m Int32
asciiStrncasecmp s1 :: Text
s1 s2 :: Text
s2 n :: CGType
n = IO Int32 -> m Int32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int32 -> m Int32) -> IO Int32 -> m Int32
forall a b. (a -> b) -> a -> b
$ do
    CString
s1' <- Text -> IO CString
textToCString Text
s1
    CString
s2' <- Text -> IO CString
textToCString Text
s2
    Int32
result <- CString -> CString -> CGType -> IO Int32
g_ascii_strncasecmp CString
s1' CString
s2' CGType
n
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
s1'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
s2'
    Int32 -> IO Int32
forall (m :: * -> *) a. Monad m => a -> m a
return Int32
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 :: Text -> Word32 -> CGType -> CGType -> m CGType
asciiStringToUnsigned str :: Text
str base :: Word32
base min :: CGType
min max :: CGType
max = IO CGType -> m CGType
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO CGType -> m CGType) -> IO CGType -> m CGType
forall a b. (a -> b) -> a -> b
$ do
    CString
str' <- Text -> IO CString
textToCString Text
str
    Ptr CGType
outNum <- IO (Ptr CGType)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Word64)
    IO CGType -> IO () -> IO CGType
forall a b. IO a -> IO b -> IO a
onException (do
        CInt
_ <- (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ CString
-> Word32
-> CGType
-> CGType
-> Ptr CGType
-> Ptr (Ptr GError)
-> IO CInt
g_ascii_string_to_unsigned CString
str' Word32
base CGType
min CGType
max Ptr CGType
outNum
        CGType
outNum' <- Ptr CGType -> IO CGType
forall a. Storable a => Ptr a -> IO a
peek Ptr CGType
outNum
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
str'
        Ptr CGType -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CGType
outNum
        CGType -> IO CGType
forall (m :: * -> *) a. Monad m => a -> m a
return CGType
outNum'
     ) (do
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
str'
        Ptr CGType -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CGType
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 :: Text -> Word32 -> Int64 -> Int64 -> m Int64
asciiStringToSigned str :: Text
str base :: Word32
base min :: Int64
min max :: Int64
max = IO Int64 -> m Int64
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int64 -> m Int64) -> IO Int64 -> m Int64
forall a b. (a -> b) -> a -> b
$ do
    CString
str' <- Text -> IO CString
textToCString Text
str
    Ptr Int64
outNum <- IO (Ptr Int64)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Int64)
    IO Int64 -> IO () -> IO Int64
forall a b. IO a -> IO b -> IO a
onException (do
        CInt
_ <- (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ CString
-> Word32
-> Int64
-> Int64
-> Ptr Int64
-> Ptr (Ptr GError)
-> IO CInt
g_ascii_string_to_signed CString
str' Word32
base Int64
min Int64
max Ptr Int64
outNum
        Int64
outNum' <- Ptr Int64 -> IO Int64
forall a. Storable a => Ptr a -> IO a
peek Ptr Int64
outNum
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
str'
        Ptr Int64 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Int64
outNum
        Int64 -> IO Int64
forall (m :: * -> *) a. Monad m => a -> m a
return Int64
outNum'
     ) (do
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
str'
        Ptr Int64 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Int64
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 :: Text -> Int64 -> m Text
asciiStrdown str :: Text
str len :: Int64
len = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
str' <- Text -> IO CString
textToCString Text
str
    CString
result <- CString -> Int64 -> IO CString
g_ascii_strdown CString
str' Int64
len
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "asciiStrdown" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
str'
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
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 :: Text -> Text -> m Int32
asciiStrcasecmp s1 :: Text
s1 s2 :: Text
s2 = IO Int32 -> m Int32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int32 -> m Int32) -> IO Int32 -> m Int32
forall a b. (a -> b) -> a -> b
$ do
    CString
s1' <- Text -> IO CString
textToCString Text
s1
    CString
s2' <- Text -> IO CString
textToCString Text
s2
    Int32
result <- CString -> CString -> IO Int32
g_ascii_strcasecmp CString
s1' CString
s2'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
s1'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
s2'
    Int32 -> IO Int32
forall (m :: * -> *) a. Monad m => a -> m a
return Int32
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 :: Text -> Int32 -> Text -> Double -> m Text
asciiFormatd buffer :: Text
buffer bufLen :: Int32
bufLen format :: Text
format d :: Double
d = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
buffer' <- Text -> IO CString
textToCString Text
buffer
    CString
format' <- Text -> IO CString
textToCString Text
format
    let d' :: CDouble
d' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
d
    CString
result <- CString -> Int32 -> CString -> CDouble -> IO CString
g_ascii_formatd CString
buffer' Int32
bufLen CString
format' CDouble
d'
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "asciiFormatd" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
buffer'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
format'
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
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 :: Text -> Int32 -> Double -> m Text
asciiDtostr buffer :: Text
buffer bufLen :: Int32
bufLen d :: Double
d = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
buffer' <- Text -> IO CString
textToCString Text
buffer
    let d' :: CDouble
d' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
d
    CString
result <- CString -> Int32 -> CDouble -> IO CString
g_ascii_dtostr CString
buffer' Int32
bufLen CDouble
d'
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "asciiDtostr" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
buffer'
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
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 :: Int8 -> m Int32
asciiDigitValue c :: Int8
c = IO Int32 -> m Int32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int32 -> m Int32) -> IO Int32 -> m Int32
forall a b. (a -> b) -> a -> b
$ do
    Int32
result <- Int8 -> IO Int32
g_ascii_digit_value Int8
c
    Int32 -> IO Int32
forall (m :: * -> *) a. Monad m => a -> m a
return Int32
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 :: [Char] -> Int32 -> m Int32
access filename :: [Char]
filename mode :: Int32
mode = IO Int32 -> m Int32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int32 -> m Int32) -> IO Int32 -> m Int32
forall a b. (a -> b) -> a -> b
$ do
    CString
filename' <- [Char] -> IO CString
stringToCString [Char]
filename
    Int32
result <- CString -> Int32 -> IO Int32
g_access CString
filename' Int32
mode
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
filename'
    Int32 -> IO Int32
forall (m :: * -> *) a. Monad m => a -> m a
return Int32
result