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

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                            ,


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


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


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


-- ** convertWithIconv #method:convertWithIconv#
    convertWithIconv                        ,


-- ** datalistClear #method:datalistClear#
    datalistClear                           ,


-- ** datalistGetData #method:datalistGetData#
    datalistGetData                         ,


-- ** datalistGetFlags #method:datalistGetFlags#
    datalistGetFlags                        ,


-- ** datalistIdGetData #method:datalistIdGetData#
    datalistIdGetData                       ,


-- ** datalistIdRemoveNoNotify #method:datalistIdRemoveNoNotify#
    datalistIdRemoveNoNotify                ,


-- ** datalistIdReplaceData #method:datalistIdReplaceData#
    datalistIdReplaceData                   ,


-- ** datalistIdSetDataFull #method:datalistIdSetDataFull#
    datalistIdSetDataFull                   ,


-- ** datalistInit #method:datalistInit#
    datalistInit                            ,


-- ** datalistSetFlags #method:datalistSetFlags#
    datalistSetFlags                        ,


-- ** datalistUnsetFlags #method:datalistUnsetFlags#
    datalistUnsetFlags                      ,


-- ** datasetDestroy #method:datasetDestroy#
    datasetDestroy                          ,


-- ** datasetIdGetData #method:datasetIdGetData#
    datasetIdGetData                        ,


-- ** datasetIdRemoveNoNotify #method:datasetIdRemoveNoNotify#
    datasetIdRemoveNoNotify                 ,


-- ** datasetIdSetDataFull #method:datasetIdSetDataFull#
    datasetIdSetDataFull                    ,


-- ** dcgettext #method:dcgettext#
    dcgettext                               ,


-- ** dgettext #method:dgettext#
    dgettext                                ,


-- ** directEqual #method:directEqual#
    directEqual                             ,


-- ** directHash #method:directHash#
    directHash                              ,


-- ** dngettext #method:dngettext#
    dngettext                               ,


-- ** doubleEqual #method:doubleEqual#
    doubleEqual                             ,


-- ** doubleHash #method:doubleHash#
    doubleHash                              ,


-- ** dpgettext #method:dpgettext#
    dpgettext                               ,


-- ** dpgettext2 #method:dpgettext2#
    dpgettext2                              ,


-- ** environGetenv #method:environGetenv#
    environGetenv                           ,


-- ** environSetenv #method:environSetenv#
    environSetenv                           ,


-- ** environUnsetenv #method:environUnsetenv#
    environUnsetenv                         ,


-- ** fileErrorFromErrno #method:fileErrorFromErrno#
    fileErrorFromErrno                      ,


-- ** fileErrorQuark #method:fileErrorQuark#
    fileErrorQuark                          ,


-- ** fileGetContents #method:fileGetContents#
    fileGetContents                         ,


-- ** fileOpenTmp #method:fileOpenTmp#
    fileOpenTmp                             ,


-- ** fileReadLink #method:fileReadLink#
    fileReadLink                            ,


-- ** fileSetContents #method:fileSetContents#
    fileSetContents                         ,


-- ** fileTest #method:fileTest#
    fileTest                                ,


-- ** filenameDisplayBasename #method:filenameDisplayBasename#
    filenameDisplayBasename                 ,


-- ** filenameDisplayName #method:filenameDisplayName#
    filenameDisplayName                     ,


-- ** filenameFromUri #method:filenameFromUri#
    filenameFromUri                         ,


-- ** filenameFromUtf8 #method:filenameFromUtf8#
    filenameFromUtf8                        ,


-- ** filenameToUri #method:filenameToUri#
    filenameToUri                           ,


-- ** filenameToUtf8 #method:filenameToUtf8#
    filenameToUtf8                          ,


-- ** findProgramInPath #method:findProgramInPath#
    findProgramInPath                       ,


-- ** formatSize #method:formatSize#
    formatSize                              ,


-- ** formatSizeForDisplay #method:formatSizeForDisplay#
    formatSizeForDisplay                    ,


-- ** formatSizeFull #method:formatSizeFull#
    formatSizeFull                          ,


-- ** free #method:free#
    free                                    ,


-- ** getApplicationName #method:getApplicationName#
    getApplicationName                      ,


-- ** getCharset #method:getCharset#
    getCharset                              ,


-- ** getCodeset #method:getCodeset#
    getCodeset                              ,


-- ** getCurrentDir #method:getCurrentDir#
    getCurrentDir                           ,


-- ** getCurrentTime #method:getCurrentTime#
    getCurrentTime                          ,


-- ** getEnviron #method:getEnviron#
    getEnviron                              ,


-- ** getFilenameCharsets #method:getFilenameCharsets#
    getFilenameCharsets                     ,


-- ** getHomeDir #method:getHomeDir#
    getHomeDir                              ,


-- ** getHostName #method:getHostName#
    getHostName                             ,


-- ** getLanguageNames #method:getLanguageNames#
    getLanguageNames                        ,


-- ** getLocaleVariants #method:getLocaleVariants#
    getLocaleVariants                       ,


-- ** getMonotonicTime #method:getMonotonicTime#
    getMonotonicTime                        ,


-- ** getNumProcessors #method:getNumProcessors#
    getNumProcessors                        ,


-- ** getPrgname #method:getPrgname#
    getPrgname                              ,


-- ** getRealName #method:getRealName#
    getRealName                             ,


-- ** getRealTime #method:getRealTime#
    getRealTime                             ,


-- ** getSystemConfigDirs #method:getSystemConfigDirs#
    getSystemConfigDirs                     ,


-- ** getSystemDataDirs #method:getSystemDataDirs#
    getSystemDataDirs                       ,


-- ** getTmpDir #method:getTmpDir#
    getTmpDir                               ,


-- ** getUserCacheDir #method:getUserCacheDir#
    getUserCacheDir                         ,


-- ** getUserConfigDir #method:getUserConfigDir#
    getUserConfigDir                        ,


-- ** getUserDataDir #method:getUserDataDir#
    getUserDataDir                          ,


-- ** getUserName #method:getUserName#
    getUserName                             ,


-- ** getUserRuntimeDir #method:getUserRuntimeDir#
    getUserRuntimeDir                       ,


-- ** getUserSpecialDir #method:getUserSpecialDir#
    getUserSpecialDir                       ,


-- ** getenv #method:getenv#
    getenv                                  ,


-- ** hostnameIsAsciiEncoded #method:hostnameIsAsciiEncoded#
    hostnameIsAsciiEncoded                  ,


-- ** hostnameIsIpAddress #method:hostnameIsIpAddress#
    hostnameIsIpAddress                     ,


-- ** hostnameIsNonAscii #method:hostnameIsNonAscii#
    hostnameIsNonAscii                      ,


-- ** hostnameToAscii #method:hostnameToAscii#
    hostnameToAscii                         ,


-- ** hostnameToUnicode #method:hostnameToUnicode#
    hostnameToUnicode                       ,


-- ** iconv #method:iconv#
    iconv                                   ,


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


-- ** mkdtemp #method:mkdtemp#
    mkdtemp                                 ,


-- ** mkdtempFull #method:mkdtempFull#
    mkdtempFull                             ,


-- ** mkstemp #method:mkstemp#
    mkstemp                                 ,


-- ** mkstempFull #method:mkstempFull#
    mkstempFull                             ,


-- ** nullifyPointer #method:nullifyPointer#
    nullifyPointer                          ,


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


-- ** realloc #method:realloc#
    realloc                                 ,


-- ** reallocN #method:reallocN#
    reallocN                                ,


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


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


-- ** strvGetType #method:strvGetType#
    strvGetType                             ,


-- ** strvLength #method:strvLength#
    strvLength                              ,


-- ** testAddDataFunc #method:testAddDataFunc#
    testAddDataFunc                         ,


-- ** testAddFunc #method:testAddFunc#
    testAddFunc                             ,


-- ** testAssertExpectedMessagesInternal #method:testAssertExpectedMessagesInternal#
    testAssertExpectedMessagesInternal      ,


-- ** testBug #method:testBug#
    testBug                                 ,


-- ** testBugBase #method:testBugBase#
    testBugBase                             ,


-- ** testExpectMessage #method:testExpectMessage#
    testExpectMessage                       ,


-- ** testFail #method:testFail#
    testFail                                ,


-- ** testFailed #method:testFailed#
    testFailed                              ,


-- ** testGetDir #method:testGetDir#
    testGetDir                              ,


-- ** testIncomplete #method:testIncomplete#
    testIncomplete                          ,


-- ** testLogTypeName #method:testLogTypeName#
    testLogTypeName                         ,


-- ** testQueueDestroy #method:testQueueDestroy#
    testQueueDestroy                        ,


-- ** testQueueFree #method:testQueueFree#
    testQueueFree                           ,


-- ** testRandDouble #method:testRandDouble#
    testRandDouble                          ,


-- ** testRandDoubleRange #method:testRandDoubleRange#
    testRandDoubleRange                     ,


-- ** testRandInt #method:testRandInt#
    testRandInt                             ,


-- ** testRandIntRange #method:testRandIntRange#
    testRandIntRange                        ,


-- ** testRun #method:testRun#
    testRun                                 ,


-- ** testRunSuite #method:testRunSuite#
    testRunSuite                            ,


-- ** testSetNonfatalAssertions #method:testSetNonfatalAssertions#
    testSetNonfatalAssertions               ,


-- ** testSkip #method:testSkip#
    testSkip                                ,


-- ** testSubprocess #method:testSubprocess#
    testSubprocess                          ,


-- ** testTimerElapsed #method:testTimerElapsed#
    testTimerElapsed                        ,


-- ** testTimerLast #method:testTimerLast#
    testTimerLast                           ,


-- ** testTimerStart #method:testTimerStart#
    testTimerStart                          ,


-- ** testTrapAssertions #method:testTrapAssertions#
    testTrapAssertions                      ,


-- ** testTrapFork #method:testTrapFork#
    testTrapFork                            ,


-- ** testTrapHasPassed #method:testTrapHasPassed#
    testTrapHasPassed                       ,


-- ** testTrapReachedTimeout #method:testTrapReachedTimeout#
    testTrapReachedTimeout                  ,


-- ** testTrapSubprocess #method:testTrapSubprocess#
    testTrapSubprocess                      ,


-- ** timeoutAdd #method:timeoutAdd#
    timeoutAdd                              ,


-- ** timeoutAddSeconds #method:timeoutAddSeconds#
    timeoutAddSeconds                       ,


-- ** timeoutSourceNew #method:timeoutSourceNew#
    timeoutSourceNew                        ,


-- ** timeoutSourceNewSeconds #method:timeoutSourceNewSeconds#
    timeoutSourceNewSeconds                 ,


-- ** tryMalloc #method:tryMalloc#
    tryMalloc                               ,


-- ** tryMalloc0 #method:tryMalloc0#
    tryMalloc0                              ,


-- ** tryMalloc0N #method:tryMalloc0N#
    tryMalloc0N                             ,


-- ** tryMallocN #method:tryMallocN#
    tryMallocN                              ,


-- ** tryRealloc #method:tryRealloc#
    tryRealloc                              ,


-- ** tryReallocN #method:tryReallocN#
    tryReallocN                             ,


-- ** unicharBreakType #method:unicharBreakType#
    unicharBreakType                        ,


-- ** unicharCombiningClass #method:unicharCombiningClass#
    unicharCombiningClass                   ,


-- ** unicharCompose #method:unicharCompose#
    unicharCompose                          ,


-- ** unicharDecompose #method:unicharDecompose#
    unicharDecompose                        ,


-- ** unicharDigitValue #method:unicharDigitValue#
    unicharDigitValue                       ,


-- ** unicharGetMirrorChar #method:unicharGetMirrorChar#
    unicharGetMirrorChar                    ,


-- ** unicharGetScript #method:unicharGetScript#
    unicharGetScript                        ,


-- ** unicharIsalnum #method:unicharIsalnum#
    unicharIsalnum                          ,


-- ** unicharIsalpha #method:unicharIsalpha#
    unicharIsalpha                          ,


-- ** unicharIscntrl #method:unicharIscntrl#
    unicharIscntrl                          ,


-- ** unicharIsdefined #method:unicharIsdefined#
    unicharIsdefined                        ,


-- ** unicharIsdigit #method:unicharIsdigit#
    unicharIsdigit                          ,


-- ** unicharIsgraph #method:unicharIsgraph#
    unicharIsgraph                          ,


-- ** unicharIslower #method:unicharIslower#
    unicharIslower                          ,


-- ** unicharIsmark #method:unicharIsmark#
    unicharIsmark                           ,


-- ** unicharIsprint #method:unicharIsprint#
    unicharIsprint                          ,


-- ** unicharIspunct #method:unicharIspunct#
    unicharIspunct                          ,


-- ** unicharIsspace #method:unicharIsspace#
    unicharIsspace                          ,


-- ** unicharIstitle #method:unicharIstitle#
    unicharIstitle                          ,


-- ** unicharIsupper #method:unicharIsupper#
    unicharIsupper                          ,


-- ** unicharIswide #method:unicharIswide#
    unicharIswide                           ,


-- ** unicharIswideCjk #method:unicharIswideCjk#
    unicharIswideCjk                        ,


-- ** unicharIsxdigit #method:unicharIsxdigit#
    unicharIsxdigit                         ,


-- ** unicharIszerowidth #method:unicharIszerowidth#
    unicharIszerowidth                      ,


-- ** unicharTolower #method:unicharTolower#
    unicharTolower                          ,


-- ** unicharTotitle #method:unicharTotitle#
    unicharTotitle                          ,


-- ** unicharToupper #method:unicharToupper#
    unicharToupper                          ,


-- ** unicharType #method:unicharType#
    unicharType                             ,


-- ** unicharValidate #method:unicharValidate#
    unicharValidate                         ,


-- ** unicharXdigitValue #method:unicharXdigitValue#
    unicharXdigitValue                      ,


-- ** unicodeCanonicalDecomposition #method:unicodeCanonicalDecomposition#
    unicodeCanonicalDecomposition           ,


-- ** unicodeCanonicalOrdering #method:unicodeCanonicalOrdering#
    unicodeCanonicalOrdering                ,


-- ** unicodeScriptFromIso15924 #method:unicodeScriptFromIso15924#
    unicodeScriptFromIso15924               ,


-- ** unicodeScriptToIso15924 #method:unicodeScriptToIso15924#
    unicodeScriptToIso15924                 ,


-- ** unixErrorQuark #method:unixErrorQuark#
    unixErrorQuark                          ,


-- ** unixFdAddFull #method:unixFdAddFull#
    unixFdAddFull                           ,


-- ** unixFdSourceNew #method:unixFdSourceNew#
    unixFdSourceNew                         ,


-- ** unixOpenPipe #method:unixOpenPipe#
    unixOpenPipe                            ,


-- ** unixSetFdNonblocking #method:unixSetFdNonblocking#
    unixSetFdNonblocking                    ,


-- ** unixSignalAdd #method:unixSignalAdd#
    unixSignalAdd                           ,


-- ** unixSignalSourceNew #method:unixSignalSourceNew#
    unixSignalSourceNew                     ,


-- ** unlink #method:unlink#
    unlink                                  ,


-- ** unsetenv #method:unsetenv#
    unsetenv                                ,


-- ** uriEscapeString #method:uriEscapeString#
    uriEscapeString                         ,


-- ** uriListExtractUris #method:uriListExtractUris#
    uriListExtractUris                      ,


-- ** uriParseScheme #method:uriParseScheme#
    uriParseScheme                          ,


-- ** uriUnescapeSegment #method:uriUnescapeSegment#
    uriUnescapeSegment                      ,


-- ** uriUnescapeString #method:uriUnescapeString#
    uriUnescapeString                       ,


-- ** usleep #method:usleep#
    usleep                                  ,


-- ** utf8Casefold #method:utf8Casefold#
    utf8Casefold                            ,


-- ** utf8Collate #method:utf8Collate#
    utf8Collate                             ,


-- ** utf8CollateKey #method:utf8CollateKey#
    utf8CollateKey                          ,


-- ** utf8CollateKeyForFilename #method:utf8CollateKeyForFilename#
    utf8CollateKeyForFilename               ,


-- ** utf8FindNextChar #method:utf8FindNextChar#
    utf8FindNextChar                        ,


-- ** utf8FindPrevChar #method:utf8FindPrevChar#
    utf8FindPrevChar                        ,


-- ** utf8GetChar #method:utf8GetChar#
    utf8GetChar                             ,


-- ** utf8GetCharValidated #method:utf8GetCharValidated#
    utf8GetCharValidated                    ,


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


-- ** 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.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.IConv as GLib.IConv
import {-# SOURCE #-} qualified GI.GLib.Structs.IOChannel as GLib.IOChannel
import {-# SOURCE #-} qualified GI.GLib.Structs.LogField as GLib.LogField
import {-# SOURCE #-} qualified GI.GLib.Structs.MemVTable as GLib.MemVTable
import {-# SOURCE #-} qualified GI.GLib.Structs.PatternSpec as GLib.PatternSpec
import {-# SOURCE #-} qualified GI.GLib.Structs.PollFD as GLib.PollFD
import {-# SOURCE #-} qualified GI.GLib.Structs.Source as GLib.Source
import {-# SOURCE #-} qualified GI.GLib.Structs.String as GLib.String
import {-# SOURCE #-} qualified GI.GLib.Structs.TestSuite as GLib.TestSuite
import {-# SOURCE #-} qualified GI.GLib.Structs.TimeVal as GLib.TimeVal

-- function g_variant_get_gtype
-- Args : []
-- Lengths : []
-- returnType : Just (TBasicType TGType)
-- throws : False
-- Skip return : False

foreign import ccall "g_variant_get_gtype" g_variant_get_gtype :: 
    IO CGType

{- |
/No description available in the introspection data./
-}
variantGetGtype ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m GType
variantGetGtype  = liftIO $ do
    result <- g_variant_get_gtype
    let result' = GType result
    return result'


-- function g_utf8_validate
-- Args : [Arg {argCName = "str", argType = TCArray False (-1) 1 (TBasicType TUInt8), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a pointer to character data", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "max_len", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "max bytes to validate, or -1 to go until NUL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "end", argType = TBasicType TUTF8, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "return location for end of valid data", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : [Arg {argCName = "max_len", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "max bytes to validate, or -1 to go until NUL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_utf8_validate" g_utf8_validate :: 
    Ptr Word8 ->                            -- str : TCArray False (-1) 1 (TBasicType TUInt8)
    Int64 ->                                -- max_len : TBasicType TInt64
    Ptr CString ->                          -- end : TBasicType TUTF8
    IO CInt

{- |
Validates UTF-8 encoded text. /@str@/ is the text to validate;
if /@str@/ is nul-terminated, then /@maxLen@/ can be -1, otherwise
/@maxLen@/ should be the number of bytes to validate.
If /@end@/ is non-'Nothing', then the end of the valid range
will be stored there (i.e. the start of the first invalid
character if some bytes were invalid, or the end of the text
being validated otherwise).

Note that 'GI.GLib.Functions.utf8Validate' returns 'False' if /@maxLen@/ is
positive and any of the /@maxLen@/ bytes are nul.

Returns 'True' if all of /@str@/ was valid. Many GLib and GTK+
routines require valid UTF-8 as input; so data read from a file
or the network should be checked with 'GI.GLib.Functions.utf8Validate' before
doing anything else with it.
-}
utf8Validate ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    ByteString
    {- ^ /@str@/: a pointer to character data -}
    -> m ((Bool, T.Text))
    {- ^ __Returns:__ 'True' if the text was valid UTF-8 -}
utf8Validate str = liftIO $ do
    let maxLen = fromIntegral $ B.length str
    str' <- packByteString str
    end <- allocMem :: IO (Ptr CString)
    result <- g_utf8_validate str' maxLen end
    let result' = (/= 0) result
    end' <- peek end
    end'' <- cstringToText end'
    freeMem str'
    freeMem end
    return (result', end'')


-- function g_utf8_substring
-- Args : [Arg {argCName = "str", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a UTF-8 encoded string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "start_pos", argType = TBasicType TLong, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a character offset within @str", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "end_pos", argType = TBasicType TLong, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "another character offset within @str", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "g_utf8_substring" g_utf8_substring :: 
    CString ->                              -- str : TBasicType TUTF8
    CLong ->                                -- start_pos : TBasicType TLong
    CLong ->                                -- end_pos : TBasicType TLong
    IO CString

{- |
Copies a substring out of a UTF-8 encoded string.
The substring will contain /@endPos@/ - /@startPos@/ characters.

@since 2.30
-}
utf8Substring ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@str@/: a UTF-8 encoded string -}
    -> CLong
    {- ^ /@startPos@/: a character offset within /@str@/ -}
    -> CLong
    {- ^ /@endPos@/: another character offset within /@str@/ -}
    -> m T.Text
    {- ^ __Returns:__ a newly allocated copy of the requested
    substring. Free with 'GI.GLib.Functions.free' when no longer needed. -}
utf8Substring str startPos endPos = liftIO $ do
    str' <- textToCString str
    result <- g_utf8_substring str' startPos endPos
    checkUnexpectedReturnNULL "utf8Substring" result
    result' <- cstringToText result
    freeMem result
    freeMem str'
    return result'


-- function g_utf8_strup
-- Args : [Arg {argCName = "str", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a UTF-8 encoded string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "len", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "length of @str, in bytes, or -1 if @str is nul-terminated.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "g_utf8_strup" g_utf8_strup :: 
    CString ->                              -- str : TBasicType TUTF8
    Int64 ->                                -- len : TBasicType TInt64
    IO CString

{- |
Converts all Unicode characters in the string that have a case
to uppercase. The exact manner that this is done depends
on the current locale, and may result in the number of
characters in the string increasing. (For instance, the
German ess-zet will be changed to SS.)
-}
utf8Strup ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@str@/: a UTF-8 encoded string -}
    -> Int64
    {- ^ /@len@/: length of /@str@/, in bytes, or -1 if /@str@/ is nul-terminated. -}
    -> m T.Text
    {- ^ __Returns:__ a newly allocated string, with all characters
   converted to uppercase. -}
utf8Strup str len = liftIO $ do
    str' <- textToCString str
    result <- g_utf8_strup str' len
    checkUnexpectedReturnNULL "utf8Strup" result
    result' <- cstringToText result
    freeMem result
    freeMem str'
    return result'


-- function g_utf8_strreverse
-- Args : [Arg {argCName = "str", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a UTF-8 encoded string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "len", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the maximum length of @str to use, in bytes. If @len < 0,\n    then the string is nul-terminated.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "g_utf8_strreverse" g_utf8_strreverse :: 
    CString ->                              -- str : TBasicType TUTF8
    Int64 ->                                -- len : TBasicType TInt64
    IO CString

{- |
Reverses a UTF-8 string. /@str@/ must be valid UTF-8 encoded text.
(Use 'GI.GLib.Functions.utf8Validate' on all text before trying to use UTF-8
utility functions with it.)

This function is intended for programmatic uses of reversed strings.
It pays no attention to decomposed characters, combining marks, byte
order marks, directional indicators (LRM, LRO, etc) and similar
characters which might need special handling when reversing a string
for display purposes.

Note that unlike 'GI.GLib.Functions.strreverse', this function returns
newly-allocated memory, which should be freed with 'GI.GLib.Functions.free' when
no longer needed.

@since 2.2
-}
utf8Strreverse ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@str@/: a UTF-8 encoded string -}
    -> Int64
    {- ^ /@len@/: the maximum length of /@str@/ to use, in bytes. If /@len@/ \< 0,
    then the string is nul-terminated. -}
    -> m T.Text
    {- ^ __Returns:__ a newly-allocated string which is the reverse of /@str@/ -}
utf8Strreverse str len = liftIO $ do
    str' <- textToCString str
    result <- g_utf8_strreverse str' len
    checkUnexpectedReturnNULL "utf8Strreverse" result
    result' <- cstringToText result
    freeMem result
    freeMem str'
    return result'


-- function g_utf8_strrchr
-- Args : [Arg {argCName = "p", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a nul-terminated UTF-8 encoded string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "len", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the maximum length of @p", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "c", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "g_utf8_strrchr" g_utf8_strrchr :: 
    CString ->                              -- p : TBasicType TUTF8
    Int64 ->                                -- len : TBasicType TInt64
    CInt ->                                 -- c : TBasicType TUniChar
    IO CString

{- |
Find the rightmost occurrence of the given Unicode character
in a UTF-8 encoded string, while limiting the search to /@len@/ bytes.
If /@len@/ is -1, allow unbounded search.
-}
utf8Strrchr ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@p@/: a nul-terminated UTF-8 encoded string -}
    -> Int64
    {- ^ /@len@/: the maximum length of /@p@/ -}
    -> Char
    {- ^ /@c@/: a Unicode character -}
    -> m T.Text
    {- ^ __Returns:__ 'Nothing' if the string does not contain the character,
    otherwise, a pointer to the start of the rightmost occurrence
    of the character in the string. -}
utf8Strrchr p len c = liftIO $ do
    p' <- textToCString p
    let c' = (fromIntegral . ord) c
    result <- g_utf8_strrchr p' len c'
    checkUnexpectedReturnNULL "utf8Strrchr" result
    result' <- cstringToText result
    freeMem result
    freeMem p'
    return result'


-- function g_utf8_strncpy
-- Args : [Arg {argCName = "dest", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "buffer to fill with characters from @src", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "src", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "UTF-8 encoded string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "n", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "character count", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "g_utf8_strncpy" g_utf8_strncpy :: 
    CString ->                              -- dest : TBasicType TUTF8
    CString ->                              -- src : TBasicType TUTF8
    Word64 ->                               -- n : TBasicType TUInt64
    IO CString

{- |
Like the standard C @/strncpy()/@ function, but copies a given number
of characters instead of a given number of bytes. The /@src@/ string
must be valid UTF-8 encoded text. (Use 'GI.GLib.Functions.utf8Validate' on all
text before trying to use UTF-8 utility functions with it.)
-}
utf8Strncpy ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@dest@/: buffer to fill with characters from /@src@/ -}
    -> T.Text
    {- ^ /@src@/: UTF-8 encoded string -}
    -> Word64
    {- ^ /@n@/: character count -}
    -> m T.Text
    {- ^ __Returns:__ /@dest@/ -}
utf8Strncpy dest src n = liftIO $ do
    dest' <- textToCString dest
    src' <- textToCString src
    result <- g_utf8_strncpy dest' src' n
    checkUnexpectedReturnNULL "utf8Strncpy" result
    result' <- cstringToText result
    freeMem result
    freeMem dest'
    freeMem src'
    return result'


-- function g_utf8_strlen
-- Args : [Arg {argCName = "p", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "pointer to the start of a UTF-8 encoded string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "max", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the maximum number of bytes to examine. If @max\n      is less than 0, then the string is assumed to be\n      nul-terminated. If @max is 0, @p will not be examined and\n      may be %NULL. If @max is greater than 0, up to @max\n      bytes are examined", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TLong)
-- throws : False
-- Skip return : False

foreign import ccall "g_utf8_strlen" g_utf8_strlen :: 
    CString ->                              -- p : TBasicType TUTF8
    Int64 ->                                -- max : TBasicType TInt64
    IO CLong

{- |
Computes the length of the string in characters, not including
the terminating nul character. If the /@max@/\'th byte falls in the
middle of a character, the last (partial) character is not counted.
-}
utf8Strlen ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@p@/: pointer to the start of a UTF-8 encoded string -}
    -> Int64
    {- ^ /@max@/: the maximum number of bytes to examine. If /@max@/
      is less than 0, then the string is assumed to be
      nul-terminated. If /@max@/ is 0, /@p@/ will not be examined and
      may be 'Nothing'. If /@max@/ is greater than 0, up to /@max@/
      bytes are examined -}
    -> m CLong
    {- ^ __Returns:__ the length of the string in characters -}
utf8Strlen p max = liftIO $ do
    p' <- textToCString p
    result <- g_utf8_strlen p' max
    freeMem p'
    return result


-- function g_utf8_strdown
-- Args : [Arg {argCName = "str", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a UTF-8 encoded string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "len", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "length of @str, in bytes, or -1 if @str is nul-terminated.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "g_utf8_strdown" g_utf8_strdown :: 
    CString ->                              -- str : TBasicType TUTF8
    Int64 ->                                -- len : TBasicType TInt64
    IO CString

{- |
Converts all Unicode characters in the string that have a case
to lowercase. The exact manner that this is done depends
on the current locale, and may result in the number of
characters in the string changing.
-}
utf8Strdown ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@str@/: a UTF-8 encoded string -}
    -> Int64
    {- ^ /@len@/: length of /@str@/, in bytes, or -1 if /@str@/ is nul-terminated. -}
    -> m T.Text
    {- ^ __Returns:__ a newly allocated string, with all characters
   converted to lowercase. -}
utf8Strdown str len = liftIO $ do
    str' <- textToCString str
    result <- g_utf8_strdown str' len
    checkUnexpectedReturnNULL "utf8Strdown" result
    result' <- cstringToText result
    freeMem result
    freeMem str'
    return result'


-- function g_utf8_strchr
-- Args : [Arg {argCName = "p", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a nul-terminated UTF-8 encoded string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "len", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the maximum length of @p", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "c", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "g_utf8_strchr" g_utf8_strchr :: 
    CString ->                              -- p : TBasicType TUTF8
    Int64 ->                                -- len : TBasicType TInt64
    CInt ->                                 -- c : TBasicType TUniChar
    IO CString

{- |
Finds the leftmost occurrence of the given Unicode character
in a UTF-8 encoded string, while limiting the search to /@len@/ bytes.
If /@len@/ is -1, allow unbounded search.
-}
utf8Strchr ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@p@/: a nul-terminated UTF-8 encoded string -}
    -> Int64
    {- ^ /@len@/: the maximum length of /@p@/ -}
    -> Char
    {- ^ /@c@/: a Unicode character -}
    -> m T.Text
    {- ^ __Returns:__ 'Nothing' if the string does not contain the character,
    otherwise, a pointer to the start of the leftmost occurrence
    of the character in the string. -}
utf8Strchr p len c = liftIO $ do
    p' <- textToCString p
    let c' = (fromIntegral . ord) c
    result <- g_utf8_strchr p' len c'
    checkUnexpectedReturnNULL "utf8Strchr" result
    result' <- cstringToText result
    freeMem result
    freeMem p'
    return result'


-- function g_utf8_prev_char
-- Args : [Arg {argCName = "p", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a pointer to a position within a UTF-8 encoded string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "g_utf8_prev_char" g_utf8_prev_char :: 
    CString ->                              -- p : TBasicType TUTF8
    IO CString

{- |
Finds the previous UTF-8 character in the string before /@p@/.

/@p@/ does not have to be at the beginning of a UTF-8 character. No check
is made to see if the character found is actually valid other than
it starts with an appropriate byte. If /@p@/ might be the first
character of the string, you must use 'GI.GLib.Functions.utf8FindPrevChar' instead.
-}
utf8PrevChar ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@p@/: a pointer to a position within a UTF-8 encoded string -}
    -> m T.Text
    {- ^ __Returns:__ a pointer to the found character -}
utf8PrevChar p = liftIO $ do
    p' <- textToCString p
    result <- g_utf8_prev_char p'
    checkUnexpectedReturnNULL "utf8PrevChar" result
    result' <- cstringToText result
    freeMem result
    freeMem p'
    return result'


-- function g_utf8_pointer_to_offset
-- Args : [Arg {argCName = "str", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a UTF-8 encoded string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "pos", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a pointer to a position within @str", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TLong)
-- throws : False
-- Skip return : False

foreign import ccall "g_utf8_pointer_to_offset" g_utf8_pointer_to_offset :: 
    CString ->                              -- str : TBasicType TUTF8
    CString ->                              -- pos : TBasicType TUTF8
    IO CLong

{- |
Converts from a pointer to position within a string to a integer
character offset.

Since 2.10, this function allows /@pos@/ to be before /@str@/, and returns
a negative offset in this case.
-}
utf8PointerToOffset ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@str@/: a UTF-8 encoded string -}
    -> T.Text
    {- ^ /@pos@/: a pointer to a position within /@str@/ -}
    -> m CLong
    {- ^ __Returns:__ the resulting character offset -}
utf8PointerToOffset str pos = liftIO $ do
    str' <- textToCString str
    pos' <- textToCString pos
    result <- g_utf8_pointer_to_offset str' pos'
    freeMem str'
    freeMem pos'
    return result


-- function g_utf8_offset_to_pointer
-- Args : [Arg {argCName = "str", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a UTF-8 encoded string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "offset", argType = TBasicType TLong, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a character offset within @str", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "g_utf8_offset_to_pointer" g_utf8_offset_to_pointer :: 
    CString ->                              -- str : TBasicType TUTF8
    CLong ->                                -- offset : TBasicType TLong
    IO CString

{- |
Converts from an integer character offset to a pointer to a position
within the string.

Since 2.10, this function allows to pass a negative /@offset@/ to
step backwards. It is usually worth stepping backwards from the end
instead of forwards if /@offset@/ is in the last fourth of the string,
since moving forward is about 3 times faster than moving backward.

Note that this function doesn\'t abort when reaching the end of /@str@/.
Therefore you should be sure that /@offset@/ is within string boundaries
before calling that function. Call 'GI.GLib.Functions.utf8Strlen' when unsure.
This limitation exists as this function is called frequently during
text rendering and therefore has to be as fast as possible.
-}
utf8OffsetToPointer ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@str@/: a UTF-8 encoded string -}
    -> CLong
    {- ^ /@offset@/: a character offset within /@str@/ -}
    -> m T.Text
    {- ^ __Returns:__ the resulting pointer -}
utf8OffsetToPointer str offset = liftIO $ do
    str' <- textToCString str
    result <- g_utf8_offset_to_pointer str' offset
    checkUnexpectedReturnNULL "utf8OffsetToPointer" result
    result' <- cstringToText result
    freeMem result
    freeMem str'
    return result'


-- function g_utf8_normalize
-- Args : [Arg {argCName = "str", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a UTF-8 encoded string.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "len", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "length of @str, in bytes, or -1 if @str is nul-terminated.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "mode", argType = TInterface (Name {namespace = "GLib", name = "NormalizeMode"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the type of normalization to perform.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "g_utf8_normalize" g_utf8_normalize :: 
    CString ->                              -- str : TBasicType TUTF8
    Int64 ->                                -- len : TBasicType TInt64
    CUInt ->                                -- mode : TInterface (Name {namespace = "GLib", name = "NormalizeMode"})
    IO CString

{- |
Converts a string into canonical form, standardizing
such issues as whether a character with an accent
is represented as a base character and combining
accent or as a single precomposed character. The
string has to be valid UTF-8, otherwise 'Nothing' is
returned. You should generally call 'GI.GLib.Functions.utf8Normalize'
before comparing two Unicode strings.

The normalization mode 'GI.GLib.Enums.NormalizeModeDefault' only
standardizes differences that do not affect the
text content, such as the above-mentioned accent
representation. 'GI.GLib.Enums.NormalizeModeAll' also standardizes
the \"compatibility\" characters in Unicode, such
as SUPERSCRIPT THREE to the standard forms
(in this case DIGIT THREE). Formatting information
may be lost but for most text operations such
characters should be considered the same.

'GI.GLib.Enums.NormalizeModeDefaultCompose' and 'GI.GLib.Enums.NormalizeModeAllCompose'
are like 'GI.GLib.Enums.NormalizeModeDefault' and 'GI.GLib.Enums.NormalizeModeAll',
but returned a result with composed forms rather
than a maximally decomposed form. This is often
useful if you intend to convert the string to
a legacy encoding or pass it to a system with
less capable Unicode handling.
-}
utf8Normalize ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@str@/: a UTF-8 encoded string. -}
    -> Int64
    {- ^ /@len@/: length of /@str@/, in bytes, or -1 if /@str@/ is nul-terminated. -}
    -> GLib.Enums.NormalizeMode
    {- ^ /@mode@/: the type of normalization to perform. -}
    -> m T.Text
    {- ^ __Returns:__ a newly allocated string, that is the
  normalized form of /@str@/, or 'Nothing' if /@str@/ is not
  valid UTF-8. -}
utf8Normalize str len mode = liftIO $ do
    str' <- textToCString str
    let mode' = (fromIntegral . fromEnum) mode
    result <- g_utf8_normalize str' len mode'
    checkUnexpectedReturnNULL "utf8Normalize" result
    result' <- cstringToText result
    freeMem result
    freeMem str'
    return result'


-- function g_utf8_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, for no maximum or\n    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.
-}
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, for no maximum or
    if /@p@/ is nul-terminated -}
    -> m Char
    {- ^ __Returns:__ the resulting character. If /@p@/ points to a partial
    sequence at the end of a string that could begin a valid
    character (or if /@maxLen@/ is zero), returns (gunichar)-2;
    otherwise, if /@p@/ does not point to a valid UTF-8 encoded
    Unicode character, returns (gunichar)-1. -}
utf8GetCharValidated p maxLen = liftIO $ do
    p' <- textToCString p
    result <- g_utf8_get_char_validated p' maxLen
    let result' = (chr . fromIntegral) result
    freeMem p'
    return result'


-- function g_utf8_get_char
-- Args : [Arg {argCName = "p", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a pointer to Unicode character encoded as UTF-8", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUniChar)
-- throws : False
-- Skip return : False

foreign import ccall "g_utf8_get_char" g_utf8_get_char :: 
    CString ->                              -- p : TBasicType TUTF8
    IO CInt

{- |
Converts a sequence of bytes encoded as UTF-8 to a Unicode character.

If /@p@/ does not point to a valid UTF-8 encoded character, results
are undefined. If you are not sure that the bytes are complete
valid Unicode characters, you should use 'GI.GLib.Functions.utf8GetCharValidated'
instead.
-}
utf8GetChar ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@p@/: a pointer to Unicode character encoded as UTF-8 -}
    -> m Char
    {- ^ __Returns:__ the resulting character -}
utf8GetChar p = liftIO $ do
    p' <- textToCString p
    result <- g_utf8_get_char p'
    let result' = (chr . fromIntegral) result
    freeMem p'
    return result'


-- function g_utf8_find_prev_char
-- Args : [Arg {argCName = "str", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "pointer to the beginning of a UTF-8 encoded string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "p", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "pointer to some position within @str", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "g_utf8_find_prev_char" g_utf8_find_prev_char :: 
    CString ->                              -- str : TBasicType TUTF8
    CString ->                              -- p : TBasicType TUTF8
    IO CString

{- |
Given a position /@p@/ with a UTF-8 encoded string /@str@/, find the start
of the previous UTF-8 character starting before /@p@/. Returns 'Nothing' if no
UTF-8 characters are present in /@str@/ before /@p@/.

/@p@/ does not have to be at the beginning of a UTF-8 character. No check
is made to see if the character found is actually valid other than
it starts with an appropriate byte.
-}
utf8FindPrevChar ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@str@/: pointer to the beginning of a UTF-8 encoded string -}
    -> T.Text
    {- ^ /@p@/: pointer to some position within /@str@/ -}
    -> m T.Text
    {- ^ __Returns:__ a pointer to the found character or 'Nothing'. -}
utf8FindPrevChar str p = liftIO $ do
    str' <- textToCString str
    p' <- textToCString p
    result <- g_utf8_find_prev_char str' p'
    checkUnexpectedReturnNULL "utf8FindPrevChar" result
    result' <- cstringToText result
    freeMem result
    freeMem str'
    freeMem p'
    return result'


-- function g_utf8_find_next_char
-- Args : [Arg {argCName = "p", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a pointer to a position within a UTF-8 encoded string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "end", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a pointer to the byte following the end of the string,\n    or %NULL to indicate that the string is nul-terminated", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "g_utf8_find_next_char" g_utf8_find_next_char :: 
    CString ->                              -- p : TBasicType TUTF8
    CString ->                              -- end : TBasicType TUTF8
    IO CString

{- |
Finds the start of the next UTF-8 character in the string after /@p@/.

/@p@/ does not have to be at the beginning of a UTF-8 character. No check
is made to see if the character found is actually valid other than
it starts with an appropriate byte.
-}
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 T.Text
    {- ^ __Returns:__ a pointer to the found character or 'Nothing' -}
utf8FindNextChar p end = liftIO $ do
    p' <- textToCString p
    maybeEnd <- case end of
        Nothing -> return nullPtr
        Just jEnd -> do
            jEnd' <- textToCString jEnd
            return jEnd'
    result <- g_utf8_find_next_char p' maybeEnd
    checkUnexpectedReturnNULL "utf8FindNextChar" result
    result' <- cstringToText result
    freeMem result
    freeMem p'
    freeMem maybeEnd
    return result'


-- function g_utf8_collate_key_for_filename
-- Args : [Arg {argCName = "str", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a UTF-8 encoded string.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "len", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "length of @str, in bytes, or -1 if @str is nul-terminated.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "g_utf8_collate_key_for_filename" g_utf8_collate_key_for_filename :: 
    CString ->                              -- str : TBasicType TUTF8
    Int64 ->                                -- len : TBasicType TInt64
    IO CString

{- |
Converts a string into a collation key that can be compared
with other collation keys produced by the same function using @/strcmp()/@.

In order to sort filenames correctly, this function treats the dot \'.\'
as a special case. Most dictionary orderings seem to consider it
insignificant, thus producing the ordering \"event.c\" \"eventgenerator.c\"
\"event.h\" instead of \"event.c\" \"event.h\" \"eventgenerator.c\". Also, we
would like to treat numbers intelligently so that \"file1\" \"file10\" \"file5\"
is sorted as \"file1\" \"file5\" \"file10\".

Note that this function depends on the [current locale][setlocale].

@since 2.8
-}
utf8CollateKeyForFilename ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@str@/: a UTF-8 encoded string. -}
    -> Int64
    {- ^ /@len@/: length of /@str@/, in bytes, or -1 if /@str@/ is nul-terminated. -}
    -> m T.Text
    {- ^ __Returns:__ a newly allocated string. This string should
  be freed with 'GI.GLib.Functions.free' when you are done with it. -}
utf8CollateKeyForFilename str len = liftIO $ do
    str' <- textToCString str
    result <- g_utf8_collate_key_for_filename str' len
    checkUnexpectedReturnNULL "utf8CollateKeyForFilename" result
    result' <- cstringToText result
    freeMem result
    freeMem str'
    return result'


-- function g_utf8_collate_key
-- Args : [Arg {argCName = "str", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a UTF-8 encoded string.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "len", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "length of @str, in bytes, or -1 if @str is nul-terminated.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "g_utf8_collate_key" g_utf8_collate_key :: 
    CString ->                              -- str : TBasicType TUTF8
    Int64 ->                                -- len : TBasicType TInt64
    IO CString

{- |
Converts a string into a collation key that can be compared
with other collation keys produced by the same function using
@/strcmp()/@.

The results of comparing the collation keys of two strings
with @/strcmp()/@ will always be the same as comparing the two
original keys with 'GI.GLib.Functions.utf8Collate'.

Note that this function depends on the [current locale][setlocale].
-}
utf8CollateKey ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@str@/: a UTF-8 encoded string. -}
    -> Int64
    {- ^ /@len@/: length of /@str@/, in bytes, or -1 if /@str@/ is nul-terminated. -}
    -> m T.Text
    {- ^ __Returns:__ a newly allocated string. This string should
  be freed with 'GI.GLib.Functions.free' when you are done with it. -}
utf8CollateKey str len = liftIO $ do
    str' <- textToCString str
    result <- g_utf8_collate_key str' len
    checkUnexpectedReturnNULL "utf8CollateKey" result
    result' <- cstringToText result
    freeMem result
    freeMem str'
    return result'


-- function g_utf8_collate
-- Args : [Arg {argCName = "str1", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a UTF-8 encoded string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "str2", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a UTF-8 encoded string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TInt)
-- throws : False
-- Skip return : False

foreign import ccall "g_utf8_collate" g_utf8_collate :: 
    CString ->                              -- str1 : TBasicType TUTF8
    CString ->                              -- str2 : TBasicType TUTF8
    IO Int32

{- |
Compares two strings for ordering using the linguistically
correct rules for the [current locale][setlocale].
When sorting a large number of strings, it will be significantly
faster to obtain collation keys with 'GI.GLib.Functions.utf8CollateKey' and
compare the keys with @/strcmp()/@ when sorting instead of sorting
the original strings.
-}
utf8Collate ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@str1@/: a UTF-8 encoded string -}
    -> T.Text
    {- ^ /@str2@/: a UTF-8 encoded string -}
    -> m Int32
    {- ^ __Returns:__ \< 0 if /@str1@/ compares before /@str2@/,
  0 if they compare equal, > 0 if /@str1@/ compares after /@str2@/. -}
utf8Collate str1 str2 = liftIO $ do
    str1' <- textToCString str1
    str2' <- textToCString str2
    result <- g_utf8_collate str1' str2'
    freeMem str1'
    freeMem str2'
    return result


-- function g_utf8_casefold
-- Args : [Arg {argCName = "str", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a UTF-8 encoded string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "len", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "length of @str, in bytes, or -1 if @str is nul-terminated.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "g_utf8_casefold" g_utf8_casefold :: 
    CString ->                              -- str : TBasicType TUTF8
    Int64 ->                                -- len : TBasicType TInt64
    IO CString

{- |
Converts a string into a form that is independent of case. The
result will not correspond to any particular case, but can be
compared for equality or ordered with the results of calling
'GI.GLib.Functions.utf8Casefold' on other strings.

Note that calling 'GI.GLib.Functions.utf8Casefold' followed by 'GI.GLib.Functions.utf8Collate' is
only an approximation to the correct linguistic case insensitive
ordering, though it is a fairly good one. Getting this exactly
right would require a more sophisticated collation function that
takes case sensitivity into account. GLib does not currently
provide such a function.
-}
utf8Casefold ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@str@/: a UTF-8 encoded string -}
    -> Int64
    {- ^ /@len@/: length of /@str@/, in bytes, or -1 if /@str@/ is nul-terminated. -}
    -> m T.Text
    {- ^ __Returns:__ a newly allocated string, that is a
  case independent form of /@str@/. -}
utf8Casefold str len = liftIO $ do
    str' <- textToCString str
    result <- g_utf8_casefold str' len
    checkUnexpectedReturnNULL "utf8Casefold" result
    result' <- cstringToText result
    freeMem result
    freeMem str'
    return result'


-- function g_usleep
-- Args : [Arg {argCName = "microseconds", argType = TBasicType TULong, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "number of microseconds to pause", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_usleep" g_usleep :: 
    CULong ->                               -- microseconds : TBasicType TULong
    IO ()

{- |
Pauses the current thread for the given number of microseconds.

There are 1 million microseconds per second (represented by the
'GI.GLib.Constants.USEC_PER_SEC' macro). 'GI.GLib.Functions.usleep' may have limited precision,
depending on hardware and operating system; don\'t rely on the exact
length of the sleep.
-}
usleep ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    CULong
    {- ^ /@microseconds@/: number of microseconds to pause -}
    -> m ()
usleep microseconds = liftIO $ do
    g_usleep microseconds
    return ()


-- function g_uri_unescape_string
-- Args : [Arg {argCName = "escaped_string", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an escaped string to be unescaped.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "illegal_characters", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a string of illegal characters not to be\n     allowed, or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "g_uri_unescape_string" g_uri_unescape_string :: 
    CString ->                              -- escaped_string : TBasicType TUTF8
    CString ->                              -- illegal_characters : TBasicType TUTF8
    IO CString

{- |
Unescapes a whole escaped string.

If any of the characters in /@illegalCharacters@/ or the character zero appears
as an escaped character in /@escapedString@/ then that is an error and 'Nothing'
will be returned. This is useful it you want to avoid for instance having a
slash being expanded in an escaped path element, which might confuse pathname
handling.

@since 2.16
-}
uriUnescapeString ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@escapedString@/: an escaped string to be unescaped. -}
    -> Maybe (T.Text)
    {- ^ /@illegalCharacters@/: a string of illegal characters not to be
     allowed, or 'Nothing'. -}
    -> m T.Text
    {- ^ __Returns:__ an unescaped version of /@escapedString@/. The returned string
should be freed when no longer needed. -}
uriUnescapeString escapedString illegalCharacters = liftIO $ do
    escapedString' <- textToCString escapedString
    maybeIllegalCharacters <- case illegalCharacters of
        Nothing -> return nullPtr
        Just jIllegalCharacters -> do
            jIllegalCharacters' <- textToCString jIllegalCharacters
            return jIllegalCharacters'
    result <- g_uri_unescape_string escapedString' maybeIllegalCharacters
    checkUnexpectedReturnNULL "uriUnescapeString" result
    result' <- cstringToText result
    freeMem result
    freeMem escapedString'
    freeMem maybeIllegalCharacters
    return result'


-- function g_uri_unescape_segment
-- Args : [Arg {argCName = "escaped_string", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "A string, may be %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "escaped_string_end", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Pointer to end of @escaped_string, may be %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "illegal_characters", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "An optional string of illegal characters not to be allowed, may be %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "g_uri_unescape_segment" g_uri_unescape_segment :: 
    CString ->                              -- escaped_string : TBasicType TUTF8
    CString ->                              -- escaped_string_end : TBasicType TUTF8
    CString ->                              -- illegal_characters : TBasicType TUTF8
    IO CString

{- |
Unescapes a segment of an escaped string.

If any of the characters in /@illegalCharacters@/ or the character zero appears
as an escaped character in /@escapedString@/ then that is an error and 'Nothing'
will be returned. This is useful it you want to avoid for instance having a
slash being expanded in an escaped path element, which might confuse pathname
handling.

@since 2.16
-}
uriUnescapeSegment ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Maybe (T.Text)
    {- ^ /@escapedString@/: A string, may be 'Nothing' -}
    -> Maybe (T.Text)
    {- ^ /@escapedStringEnd@/: Pointer to end of /@escapedString@/, may be 'Nothing' -}
    -> Maybe (T.Text)
    {- ^ /@illegalCharacters@/: An optional string of illegal characters not to be allowed, may be 'Nothing' -}
    -> m T.Text
    {- ^ __Returns:__ an unescaped version of /@escapedString@/ or 'Nothing' on error.
The returned string should be freed when no longer needed.  As a
special case if 'Nothing' is given for /@escapedString@/, this function
will return 'Nothing'. -}
uriUnescapeSegment escapedString escapedStringEnd illegalCharacters = liftIO $ do
    maybeEscapedString <- case escapedString of
        Nothing -> return nullPtr
        Just jEscapedString -> do
            jEscapedString' <- textToCString jEscapedString
            return jEscapedString'
    maybeEscapedStringEnd <- case escapedStringEnd of
        Nothing -> return nullPtr
        Just jEscapedStringEnd -> do
            jEscapedStringEnd' <- textToCString jEscapedStringEnd
            return jEscapedStringEnd'
    maybeIllegalCharacters <- case illegalCharacters of
        Nothing -> return nullPtr
        Just jIllegalCharacters -> do
            jIllegalCharacters' <- textToCString jIllegalCharacters
            return jIllegalCharacters'
    result <- g_uri_unescape_segment maybeEscapedString maybeEscapedStringEnd maybeIllegalCharacters
    checkUnexpectedReturnNULL "uriUnescapeSegment" result
    result' <- cstringToText result
    freeMem result
    freeMem maybeEscapedString
    freeMem maybeEscapedStringEnd
    freeMem maybeIllegalCharacters
    return result'


-- function g_uri_parse_scheme
-- Args : [Arg {argCName = "uri", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a valid URI.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "g_uri_parse_scheme" g_uri_parse_scheme :: 
    CString ->                              -- uri : TBasicType TUTF8
    IO CString

{- |
Gets the scheme portion of a URI string. RFC 3986 decodes the scheme as:
>
>URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ]

Common schemes include \"file\", \"http\", \"svn+ssh\", etc.

@since 2.16
-}
uriParseScheme ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@uri@/: a valid URI. -}
    -> m T.Text
    {- ^ __Returns:__ The \"Scheme\" component of the URI, or 'Nothing' on error.
The returned string should be freed when no longer needed. -}
uriParseScheme uri = liftIO $ do
    uri' <- textToCString uri
    result <- g_uri_parse_scheme uri'
    checkUnexpectedReturnNULL "uriParseScheme" result
    result' <- cstringToText result
    freeMem result
    freeMem uri'
    return result'


-- function g_uri_list_extract_uris
-- Args : [Arg {argCName = "uri_list", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an URI list", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TCArray True (-1) (-1) (TBasicType TUTF8))
-- throws : False
-- Skip return : False

foreign import ccall "g_uri_list_extract_uris" g_uri_list_extract_uris :: 
    CString ->                              -- uri_list : TBasicType TUTF8
    IO (Ptr CString)

{- |
Splits an URI list conforming to the text\/uri-list
mime type defined in RFC 2483 into individual URIs,
discarding any comments. The URIs are not validated.

@since 2.6
-}
uriListExtractUris ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@uriList@/: an URI list -}
    -> m [T.Text]
    {- ^ __Returns:__ a newly allocated 'Nothing'-terminated list
  of strings holding the individual URIs. The array should be freed
  with 'GI.GLib.Functions.strfreev'. -}
uriListExtractUris uriList = liftIO $ do
    uriList' <- textToCString uriList
    result <- g_uri_list_extract_uris uriList'
    checkUnexpectedReturnNULL "uriListExtractUris" result
    result' <- unpackZeroTerminatedUTF8CArray result
    mapZeroTerminatedCArray freeMem result
    freeMem result
    freeMem uriList'
    return result'


-- function g_uri_escape_string
-- Args : [Arg {argCName = "unescaped", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the unescaped input string.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "reserved_chars_allowed", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a string of reserved characters that\n     are allowed to be used, or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "allow_utf8", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "%TRUE if the result can include UTF-8 characters.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "g_uri_escape_string" g_uri_escape_string :: 
    CString ->                              -- unescaped : TBasicType TUTF8
    CString ->                              -- reserved_chars_allowed : TBasicType TUTF8
    CInt ->                                 -- allow_utf8 : TBasicType TBoolean
    IO CString

{- |
Escapes a string for use in a URI.

Normally all characters that are not \"unreserved\" (i.e. ASCII alphanumerical
characters plus dash, dot, underscore and tilde) are escaped.
But if you specify characters in /@reservedCharsAllowed@/ they are not
escaped. This is useful for the \"reserved\" characters in the URI
specification, since those are allowed unescaped in some portions of
a URI.

@since 2.16
-}
uriEscapeString ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@unescaped@/: the unescaped input string. -}
    -> Maybe (T.Text)
    {- ^ /@reservedCharsAllowed@/: a string of reserved characters that
     are allowed to be used, or 'Nothing'. -}
    -> Bool
    {- ^ /@allowUtf8@/: 'True' if the result can include UTF-8 characters. -}
    -> m T.Text
    {- ^ __Returns:__ an escaped version of /@unescaped@/. The returned string should be
freed when no longer needed. -}
uriEscapeString unescaped reservedCharsAllowed allowUtf8 = liftIO $ do
    unescaped' <- textToCString unescaped
    maybeReservedCharsAllowed <- case reservedCharsAllowed of
        Nothing -> return nullPtr
        Just jReservedCharsAllowed -> do
            jReservedCharsAllowed' <- textToCString jReservedCharsAllowed
            return jReservedCharsAllowed'
    let allowUtf8' = (fromIntegral . fromEnum) allowUtf8
    result <- g_uri_escape_string unescaped' maybeReservedCharsAllowed allowUtf8'
    checkUnexpectedReturnNULL "uriEscapeString" result
    result' <- cstringToText result
    freeMem result
    freeMem unescaped'
    freeMem maybeReservedCharsAllowed
    return result'


-- function g_unsetenv
-- Args : [Arg {argCName = "variable", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the environment variable to remove, must 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 TUTF8
    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) =>
    T.Text
    {- ^ /@variable@/: the environment variable to remove, must not contain \'=\' -}
    -> m ()
unsetenv variable = liftIO $ do
    variable' <- textToCString variable
    g_unsetenv variable'
    freeMem variable'
    return ()


-- function g_unlink
-- Args : [Arg {argCName = "filename", argType = TBasicType TFileName, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a pathname in the GLib file name encoding\n    (UTF-8 on Windows)", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TInt)
-- throws : False
-- Skip return : False

foreign import ccall "g_unlink" g_unlink :: 
    CString ->                              -- filename : TBasicType TFileName
    IO Int32

{- |
A wrapper for the POSIX @/unlink()/@ function. The @/unlink()/@ function
deletes a name from the filesystem. If this was the last link to the
file and no processes have it opened, the diskspace occupied by the
file is freed.

See your C library manual for more details about @/unlink()/@. Note
that on Windows, it is in general not possible to delete files that
are open to some process, or mapped into memory.

@since 2.6
-}
unlink ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    [Char]
    {- ^ /@filename@/: a pathname in the GLib file name encoding
    (UTF-8 on Windows) -}
    -> m Int32
    {- ^ __Returns:__ 0 if the name was successfully deleted, -1 if an error
   occurred -}
unlink filename = liftIO $ do
    filename' <- stringToCString filename
    result <- g_unlink filename'
    freeMem filename'
    return result


-- function g_unix_signal_source_new
-- Args : [Arg {argCName = "signum", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A signal number", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "GLib", name = "Source"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_unix_signal_source_new" g_unix_signal_source_new :: 
    Int32 ->                                -- signum : TBasicType TInt
    IO (Ptr GLib.Source.Source)

{- |
Create a 'GI.GLib.Structs.Source.Source' that will be dispatched upon delivery of the UNIX
signal /@signum@/.  In GLib versions before 2.36, only @SIGHUP@, @SIGINT@,
@SIGTERM@ can be monitored.  In GLib 2.36, @SIGUSR1@ and @SIGUSR2@
were added.

Note that unlike the UNIX default, all sources which have created a
watch will be dispatched, regardless of which underlying thread
invoked 'GI.GLib.Functions.unixSignalSourceNew'.

For example, an effective use of this function is to handle @SIGTERM@
cleanly; flushing any outstanding files, and then calling
g_main_loop_quit ().  It is not safe to do any of this a regular
UNIX signal handler; your handler may be invoked while @/malloc()/@ or
another library function is running, causing reentrancy if you
attempt to use it from the handler.  None of the GLib\/GObject API
is safe against this kind of reentrancy.

The interaction of this source when combined with native UNIX
functions like @/sigprocmask()/@ is not defined.

The source will not initially be associated with any 'GI.GLib.Structs.MainContext.MainContext'
and must be added to one with 'GI.GLib.Structs.Source.sourceAttach' before it will be
executed.

@since 2.30
-}
unixSignalSourceNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Int32
    {- ^ /@signum@/: A signal number -}
    -> m GLib.Source.Source
    {- ^ __Returns:__ A newly created 'GI.GLib.Structs.Source.Source' -}
unixSignalSourceNew signum = liftIO $ do
    result <- g_unix_signal_source_new signum
    checkUnexpectedReturnNULL "unixSignalSourceNew" result
    result' <- (wrapBoxed GLib.Source.Source) result
    return result'


-- function g_unix_signal_add_full
-- Args : [Arg {argCName = "priority", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the priority of the signal source. Typically this will be in\n           the range between #G_PRIORITY_DEFAULT and #G_PRIORITY_HIGH.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "signum", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Signal number", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "handler", argType = TInterface (Name {namespace = "GLib", name = "SourceFunc"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Callback", sinceVersion = Nothing}, argScope = ScopeTypeNotified, argClosure = 3, argDestroy = 4, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Data for @handler", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "notify", argType = TInterface (Name {namespace = "GLib", name = "DestroyNotify"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "#GDestroyNotify for @handler", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUInt)
-- throws : False
-- Skip return : False

foreign import ccall "g_unix_signal_add_full" g_unix_signal_add_full :: 
    Int32 ->                                -- priority : TBasicType TInt
    Int32 ->                                -- signum : TBasicType TInt
    FunPtr GLib.Callbacks.C_SourceFunc ->   -- handler : TInterface (Name {namespace = "GLib", name = "SourceFunc"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    FunPtr GLib.Callbacks.C_DestroyNotify -> -- notify : TInterface (Name {namespace = "GLib", name = "DestroyNotify"})
    IO Word32

{- |
A convenience function for 'GI.GLib.Functions.unixSignalSourceNew', which
attaches to the default 'GI.GLib.Structs.MainContext.MainContext'.  You can remove the watch
using 'GI.GLib.Functions.sourceRemove'.

@since 2.30
-}
unixSignalAdd ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Int32
    {- ^ /@priority@/: the priority of the signal source. Typically this will be in
           the range between 'GI.GLib.Constants.PRIORITY_DEFAULT' and 'GI.GLib.Constants.PRIORITY_HIGH'. -}
    -> Int32
    {- ^ /@signum@/: Signal number -}
    -> GLib.Callbacks.SourceFunc
    {- ^ /@handler@/: Callback -}
    -> m Word32
    {- ^ __Returns:__ An ID (greater than 0) for the event source -}
unixSignalAdd priority signum handler = liftIO $ do
    handler' <- GLib.Callbacks.mk_SourceFunc (GLib.Callbacks.wrap_SourceFunc Nothing (GLib.Callbacks.drop_closures_SourceFunc handler))
    let userData = castFunPtrToPtr handler'
    let notify = safeFreeFunPtrPtr
    result <- g_unix_signal_add_full priority signum handler' userData notify
    return result


-- function g_unix_set_fd_nonblocking
-- Args : [Arg {argCName = "fd", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A file descriptor", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "nonblock", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "If %TRUE, set the descriptor to be non-blocking", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "g_unix_set_fd_nonblocking" g_unix_set_fd_nonblocking :: 
    Int32 ->                                -- fd : TBasicType TInt
    CInt ->                                 -- nonblock : TBasicType TBoolean
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Control the non-blocking state of the given file descriptor,
according to /@nonblock@/. On most systems this uses @/O_NONBLOCK/@, but
on some older ones may use @/O_NDELAY/@.

@since 2.30
-}
unixSetFdNonblocking ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Int32
    {- ^ /@fd@/: A file descriptor -}
    -> Bool
    {- ^ /@nonblock@/: If 'True', set the descriptor to be non-blocking -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
unixSetFdNonblocking fd nonblock = liftIO $ do
    let nonblock' = (fromIntegral . fromEnum) nonblock
    onException (do
        _ <- propagateGError $ g_unix_set_fd_nonblocking fd nonblock'
        return ()
     ) (do
        return ()
     )


-- function g_unix_open_pipe
-- Args : [Arg {argCName = "fds", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Array of two integers", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Bitfield of file descriptor flags, as for fcntl()", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "g_unix_open_pipe" g_unix_open_pipe :: 
    Int32 ->                                -- fds : TBasicType TInt
    Int32 ->                                -- flags : TBasicType TInt
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Similar to the UNIX @/pipe()/@ call, but on modern systems like Linux
uses the @/pipe2()/@ system call, which atomically creates a pipe with
the configured flags. The only supported flag currently is
@/FD_CLOEXEC/@. If for example you want to configure @/O_NONBLOCK/@, that
must still be done separately with @/fcntl()/@.

This function does not take @/O_CLOEXEC/@, it takes @/FD_CLOEXEC/@ as if
for @/fcntl()/@; these are different on Linux\/glibc.

@since 2.30
-}
unixOpenPipe ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Int32
    {- ^ /@fds@/: Array of two integers -}
    -> Int32
    {- ^ /@flags@/: Bitfield of file descriptor flags, as for @/fcntl()/@ -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
unixOpenPipe fds flags = liftIO $ do
    onException (do
        _ <- propagateGError $ g_unix_open_pipe fds flags
        return ()
     ) (do
        return ()
     )


-- function g_unix_fd_source_new
-- Args : [Arg {argCName = "fd", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a file descriptor", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "condition", argType = TInterface (Name {namespace = "GLib", name = "IOCondition"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "IO conditions to watch for on @fd", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "GLib", name = "Source"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_unix_fd_source_new" g_unix_fd_source_new :: 
    Int32 ->                                -- fd : TBasicType TInt
    CUInt ->                                -- condition : TInterface (Name {namespace = "GLib", name = "IOCondition"})
    IO (Ptr GLib.Source.Source)

{- |
Creates a 'GI.GLib.Structs.Source.Source' to watch for a particular IO condition on a file
descriptor.

The source will never close the fd -- you must do it yourself.

@since 2.36
-}
unixFdSourceNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Int32
    {- ^ /@fd@/: a file descriptor -}
    -> [GLib.Flags.IOCondition]
    {- ^ /@condition@/: IO conditions to watch for on /@fd@/ -}
    -> m GLib.Source.Source
    {- ^ __Returns:__ the newly created 'GI.GLib.Structs.Source.Source' -}
unixFdSourceNew fd condition = liftIO $ do
    let condition' = gflagsToWord condition
    result <- g_unix_fd_source_new fd condition'
    checkUnexpectedReturnNULL "unixFdSourceNew" result
    result' <- (wrapBoxed GLib.Source.Source) result
    return result'


-- function g_unix_fd_add_full
-- Args : [Arg {argCName = "priority", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the priority of the source", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "fd", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a file descriptor", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "condition", argType = TInterface (Name {namespace = "GLib", name = "IOCondition"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "IO conditions to watch for on @fd", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "function", argType = TInterface (Name {namespace = "GLib", name = "UnixFDSourceFunc"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GUnixFDSourceFunc", sinceVersion = Nothing}, argScope = ScopeTypeNotified, argClosure = 4, argDestroy = 5, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "data to pass to @function", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "notify", argType = TInterface (Name {namespace = "GLib", name = "DestroyNotify"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "function to call when the idle is removed, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUInt)
-- throws : False
-- Skip return : False

foreign import ccall "g_unix_fd_add_full" g_unix_fd_add_full :: 
    Int32 ->                                -- priority : TBasicType TInt
    Int32 ->                                -- fd : TBasicType TInt
    CUInt ->                                -- condition : TInterface (Name {namespace = "GLib", name = "IOCondition"})
    FunPtr GLib.Callbacks.C_UnixFDSourceFunc -> -- function : TInterface (Name {namespace = "GLib", name = "UnixFDSourceFunc"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    FunPtr GLib.Callbacks.C_DestroyNotify -> -- notify : TInterface (Name {namespace = "GLib", name = "DestroyNotify"})
    IO Word32

{- |
Sets a function to be called when the IO condition, as specified by
/@condition@/ becomes true for /@fd@/.

This is the same as @/g_unix_fd_add()/@, except that it allows you to
specify a non-default priority and a provide a 'GI.GLib.Callbacks.DestroyNotify' for
/@userData@/.

@since 2.36
-}
unixFdAddFull ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Int32
    {- ^ /@priority@/: the priority of the source -}
    -> Int32
    {- ^ /@fd@/: a file descriptor -}
    -> [GLib.Flags.IOCondition]
    {- ^ /@condition@/: IO conditions to watch for on /@fd@/ -}
    -> GLib.Callbacks.UnixFDSourceFunc
    {- ^ /@function@/: a 'GI.GLib.Callbacks.UnixFDSourceFunc' -}
    -> m Word32
    {- ^ __Returns:__ the ID (greater than 0) of the event source -}
unixFdAddFull priority fd condition function = liftIO $ do
    let condition' = gflagsToWord condition
    function' <- GLib.Callbacks.mk_UnixFDSourceFunc (GLib.Callbacks.wrap_UnixFDSourceFunc Nothing (GLib.Callbacks.drop_closures_UnixFDSourceFunc function))
    let userData = castFunPtrToPtr function'
    let notify = safeFreeFunPtrPtr
    result <- g_unix_fd_add_full priority fd condition' function' userData notify
    return result


-- function g_unix_error_quark
-- Args : []
-- Lengths : []
-- returnType : Just (TBasicType TUInt32)
-- throws : False
-- Skip return : False

foreign import ccall "g_unix_error_quark" g_unix_error_quark :: 
    IO Word32

{- |
/No description available in the introspection data./
-}
unixErrorQuark ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m Word32
unixErrorQuark  = liftIO $ do
    result <- g_unix_error_quark
    return result


-- function g_unicode_script_to_iso15924
-- Args : [Arg {argCName = "script", argType = TInterface (Name {namespace = "GLib", name = "UnicodeScript"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode script", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUInt32)
-- throws : False
-- Skip return : False

foreign import ccall "g_unicode_script_to_iso15924" g_unicode_script_to_iso15924 :: 
    CUInt ->                                -- script : TInterface (Name {namespace = "GLib", name = "UnicodeScript"})
    IO Word32

{- |
Looks up the ISO 15924 code for /@script@/.  ISO 15924 assigns four-letter
codes to scripts.  For example, the code for Arabic is \'Arab\'.  The
four letter codes are encoded as a /@guint32@/ by this function in a
big-endian fashion.  That is, the code returned for Arabic is
0x41726162 (0x41 is ASCII code for \'A\', 0x72 is ASCII code for \'r\', etc).

See
<http://unicode.org/iso15924/codelists.html Codes for the representation of names of scripts>
for details.

@since 2.30
-}
unicodeScriptToIso15924 ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    GLib.Enums.UnicodeScript
    {- ^ /@script@/: a Unicode script -}
    -> m Word32
    {- ^ __Returns:__ the ISO 15924 code for /@script@/, encoded as an integer,
  of zero if /@script@/ is 'GI.GLib.Enums.UnicodeScriptInvalidCode' or
  ISO 15924 code \'Zzzz\' (script code for UNKNOWN) if /@script@/ is not understood. -}
unicodeScriptToIso15924 script = liftIO $ do
    let script' = (fromIntegral . fromEnum) script
    result <- g_unicode_script_to_iso15924 script'
    return result


-- function g_unicode_script_from_iso15924
-- Args : [Arg {argCName = "iso15924", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode script", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "GLib", name = "UnicodeScript"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_unicode_script_from_iso15924" g_unicode_script_from_iso15924 :: 
    Word32 ->                               -- iso15924 : TBasicType TUInt32
    IO CUInt

{- |
Looks up the Unicode script for /@iso15924@/.  ISO 15924 assigns four-letter
codes to scripts.  For example, the code for Arabic is \'Arab\'.
This function accepts four letter codes encoded as a /@guint32@/ in a
big-endian fashion.  That is, the code expected for Arabic is
0x41726162 (0x41 is ASCII code for \'A\', 0x72 is ASCII code for \'r\', etc).

See
<http://unicode.org/iso15924/codelists.html Codes for the representation of names of scripts>
for details.

@since 2.30
-}
unicodeScriptFromIso15924 ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Word32
    {- ^ /@iso15924@/: a Unicode script -}
    -> m GLib.Enums.UnicodeScript
    {- ^ __Returns:__ the Unicode script for /@iso15924@/, or
  of 'GI.GLib.Enums.UnicodeScriptInvalidCode' if /@iso15924@/ is zero and
  'GI.GLib.Enums.UnicodeScriptUnknown' if /@iso15924@/ is unknown. -}
unicodeScriptFromIso15924 iso15924 = liftIO $ do
    result <- g_unicode_script_from_iso15924 iso15924
    let result' = (toEnum . fromIntegral) result
    return result'


-- function g_unicode_canonical_ordering
-- Args : [Arg {argCName = "string", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a UCS-4 encoded string.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "len", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the maximum length of @string to use.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_unicode_canonical_ordering" g_unicode_canonical_ordering :: 
    CInt ->                                 -- string : TBasicType TUniChar
    Word64 ->                               -- len : TBasicType TUInt64
    IO ()

{- |
Computes the canonical ordering of a string in-place.
This rearranges decomposed characters in the string
according to their combining classes.  See the Unicode
manual for more information.
-}
unicodeCanonicalOrdering ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Char
    {- ^ /@string@/: a UCS-4 encoded string. -}
    -> Word64
    {- ^ /@len@/: the maximum length of /@string@/ to use. -}
    -> m ()
unicodeCanonicalOrdering string len = liftIO $ do
    let string' = (fromIntegral . ord) string
    g_unicode_canonical_ordering string' len
    return ()


-- function g_unicode_canonical_decomposition
-- Args : [Arg {argCName = "ch", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode character.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "result_len", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "location to store the length of the return value.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUniChar)
-- throws : False
-- Skip return : False

foreign import ccall "g_unicode_canonical_decomposition" g_unicode_canonical_decomposition :: 
    CInt ->                                 -- ch : TBasicType TUniChar
    Word64 ->                               -- result_len : TBasicType TUInt64
    IO CInt

{-# DEPRECATED unicodeCanonicalDecomposition ["(Since version 2.30)","Use the more flexible @/g_unichar_fully_decompose()/@","  instead."] #-}
{- |
Computes the canonical decomposition of a Unicode character.
-}
unicodeCanonicalDecomposition ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Char
    {- ^ /@ch@/: a Unicode character. -}
    -> Word64
    {- ^ /@resultLen@/: location to store the length of the return value. -}
    -> m Char
    {- ^ __Returns:__ a newly allocated string of Unicode characters.
  /@resultLen@/ is set to the resulting length of the string. -}
unicodeCanonicalDecomposition ch resultLen = liftIO $ do
    let ch' = (fromIntegral . ord) ch
    result <- g_unicode_canonical_decomposition ch' resultLen
    let result' = (chr . fromIntegral) result
    return result'


-- function g_unichar_xdigit_value
-- Args : [Arg {argCName = "c", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TInt)
-- throws : False
-- Skip return : False

foreign import ccall "g_unichar_xdigit_value" g_unichar_xdigit_value :: 
    CInt ->                                 -- c : TBasicType TUniChar
    IO Int32

{- |
Determines the numeric value of a character as a hexidecimal
digit.
-}
unicharXdigitValue ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Char
    {- ^ /@c@/: a Unicode character -}
    -> m Int32
    {- ^ __Returns:__ If /@c@/ is a hex digit (according to
'GI.GLib.Functions.unicharIsxdigit'), its numeric value. Otherwise, -1. -}
unicharXdigitValue c = liftIO $ do
    let c' = (fromIntegral . ord) c
    result <- g_unichar_xdigit_value c'
    return result


-- function g_unichar_validate
-- Args : [Arg {argCName = "ch", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_unichar_validate" g_unichar_validate :: 
    CInt ->                                 -- ch : TBasicType TUniChar
    IO CInt

{- |
Checks whether /@ch@/ is a valid Unicode character. Some possible
integer values of /@ch@/ will not be valid. 0 is considered a valid
character, though it\'s normally a string terminator.
-}
unicharValidate ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Char
    {- ^ /@ch@/: a Unicode character -}
    -> m Bool
    {- ^ __Returns:__ 'True' if /@ch@/ is a valid Unicode character -}
unicharValidate ch = liftIO $ do
    let ch' = (fromIntegral . ord) ch
    result <- g_unichar_validate ch'
    let result' = (/= 0) result
    return result'


-- function g_unichar_type
-- Args : [Arg {argCName = "c", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "GLib", name = "UnicodeType"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_unichar_type" g_unichar_type :: 
    CInt ->                                 -- c : TBasicType TUniChar
    IO CUInt

{- |
Classifies a Unicode character by type.
-}
unicharType ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Char
    {- ^ /@c@/: a Unicode character -}
    -> m GLib.Enums.UnicodeType
    {- ^ __Returns:__ the type of the character. -}
unicharType c = liftIO $ do
    let c' = (fromIntegral . ord) c
    result <- g_unichar_type c'
    let result' = (toEnum . fromIntegral) result
    return result'


-- function g_unichar_toupper
-- Args : [Arg {argCName = "c", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUniChar)
-- throws : False
-- Skip return : False

foreign import ccall "g_unichar_toupper" g_unichar_toupper :: 
    CInt ->                                 -- c : TBasicType TUniChar
    IO CInt

{- |
Converts a character to uppercase.
-}
unicharToupper ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Char
    {- ^ /@c@/: a Unicode character -}
    -> m Char
    {- ^ __Returns:__ the result of converting /@c@/ to uppercase.
              If /@c@/ is not an lowercase or titlecase character,
              or has no upper case equivalent /@c@/ is returned unchanged. -}
unicharToupper c = liftIO $ do
    let c' = (fromIntegral . ord) c
    result <- g_unichar_toupper c'
    let result' = (chr . fromIntegral) result
    return result'


-- function g_unichar_totitle
-- Args : [Arg {argCName = "c", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUniChar)
-- throws : False
-- Skip return : False

foreign import ccall "g_unichar_totitle" g_unichar_totitle :: 
    CInt ->                                 -- c : TBasicType TUniChar
    IO CInt

{- |
Converts a character to the titlecase.
-}
unicharTotitle ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Char
    {- ^ /@c@/: a Unicode character -}
    -> m Char
    {- ^ __Returns:__ the result of converting /@c@/ to titlecase.
              If /@c@/ is not an uppercase or lowercase character,
              /@c@/ is returned unchanged. -}
unicharTotitle c = liftIO $ do
    let c' = (fromIntegral . ord) c
    result <- g_unichar_totitle c'
    let result' = (chr . fromIntegral) result
    return result'


-- function g_unichar_tolower
-- Args : [Arg {argCName = "c", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode character.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUniChar)
-- throws : False
-- Skip return : False

foreign import ccall "g_unichar_tolower" g_unichar_tolower :: 
    CInt ->                                 -- c : TBasicType TUniChar
    IO CInt

{- |
Converts a character to lower case.
-}
unicharTolower ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Char
    {- ^ /@c@/: a Unicode character. -}
    -> m Char
    {- ^ __Returns:__ the result of converting /@c@/ to lower case.
              If /@c@/ is not an upperlower or titlecase character,
              or has no lowercase equivalent /@c@/ is returned unchanged. -}
unicharTolower c = liftIO $ do
    let c' = (fromIntegral . ord) c
    result <- g_unichar_tolower c'
    let result' = (chr . fromIntegral) result
    return result'


-- function g_unichar_to_utf8
-- XXX Could not generate function g_unichar_to_utf8
-- Error was : Not implemented: "Don't know how to allocate \"outbuf\" of type TBasicType TUTF8"

-- function g_unichar_iszerowidth
-- Args : [Arg {argCName = "c", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_unichar_iszerowidth" g_unichar_iszerowidth :: 
    CInt ->                                 -- c : TBasicType TUniChar
    IO CInt

{- |
Determines if a given character typically takes zero width when rendered.
The return value is 'True' for all non-spacing and enclosing marks
(e.g., combining accents), format characters, zero-width
space, but not U+00AD SOFT HYPHEN.

A typical use of this function is with one of 'GI.GLib.Functions.unicharIswide' or
'GI.GLib.Functions.unicharIswideCjk' to determine the number of cells a string occupies
when displayed on a grid display (terminals).  However, note that not all
terminals support zero-width rendering of zero-width marks.

@since 2.14
-}
unicharIszerowidth ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Char
    {- ^ /@c@/: a Unicode character -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the character has zero width -}
unicharIszerowidth c = liftIO $ do
    let c' = (fromIntegral . ord) c
    result <- g_unichar_iszerowidth c'
    let result' = (/= 0) result
    return result'


-- function g_unichar_isxdigit
-- Args : [Arg {argCName = "c", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode character.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_unichar_isxdigit" g_unichar_isxdigit :: 
    CInt ->                                 -- c : TBasicType TUniChar
    IO CInt

{- |
Determines if a character is a hexidecimal digit.
-}
unicharIsxdigit ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Char
    {- ^ /@c@/: a Unicode character. -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the character is a hexadecimal digit -}
unicharIsxdigit c = liftIO $ do
    let c' = (fromIntegral . ord) c
    result <- g_unichar_isxdigit c'
    let result' = (/= 0) result
    return result'


-- function g_unichar_iswide_cjk
-- Args : [Arg {argCName = "c", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_unichar_iswide_cjk" g_unichar_iswide_cjk :: 
    CInt ->                                 -- c : TBasicType TUniChar
    IO CInt

{- |
Determines if a character is typically rendered in a double-width
cell under legacy East Asian locales.  If a character is wide according to
'GI.GLib.Functions.unicharIswide', then it is also reported wide with this function, but
the converse is not necessarily true. See the
<http://www.unicode.org/reports/tr11/ Unicode Standard Annex #11>
for details.

If a character passes the 'GI.GLib.Functions.unicharIswide' test then it will also pass
this test, but not the other way around.  Note that some characters may
pass both this test and 'GI.GLib.Functions.unicharIszerowidth'.

@since 2.12
-}
unicharIswideCjk ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Char
    {- ^ /@c@/: a Unicode character -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the character is wide in legacy East Asian locales -}
unicharIswideCjk c = liftIO $ do
    let c' = (fromIntegral . ord) c
    result <- g_unichar_iswide_cjk c'
    let result' = (/= 0) result
    return result'


-- function g_unichar_iswide
-- Args : [Arg {argCName = "c", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_unichar_iswide" g_unichar_iswide :: 
    CInt ->                                 -- c : TBasicType TUniChar
    IO CInt

{- |
Determines if a character is typically rendered in a double-width
cell.
-}
unicharIswide ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Char
    {- ^ /@c@/: a Unicode character -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the character is wide -}
unicharIswide c = liftIO $ do
    let c' = (fromIntegral . ord) c
    result <- g_unichar_iswide c'
    let result' = (/= 0) result
    return result'


-- function g_unichar_isupper
-- Args : [Arg {argCName = "c", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_unichar_isupper" g_unichar_isupper :: 
    CInt ->                                 -- c : TBasicType TUniChar
    IO CInt

{- |
Determines if a character is uppercase.
-}
unicharIsupper ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Char
    {- ^ /@c@/: a Unicode character -}
    -> m Bool
    {- ^ __Returns:__ 'True' if /@c@/ is an uppercase character -}
unicharIsupper c = liftIO $ do
    let c' = (fromIntegral . ord) c
    result <- g_unichar_isupper c'
    let result' = (/= 0) result
    return result'


-- function g_unichar_istitle
-- Args : [Arg {argCName = "c", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_unichar_istitle" g_unichar_istitle :: 
    CInt ->                                 -- c : TBasicType TUniChar
    IO CInt

{- |
Determines if a character is titlecase. Some characters in
Unicode which are composites, such as the DZ digraph
have three case variants instead of just two. The titlecase
form is used at the beginning of a word where only the
first letter is capitalized. The titlecase form of the DZ
digraph is U+01F2 LATIN CAPITAL LETTTER D WITH SMALL LETTER Z.
-}
unicharIstitle ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Char
    {- ^ /@c@/: a Unicode character -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the character is titlecase -}
unicharIstitle c = liftIO $ do
    let c' = (fromIntegral . ord) c
    result <- g_unichar_istitle c'
    let result' = (/= 0) result
    return result'


-- function g_unichar_isspace
-- Args : [Arg {argCName = "c", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_unichar_isspace" g_unichar_isspace :: 
    CInt ->                                 -- c : TBasicType TUniChar
    IO CInt

{- |
Determines whether a character is a space, tab, or line separator
(newline, carriage return, etc.).  Given some UTF-8 text, obtain a
character value with 'GI.GLib.Functions.utf8GetChar'.

(Note: don\'t use this to do word breaking; you have to use
Pango or equivalent to get word breaking right, the algorithm
is fairly complex.)
-}
unicharIsspace ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Char
    {- ^ /@c@/: a Unicode character -}
    -> m Bool
    {- ^ __Returns:__ 'True' if /@c@/ is a space character -}
unicharIsspace c = liftIO $ do
    let c' = (fromIntegral . ord) c
    result <- g_unichar_isspace c'
    let result' = (/= 0) result
    return result'


-- function g_unichar_ispunct
-- Args : [Arg {argCName = "c", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_unichar_ispunct" g_unichar_ispunct :: 
    CInt ->                                 -- c : TBasicType TUniChar
    IO CInt

{- |
Determines whether a character is punctuation or a symbol.
Given some UTF-8 text, obtain a character value with
'GI.GLib.Functions.utf8GetChar'.
-}
unicharIspunct ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Char
    {- ^ /@c@/: a Unicode character -}
    -> m Bool
    {- ^ __Returns:__ 'True' if /@c@/ is a punctuation or symbol character -}
unicharIspunct c = liftIO $ do
    let c' = (fromIntegral . ord) c
    result <- g_unichar_ispunct c'
    let result' = (/= 0) result
    return result'


-- function g_unichar_isprint
-- Args : [Arg {argCName = "c", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_unichar_isprint" g_unichar_isprint :: 
    CInt ->                                 -- c : TBasicType TUniChar
    IO CInt

{- |
Determines whether a character is printable.
Unlike 'GI.GLib.Functions.unicharIsgraph', returns 'True' for spaces.
Given some UTF-8 text, obtain a character value with
'GI.GLib.Functions.utf8GetChar'.
-}
unicharIsprint ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Char
    {- ^ /@c@/: a Unicode character -}
    -> m Bool
    {- ^ __Returns:__ 'True' if /@c@/ is printable -}
unicharIsprint c = liftIO $ do
    let c' = (fromIntegral . ord) c
    result <- g_unichar_isprint c'
    let result' = (/= 0) result
    return result'


-- function g_unichar_ismark
-- Args : [Arg {argCName = "c", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_unichar_ismark" g_unichar_ismark :: 
    CInt ->                                 -- c : TBasicType TUniChar
    IO CInt

{- |
Determines whether a character is a mark (non-spacing mark,
combining mark, or enclosing mark in Unicode speak).
Given some UTF-8 text, obtain a character value
with 'GI.GLib.Functions.utf8GetChar'.

Note: in most cases where isalpha characters are allowed,
ismark characters should be allowed to as they are essential
for writing most European languages as well as many non-Latin
scripts.

@since 2.14
-}
unicharIsmark ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Char
    {- ^ /@c@/: a Unicode character -}
    -> m Bool
    {- ^ __Returns:__ 'True' if /@c@/ is a mark character -}
unicharIsmark c = liftIO $ do
    let c' = (fromIntegral . ord) c
    result <- g_unichar_ismark c'
    let result' = (/= 0) result
    return result'


-- function g_unichar_islower
-- Args : [Arg {argCName = "c", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_unichar_islower" g_unichar_islower :: 
    CInt ->                                 -- c : TBasicType TUniChar
    IO CInt

{- |
Determines whether a character is a lowercase letter.
Given some UTF-8 text, obtain a character value with
'GI.GLib.Functions.utf8GetChar'.
-}
unicharIslower ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Char
    {- ^ /@c@/: a Unicode character -}
    -> m Bool
    {- ^ __Returns:__ 'True' if /@c@/ is a lowercase letter -}
unicharIslower c = liftIO $ do
    let c' = (fromIntegral . ord) c
    result <- g_unichar_islower c'
    let result' = (/= 0) result
    return result'


-- function g_unichar_isgraph
-- Args : [Arg {argCName = "c", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_unichar_isgraph" g_unichar_isgraph :: 
    CInt ->                                 -- c : TBasicType TUniChar
    IO CInt

{- |
Determines whether a character is printable and not a space
(returns 'False' for control characters, format characters, and
spaces). 'GI.GLib.Functions.unicharIsprint' is similar, but returns 'True' for
spaces. Given some UTF-8 text, obtain a character value with
'GI.GLib.Functions.utf8GetChar'.
-}
unicharIsgraph ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Char
    {- ^ /@c@/: a Unicode character -}
    -> m Bool
    {- ^ __Returns:__ 'True' if /@c@/ is printable unless it\'s a space -}
unicharIsgraph c = liftIO $ do
    let c' = (fromIntegral . ord) c
    result <- g_unichar_isgraph c'
    let result' = (/= 0) result
    return result'


-- function g_unichar_isdigit
-- Args : [Arg {argCName = "c", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_unichar_isdigit" g_unichar_isdigit :: 
    CInt ->                                 -- c : TBasicType TUniChar
    IO CInt

{- |
Determines whether a character is numeric (i.e. a digit).  This
covers ASCII 0-9 and also digits in other languages\/scripts.  Given
some UTF-8 text, obtain a character value with 'GI.GLib.Functions.utf8GetChar'.
-}
unicharIsdigit ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Char
    {- ^ /@c@/: a Unicode character -}
    -> m Bool
    {- ^ __Returns:__ 'True' if /@c@/ is a digit -}
unicharIsdigit c = liftIO $ do
    let c' = (fromIntegral . ord) c
    result <- g_unichar_isdigit c'
    let result' = (/= 0) result
    return result'


-- function g_unichar_isdefined
-- Args : [Arg {argCName = "c", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_unichar_isdefined" g_unichar_isdefined :: 
    CInt ->                                 -- c : TBasicType TUniChar
    IO CInt

{- |
Determines if a given character is assigned in the Unicode
standard.
-}
unicharIsdefined ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Char
    {- ^ /@c@/: a Unicode character -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the character has an assigned value -}
unicharIsdefined c = liftIO $ do
    let c' = (fromIntegral . ord) c
    result <- g_unichar_isdefined c'
    let result' = (/= 0) result
    return result'


-- function g_unichar_iscntrl
-- Args : [Arg {argCName = "c", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_unichar_iscntrl" g_unichar_iscntrl :: 
    CInt ->                                 -- c : TBasicType TUniChar
    IO CInt

{- |
Determines whether a character is a control character.
Given some UTF-8 text, obtain a character value with
'GI.GLib.Functions.utf8GetChar'.
-}
unicharIscntrl ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Char
    {- ^ /@c@/: a Unicode character -}
    -> m Bool
    {- ^ __Returns:__ 'True' if /@c@/ is a control character -}
unicharIscntrl c = liftIO $ do
    let c' = (fromIntegral . ord) c
    result <- g_unichar_iscntrl c'
    let result' = (/= 0) result
    return result'


-- function g_unichar_isalpha
-- Args : [Arg {argCName = "c", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_unichar_isalpha" g_unichar_isalpha :: 
    CInt ->                                 -- c : TBasicType TUniChar
    IO CInt

{- |
Determines whether a character is alphabetic (i.e. a letter).
Given some UTF-8 text, obtain a character value with
'GI.GLib.Functions.utf8GetChar'.
-}
unicharIsalpha ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Char
    {- ^ /@c@/: a Unicode character -}
    -> m Bool
    {- ^ __Returns:__ 'True' if /@c@/ is an alphabetic character -}
unicharIsalpha c = liftIO $ do
    let c' = (fromIntegral . ord) c
    result <- g_unichar_isalpha c'
    let result' = (/= 0) result
    return result'


-- function g_unichar_isalnum
-- Args : [Arg {argCName = "c", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_unichar_isalnum" g_unichar_isalnum :: 
    CInt ->                                 -- c : TBasicType TUniChar
    IO CInt

{- |
Determines whether a character is alphanumeric.
Given some UTF-8 text, obtain a character value
with 'GI.GLib.Functions.utf8GetChar'.
-}
unicharIsalnum ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Char
    {- ^ /@c@/: a Unicode character -}
    -> m Bool
    {- ^ __Returns:__ 'True' if /@c@/ is an alphanumeric character -}
unicharIsalnum c = liftIO $ do
    let c' = (fromIntegral . ord) c
    result <- g_unichar_isalnum c'
    let result' = (/= 0) result
    return result'


-- function g_unichar_get_script
-- Args : [Arg {argCName = "ch", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "GLib", name = "UnicodeScript"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_unichar_get_script" g_unichar_get_script :: 
    CInt ->                                 -- ch : TBasicType TUniChar
    IO CUInt

{- |
Looks up the 'GI.GLib.Enums.UnicodeScript' for a particular character (as defined
by Unicode Standard Annex #24). No check is made for /@ch@/ being a
valid Unicode character; if you pass in invalid character, the
result is undefined.

This function is equivalent to @/pango_script_for_unichar()/@ and the
two are interchangeable.

@since 2.14
-}
unicharGetScript ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Char
    {- ^ /@ch@/: a Unicode character -}
    -> m GLib.Enums.UnicodeScript
    {- ^ __Returns:__ the 'GI.GLib.Enums.UnicodeScript' for the character. -}
unicharGetScript ch = liftIO $ do
    let ch' = (fromIntegral . ord) ch
    result <- g_unichar_get_script ch'
    let result' = (toEnum . fromIntegral) result
    return result'


-- function g_unichar_get_mirror_char
-- Args : [Arg {argCName = "ch", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "mirrored_ch", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "location to store the mirrored character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_unichar_get_mirror_char" g_unichar_get_mirror_char :: 
    CInt ->                                 -- ch : TBasicType TUniChar
    CInt ->                                 -- mirrored_ch : TBasicType TUniChar
    IO CInt

{- |
In Unicode, some characters are \"mirrored\". This means that their
images are mirrored horizontally in text that is laid out from right
to left. For instance, \"(\" would become its mirror image, \")\", in
right-to-left text.

If /@ch@/ has the Unicode mirrored property and there is another unicode
character that typically has a glyph that is the mirror image of /@ch@/\'s
glyph and /@mirroredCh@/ is set, it puts that character in the address
pointed to by /@mirroredCh@/.  Otherwise the original character is put.

@since 2.4
-}
unicharGetMirrorChar ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Char
    {- ^ /@ch@/: a Unicode character -}
    -> Char
    {- ^ /@mirroredCh@/: location to store the mirrored character -}
    -> m Bool
    {- ^ __Returns:__ 'True' if /@ch@/ has a mirrored character, 'False' otherwise -}
unicharGetMirrorChar ch mirroredCh = liftIO $ do
    let ch' = (fromIntegral . ord) ch
    let mirroredCh' = (fromIntegral . ord) mirroredCh
    result <- g_unichar_get_mirror_char ch' mirroredCh'
    let result' = (/= 0) result
    return result'


-- function g_unichar_digit_value
-- Args : [Arg {argCName = "c", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TInt)
-- throws : False
-- Skip return : False

foreign import ccall "g_unichar_digit_value" g_unichar_digit_value :: 
    CInt ->                                 -- c : TBasicType TUniChar
    IO Int32

{- |
Determines the numeric value of a character as a decimal
digit.
-}
unicharDigitValue ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Char
    {- ^ /@c@/: a Unicode character -}
    -> m Int32
    {- ^ __Returns:__ If /@c@/ is a decimal digit (according to
'GI.GLib.Functions.unicharIsdigit'), its numeric value. Otherwise, -1. -}
unicharDigitValue c = liftIO $ do
    let c' = (fromIntegral . ord) c
    result <- g_unichar_digit_value c'
    return result


-- function g_unichar_decompose
-- Args : [Arg {argCName = "ch", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "a", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "return location for the first component of @ch", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "b", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "return location for the second component of @ch", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_unichar_decompose" g_unichar_decompose :: 
    CInt ->                                 -- ch : TBasicType TUniChar
    CInt ->                                 -- a : TBasicType TUniChar
    CInt ->                                 -- b : TBasicType TUniChar
    IO CInt

{- |
Performs a single decomposition step of the
Unicode canonical decomposition algorithm.

This function does not include compatibility
decompositions. It does, however, include algorithmic
Hangul Jamo decomposition, as well as \'singleton\'
decompositions which replace a character by a single
other character. In the case of singletons */@b@/ will
be set to zero.

If /@ch@/ is not decomposable, */@a@/ is set to /@ch@/ and */@b@/
is set to zero.

Note that the way Unicode decomposition pairs are
defined, it is guaranteed that /@b@/ would not decompose
further, but /@a@/ may itself decompose.  To get the full
canonical decomposition for /@ch@/, one would need to
recursively call this function on /@a@/.  Or use
@/g_unichar_fully_decompose()/@.

See
<http://unicode.org/reports/tr15/ UAX#15>
for details.

@since 2.30
-}
unicharDecompose ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Char
    {- ^ /@ch@/: a Unicode character -}
    -> Char
    {- ^ /@a@/: return location for the first component of /@ch@/ -}
    -> Char
    {- ^ /@b@/: return location for the second component of /@ch@/ -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the character could be decomposed -}
unicharDecompose ch a b = liftIO $ do
    let ch' = (fromIntegral . ord) ch
    let a' = (fromIntegral . ord) a
    let b' = (fromIntegral . ord) b
    result <- g_unichar_decompose ch' a' b'
    let result' = (/= 0) result
    return result'


-- function g_unichar_compose
-- Args : [Arg {argCName = "a", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "b", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "ch", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "return location for the composed character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_unichar_compose" g_unichar_compose :: 
    CInt ->                                 -- a : TBasicType TUniChar
    CInt ->                                 -- b : TBasicType TUniChar
    CInt ->                                 -- ch : TBasicType TUniChar
    IO CInt

{- |
Performs a single composition step of the
Unicode canonical composition algorithm.

This function includes algorithmic Hangul Jamo composition,
but it is not exactly the inverse of 'GI.GLib.Functions.unicharDecompose'.
No composition can have either of /@a@/ or /@b@/ equal to zero.
To be precise, this function composes if and only if
there exists a Primary Composite P which is canonically
equivalent to the sequence \</@a@/,/@b@/>.  See the Unicode
Standard for the definition of Primary Composite.

If /@a@/ and /@b@/ do not compose a new character, /@ch@/ is set to zero.

See
<http://unicode.org/reports/tr15/ UAX#15>
for details.

@since 2.30
-}
unicharCompose ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Char
    {- ^ /@a@/: a Unicode character -}
    -> Char
    {- ^ /@b@/: a Unicode character -}
    -> Char
    {- ^ /@ch@/: return location for the composed character -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the characters could be composed -}
unicharCompose a b ch = liftIO $ do
    let a' = (fromIntegral . ord) a
    let b' = (fromIntegral . ord) b
    let ch' = (fromIntegral . ord) ch
    result <- g_unichar_compose a' b' ch'
    let result' = (/= 0) result
    return result'


-- function g_unichar_combining_class
-- Args : [Arg {argCName = "uc", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TInt)
-- throws : False
-- Skip return : False

foreign import ccall "g_unichar_combining_class" g_unichar_combining_class :: 
    CInt ->                                 -- uc : TBasicType TUniChar
    IO Int32

{- |
Determines the canonical combining class of a Unicode character.

@since 2.14
-}
unicharCombiningClass ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Char
    {- ^ /@uc@/: a Unicode character -}
    -> m Int32
    {- ^ __Returns:__ the combining class of the character -}
unicharCombiningClass uc = liftIO $ do
    let uc' = (fromIntegral . ord) uc
    result <- g_unichar_combining_class uc'
    return result


-- function g_unichar_break_type
-- Args : [Arg {argCName = "c", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "GLib", name = "UnicodeBreakType"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_unichar_break_type" g_unichar_break_type :: 
    CInt ->                                 -- c : TBasicType TUniChar
    IO CUInt

{- |
Determines the break type of /@c@/. /@c@/ should be a Unicode character
(to derive a character from UTF-8 encoded text, use
'GI.GLib.Functions.utf8GetChar'). The break type is used to find word and line
breaks (\"text boundaries\"), Pango implements the Unicode boundary
resolution algorithms and normally you would use a function such
as @/pango_break()/@ instead of caring about break types yourself.
-}
unicharBreakType ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Char
    {- ^ /@c@/: a Unicode character -}
    -> m GLib.Enums.UnicodeBreakType
    {- ^ __Returns:__ the break type of /@c@/ -}
unicharBreakType c = liftIO $ do
    let c' = (fromIntegral . ord) c
    result <- g_unichar_break_type c'
    let result' = (toEnum . fromIntegral) result
    return result'


-- function g_try_realloc_n
-- Args : [Arg {argCName = "mem", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "previously-allocated memory, or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "n_blocks", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the number of blocks to allocate", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "n_block_bytes", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the size of each block in bytes", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TPtr)
-- throws : False
-- Skip return : False

foreign import ccall "g_try_realloc_n" g_try_realloc_n :: 
    Ptr () ->                               -- mem : TBasicType TPtr
    Word64 ->                               -- n_blocks : TBasicType TUInt64
    Word64 ->                               -- n_block_bytes : TBasicType TUInt64
    IO (Ptr ())

{- |
This function is similar to 'GI.GLib.Functions.tryRealloc', allocating (/@nBlocks@/ * /@nBlockBytes@/) bytes,
but care is taken to detect possible overflow during multiplication.

@since 2.24
-}
tryReallocN ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Ptr ()
    {- ^ /@mem@/: previously-allocated memory, or 'Nothing'. -}
    -> Word64
    {- ^ /@nBlocks@/: the number of blocks to allocate -}
    -> Word64
    {- ^ /@nBlockBytes@/: the size of each block in bytes -}
    -> m (Ptr ())
    {- ^ __Returns:__ the allocated memory, or 'Nothing'. -}
tryReallocN mem nBlocks nBlockBytes = liftIO $ do
    result <- g_try_realloc_n mem nBlocks nBlockBytes
    return result


-- function g_try_realloc
-- Args : [Arg {argCName = "mem", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "previously-allocated memory, or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "n_bytes", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "number of bytes to allocate.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TPtr)
-- throws : False
-- Skip return : False

foreign import ccall "g_try_realloc" g_try_realloc :: 
    Ptr () ->                               -- mem : TBasicType TPtr
    Word64 ->                               -- n_bytes : TBasicType TUInt64
    IO (Ptr ())

{- |
Attempts to realloc /@mem@/ to a new size, /@nBytes@/, and returns 'Nothing'
on failure. Contrast with 'GI.GLib.Functions.realloc', which aborts the program
on failure.

If /@mem@/ is 'Nothing', behaves the same as 'GI.GLib.Functions.tryMalloc'.
-}
tryRealloc ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Ptr ()
    {- ^ /@mem@/: previously-allocated memory, or 'Nothing'. -}
    -> Word64
    {- ^ /@nBytes@/: number of bytes to allocate. -}
    -> m (Ptr ())
    {- ^ __Returns:__ the allocated memory, or 'Nothing'. -}
tryRealloc mem nBytes = liftIO $ do
    result <- g_try_realloc mem nBytes
    return result


-- function g_try_malloc_n
-- Args : [Arg {argCName = "n_blocks", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the number of blocks to allocate", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "n_block_bytes", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the size of each block in bytes", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TPtr)
-- throws : False
-- Skip return : False

foreign import ccall "g_try_malloc_n" g_try_malloc_n :: 
    Word64 ->                               -- n_blocks : TBasicType TUInt64
    Word64 ->                               -- n_block_bytes : TBasicType TUInt64
    IO (Ptr ())

{- |
This function is similar to 'GI.GLib.Functions.tryMalloc', allocating (/@nBlocks@/ * /@nBlockBytes@/) bytes,
but care is taken to detect possible overflow during multiplication.

@since 2.24
-}
tryMallocN ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Word64
    {- ^ /@nBlocks@/: the number of blocks to allocate -}
    -> Word64
    {- ^ /@nBlockBytes@/: the size of each block in bytes -}
    -> m (Ptr ())
    {- ^ __Returns:__ the allocated memory, or 'Nothing'. -}
tryMallocN nBlocks nBlockBytes = liftIO $ do
    result <- g_try_malloc_n nBlocks nBlockBytes
    return result


-- function g_try_malloc0_n
-- Args : [Arg {argCName = "n_blocks", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the number of blocks to allocate", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "n_block_bytes", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the size of each block in bytes", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TPtr)
-- throws : False
-- Skip return : False

foreign import ccall "g_try_malloc0_n" g_try_malloc0_n :: 
    Word64 ->                               -- n_blocks : TBasicType TUInt64
    Word64 ->                               -- n_block_bytes : TBasicType TUInt64
    IO (Ptr ())

{- |
This function is similar to 'GI.GLib.Functions.tryMalloc0', allocating (/@nBlocks@/ * /@nBlockBytes@/) bytes,
but care is taken to detect possible overflow during multiplication.

@since 2.24
-}
tryMalloc0N ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Word64
    {- ^ /@nBlocks@/: the number of blocks to allocate -}
    -> Word64
    {- ^ /@nBlockBytes@/: the size of each block in bytes -}
    -> m (Ptr ())
    {- ^ __Returns:__ the allocated memory, or 'Nothing' -}
tryMalloc0N nBlocks nBlockBytes = liftIO $ do
    result <- g_try_malloc0_n nBlocks nBlockBytes
    return result


-- function g_try_malloc0
-- Args : [Arg {argCName = "n_bytes", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "number of bytes to allocate", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TPtr)
-- throws : False
-- Skip return : False

foreign import ccall "g_try_malloc0" g_try_malloc0 :: 
    Word64 ->                               -- n_bytes : TBasicType TUInt64
    IO (Ptr ())

{- |
Attempts to allocate /@nBytes@/, initialized to 0\'s, and returns 'Nothing' on
failure. Contrast with 'GI.GLib.Functions.malloc0', which aborts the program on failure.

@since 2.8
-}
tryMalloc0 ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Word64
    {- ^ /@nBytes@/: number of bytes to allocate -}
    -> m (Ptr ())
    {- ^ __Returns:__ the allocated memory, or 'Nothing' -}
tryMalloc0 nBytes = liftIO $ do
    result <- g_try_malloc0 nBytes
    return result


-- function g_try_malloc
-- Args : [Arg {argCName = "n_bytes", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "number of bytes to allocate.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TPtr)
-- throws : False
-- Skip return : False

foreign import ccall "g_try_malloc" g_try_malloc :: 
    Word64 ->                               -- n_bytes : TBasicType TUInt64
    IO (Ptr ())

{- |
Attempts to allocate /@nBytes@/, and returns 'Nothing' on failure.
Contrast with 'GI.GLib.Functions.malloc', which aborts the program on failure.
-}
tryMalloc ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Word64
    {- ^ /@nBytes@/: number of bytes to allocate. -}
    -> m (Ptr ())
    {- ^ __Returns:__ the allocated memory, or 'Nothing'. -}
tryMalloc nBytes = liftIO $ do
    result <- g_try_malloc nBytes
    return result


-- function g_timeout_source_new_seconds
-- Args : [Arg {argCName = "interval", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the timeout interval in seconds", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "GLib", name = "Source"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_timeout_source_new_seconds" g_timeout_source_new_seconds :: 
    Word32 ->                               -- interval : TBasicType TUInt
    IO (Ptr GLib.Source.Source)

{- |
Creates a new timeout source.

The source will not initially be associated with any 'GI.GLib.Structs.MainContext.MainContext'
and must be added to one with 'GI.GLib.Structs.Source.sourceAttach' before it will be
executed.

The scheduling granularity\/accuracy of this timeout source will be
in seconds.

The interval given in terms of monotonic time, not wall clock time.
See 'GI.GLib.Functions.getMonotonicTime'.

@since 2.14
-}
timeoutSourceNewSeconds ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Word32
    {- ^ /@interval@/: the timeout interval in seconds -}
    -> m GLib.Source.Source
    {- ^ __Returns:__ the newly-created timeout source -}
timeoutSourceNewSeconds interval = liftIO $ do
    result <- g_timeout_source_new_seconds interval
    checkUnexpectedReturnNULL "timeoutSourceNewSeconds" result
    result' <- (wrapBoxed GLib.Source.Source) result
    return result'


-- function g_timeout_source_new
-- Args : [Arg {argCName = "interval", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the timeout interval in milliseconds.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "GLib", name = "Source"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_timeout_source_new" g_timeout_source_new :: 
    Word32 ->                               -- interval : TBasicType TUInt
    IO (Ptr GLib.Source.Source)

{- |
Creates a new timeout source.

The source will not initially be associated with any 'GI.GLib.Structs.MainContext.MainContext'
and must be added to one with 'GI.GLib.Structs.Source.sourceAttach' before it will be
executed.

The interval given is in terms of monotonic time, not wall clock
time.  See 'GI.GLib.Functions.getMonotonicTime'.
-}
timeoutSourceNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Word32
    {- ^ /@interval@/: the timeout interval in milliseconds. -}
    -> m GLib.Source.Source
    {- ^ __Returns:__ the newly-created timeout source -}
timeoutSourceNew interval = liftIO $ do
    result <- g_timeout_source_new interval
    checkUnexpectedReturnNULL "timeoutSourceNew" result
    result' <- (wrapBoxed GLib.Source.Source) result
    return result'


-- function g_timeout_add_seconds_full
-- Args : [Arg {argCName = "priority", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the priority of the timeout source. Typically this will be in\n           the range between #G_PRIORITY_DEFAULT and #G_PRIORITY_HIGH.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "interval", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the time between calls to the function, in seconds", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "function", argType = TInterface (Name {namespace = "GLib", name = "SourceFunc"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "function to call", sinceVersion = Nothing}, argScope = ScopeTypeNotified, argClosure = 3, argDestroy = 4, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "data to pass to @function", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "notify", argType = TInterface (Name {namespace = "GLib", name = "DestroyNotify"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "function to call when the timeout is removed, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUInt)
-- throws : False
-- Skip return : False

foreign import ccall "g_timeout_add_seconds_full" g_timeout_add_seconds_full :: 
    Int32 ->                                -- priority : TBasicType TInt
    Word32 ->                               -- interval : TBasicType TUInt
    FunPtr GLib.Callbacks.C_SourceFunc ->   -- function : TInterface (Name {namespace = "GLib", name = "SourceFunc"})
    Ptr () ->                               -- data : TBasicType TPtr
    FunPtr GLib.Callbacks.C_DestroyNotify -> -- notify : TInterface (Name {namespace = "GLib", name = "DestroyNotify"})
    IO Word32

{- |
Sets a function to be called at regular intervals, with /@priority@/.
The function is called repeatedly until it returns 'False', at which
point the timeout is automatically destroyed and the function will
not be called again.

Unlike @/g_timeout_add()/@, this function operates at whole second granularity.
The initial starting point of the timer is determined by the implementation
and the implementation is expected to group multiple timers together so that
they fire all at the same time.
To allow this grouping, the /@interval@/ to the first timer is rounded
and can deviate up to one second from the specified interval.
Subsequent timer iterations will generally run at the specified interval.

Note that timeout functions may be delayed, due to the processing of other
event sources. Thus they should not be relied on for precise timing.
After each call to the timeout function, the time of the next
timeout is recalculated based on the current time and the given /@interval@/

See [memory management of sources][mainloop-memory-management] for details
on how to handle the return value and memory management of /@data@/.

If you want timing more precise than whole seconds, use @/g_timeout_add()/@
instead.

The grouping of timers to fire at the same time results in a more power
and CPU efficient behavior so if your timer is in multiples of seconds
and you don\'t require the first timer exactly one second from now, the
use of @/g_timeout_add_seconds()/@ is preferred over @/g_timeout_add()/@.

This internally creates a main loop source using
'GI.GLib.Functions.timeoutSourceNewSeconds' and attaches it to the main loop context
using 'GI.GLib.Structs.Source.sourceAttach'. You can do these steps manually if you need
greater control.

The interval given is in terms of monotonic time, not wall clock
time.  See 'GI.GLib.Functions.getMonotonicTime'.

@since 2.14
-}
timeoutAddSeconds ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Int32
    {- ^ /@priority@/: the priority of the timeout source. Typically this will be in
           the range between 'GI.GLib.Constants.PRIORITY_DEFAULT' and 'GI.GLib.Constants.PRIORITY_HIGH'. -}
    -> Word32
    {- ^ /@interval@/: the time between calls to the function, in seconds -}
    -> GLib.Callbacks.SourceFunc
    {- ^ /@function@/: function to call -}
    -> m Word32
    {- ^ __Returns:__ the ID (greater than 0) of the event source. -}
timeoutAddSeconds priority interval function = liftIO $ do
    function' <- GLib.Callbacks.mk_SourceFunc (GLib.Callbacks.wrap_SourceFunc Nothing (GLib.Callbacks.drop_closures_SourceFunc function))
    let data_ = castFunPtrToPtr function'
    let notify = safeFreeFunPtrPtr
    result <- g_timeout_add_seconds_full priority interval function' data_ notify
    return result


-- function g_timeout_add_full
-- Args : [Arg {argCName = "priority", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the priority of the timeout source. Typically this will be in\n           the range between #G_PRIORITY_DEFAULT and #G_PRIORITY_HIGH.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "interval", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the time between calls to the function, in milliseconds\n            (1/1000ths of a second)", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "function", argType = TInterface (Name {namespace = "GLib", name = "SourceFunc"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "function to call", sinceVersion = Nothing}, argScope = ScopeTypeNotified, argClosure = 3, argDestroy = 4, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "data to pass to @function", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "notify", argType = TInterface (Name {namespace = "GLib", name = "DestroyNotify"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "function to call when the timeout is removed, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUInt)
-- throws : False
-- Skip return : False

foreign import ccall "g_timeout_add_full" g_timeout_add_full :: 
    Int32 ->                                -- priority : TBasicType TInt
    Word32 ->                               -- interval : TBasicType TUInt
    FunPtr GLib.Callbacks.C_SourceFunc ->   -- function : TInterface (Name {namespace = "GLib", name = "SourceFunc"})
    Ptr () ->                               -- data : TBasicType TPtr
    FunPtr GLib.Callbacks.C_DestroyNotify -> -- notify : TInterface (Name {namespace = "GLib", name = "DestroyNotify"})
    IO Word32

{- |
Sets a function to be called at regular intervals, with the given
priority.  The function is called repeatedly until it returns
'False', at which point the timeout is automatically destroyed and
the function will not be called again.  The /@notify@/ function is
called when the timeout is destroyed.  The first call to the
function will be at the end of the first /@interval@/.

Note that timeout functions may be delayed, due to the processing of other
event sources. Thus they should not be relied on for precise timing.
After each call to the timeout function, the time of the next
timeout is recalculated based on the current time and the given interval
(it does not try to \'catch up\' time lost in delays).

See [memory management of sources][mainloop-memory-management] for details
on how to handle the return value and memory management of /@data@/.

This internally creates a main loop source using 'GI.GLib.Functions.timeoutSourceNew'
and attaches it to the global 'GI.GLib.Structs.MainContext.MainContext' using 'GI.GLib.Structs.Source.sourceAttach', so
the callback will be invoked in whichever thread is running that main
context. You can do these steps manually if you need greater control or to
use a custom main context.

The interval given in terms of monotonic time, not wall clock time.
See 'GI.GLib.Functions.getMonotonicTime'.
-}
timeoutAdd ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Int32
    {- ^ /@priority@/: the priority of the timeout source. Typically this will be in
           the range between 'GI.GLib.Constants.PRIORITY_DEFAULT' and 'GI.GLib.Constants.PRIORITY_HIGH'. -}
    -> Word32
    {- ^ /@interval@/: the time between calls to the function, in milliseconds
            (1\/1000ths of a second) -}
    -> GLib.Callbacks.SourceFunc
    {- ^ /@function@/: function to call -}
    -> m Word32
    {- ^ __Returns:__ the ID (greater than 0) of the event source. -}
timeoutAdd priority interval function = liftIO $ do
    function' <- GLib.Callbacks.mk_SourceFunc (GLib.Callbacks.wrap_SourceFunc Nothing (GLib.Callbacks.drop_closures_SourceFunc function))
    let data_ = castFunPtrToPtr function'
    let notify = safeFreeFunPtrPtr
    result <- g_timeout_add_full priority interval function' data_ notify
    return result


-- function g_test_trap_subprocess
-- Args : [Arg {argCName = "test_path", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Test to run in a subprocess", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "usec_timeout", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Timeout for the subprocess test in micro seconds.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "test_flags", argType = TInterface (Name {namespace = "GLib", name = "TestSubprocessFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Flags to modify subprocess behaviour.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_test_trap_subprocess" g_test_trap_subprocess :: 
    CString ->                              -- test_path : TBasicType TUTF8
    Word64 ->                               -- usec_timeout : TBasicType TUInt64
    CUInt ->                                -- test_flags : TInterface (Name {namespace = "GLib", name = "TestSubprocessFlags"})
    IO ()

{- |
Respawns the test program to run only /@testPath@/ in a subprocess.
This can be used for a test case that might not return, or that
might abort.

If /@testPath@/ is 'Nothing' then the same test is re-run in a subprocess.
You can use 'GI.GLib.Functions.testSubprocess' to determine whether the test is in
a subprocess or not.

/@testPath@/ can also be the name of the parent test, followed by
\"@\/subprocess\/@\" and then a name for the specific subtest (or just
ending with \"@\/subprocess@\" if the test only has one child test);
tests with names of this form will automatically be skipped in the
parent process.

If /@usecTimeout@/ is non-0, the test subprocess is aborted and
considered failing if its run time exceeds it.

The subprocess behavior can be configured with the
'GI.GLib.Flags.TestSubprocessFlags' flags.

You can use methods such as @/g_test_trap_assert_passed()/@,
@/g_test_trap_assert_failed()/@, and @/g_test_trap_assert_stderr()/@ to
check the results of the subprocess. (But note that
@/g_test_trap_assert_stdout()/@ and @/g_test_trap_assert_stderr()/@
cannot be used if /@testFlags@/ specifies that the child should
inherit the parent stdout\/stderr.)

If your @main ()@ needs to behave differently in
the subprocess, you can call 'GI.GLib.Functions.testSubprocess' (after calling
@/g_test_init()/@) to see whether you are in a subprocess.

The following example tests that calling
@my_object_new(1000000)@ will abort with an error
message.


=== /C code/
>
>  static void
>  test_create_large_object (void)
>  {
>    if (g_test_subprocess ())
>      {
>        my_object_new (1000000);
>        return;
>      }
>
>    // Reruns this same test in a subprocess
>    g_test_trap_subprocess (NULL, 0, 0);
>    g_test_trap_assert_failed ();
>    g_test_trap_assert_stderr ("*ERROR*too large*");
>  }
>
>  int
>  main (int argc, char **argv)
>  {
>    g_test_init (&argc, &argv, NULL);
>
>    g_test_add_func ("/myobject/create_large_object",
>                     test_create_large_object);
>    return g_test_run ();
>  }

@since 2.38
-}
testTrapSubprocess ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Maybe (T.Text)
    {- ^ /@testPath@/: Test to run in a subprocess -}
    -> Word64
    {- ^ /@usecTimeout@/: Timeout for the subprocess test in micro seconds. -}
    -> [GLib.Flags.TestSubprocessFlags]
    {- ^ /@testFlags@/: Flags to modify subprocess behaviour. -}
    -> m ()
testTrapSubprocess testPath usecTimeout testFlags = liftIO $ do
    maybeTestPath <- case testPath of
        Nothing -> return nullPtr
        Just jTestPath -> do
            jTestPath' <- textToCString jTestPath
            return jTestPath'
    let testFlags' = gflagsToWord testFlags
    g_test_trap_subprocess maybeTestPath usecTimeout testFlags'
    freeMem maybeTestPath
    return ()


-- function g_test_trap_reached_timeout
-- Args : []
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_test_trap_reached_timeout" g_test_trap_reached_timeout :: 
    IO CInt

{- |
Check the result of the last 'GI.GLib.Functions.testTrapSubprocess' call.

@since 2.16
-}
testTrapReachedTimeout ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m Bool
    {- ^ __Returns:__ 'True' if the last test subprocess got killed due to a timeout. -}
testTrapReachedTimeout  = liftIO $ do
    result <- g_test_trap_reached_timeout
    let result' = (/= 0) result
    return result'


-- function g_test_trap_has_passed
-- Args : []
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_test_trap_has_passed" g_test_trap_has_passed :: 
    IO CInt

{- |
Check the result of the last 'GI.GLib.Functions.testTrapSubprocess' call.

@since 2.16
-}
testTrapHasPassed ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m Bool
    {- ^ __Returns:__ 'True' if the last test subprocess terminated successfully. -}
testTrapHasPassed  = liftIO $ do
    result <- g_test_trap_has_passed
    let result' = (/= 0) result
    return result'


-- function g_test_trap_fork
-- Args : [Arg {argCName = "usec_timeout", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Timeout for the forked test in micro seconds.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "test_trap_flags", argType = TInterface (Name {namespace = "GLib", name = "TestTrapFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Flags to modify forking behaviour.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_test_trap_fork" g_test_trap_fork :: 
    Word64 ->                               -- usec_timeout : TBasicType TUInt64
    CUInt ->                                -- test_trap_flags : TInterface (Name {namespace = "GLib", name = "TestTrapFlags"})
    IO CInt

{-# DEPRECATED testTrapFork ["This function is implemented only on Unix platforms,","and is not always reliable due to problems inherent in","fork-without-exec. Use 'GI.GLib.Functions.testTrapSubprocess' instead."] #-}
{- |
Fork the current test program to execute a test case that might
not return or that might abort.

If /@usecTimeout@/ is non-0, the forked test case is aborted and
considered failing if its run time exceeds it.

The forking behavior can be configured with the 'GI.GLib.Flags.TestTrapFlags' flags.

In the following example, the test code forks, the forked child
process produces some sample output and exits successfully.
The forking parent process then asserts successful child program
termination and validates child program outputs.


=== /C code/
>
>  static void
>  test_fork_patterns (void)
>  {
>    if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT | G_TEST_TRAP_SILENCE_STDERR))
>      {
>        g_print ("some stdout text: somagic17\n");
>        g_printerr ("some stderr text: semagic43\n");
>        exit (0); // successful test run
>      }
>    g_test_trap_assert_passed ();
>    g_test_trap_assert_stdout ("*somagic17*");
>    g_test_trap_assert_stderr ("*semagic43*");
>  }

@since 2.16
-}
testTrapFork ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Word64
    {- ^ /@usecTimeout@/: Timeout for the forked test in micro seconds. -}
    -> [GLib.Flags.TestTrapFlags]
    {- ^ /@testTrapFlags@/: Flags to modify forking behaviour. -}
    -> m Bool
    {- ^ __Returns:__ 'True' for the forked child and 'False' for the executing parent process. -}
testTrapFork usecTimeout testTrapFlags = liftIO $ do
    let testTrapFlags' = gflagsToWord testTrapFlags
    result <- g_test_trap_fork usecTimeout testTrapFlags'
    let result' = (/= 0) result
    return result'


-- function g_test_trap_assertions
-- Args : [Arg {argCName = "domain", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "file", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "line", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "func", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "assertion_flags", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "pattern", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_test_trap_assertions" g_test_trap_assertions :: 
    CString ->                              -- domain : TBasicType TUTF8
    CString ->                              -- file : TBasicType TUTF8
    Int32 ->                                -- line : TBasicType TInt
    CString ->                              -- func : TBasicType TUTF8
    Word64 ->                               -- assertion_flags : TBasicType TUInt64
    CString ->                              -- pattern : TBasicType TUTF8
    IO ()

{- |
/No description available in the introspection data./
-}
testTrapAssertions ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -> T.Text
    -> Int32
    -> T.Text
    -> Word64
    -> T.Text
    -> m ()
testTrapAssertions domain file line func assertionFlags pattern = liftIO $ do
    domain' <- textToCString domain
    file' <- textToCString file
    func' <- textToCString func
    pattern' <- textToCString pattern
    g_test_trap_assertions domain' file' line func' assertionFlags pattern'
    freeMem domain'
    freeMem file'
    freeMem func'
    freeMem pattern'
    return ()


-- function g_test_timer_start
-- Args : []
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_test_timer_start" g_test_timer_start :: 
    IO ()

{- |
Start a timing test. Call 'GI.GLib.Functions.testTimerElapsed' when the task is supposed
to be done. Call this function again to restart the timer.

@since 2.16
-}
testTimerStart ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m ()
testTimerStart  = liftIO $ do
    g_test_timer_start
    return ()


-- function g_test_timer_last
-- Args : []
-- Lengths : []
-- returnType : Just (TBasicType TDouble)
-- throws : False
-- Skip return : False

foreign import ccall "g_test_timer_last" g_test_timer_last :: 
    IO CDouble

{- |
Report the last result of 'GI.GLib.Functions.testTimerElapsed'.

@since 2.16
-}
testTimerLast ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m Double
    {- ^ __Returns:__ the last result of 'GI.GLib.Functions.testTimerElapsed', as a double -}
testTimerLast  = liftIO $ do
    result <- g_test_timer_last
    let result' = realToFrac result
    return result'


-- function g_test_timer_elapsed
-- Args : []
-- Lengths : []
-- returnType : Just (TBasicType TDouble)
-- throws : False
-- Skip return : False

foreign import ccall "g_test_timer_elapsed" g_test_timer_elapsed :: 
    IO CDouble

{- |
Get the time since the last start of the timer with 'GI.GLib.Functions.testTimerStart'.

@since 2.16
-}
testTimerElapsed ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m Double
    {- ^ __Returns:__ the time since the last start of the timer, as a double -}
testTimerElapsed  = liftIO $ do
    result <- g_test_timer_elapsed
    let result' = realToFrac result
    return result'


-- function g_test_subprocess
-- Args : []
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_test_subprocess" g_test_subprocess :: 
    IO CInt

{- |
Returns 'True' (after @/g_test_init()/@ has been called) if the test
program is running under 'GI.GLib.Functions.testTrapSubprocess'.

@since 2.38
-}
testSubprocess ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m Bool
    {- ^ __Returns:__ 'True' if the test program is running under
'GI.GLib.Functions.testTrapSubprocess'. -}
testSubprocess  = liftIO $ do
    result <- g_test_subprocess
    let result' = (/= 0) result
    return result'


-- function g_test_skip
-- Args : [Arg {argCName = "msg", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "explanation", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_test_skip" g_test_skip :: 
    CString ->                              -- msg : TBasicType TUTF8
    IO ()

{- |
Indicates that a test was skipped.

Calling this function will not stop the test from running, you
need to return from the test function yourself. So you can
produce additional diagnostic messages or even continue running
the test.

If not called from inside a test, this function does nothing.

@since 2.38
-}
testSkip ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Maybe (T.Text)
    {- ^ /@msg@/: explanation -}
    -> m ()
testSkip msg = liftIO $ do
    maybeMsg <- case msg of
        Nothing -> return nullPtr
        Just jMsg -> do
            jMsg' <- textToCString jMsg
            return jMsg'
    g_test_skip maybeMsg
    freeMem maybeMsg
    return ()


-- function g_test_set_nonfatal_assertions
-- Args : []
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_test_set_nonfatal_assertions" g_test_set_nonfatal_assertions :: 
    IO ()

{- |
Changes the behaviour of @/g_assert_cmpstr()/@, @/g_assert_cmpint()/@,
@/g_assert_cmpuint()/@, @/g_assert_cmphex()/@, @/g_assert_cmpfloat()/@,
@/g_assert_true()/@, @/g_assert_false()/@, @/g_assert_null()/@, @/g_assert_no_error()/@,
@/g_assert_error()/@, @/g_test_assert_expected_messages()/@ and the various
g_test_trap_assert_*() macros to not abort to program, but instead
call 'GI.GLib.Functions.testFail' and continue. (This also changes the behavior of
'GI.GLib.Functions.testFail' so that it will not cause the test program to abort
after completing the failed test.)

Note that the @/g_assert_not_reached()/@ and @/g_assert()/@ are not
affected by this.

This function can only be called after @/g_test_init()/@.

@since 2.38
-}
testSetNonfatalAssertions ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m ()
testSetNonfatalAssertions  = liftIO $ do
    g_test_set_nonfatal_assertions
    return ()


-- function g_test_run_suite
-- Args : [Arg {argCName = "suite", argType = TInterface (Name {namespace = "GLib", name = "TestSuite"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GTestSuite", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TInt)
-- throws : False
-- Skip return : False

foreign import ccall "g_test_run_suite" g_test_run_suite :: 
    Ptr GLib.TestSuite.TestSuite ->         -- suite : TInterface (Name {namespace = "GLib", name = "TestSuite"})
    IO Int32

{- |
Execute the tests within /@suite@/ and all nested @/GTestSuites/@.
The test suites to be executed are filtered according to
test path arguments (@-p testpath@) as parsed by @/g_test_init()/@.
See the 'GI.GLib.Functions.testRun' documentation for more information on the
order that tests are run in.

'GI.GLib.Functions.testRunSuite' or 'GI.GLib.Functions.testRun' may only be called once
in a program.

@since 2.16
-}
testRunSuite ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    GLib.TestSuite.TestSuite
    {- ^ /@suite@/: a 'GI.GLib.Structs.TestSuite.TestSuite' -}
    -> m Int32
    {- ^ __Returns:__ 0 on success -}
testRunSuite suite = liftIO $ do
    suite' <- unsafeManagedPtrGetPtr suite
    result <- g_test_run_suite suite'
    touchManagedPtr suite
    return result


-- function g_test_run
-- Args : []
-- Lengths : []
-- returnType : Just (TBasicType TInt)
-- throws : False
-- Skip return : False

foreign import ccall "g_test_run" g_test_run :: 
    IO Int32

{- |
Runs all tests under the toplevel suite which can be retrieved
with @/g_test_get_root()/@. Similar to 'GI.GLib.Functions.testRunSuite', the test
cases to be run are filtered according to test path arguments
(@-p testpath@) 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, 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' -}
testRun  = liftIO $ do
    result <- g_test_run
    return result


-- function g_test_rand_int_range
-- Args : [Arg {argCName = "begin", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the minimum value returned by this function", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "end", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the smallest value not to be returned by this function", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TInt32)
-- throws : False
-- Skip return : False

foreign import ccall "g_test_rand_int_range" g_test_rand_int_range :: 
    Int32 ->                                -- begin : TBasicType TInt32
    Int32 ->                                -- end : TBasicType TInt32
    IO Int32

{- |
Get a reproducible random integer number out of a specified range,
see 'GI.GLib.Functions.testRandInt' for details on test case random numbers.

@since 2.16
-}
testRandIntRange ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Int32
    {- ^ /@begin@/: the minimum value returned by this function -}
    -> Int32
    {- ^ /@end@/: the smallest value not to be returned by this function -}
    -> m Int32
    {- ^ __Returns:__ a number with /@begin@/ \<= number \< /@end@/. -}
testRandIntRange begin end = liftIO $ do
    result <- g_test_rand_int_range begin end
    return result


-- function g_test_rand_int
-- Args : []
-- Lengths : []
-- returnType : Just (TBasicType TInt32)
-- throws : False
-- Skip return : False

foreign import ccall "g_test_rand_int" g_test_rand_int :: 
    IO Int32

{- |
Get a reproducible random integer number.

The random numbers generated by the g_test_rand_*() family of functions
change with every new test program start, unless the --seed option is
given when starting test programs.

For individual test cases however, the random number generator is
reseeded, to avoid dependencies between tests and to make --seed
effective for all test cases.

@since 2.16
-}
testRandInt ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m Int32
    {- ^ __Returns:__ a random number from the seeded random number generator. -}
testRandInt  = liftIO $ do
    result <- g_test_rand_int
    return result


-- function g_test_rand_double_range
-- Args : [Arg {argCName = "range_start", argType = TBasicType TDouble, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the minimum value returned by this function", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "range_end", argType = TBasicType TDouble, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the minimum value not returned by this function", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TDouble)
-- throws : False
-- Skip return : False

foreign import ccall "g_test_rand_double_range" g_test_rand_double_range :: 
    CDouble ->                              -- range_start : TBasicType TDouble
    CDouble ->                              -- range_end : TBasicType TDouble
    IO CDouble

{- |
Get a reproducible random floating pointer number out of a specified range,
see 'GI.GLib.Functions.testRandInt' for details on test case random numbers.

@since 2.16
-}
testRandDoubleRange ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Double
    {- ^ /@rangeStart@/: the minimum value returned by this function -}
    -> Double
    {- ^ /@rangeEnd@/: the minimum value not returned by this function -}
    -> m Double
    {- ^ __Returns:__ a number with /@rangeStart@/ \<= number \< /@rangeEnd@/. -}
testRandDoubleRange rangeStart rangeEnd = liftIO $ do
    let rangeStart' = realToFrac rangeStart
    let rangeEnd' = realToFrac rangeEnd
    result <- g_test_rand_double_range rangeStart' rangeEnd'
    let result' = realToFrac result
    return result'


-- function g_test_rand_double
-- Args : []
-- Lengths : []
-- returnType : Just (TBasicType TDouble)
-- throws : False
-- Skip return : False

foreign import ccall "g_test_rand_double" g_test_rand_double :: 
    IO CDouble

{- |
Get a reproducible random floating point number,
see 'GI.GLib.Functions.testRandInt' for details on test case random numbers.

@since 2.16
-}
testRandDouble ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m Double
    {- ^ __Returns:__ a random number from the seeded random number generator. -}
testRandDouble  = liftIO $ do
    result <- g_test_rand_double
    let result' = realToFrac result
    return result'


-- function g_test_queue_free
-- Args : [Arg {argCName = "gfree_pointer", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the pointer to be stored.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_test_queue_free" g_test_queue_free :: 
    Ptr () ->                               -- gfree_pointer : TBasicType TPtr
    IO ()

{- |
Enqueue a pointer to be released with 'GI.GLib.Functions.free' during the next
teardown phase. This is equivalent to calling 'GI.GLib.Functions.testQueueDestroy'
with a destroy callback of 'GI.GLib.Functions.free'.

@since 2.16
-}
testQueueFree ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Ptr ()
    {- ^ /@gfreePointer@/: the pointer to be stored. -}
    -> m ()
testQueueFree gfreePointer = liftIO $ do
    g_test_queue_free gfreePointer
    return ()


-- function g_test_queue_destroy
-- Args : [Arg {argCName = "destroy_func", argType = TInterface (Name {namespace = "GLib", name = "DestroyNotify"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Destroy callback for teardown phase.", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "destroy_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Destroy callback data.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_test_queue_destroy" g_test_queue_destroy :: 
    FunPtr GLib.Callbacks.C_DestroyNotify -> -- destroy_func : TInterface (Name {namespace = "GLib", name = "DestroyNotify"})
    Ptr () ->                               -- destroy_data : TBasicType TPtr
    IO ()

{- |
This function enqueus a callback /@destroyFunc@/ to be executed
during the next test case teardown phase. This is most useful
to auto destruct allocted test resources at the end of a test run.
Resources are released in reverse queue order, that means enqueueing
callback A before callback B will cause @/B()/@ to be called before
@/A()/@ during teardown.

@since 2.16
-}
testQueueDestroy ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    GLib.Callbacks.DestroyNotify
    {- ^ /@destroyFunc@/: Destroy callback for teardown phase. -}
    -> Ptr ()
    {- ^ /@destroyData@/: Destroy callback data. -}
    -> m ()
testQueueDestroy destroyFunc destroyData = liftIO $ do
    ptrdestroyFunc <- callocMem :: IO (Ptr (FunPtr GLib.Callbacks.C_DestroyNotify))
    destroyFunc' <- GLib.Callbacks.mk_DestroyNotify (GLib.Callbacks.wrap_DestroyNotify (Just ptrdestroyFunc) destroyFunc)
    poke ptrdestroyFunc destroyFunc'
    g_test_queue_destroy destroyFunc' destroyData
    return ()


-- function g_test_log_type_name
-- Args : [Arg {argCName = "log_type", argType = TInterface (Name {namespace = "GLib", name = "TestLogType"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "g_test_log_type_name" g_test_log_type_name :: 
    CUInt ->                                -- log_type : TInterface (Name {namespace = "GLib", name = "TestLogType"})
    IO CString

{- |
/No description available in the introspection data./
-}
testLogTypeName ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    GLib.Enums.TestLogType
    -> m T.Text
testLogTypeName logType = liftIO $ do
    let logType' = (fromIntegral . fromEnum) logType
    result <- g_test_log_type_name logType'
    checkUnexpectedReturnNULL "testLogTypeName" result
    result' <- cstringToText result
    return result'


-- function g_test_incomplete
-- Args : [Arg {argCName = "msg", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "explanation", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_test_incomplete" g_test_incomplete :: 
    CString ->                              -- msg : TBasicType TUTF8
    IO ()

{- |
Indicates that a test failed because of some incomplete
functionality. This function can be called multiple times
from the same test.

Calling this function will not stop the test from running, you
need to return from the test function yourself. So you can
produce additional diagnostic messages or even continue running
the test.

If not called from inside a test, this function does nothing.

@since 2.38
-}
testIncomplete ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Maybe (T.Text)
    {- ^ /@msg@/: explanation -}
    -> m ()
testIncomplete msg = liftIO $ do
    maybeMsg <- case msg of
        Nothing -> return nullPtr
        Just jMsg -> do
            jMsg' <- textToCString jMsg
            return jMsg'
    g_test_incomplete maybeMsg
    freeMem maybeMsg
    return ()


-- function g_test_get_dir
-- Args : [Arg {argCName = "file_type", argType = TInterface (Name {namespace = "GLib", name = "TestFileType"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the type of file (built vs. distributed)", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TFileName)
-- throws : False
-- Skip return : False

foreign import ccall "g_test_get_dir" g_test_get_dir :: 
    CUInt ->                                -- file_type : TInterface (Name {namespace = "GLib", name = "TestFileType"})
    IO CString

{- |
Gets the pathname of the directory containing test files of the type
specified by /@fileType@/.

This is approximately the same as calling g_test_build_filename(\".\"),
but you don\'t need to free the return value.

@since 2.38
-}
testGetDir ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    GLib.Enums.TestFileType
    {- ^ /@fileType@/: the type of file (built vs. distributed) -}
    -> m [Char]
    {- ^ __Returns:__ the path of the directory, owned by GLib -}
testGetDir fileType = liftIO $ do
    let fileType' = (fromIntegral . fromEnum) fileType
    result <- g_test_get_dir fileType'
    checkUnexpectedReturnNULL "testGetDir" result
    result' <- cstringToString result
    return result'


-- function g_test_failed
-- Args : []
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_test_failed" g_test_failed :: 
    IO CInt

{- |
Returns whether a test has already failed. This will
be the case when 'GI.GLib.Functions.testFail', 'GI.GLib.Functions.testIncomplete'
or 'GI.GLib.Functions.testSkip' have been called, but also if an
assertion has failed.

This can be useful to return early from a test if
continuing after a failed assertion might be harmful.

The return value of this function is only meaningful
if it is called from inside a test function.

@since 2.38
-}
testFailed ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m Bool
    {- ^ __Returns:__ 'True' if the test has failed -}
testFailed  = liftIO $ do
    result <- g_test_failed
    let result' = (/= 0) result
    return result'


-- function g_test_fail
-- Args : []
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_test_fail" g_test_fail :: 
    IO ()

{- |
Indicates that a test failed. This function can be called
multiple times from the same test. You can use this function
if your test failed in a recoverable way.

Do not use this function if the failure of a test could cause
other tests to malfunction.

Calling this function will not stop the test from running, you
need to return from the test function yourself. So you can
produce additional diagnostic messages or even continue running
the test.

If not called from inside a test, this function does nothing.

@since 2.30
-}
testFail ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m ()
testFail  = liftIO $ do
    g_test_fail
    return ()


-- function g_test_expect_message
-- Args : [Arg {argCName = "log_domain", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the log domain of the message", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "log_level", argType = TInterface (Name {namespace = "GLib", name = "LogLevelFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the log level of the message", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "pattern", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a glob-style [pattern][glib-Glob-style-pattern-matching]", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_test_expect_message" g_test_expect_message :: 
    CString ->                              -- log_domain : TBasicType TUTF8
    CUInt ->                                -- log_level : TInterface (Name {namespace = "GLib", name = "LogLevelFlags"})
    CString ->                              -- pattern : TBasicType TUTF8
    IO ()

{- |
Indicates that a message with the given /@logDomain@/ and /@logLevel@/,
with text matching /@pattern@/, is expected to be logged. When this
message is logged, it will not be printed, and the test case will
not abort.

This API may only be used with the old logging API (@/g_log()/@ without
@/G_LOG_USE_STRUCTURED/@ defined). It will not work with the structured logging
API. See [Testing for Messages][testing-for-messages].

Use @/g_test_assert_expected_messages()/@ to assert that all
previously-expected messages have been seen and suppressed.

You can call this multiple times in a row, if multiple messages are
expected as a result of a single call. (The messages must appear in
the same order as the calls to 'GI.GLib.Functions.testExpectMessage'.)

For example:


=== /C code/
>
>  // g_main_context_push_thread_default() should fail if the
>  // context is already owned by another thread.
>  g_test_expect_message (G_LOG_DOMAIN,
>                         G_LOG_LEVEL_CRITICAL,
>                         "assertion*acquired_context*failed");
>  g_main_context_push_thread_default (bad_context);
>  g_test_assert_expected_messages ();


Note that you cannot use this to test @/g_error()/@ messages, since
@/g_error()/@ intentionally never returns even if the program doesn\'t
abort; use 'GI.GLib.Functions.testTrapSubprocess' in this case.

If messages at 'GI.GLib.Flags.LogLevelFlagsLevelDebug' are emitted, but not explicitly
expected via 'GI.GLib.Functions.testExpectMessage' then they will be ignored.

@since 2.34
-}
testExpectMessage ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Maybe (T.Text)
    {- ^ /@logDomain@/: the log domain of the message -}
    -> [GLib.Flags.LogLevelFlags]
    {- ^ /@logLevel@/: the log level of the message -}
    -> T.Text
    {- ^ /@pattern@/: a glob-style [pattern][glib-Glob-style-pattern-matching] -}
    -> m ()
testExpectMessage logDomain logLevel pattern = liftIO $ do
    maybeLogDomain <- case logDomain of
        Nothing -> return nullPtr
        Just jLogDomain -> do
            jLogDomain' <- textToCString jLogDomain
            return jLogDomain'
    let logLevel' = gflagsToWord logLevel
    pattern' <- textToCString pattern
    g_test_expect_message maybeLogDomain logLevel' pattern'
    freeMem maybeLogDomain
    freeMem pattern'
    return ()


-- function g_test_bug_base
-- Args : [Arg {argCName = "uri_pattern", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the base pattern for bug URIs", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_test_bug_base" g_test_bug_base :: 
    CString ->                              -- uri_pattern : TBasicType TUTF8
    IO ()

{- |
Specify the base URI for bug reports.

The base URI is used to construct bug report messages for
@/g_test_message()/@ when 'GI.GLib.Functions.testBug' is called.
Calling this function outside of a test case sets the
default base URI for all test cases. Calling it from within
a test case changes the base URI for the scope of the test
case only.
Bug URIs are constructed by appending a bug specific URI
portion to /@uriPattern@/, or by replacing the special string
\'%s\' within /@uriPattern@/ if that is present.

@since 2.16
-}
testBugBase ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@uriPattern@/: the base pattern for bug URIs -}
    -> m ()
testBugBase uriPattern = liftIO $ do
    uriPattern' <- textToCString uriPattern
    g_test_bug_base uriPattern'
    freeMem uriPattern'
    return ()


-- function g_test_bug
-- Args : [Arg {argCName = "bug_uri_snippet", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Bug specific bug tracker URI portion.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_test_bug" g_test_bug :: 
    CString ->                              -- bug_uri_snippet : TBasicType TUTF8
    IO ()

{- |
This function adds a message to test reports that
associates a bug URI with a test case.
Bug URIs are constructed from a base URI set with 'GI.GLib.Functions.testBugBase'
and /@bugUriSnippet@/.

@since 2.16
-}
testBug ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@bugUriSnippet@/: Bug specific bug tracker URI portion. -}
    -> m ()
testBug bugUriSnippet = liftIO $ do
    bugUriSnippet' <- textToCString bugUriSnippet
    g_test_bug bugUriSnippet'
    freeMem bugUriSnippet'
    return ()


-- function g_test_assert_expected_messages_internal
-- Args : [Arg {argCName = "domain", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "file", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "line", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "func", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_test_assert_expected_messages_internal" g_test_assert_expected_messages_internal :: 
    CString ->                              -- domain : TBasicType TUTF8
    CString ->                              -- file : TBasicType TUTF8
    Int32 ->                                -- line : TBasicType TInt
    CString ->                              -- func : TBasicType TUTF8
    IO ()

{- |
/No description available in the introspection data./
-}
testAssertExpectedMessagesInternal ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -> T.Text
    -> Int32
    -> T.Text
    -> m ()
testAssertExpectedMessagesInternal domain file line func = liftIO $ do
    domain' <- textToCString domain
    file' <- textToCString file
    func' <- textToCString func
    g_test_assert_expected_messages_internal domain' file' line func'
    freeMem domain'
    freeMem file'
    freeMem func'
    return ()


-- function g_test_add_func
-- Args : [Arg {argCName = "testpath", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "/-separated test case path name for the test.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "test_func", argType = TInterface (Name {namespace = "GLib", name = "TestFunc"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The test function to invoke for this test.", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_test_add_func" g_test_add_func :: 
    CString ->                              -- testpath : TBasicType TUTF8
    FunPtr GLib.Callbacks.C_TestFunc ->     -- test_func : TInterface (Name {namespace = "GLib", name = "TestFunc"})
    IO ()

{- |
Create a new test case, similar to @/g_test_create_case()/@. However
the test is assumed to use no fixture, and test suites are automatically
created on the fly and added to the root fixture, based on the
slash-separated portions of /@testpath@/.

If /@testpath@/ includes the component \"subprocess\" anywhere in it,
the test will be skipped by default, and only run if explicitly
required via the @-p@ command-line option or 'GI.GLib.Functions.testTrapSubprocess'.

@since 2.16
-}
testAddFunc ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@testpath@/: \/-separated test case path name for the test. -}
    -> GLib.Callbacks.TestFunc
    {- ^ /@testFunc@/: The test function to invoke for this test. -}
    -> m ()
testAddFunc testpath testFunc = liftIO $ do
    testpath' <- textToCString testpath
    ptrtestFunc <- callocMem :: IO (Ptr (FunPtr GLib.Callbacks.C_TestFunc))
    testFunc' <- GLib.Callbacks.mk_TestFunc (GLib.Callbacks.wrap_TestFunc (Just ptrtestFunc) testFunc)
    poke ptrtestFunc testFunc'
    g_test_add_func testpath' testFunc'
    freeMem testpath'
    return ()


-- function g_test_add_data_func
-- Args : [Arg {argCName = "testpath", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "/-separated test case path name for the test.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "test_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Test data argument for the test function.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "test_func", argType = TInterface (Name {namespace = "GLib", name = "TestDataFunc"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The test function to invoke for this test.", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_test_add_data_func" g_test_add_data_func :: 
    CString ->                              -- testpath : TBasicType TUTF8
    Ptr () ->                               -- test_data : TBasicType TPtr
    FunPtr GLib.Callbacks.C_TestDataFunc -> -- test_func : TInterface (Name {namespace = "GLib", name = "TestDataFunc"})
    IO ()

{- |
Create a new test case, similar to @/g_test_create_case()/@. However
the test is assumed to use no fixture, and test suites are automatically
created on the fly and added to the root fixture, based on the
slash-separated portions of /@testpath@/. The /@testData@/ argument
will be passed as first argument to /@testFunc@/.

If /@testpath@/ includes the component \"subprocess\" anywhere in it,
the test will be skipped by default, and only run if explicitly
required via the @-p@ command-line option or 'GI.GLib.Functions.testTrapSubprocess'.

@since 2.16
-}
testAddDataFunc ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@testpath@/: \/-separated test case path name for the test. -}
    -> Ptr ()
    {- ^ /@testData@/: Test data argument for the test function. -}
    -> GLib.Callbacks.TestDataFunc
    {- ^ /@testFunc@/: The test function to invoke for this test. -}
    -> m ()
testAddDataFunc testpath testData testFunc = liftIO $ do
    testpath' <- textToCString testpath
    ptrtestFunc <- callocMem :: IO (Ptr (FunPtr GLib.Callbacks.C_TestDataFunc))
    testFunc' <- GLib.Callbacks.mk_TestDataFunc (GLib.Callbacks.wrap_TestDataFunc (Just ptrtestFunc) (GLib.Callbacks.drop_closures_TestDataFunc testFunc))
    poke ptrtestFunc testFunc'
    g_test_add_data_func testpath' testData testFunc'
    freeMem testpath'
    return ()


-- function g_strv_length
-- Args : [Arg {argCName = "str_array", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a %NULL-terminated array of strings", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUInt)
-- throws : False
-- Skip return : False

foreign import ccall "g_strv_length" g_strv_length :: 
    CString ->                              -- str_array : TBasicType TUTF8
    IO Word32

{- |
Returns the length of the given 'Nothing'-terminated
string array /@strArray@/.

@since 2.6
-}
strvLength ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@strArray@/: a 'Nothing'-terminated array of strings -}
    -> m Word32
    {- ^ __Returns:__ length of /@strArray@/. -}
strvLength strArray = liftIO $ do
    strArray' <- textToCString strArray
    result <- g_strv_length strArray'
    freeMem strArray'
    return result


-- function g_strv_get_type
-- Args : []
-- Lengths : []
-- returnType : Just (TBasicType TGType)
-- throws : False
-- Skip return : False

foreign import ccall "g_strv_get_type" g_strv_get_type :: 
    IO CGType

{- |
/No description available in the introspection data./
-}
strvGetType ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m GType
strvGetType  = liftIO $ do
    result <- g_strv_get_type
    let result' = GType result
    return result'


-- function g_strv_contains
-- Args : [Arg {argCName = "strv", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a %NULL-terminated array of strings", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "str", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_strv_contains" g_strv_contains :: 
    CString ->                              -- strv : TBasicType TUTF8
    CString ->                              -- str : TBasicType TUTF8
    IO CInt

{- |
Checks if /@strv@/ contains /@str@/. /@strv@/ must not be 'Nothing'.

@since 2.44
-}
strvContains ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@strv@/: a 'Nothing'-terminated array of strings -}
    -> T.Text
    {- ^ /@str@/: a string -}
    -> m Bool
    {- ^ __Returns:__ 'True' if /@str@/ is an element of /@strv@/, according to 'GI.GLib.Functions.strEqual'. -}
strvContains strv str = liftIO $ do
    strv' <- textToCString strv
    str' <- textToCString str
    result <- g_strv_contains strv' str'
    let result' = (/= 0) result
    freeMem strv'
    freeMem str'
    return result'


-- function g_strup
-- Args : [Arg {argCName = "string", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the string to convert", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "g_strup" g_strup :: 
    CString ->                              -- string : TBasicType TUTF8
    IO CString

{-# DEPRECATED strup ["(Since version 2.2)","This function is totally broken for the reasons","    discussed in the 'GI.GLib.Functions.strncasecmp' docs - use 'GI.GLib.Functions.asciiStrup'","    or 'GI.GLib.Functions.utf8Strup' instead."] #-}
{- |
Converts a string to upper case.
-}
strup ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@string@/: the string to convert -}
    -> m T.Text
    {- ^ __Returns:__ the string -}
strup string = liftIO $ do
    string' <- textToCString string
    result <- g_strup string'
    checkUnexpectedReturnNULL "strup" result
    result' <- cstringToText result
    freeMem result
    freeMem string'
    return result'


-- function g_strtod
-- Args : [Arg {argCName = "nptr", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the string to convert to a numeric value.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "endptr", argType = TBasicType TUTF8, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "if non-%NULL, it returns the\n          character after the last character used in the conversion.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TDouble)
-- throws : False
-- Skip return : False

foreign import ccall "g_strtod" g_strtod :: 
    CString ->                              -- nptr : TBasicType TUTF8
    Ptr CString ->                          -- endptr : TBasicType TUTF8
    IO CDouble

{- |
Converts a string to a @/gdouble/@ value.
It calls the standard @/strtod()/@ function to handle the conversion, but
if the string is not completely converted it attempts the conversion
again with 'GI.GLib.Functions.asciiStrtod', and returns the best match.

This function should seldom be used. The normal situation when reading
numbers not for human consumption is to use 'GI.GLib.Functions.asciiStrtod'. Only when
you know that you must expect both locale formatted and C formatted numbers
should you use this. Make sure that you don\'t pass strings such as comma
separated lists of values, since the commas may be interpreted as a decimal
point in some locales, causing unexpected results.
-}
strtod ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@nptr@/: the string to convert to a numeric value. -}
    -> m ((Double, T.Text))
    {- ^ __Returns:__ the @/gdouble/@ value. -}
strtod nptr = liftIO $ do
    nptr' <- textToCString nptr
    endptr <- allocMem :: IO (Ptr CString)
    result <- g_strtod nptr' endptr
    let result' = realToFrac result
    endptr' <- peek endptr
    endptr'' <- cstringToText endptr'
    freeMem nptr'
    freeMem endptr
    return (result', endptr'')


-- function g_strstr_len
-- Args : [Arg {argCName = "haystack", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "haystack_len", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the maximum length of @haystack. Note that -1 is\n    a valid length, if @haystack is nul-terminated, meaning it will\n    search through the whole string.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "needle", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the string to search for", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "g_strstr_len" g_strstr_len :: 
    CString ->                              -- haystack : TBasicType TUTF8
    Int64 ->                                -- haystack_len : TBasicType TInt64
    CString ->                              -- needle : TBasicType TUTF8
    IO CString

{- |
Searches the string /@haystack@/ for the first occurrence
of the string /@needle@/, limiting the length of the search
to /@haystackLen@/.
-}
strstrLen ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@haystack@/: a string -}
    -> Int64
    {- ^ /@haystackLen@/: the maximum length of /@haystack@/. Note that -1 is
    a valid length, if /@haystack@/ is nul-terminated, meaning it will
    search through the whole string. -}
    -> T.Text
    {- ^ /@needle@/: the string to search for -}
    -> m T.Text
    {- ^ __Returns:__ a pointer to the found occurrence, or
   'Nothing' if not found. -}
strstrLen haystack haystackLen needle = liftIO $ do
    haystack' <- textToCString haystack
    needle' <- textToCString needle
    result <- g_strstr_len haystack' haystackLen needle'
    checkUnexpectedReturnNULL "strstrLen" result
    result' <- cstringToText result
    freeMem result
    freeMem haystack'
    freeMem needle'
    return result'


-- function g_strsignal
-- Args : [Arg {argCName = "signum", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the signal number. See the `signal` documentation", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "g_strsignal" g_strsignal :: 
    Int32 ->                                -- signum : TBasicType TInt
    IO CString

{- |
Returns a string describing the given signal, e.g. \"Segmentation fault\".
You should use this function in preference to @/strsignal()/@, because it
returns a string in UTF-8 encoding, and since not all platforms support
the @/strsignal()/@ function.
-}
strsignal ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Int32
    {- ^ /@signum@/: the signal number. See the @signal@ documentation -}
    -> m T.Text
    {- ^ __Returns:__ a UTF-8 string describing the signal. If the signal is unknown,
    it returns \"unknown signal (\<signum>)\". -}
strsignal signum = liftIO $ do
    result <- g_strsignal signum
    checkUnexpectedReturnNULL "strsignal" result
    result' <- cstringToText result
    return result'


-- function g_strrstr_len
-- Args : [Arg {argCName = "haystack", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a nul-terminated string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "haystack_len", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the maximum length of @haystack", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "needle", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the nul-terminated string to search for", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "g_strrstr_len" g_strrstr_len :: 
    CString ->                              -- haystack : TBasicType TUTF8
    Int64 ->                                -- haystack_len : TBasicType TInt64
    CString ->                              -- needle : TBasicType TUTF8
    IO CString

{- |
Searches the string /@haystack@/ for the last occurrence
of the string /@needle@/, limiting the length of the search
to /@haystackLen@/.
-}
strrstrLen ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@haystack@/: a nul-terminated string -}
    -> Int64
    {- ^ /@haystackLen@/: the maximum length of /@haystack@/ -}
    -> T.Text
    {- ^ /@needle@/: the nul-terminated string to search for -}
    -> m T.Text
    {- ^ __Returns:__ a pointer to the found occurrence, or
   'Nothing' if not found. -}
strrstrLen haystack haystackLen needle = liftIO $ do
    haystack' <- textToCString haystack
    needle' <- textToCString needle
    result <- g_strrstr_len haystack' haystackLen needle'
    checkUnexpectedReturnNULL "strrstrLen" result
    result' <- cstringToText result
    freeMem result
    freeMem haystack'
    freeMem needle'
    return result'


-- function g_strrstr
-- Args : [Arg {argCName = "haystack", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a nul-terminated string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "needle", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the nul-terminated string to search for", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "g_strrstr" g_strrstr :: 
    CString ->                              -- haystack : TBasicType TUTF8
    CString ->                              -- needle : TBasicType TUTF8
    IO CString

{- |
Searches the string /@haystack@/ for the last occurrence
of the string /@needle@/.
-}
strrstr ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@haystack@/: a nul-terminated string -}
    -> T.Text
    {- ^ /@needle@/: the nul-terminated string to search for -}
    -> m T.Text
    {- ^ __Returns:__ a pointer to the found occurrence, or
   'Nothing' if not found. -}
strrstr haystack needle = liftIO $ do
    haystack' <- textToCString haystack
    needle' <- textToCString needle
    result <- g_strrstr haystack' needle'
    checkUnexpectedReturnNULL "strrstr" result
    result' <- cstringToText result
    freeMem result
    freeMem haystack'
    freeMem needle'
    return result'


-- function g_strreverse
-- Args : [Arg {argCName = "string", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the string to reverse", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "g_strreverse" g_strreverse :: 
    CString ->                              -- string : TBasicType TUTF8
    IO CString

{- |
Reverses all of the bytes in a string. For example,
@g_strreverse (\"abcdef\")@ will result in \"fedcba\".

Note that 'GI.GLib.Functions.strreverse' doesn\'t work on UTF-8 strings
containing multibyte characters. For that purpose, use
'GI.GLib.Functions.utf8Strreverse'.
-}
strreverse ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@string@/: the string to reverse -}
    -> m T.Text
    {- ^ __Returns:__ the same pointer passed in as /@string@/ -}
strreverse string = liftIO $ do
    string' <- textToCString string
    result <- g_strreverse string'
    checkUnexpectedReturnNULL "strreverse" result
    result' <- cstringToText result
    freeMem result
    freeMem string'
    return result'


-- function g_strnfill
-- Args : [Arg {argCName = "length", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the length of the new string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "fill_char", argType = TBasicType TInt8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the byte to fill the string with", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "g_strnfill" g_strnfill :: 
    Word64 ->                               -- length : TBasicType TUInt64
    Int8 ->                                 -- fill_char : TBasicType TInt8
    IO CString

{- |
Creates a new string /@length@/ bytes long filled with /@fillChar@/.
The returned string should be freed when no longer needed.
-}
strnfill ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Word64
    {- ^ /@length@/: the length of the new string -}
    -> Int8
    {- ^ /@fillChar@/: the byte to fill the string with -}
    -> m T.Text
    {- ^ __Returns:__ a newly-allocated string filled the /@fillChar@/ -}
strnfill length_ fillChar = liftIO $ do
    result <- g_strnfill length_ fillChar
    checkUnexpectedReturnNULL "strnfill" result
    result' <- cstringToText result
    freeMem result
    return result'


-- function g_strndup
-- Args : [Arg {argCName = "str", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the string to duplicate", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "n", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the maximum number of bytes to copy from @str", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "g_strndup" g_strndup :: 
    CString ->                              -- str : TBasicType TUTF8
    Word64 ->                               -- n : TBasicType TUInt64
    IO CString

{- |
Duplicates the first /@n@/ bytes of a string, returning a newly-allocated
buffer /@n@/ + 1 bytes long which will always be nul-terminated. If /@str@/
is less than /@n@/ bytes long the buffer is padded with nuls. If /@str@/ is
'Nothing' it returns 'Nothing'. The returned value should be freed when no longer
needed.

To copy a number of characters from a UTF-8 encoded string,
use 'GI.GLib.Functions.utf8Strncpy' instead.
-}
strndup ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@str@/: the string to duplicate -}
    -> Word64
    {- ^ /@n@/: the maximum number of bytes to copy from /@str@/ -}
    -> m T.Text
    {- ^ __Returns:__ a newly-allocated buffer containing the first /@n@/ bytes
    of /@str@/, nul-terminated -}
strndup str n = liftIO $ do
    str' <- textToCString str
    result <- g_strndup str' n
    checkUnexpectedReturnNULL "strndup" result
    result' <- cstringToText result
    freeMem result
    freeMem str'
    return result'


-- function g_strncasecmp
-- Args : [Arg {argCName = "s1", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "s2", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a string to compare with @s1", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "n", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the maximum number of characters to compare", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TInt)
-- throws : False
-- Skip return : False

foreign import ccall "g_strncasecmp" g_strncasecmp :: 
    CString ->                              -- s1 : TBasicType TUTF8
    CString ->                              -- s2 : TBasicType TUTF8
    Word32 ->                               -- n : TBasicType TUInt
    IO Int32

{-# DEPRECATED strncasecmp ["(Since version 2.2)","The problem with 'GI.GLib.Functions.strncasecmp' is that it does","    the comparison by calling @/toupper()/@\\/@/tolower()/@. These functions","    are locale-specific and operate on single bytes. However, it is","    impossible to handle things correctly from an internationalization","    standpoint by operating on bytes, since characters may be multibyte.","    Thus 'GI.GLib.Functions.strncasecmp' is broken if your string is guaranteed to be","    ASCII, since it is locale-sensitive, and it\\'s broken if your string","    is localized, since it doesn\\'t work on many encodings at all,","    including UTF-8, EUC-JP, etc.","","    There are therefore two replacement techniques: 'GI.GLib.Functions.asciiStrncasecmp',","    which only works on ASCII and is not locale-sensitive, and","    'GI.GLib.Functions.utf8Casefold' followed by @/strcmp()/@ on the resulting strings,","    which is good for case-insensitive sorting of UTF-8."] #-}
{- |
A case-insensitive string comparison, corresponding to the standard
@/strncasecmp()/@ function on platforms which support it. It is similar
to 'GI.GLib.Functions.strcasecmp' except it only compares the first /@n@/ characters of
the strings.
-}
strncasecmp ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@s1@/: a string -}
    -> T.Text
    {- ^ /@s2@/: a string to compare with /@s1@/ -}
    -> Word32
    {- ^ /@n@/: the maximum number of characters to compare -}
    -> m Int32
    {- ^ __Returns:__ 0 if the strings match, a negative value if /@s1@/ \< /@s2@/,
    or a positive value if /@s1@/ > /@s2@/. -}
strncasecmp s1 s2 n = liftIO $ do
    s1' <- textToCString s1
    s2' <- textToCString s2
    result <- g_strncasecmp s1' s2' n
    freeMem s1'
    freeMem s2'
    return result


-- function g_strlcpy
-- Args : [Arg {argCName = "dest", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "destination buffer", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "src", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "source buffer", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "dest_size", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "length of @dest in bytes", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUInt64)
-- throws : False
-- Skip return : False

foreign import ccall "g_strlcpy" g_strlcpy :: 
    CString ->                              -- dest : TBasicType TUTF8
    CString ->                              -- src : TBasicType TUTF8
    Word64 ->                               -- dest_size : TBasicType TUInt64
    IO Word64

{- |
Portability wrapper that calls @/strlcpy()/@ on systems which have it,
and emulates @/strlcpy()/@ otherwise. Copies /@src@/ to /@dest@/; /@dest@/ is
guaranteed to be nul-terminated; /@src@/ must be nul-terminated;
/@destSize@/ is the buffer size, not the number of bytes to copy.

At most /@destSize@/ - 1 characters will be copied. Always nul-terminates
(unless /@destSize@/ is 0). This function does not allocate memory. Unlike
@/strncpy()/@, this function doesn\'t pad /@dest@/ (so it\'s often faster). It
returns the size of the attempted result, strlen (src), so if
/@retval@/ >= /@destSize@/, truncation occurred.

Caveat: @/strlcpy()/@ is supposedly more secure than @/strcpy()/@ or @/strncpy()/@,
but if you really want to avoid screwups, 'GI.GLib.Functions.strdup' is an even better
idea.
-}
strlcpy ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@dest@/: destination buffer -}
    -> T.Text
    {- ^ /@src@/: source buffer -}
    -> Word64
    {- ^ /@destSize@/: length of /@dest@/ in bytes -}
    -> m Word64
    {- ^ __Returns:__ length of /@src@/ -}
strlcpy dest src destSize = liftIO $ do
    dest' <- textToCString dest
    src' <- textToCString src
    result <- g_strlcpy dest' src' destSize
    freeMem dest'
    freeMem src'
    return result


-- function g_strlcat
-- Args : [Arg {argCName = "dest", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "destination buffer, already containing one nul-terminated string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "src", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "source buffer", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "dest_size", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "length of @dest buffer in bytes (not length of existing string\n    inside @dest)", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUInt64)
-- throws : False
-- Skip return : False

foreign import ccall "g_strlcat" g_strlcat :: 
    CString ->                              -- dest : TBasicType TUTF8
    CString ->                              -- src : TBasicType TUTF8
    Word64 ->                               -- dest_size : TBasicType TUInt64
    IO Word64

{- |
Portability wrapper that calls @/strlcat()/@ on systems which have it,
and emulates it otherwise. Appends nul-terminated /@src@/ string to /@dest@/,
guaranteeing nul-termination for /@dest@/. The total size of /@dest@/ won\'t
exceed /@destSize@/.

At most /@destSize@/ - 1 characters will be copied. Unlike @/strncat()/@,
/@destSize@/ is the full size of dest, not the space left over. This
function does not allocate memory. It always nul-terminates (unless
/@destSize@/ == 0 or there were no nul characters in the /@destSize@/
characters of dest to start with).

Caveat: this is supposedly a more secure alternative to @/strcat()/@ or
@/strncat()/@, but for real security @/g_strconcat()/@ is harder to mess up.
-}
strlcat ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@dest@/: destination buffer, already containing one nul-terminated string -}
    -> T.Text
    {- ^ /@src@/: source buffer -}
    -> Word64
    {- ^ /@destSize@/: length of /@dest@/ buffer in bytes (not length of existing string
    inside /@dest@/) -}
    -> m Word64
    {- ^ __Returns:__ size of attempted result, which is MIN (dest_size, strlen
    (original dest)) + strlen (src), so if retval >= dest_size,
    truncation occurred. -}
strlcat dest src destSize = liftIO $ do
    dest' <- textToCString dest
    src' <- textToCString src
    result <- g_strlcat dest' src' destSize
    freeMem dest'
    freeMem src'
    return result


-- function g_strjoinv
-- Args : [Arg {argCName = "separator", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a string to insert between each of the\n    strings, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "str_array", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a %NULL-terminated array of strings to join", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "g_strjoinv" g_strjoinv :: 
    CString ->                              -- separator : TBasicType TUTF8
    CString ->                              -- str_array : TBasicType TUTF8
    IO CString

{- |
Joins a number of strings together to form one long string, with the
optional /@separator@/ inserted between each of them. The returned string
should be freed with 'GI.GLib.Functions.free'.

If /@strArray@/ has no items, the return value will be an
empty string. If /@strArray@/ contains a single item, /@separator@/ will not
appear in the resulting string.
-}
strjoinv ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Maybe (T.Text)
    {- ^ /@separator@/: a string to insert between each of the
    strings, or 'Nothing' -}
    -> T.Text
    {- ^ /@strArray@/: a 'Nothing'-terminated array of strings to join -}
    -> m T.Text
    {- ^ __Returns:__ a newly-allocated string containing all of the strings joined
    together, with /@separator@/ between them -}
strjoinv separator strArray = liftIO $ do
    maybeSeparator <- case separator of
        Nothing -> return nullPtr
        Just jSeparator -> do
            jSeparator' <- textToCString jSeparator
            return jSeparator'
    strArray' <- textToCString strArray
    result <- g_strjoinv maybeSeparator strArray'
    checkUnexpectedReturnNULL "strjoinv" result
    result' <- cstringToText result
    freeMem result
    freeMem maybeSeparator
    freeMem strArray'
    return result'


-- function g_strip_context
-- Args : [Arg {argCName = "msgid", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "msgval", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "another string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "g_strip_context" g_strip_context :: 
    CString ->                              -- msgid : TBasicType TUTF8
    CString ->                              -- msgval : TBasicType TUTF8
    IO CString

{- |
An auxiliary function for @/gettext()/@ support (see @/Q_()/@).

@since 2.4
-}
stripContext ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@msgid@/: a string -}
    -> T.Text
    {- ^ /@msgval@/: another string -}
    -> m T.Text
    {- ^ __Returns:__ /@msgval@/, unless /@msgval@/ is identical to /@msgid@/
    and contains a \'|\' character, in which case a pointer to
    the substring of msgid after the first \'|\' character is returned. -}
stripContext msgid msgval = liftIO $ do
    msgid' <- textToCString msgid
    msgval' <- textToCString msgval
    result <- g_strip_context msgid' msgval'
    checkUnexpectedReturnNULL "stripContext" result
    result' <- cstringToText result
    freeMem msgid'
    freeMem msgval'
    return result'


-- function g_string_sized_new
-- Args : [Arg {argCName = "dfl_size", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the default size of the space allocated to\n    hold the string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "GLib", name = "String"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_string_sized_new" g_string_sized_new :: 
    Word64 ->                               -- dfl_size : TBasicType TUInt64
    IO (Ptr GLib.String.String)

{- |
Creates a new 'GI.GLib.Structs.String.String', with enough space for /@dflSize@/
bytes. This is useful if you are going to add a lot of
text to the string and don\'t want it to be reallocated
too often.
-}
stringSizedNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Word64
    {- ^ /@dflSize@/: the default size of the space allocated to
    hold the string -}
    -> m GLib.String.String
    {- ^ __Returns:__ the new 'GI.GLib.Structs.String.String' -}
stringSizedNew dflSize = liftIO $ do
    result <- g_string_sized_new dflSize
    checkUnexpectedReturnNULL "stringSizedNew" result
    result' <- (wrapBoxed GLib.String.String) result
    return result'


-- function g_string_new_len
-- Args : [Arg {argCName = "init", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "initial contents of the string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "len", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "length of @init to use", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "GLib", name = "String"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_string_new_len" g_string_new_len :: 
    CString ->                              -- init : TBasicType TUTF8
    Int64 ->                                -- len : TBasicType TInt64
    IO (Ptr GLib.String.String)

{- |
Creates a new 'GI.GLib.Structs.String.String' with /@len@/ bytes of the /@init@/ buffer.
Because a length is provided, /@init@/ need not be nul-terminated,
and can contain embedded nul bytes.

Since this function does not stop at nul bytes, it is the caller\'s
responsibility to ensure that /@init@/ has at least /@len@/ addressable
bytes.
-}
stringNewLen ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@init@/: initial contents of the string -}
    -> Int64
    {- ^ /@len@/: length of /@init@/ to use -}
    -> m GLib.String.String
    {- ^ __Returns:__ a new 'GI.GLib.Structs.String.String' -}
stringNewLen init len = liftIO $ do
    init' <- textToCString init
    result <- g_string_new_len init' len
    checkUnexpectedReturnNULL "stringNewLen" result
    result' <- (wrapBoxed GLib.String.String) result
    freeMem init'
    return result'


-- function g_string_new
-- Args : [Arg {argCName = "init", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the initial text to copy into the string, or %NULL to\nstart with an empty string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "GLib", name = "String"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_string_new" g_string_new :: 
    CString ->                              -- init : TBasicType TUTF8
    IO (Ptr GLib.String.String)

{- |
Creates a new 'GI.GLib.Structs.String.String', initialized with the given string.
-}
stringNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Maybe (T.Text)
    {- ^ /@init@/: the initial text to copy into the string, or 'Nothing' to
start with an empty string -}
    -> m GLib.String.String
    {- ^ __Returns:__ the new 'GI.GLib.Structs.String.String' -}
stringNew init = liftIO $ do
    maybeInit <- case init of
        Nothing -> return nullPtr
        Just jInit -> do
            jInit' <- textToCString jInit
            return jInit'
    result <- g_string_new maybeInit
    checkUnexpectedReturnNULL "stringNew" result
    result' <- (wrapBoxed GLib.String.String) result
    freeMem maybeInit
    return result'


-- function g_strfreev
-- Args : [Arg {argCName = "str_array", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a %NULL-terminated array of strings to free", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_strfreev" g_strfreev :: 
    CString ->                              -- str_array : TBasicType TUTF8
    IO ()

{- |
Frees a 'Nothing'-terminated array of strings, as well as each
string it contains.

If /@strArray@/ is 'Nothing', this function simply returns.
-}
strfreev ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Maybe (T.Text)
    {- ^ /@strArray@/: a 'Nothing'-terminated array of strings to free -}
    -> m ()
strfreev strArray = liftIO $ do
    maybeStrArray <- case strArray of
        Nothing -> return nullPtr
        Just jStrArray -> do
            jStrArray' <- textToCString jStrArray
            return jStrArray'
    g_strfreev maybeStrArray
    freeMem maybeStrArray
    return ()


-- function g_strescape
-- Args : [Arg {argCName = "source", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a string to escape", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "exceptions", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a string of characters not to escape in @source", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "g_strescape" g_strescape :: 
    CString ->                              -- source : TBasicType TUTF8
    CString ->                              -- exceptions : TBasicType TUTF8
    IO CString

{- |
Escapes the special characters \'\\b\', \'\\f\', \'\\n\', \'\\r\', \'\\t\', \'\\v\', \'\\\'
and \'\"\' in the string /@source@/ by inserting a \'\\\' before
them. Additionally all characters in the range 0x01-0x1F (everything
below SPACE) and in the range 0x7F-0xFF (all non-ASCII chars) are
replaced with a \'\\\' followed by their octal representation.
Characters supplied in /@exceptions@/ are not escaped.

'GI.GLib.Functions.strcompress' does the reverse conversion.
-}
strescape ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@source@/: a string to escape -}
    -> Maybe (T.Text)
    {- ^ /@exceptions@/: a string of characters not to escape in /@source@/ -}
    -> m T.Text
    {- ^ __Returns:__ a newly-allocated copy of /@source@/ with certain
    characters escaped. See above. -}
strescape source exceptions = liftIO $ do
    source' <- textToCString source
    maybeExceptions <- case exceptions of
        Nothing -> return nullPtr
        Just jExceptions -> do
            jExceptions' <- textToCString jExceptions
            return jExceptions'
    result <- g_strescape source' maybeExceptions
    checkUnexpectedReturnNULL "strescape" result
    result' <- cstringToText result
    freeMem result
    freeMem source'
    freeMem maybeExceptions
    return result'


-- function g_strerror
-- Args : [Arg {argCName = "errnum", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the system error number. See the standard C %errno\n    documentation", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "g_strerror" g_strerror :: 
    Int32 ->                                -- errnum : TBasicType TInt
    IO CString

{- |
Returns a string corresponding to the given error code, e.g. \"no
such process\". Unlike @/strerror()/@, this always returns a string in
UTF-8 encoding, and the pointer is guaranteed to remain valid for
the lifetime of the process.

Note that the string may be translated according to the current locale.

The value of @/errno/@ will not be changed by this function.
-}
strerror ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Int32
    {- ^ /@errnum@/: the system error number. See the standard C @/errno/@
    documentation -}
    -> m T.Text
    {- ^ __Returns:__ a UTF-8 string describing the error code. If the error code
    is unknown, it returns a string like \"unknown error (\<code>)\". -}
strerror errnum = liftIO $ do
    result <- g_strerror errnum
    checkUnexpectedReturnNULL "strerror" result
    result' <- cstringToText result
    return result'


-- function g_strdup
-- Args : [Arg {argCName = "str", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the string to duplicate", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "g_strdup" g_strdup :: 
    CString ->                              -- str : TBasicType TUTF8
    IO CString

{- |
Duplicates a string. If /@str@/ is 'Nothing' it returns 'Nothing'.
The returned string should be freed with 'GI.GLib.Functions.free'
when no longer needed.
-}
strdup ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Maybe (T.Text)
    {- ^ /@str@/: the string to duplicate -}
    -> m T.Text
    {- ^ __Returns:__ a newly-allocated copy of /@str@/ -}
strdup str = liftIO $ do
    maybeStr <- case str of
        Nothing -> return nullPtr
        Just jStr -> do
            jStr' <- textToCString jStr
            return jStr'
    result <- g_strdup maybeStr
    checkUnexpectedReturnNULL "strdup" result
    result' <- cstringToText result
    freeMem result
    freeMem maybeStr
    return result'


-- function g_strdown
-- Args : [Arg {argCName = "string", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the string to convert.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "g_strdown" g_strdown :: 
    CString ->                              -- string : TBasicType TUTF8
    IO CString

{-# DEPRECATED strdown ["(Since version 2.2)","This function is totally broken for the reasons discussed","in the 'GI.GLib.Functions.strncasecmp' docs - use 'GI.GLib.Functions.asciiStrdown' or 'GI.GLib.Functions.utf8Strdown'","instead."] #-}
{- |
Converts a string to lower case.
-}
strdown ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@string@/: the string to convert. -}
    -> m T.Text
    {- ^ __Returns:__ the string -}
strdown string = liftIO $ do
    string' <- textToCString string
    result <- g_strdown string'
    checkUnexpectedReturnNULL "strdown" result
    result' <- cstringToText result
    freeMem result
    freeMem string'
    return result'


-- function g_strdelimit
-- Args : [Arg {argCName = "string", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the string to convert", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "delimiters", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a string containing the current delimiters,\n    or %NULL to use the standard delimiters defined in #G_STR_DELIMITERS", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "new_delimiter", argType = TBasicType TInt8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the new delimiter character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "g_strdelimit" g_strdelimit :: 
    CString ->                              -- string : TBasicType TUTF8
    CString ->                              -- delimiters : TBasicType TUTF8
    Int8 ->                                 -- new_delimiter : TBasicType TInt8
    IO CString

{- |
Converts any delimiter characters in /@string@/ to /@newDelimiter@/.
Any characters in /@string@/ which are found in /@delimiters@/ are
changed to the /@newDelimiter@/ character. Modifies /@string@/ in place,
and returns /@string@/ itself, not a copy. The return value is to
allow nesting such as

=== /C code/
>
>  g_ascii_strup (g_strdelimit (str, "abc", '?'))
-}
strdelimit ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@string@/: the string to convert -}
    -> Maybe (T.Text)
    {- ^ /@delimiters@/: a string containing the current delimiters,
    or 'Nothing' to use the standard delimiters defined in 'GI.GLib.Constants.STR_DELIMITERS' -}
    -> Int8
    {- ^ /@newDelimiter@/: the new delimiter character -}
    -> m T.Text
    {- ^ __Returns:__ /@string@/ -}
strdelimit string delimiters newDelimiter = liftIO $ do
    string' <- textToCString string
    maybeDelimiters <- case delimiters of
        Nothing -> return nullPtr
        Just jDelimiters -> do
            jDelimiters' <- textToCString jDelimiters
            return jDelimiters'
    result <- g_strdelimit string' maybeDelimiters newDelimiter
    checkUnexpectedReturnNULL "strdelimit" result
    result' <- cstringToText result
    freeMem result
    freeMem string'
    freeMem maybeDelimiters
    return result'


-- function g_strcompress
-- Args : [Arg {argCName = "source", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a string to compress", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "g_strcompress" g_strcompress :: 
    CString ->                              -- source : TBasicType TUTF8
    IO CString

{- |
Replaces all escaped characters with their one byte equivalent.

This function does the reverse conversion of 'GI.GLib.Functions.strescape'.
-}
strcompress ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@source@/: a string to compress -}
    -> m T.Text
    {- ^ __Returns:__ a newly-allocated copy of /@source@/ with all escaped
    character compressed -}
strcompress source = liftIO $ do
    source' <- textToCString source
    result <- g_strcompress source'
    checkUnexpectedReturnNULL "strcompress" result
    result' <- cstringToText result
    freeMem result
    freeMem source'
    return result'


-- function g_strcmp0
-- Args : [Arg {argCName = "str1", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a C string or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "str2", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "another C string or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TInt)
-- throws : False
-- Skip return : False

foreign import ccall "g_strcmp0" g_strcmp0 :: 
    CString ->                              -- str1 : TBasicType TUTF8
    CString ->                              -- str2 : TBasicType TUTF8
    IO Int32

{- |
Compares /@str1@/ and /@str2@/ like @/strcmp()/@. Handles 'Nothing'
gracefully by sorting it before non-'Nothing' strings.
Comparing two 'Nothing' pointers returns 0.

@since 2.16
-}
strcmp0 ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Maybe (T.Text)
    {- ^ /@str1@/: a C string or 'Nothing' -}
    -> Maybe (T.Text)
    {- ^ /@str2@/: another C string or 'Nothing' -}
    -> m Int32
    {- ^ __Returns:__ an integer less than, equal to, or greater than zero, if /@str1@/ is \<, == or > than /@str2@/. -}
strcmp0 str1 str2 = liftIO $ do
    maybeStr1 <- case str1 of
        Nothing -> return nullPtr
        Just jStr1 -> do
            jStr1' <- textToCString jStr1
            return jStr1'
    maybeStr2 <- case str2 of
        Nothing -> return nullPtr
        Just jStr2 -> do
            jStr2' <- textToCString jStr2
            return jStr2'
    result <- g_strcmp0 maybeStr1 maybeStr2
    freeMem maybeStr1
    freeMem maybeStr2
    return result


-- function g_strchug
-- Args : [Arg {argCName = "string", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a string to remove the leading whitespace from", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "g_strchug" g_strchug :: 
    CString ->                              -- string : TBasicType TUTF8
    IO CString

{- |
Removes leading whitespace from a string, by moving the rest
of the characters forward.

This function doesn\'t allocate or reallocate any memory;
it modifies /@string@/ in place. Therefore, it cannot be used on
statically allocated strings.

The pointer to /@string@/ is returned to allow the nesting of functions.

Also see 'GI.GLib.Functions.strchomp' and @/g_strstrip()/@.
-}
strchug ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@string@/: a string to remove the leading whitespace from -}
    -> m T.Text
    {- ^ __Returns:__ /@string@/ -}
strchug string = liftIO $ do
    string' <- textToCString string
    result <- g_strchug string'
    checkUnexpectedReturnNULL "strchug" result
    result' <- cstringToText result
    freeMem result
    freeMem string'
    return result'


-- function g_strchomp
-- Args : [Arg {argCName = "string", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a string to remove the trailing whitespace from", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "g_strchomp" g_strchomp :: 
    CString ->                              -- string : TBasicType TUTF8
    IO CString

{- |
Removes trailing whitespace from a string.

This function doesn\'t allocate or reallocate any memory;
it modifies /@string@/ in place. Therefore, it cannot be used
on statically allocated strings.

The pointer to /@string@/ is returned to allow the nesting of functions.

Also see 'GI.GLib.Functions.strchug' and @/g_strstrip()/@.
-}
strchomp ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@string@/: a string to remove the trailing whitespace from -}
    -> m T.Text
    {- ^ __Returns:__ /@string@/ -}
strchomp string = liftIO $ do
    string' <- textToCString string
    result <- g_strchomp string'
    checkUnexpectedReturnNULL "strchomp" result
    result' <- cstringToText result
    freeMem result
    freeMem string'
    return result'


-- function g_strcasecmp
-- Args : [Arg {argCName = "s1", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "s2", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a string to compare with @s1", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TInt)
-- throws : False
-- Skip return : False

foreign import ccall "g_strcasecmp" g_strcasecmp :: 
    CString ->                              -- s1 : TBasicType TUTF8
    CString ->                              -- s2 : TBasicType TUTF8
    IO Int32

{-# DEPRECATED strcasecmp ["(Since version 2.2)","See 'GI.GLib.Functions.strncasecmp' for a discussion of why this","    function is deprecated and how to replace it."] #-}
{- |
A case-insensitive string comparison, corresponding to the standard
@/strcasecmp()/@ function on platforms which support it.
-}
strcasecmp ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@s1@/: a string -}
    -> T.Text
    {- ^ /@s2@/: a string to compare with /@s1@/ -}
    -> m Int32
    {- ^ __Returns:__ 0 if the strings match, a negative value if /@s1@/ \< /@s2@/,
    or a positive value if /@s1@/ > /@s2@/. -}
strcasecmp s1 s2 = liftIO $ do
    s1' <- textToCString s1
    s2' <- textToCString s2
    result <- g_strcasecmp s1' s2'
    freeMem s1'
    freeMem s2'
    return result


-- function g_strcanon
-- Args : [Arg {argCName = "string", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a nul-terminated array of bytes", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "valid_chars", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "bytes permitted in @string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "substitutor", argType = TBasicType TInt8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "replacement character for disallowed bytes", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "g_strcanon" g_strcanon :: 
    CString ->                              -- string : TBasicType TUTF8
    CString ->                              -- valid_chars : TBasicType TUTF8
    Int8 ->                                 -- substitutor : TBasicType TInt8
    IO CString

{- |
For each character in /@string@/, if the character is not in /@validChars@/,
replaces the character with /@substitutor@/. Modifies /@string@/ in place,
and return /@string@/ itself, not a copy. The return value is to allow
nesting such as

=== /C code/
>
>  g_ascii_strup (g_strcanon (str, "abc", '?'))
-}
strcanon ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@string@/: a nul-terminated array of bytes -}
    -> T.Text
    {- ^ /@validChars@/: bytes permitted in /@string@/ -}
    -> Int8
    {- ^ /@substitutor@/: replacement character for disallowed bytes -}
    -> m T.Text
    {- ^ __Returns:__ /@string@/ -}
strcanon string validChars substitutor = liftIO $ do
    string' <- textToCString string
    validChars' <- textToCString validChars
    result <- g_strcanon string' validChars' substitutor
    checkUnexpectedReturnNULL "strcanon" result
    result' <- cstringToText result
    freeMem result
    freeMem string'
    freeMem validChars'
    return result'


-- function g_str_tokenize_and_fold
-- Args : [Arg {argCName = "string", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "translit_locale", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the language code (like 'de' or\n  'en_GB') from which @string originates", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "ascii_alternates", argType = TCArray True (-1) (-1) (TBasicType TUTF8), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a\n  return location for ASCII alternates", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : []
-- returnType : Just (TCArray True (-1) (-1) (TBasicType TUTF8))
-- throws : False
-- Skip return : False

foreign import ccall "g_str_tokenize_and_fold" g_str_tokenize_and_fold :: 
    CString ->                              -- string : TBasicType TUTF8
    CString ->                              -- translit_locale : TBasicType TUTF8
    Ptr (Ptr CString) ->                    -- ascii_alternates : TCArray True (-1) (-1) (TBasicType TUTF8)
    IO (Ptr CString)

{- |
Tokenises /@string@/ and performs folding on each token.

A token is a non-empty sequence of alphanumeric characters in the
source string, separated by non-alphanumeric characters.  An
\"alphanumeric\" character for this purpose is one that matches
'GI.GLib.Functions.unicharIsalnum' or 'GI.GLib.Functions.unicharIsmark'.

Each token is then (Unicode) normalised and case-folded.  If
/@asciiAlternates@/ is non-'Nothing' and some of the returned tokens
contain non-ASCII characters, ASCII alternatives will be generated.

The number of ASCII alternatives that are generated and the method
for doing so is unspecified, but /@translitLocale@/ (if specified) may
improve the transliteration if the language of the source string is
known.

@since 2.40
-}
strTokenizeAndFold ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@string@/: a string -}
    -> Maybe (T.Text)
    {- ^ /@translitLocale@/: the language code (like \'de\' or
  \'en_GB\') from which /@string@/ originates -}
    -> m (([T.Text], [T.Text]))
    {- ^ __Returns:__ the folded tokens -}
strTokenizeAndFold string translitLocale = liftIO $ do
    string' <- textToCString string
    maybeTranslitLocale <- case translitLocale of
        Nothing -> return nullPtr
        Just jTranslitLocale -> do
            jTranslitLocale' <- textToCString jTranslitLocale
            return jTranslitLocale'
    asciiAlternates <- allocMem :: IO (Ptr (Ptr CString))
    result <- g_str_tokenize_and_fold string' maybeTranslitLocale asciiAlternates
    checkUnexpectedReturnNULL "strTokenizeAndFold" result
    result' <- unpackZeroTerminatedUTF8CArray result
    mapZeroTerminatedCArray freeMem result
    freeMem result
    asciiAlternates' <- peek asciiAlternates
    asciiAlternates'' <- unpackZeroTerminatedUTF8CArray asciiAlternates'
    mapZeroTerminatedCArray freeMem asciiAlternates'
    freeMem asciiAlternates'
    freeMem string'
    freeMem maybeTranslitLocale
    freeMem asciiAlternates
    return (result', asciiAlternates'')


-- function g_str_to_ascii
-- Args : [Arg {argCName = "str", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a string, in UTF-8", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "from_locale", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the source locale, if known", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "g_str_to_ascii" g_str_to_ascii :: 
    CString ->                              -- str : TBasicType TUTF8
    CString ->                              -- from_locale : TBasicType TUTF8
    IO CString

{- |
Transliterate /@str@/ to plain ASCII.

For best results, /@str@/ should be in composed normalised form.

This function performs a reasonably good set of character
replacements.  The particular set of replacements that is done may
change by version or even by runtime environment.

If the source language of /@str@/ is known, it can used to improve the
accuracy of the translation by passing it as /@fromLocale@/.  It should
be a valid POSIX locale string (of the form
\"language[_territory][.codeset][/@modifier@/]\").

If /@fromLocale@/ is 'Nothing' then the current locale is used.

If you want to do translation for no specific locale, and you want it
to be done independently of the currently locale, specify \"C\" for
/@fromLocale@/.

@since 2.40
-}
strToAscii ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@str@/: a string, in UTF-8 -}
    -> Maybe (T.Text)
    {- ^ /@fromLocale@/: the source locale, if known -}
    -> m T.Text
    {- ^ __Returns:__ a string in plain ASCII -}
strToAscii str fromLocale = liftIO $ do
    str' <- textToCString str
    maybeFromLocale <- case fromLocale of
        Nothing -> return nullPtr
        Just jFromLocale -> do
            jFromLocale' <- textToCString jFromLocale
            return jFromLocale'
    result <- g_str_to_ascii str' maybeFromLocale
    checkUnexpectedReturnNULL "strToAscii" result
    result' <- cstringToText result
    freeMem result
    freeMem str'
    freeMem maybeFromLocale
    return result'


-- function g_str_match_string
-- Args : [Arg {argCName = "search_term", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the search term from the user", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "potential_hit", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the text that may be a hit", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "accept_alternates", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "%TRUE to accept ASCII alternates", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_str_match_string" g_str_match_string :: 
    CString ->                              -- search_term : TBasicType TUTF8
    CString ->                              -- potential_hit : TBasicType TUTF8
    CInt ->                                 -- accept_alternates : TBasicType TBoolean
    IO CInt

{- |
Checks if a search conducted for /@searchTerm@/ should match
/@potentialHit@/.

This function calls 'GI.GLib.Functions.strTokenizeAndFold' on both
/@searchTerm@/ and /@potentialHit@/.  ASCII alternates are never taken
for /@searchTerm@/ but will be taken for /@potentialHit@/ according to
the value of /@acceptAlternates@/.

A hit occurs when each folded token in /@searchTerm@/ is a prefix of a
folded token from /@potentialHit@/.

Depending on how you\'re performing the search, it will typically be
faster to call 'GI.GLib.Functions.strTokenizeAndFold' on each string in
your corpus and build an index on the returned folded tokens, then
call 'GI.GLib.Functions.strTokenizeAndFold' on the search term and
perform lookups into that index.

As some examples, searching for \"fred\" would match the potential hit
\"Smith, Fred\" and also \"Frédéric\".  Searching for \"Fréd\" would match
\"Frédéric\" but not \"Frederic\" (due to the one-directional nature of
accent matching).  Searching \"fo\" would match \"Foo\" and \"Bar Foo
Baz\", but not \"SFO\" (because no word as \"fo\" as a prefix).

@since 2.40
-}
strMatchString ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@searchTerm@/: the search term from the user -}
    -> T.Text
    {- ^ /@potentialHit@/: the text that may be a hit -}
    -> Bool
    {- ^ /@acceptAlternates@/: 'True' to accept ASCII alternates -}
    -> m Bool
    {- ^ __Returns:__ 'True' if /@potentialHit@/ is a hit -}
strMatchString searchTerm potentialHit acceptAlternates = liftIO $ do
    searchTerm' <- textToCString searchTerm
    potentialHit' <- textToCString potentialHit
    let acceptAlternates' = (fromIntegral . fromEnum) acceptAlternates
    result <- g_str_match_string searchTerm' potentialHit' acceptAlternates'
    let result' = (/= 0) result
    freeMem searchTerm'
    freeMem potentialHit'
    return result'


-- function g_str_is_ascii
-- Args : [Arg {argCName = "str", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_str_is_ascii" g_str_is_ascii :: 
    CString ->                              -- str : TBasicType TUTF8
    IO CInt

{- |
Determines if a string is pure ASCII. A string is pure ASCII if it
contains no bytes with the high bit set.

@since 2.40
-}
strIsAscii ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@str@/: a string -}
    -> m Bool
    {- ^ __Returns:__ 'True' if /@str@/ is ASCII -}
strIsAscii str = liftIO $ do
    str' <- textToCString str
    result <- g_str_is_ascii str'
    let result' = (/= 0) result
    freeMem str'
    return result'


-- function g_str_hash
-- Args : [Arg {argCName = "v", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a string key", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUInt)
-- throws : False
-- Skip return : False

foreign import ccall "g_str_hash" g_str_hash :: 
    Ptr () ->                               -- v : TBasicType TPtr
    IO Word32

{- |
Converts a string to a hash value.

This function implements the widely used \"djb\" hash apparently
posted by Daniel Bernstein to comp.lang.c some time ago.  The 32
bit unsigned hash value starts at 5381 and for each byte \'c\' in
the string, is updated: @hash = hash * 33 + c@. This function
uses the signed value of each byte.

It can be passed to @/g_hash_table_new()/@ as the /@hashFunc@/ parameter,
when using non-'Nothing' strings as keys in a 'GI.GLib.Structs.HashTable.HashTable'.

Note that this function may not be a perfect fit for all use cases.
For example, it produces some hash collisions with strings as short
as 2.
-}
strHash ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Ptr ()
    {- ^ /@v@/: a string key -}
    -> m Word32
    {- ^ __Returns:__ a hash value corresponding to the key -}
strHash v = liftIO $ do
    result <- g_str_hash v
    return result


-- function g_str_has_suffix
-- Args : [Arg {argCName = "str", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a nul-terminated string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "suffix", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the nul-terminated suffix to look for", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_str_has_suffix" g_str_has_suffix :: 
    CString ->                              -- str : TBasicType TUTF8
    CString ->                              -- suffix : TBasicType TUTF8
    IO CInt

{- |
Looks whether the string /@str@/ ends with /@suffix@/.

@since 2.2
-}
strHasSuffix ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@str@/: a nul-terminated string -}
    -> T.Text
    {- ^ /@suffix@/: the nul-terminated suffix to look for -}
    -> m Bool
    {- ^ __Returns:__ 'True' if /@str@/ end with /@suffix@/, 'False' otherwise. -}
strHasSuffix str suffix = liftIO $ do
    str' <- textToCString str
    suffix' <- textToCString suffix
    result <- g_str_has_suffix str' suffix'
    let result' = (/= 0) result
    freeMem str'
    freeMem suffix'
    return result'


-- function g_str_has_prefix
-- Args : [Arg {argCName = "str", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a nul-terminated string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "prefix", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the nul-terminated prefix to look for", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_str_has_prefix" g_str_has_prefix :: 
    CString ->                              -- str : TBasicType TUTF8
    CString ->                              -- prefix : TBasicType TUTF8
    IO CInt

{- |
Looks whether the string /@str@/ begins with /@prefix@/.

@since 2.2
-}
strHasPrefix ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@str@/: a nul-terminated string -}
    -> T.Text
    {- ^ /@prefix@/: the nul-terminated prefix to look for -}
    -> m Bool
    {- ^ __Returns:__ 'True' if /@str@/ begins with /@prefix@/, 'False' otherwise. -}
strHasPrefix str prefix = liftIO $ do
    str' <- textToCString str
    prefix' <- textToCString prefix
    result <- g_str_has_prefix str' prefix'
    let result' = (/= 0) result
    freeMem str'
    freeMem prefix'
    return result'


-- function g_str_equal
-- Args : [Arg {argCName = "v1", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a key", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "v2", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a key to compare with @v1", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_str_equal" g_str_equal :: 
    Ptr () ->                               -- v1 : TBasicType TPtr
    Ptr () ->                               -- v2 : TBasicType TPtr
    IO CInt

{- |
Compares two strings for byte-by-byte equality and returns 'True'
if they are equal. It can be passed to @/g_hash_table_new()/@ as the
/@keyEqualFunc@/ parameter, when using non-'Nothing' strings as keys in a
'GI.GLib.Structs.HashTable.HashTable'.

Note that this function is primarily meant as a hash table comparison
function. For a general-purpose, 'Nothing'-safe string comparison function,
see 'GI.GLib.Functions.strcmp0'.
-}
strEqual ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Ptr ()
    {- ^ /@v1@/: a key -}
    -> Ptr ()
    {- ^ /@v2@/: a key to compare with /@v1@/ -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the two keys match -}
strEqual v1 v2 = liftIO $ do
    result <- g_str_equal v1 v2
    let result' = (/= 0) result
    return result'


-- function g_stpcpy
-- Args : [Arg {argCName = "dest", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "destination buffer.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "src", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "source string.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "g_stpcpy" g_stpcpy :: 
    CString ->                              -- dest : TBasicType TUTF8
    CString ->                              -- src : TBasicType TUTF8
    IO CString

{- |
Copies a nul-terminated string into the dest buffer, include the
trailing nul, and return a pointer to the trailing nul byte.
This is useful for concatenating multiple strings together
without having to repeatedly scan for the end.
-}
stpcpy ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@dest@/: destination buffer. -}
    -> T.Text
    {- ^ /@src@/: source string. -}
    -> m T.Text
    {- ^ __Returns:__ a pointer to trailing nul byte. -}
stpcpy dest src = liftIO $ do
    dest' <- textToCString dest
    src' <- textToCString src
    result <- g_stpcpy dest' src'
    checkUnexpectedReturnNULL "stpcpy" result
    result' <- cstringToText result
    freeMem result
    freeMem dest'
    freeMem src'
    return result'


-- function g_spawn_sync
-- Args : [Arg {argCName = "working_directory", argType = TBasicType TFileName, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "child's current working 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 TUTF8), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "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 TUTF8), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "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 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 (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@/.

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 -}
    -> [T.Text]
    {- ^ /@argv@/: child\'s argument vector -}
    -> Maybe ([T.Text])
    {- ^ /@envp@/: child\'s environment, or 'Nothing' to inherit parent\'s -}
    -> [GLib.Flags.SpawnFlags]
    {- ^ /@flags@/: flags from 'GI.GLib.Flags.SpawnFlags' -}
    -> Maybe (GLib.Callbacks.SpawnChildSetupFunc)
    {- ^ /@childSetup@/: function to run in the child just before @/exec()/@ -}
    -> m ((ByteString, ByteString, Int32))
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
spawnSync workingDirectory argv envp flags childSetup = liftIO $ do
    maybeWorkingDirectory <- case workingDirectory of
        Nothing -> return nullPtr
        Just jWorkingDirectory -> do
            jWorkingDirectory' <- stringToCString jWorkingDirectory
            return jWorkingDirectory'
    argv' <- packZeroTerminatedUTF8CArray argv
    maybeEnvp <- case envp of
        Nothing -> return nullPtr
        Just jEnvp -> do
            jEnvp' <- packZeroTerminatedUTF8CArray jEnvp
            return jEnvp'
    let flags' = gflagsToWord flags
    ptrchildSetup <- callocMem :: IO (Ptr (FunPtr GLib.Callbacks.C_SpawnChildSetupFunc))
    maybeChildSetup <- case childSetup of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jChildSetup -> do
            jChildSetup' <- GLib.Callbacks.mk_SpawnChildSetupFunc (GLib.Callbacks.wrap_SpawnChildSetupFunc (Just ptrchildSetup) (GLib.Callbacks.drop_closures_SpawnChildSetupFunc jChildSetup))
            poke ptrchildSetup jChildSetup'
            return jChildSetup'
    standardOutput <- allocMem :: IO (Ptr (Ptr Word8))
    standardError <- allocMem :: IO (Ptr (Ptr Word8))
    exitStatus <- allocMem :: IO (Ptr Int32)
    let userData = nullPtr
    onException (do
        _ <- propagateGError $ g_spawn_sync maybeWorkingDirectory argv' maybeEnvp flags' maybeChildSetup userData standardOutput standardError exitStatus
        standardOutput' <- peek standardOutput
        standardOutput'' <- unpackZeroTerminatedByteString standardOutput'
        freeMem standardOutput'
        standardError' <- peek standardError
        standardError'' <- unpackZeroTerminatedByteString standardError'
        freeMem standardError'
        exitStatus' <- peek exitStatus
        freeMem maybeWorkingDirectory
        mapZeroTerminatedCArray freeMem argv'
        freeMem argv'
        mapZeroTerminatedCArray freeMem maybeEnvp
        freeMem maybeEnvp
        freeMem standardOutput
        freeMem standardError
        freeMem exitStatus
        return (standardOutput'', standardError'', exitStatus')
     ) (do
        freeMem maybeWorkingDirectory
        mapZeroTerminatedCArray freeMem argv'
        freeMem argv'
        mapZeroTerminatedCArray freeMem maybeEnvp
        freeMem maybeEnvp
        freeMem standardOutput
        freeMem standardError
        freeMem exitStatus
     )


-- function g_spawn_exit_error_quark
-- Args : []
-- Lengths : []
-- returnType : Just (TBasicType TUInt32)
-- throws : False
-- Skip return : False

foreign import ccall "g_spawn_exit_error_quark" g_spawn_exit_error_quark :: 
    IO Word32

{- |
/No description available in the introspection data./
-}
spawnExitErrorQuark ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m Word32
spawnExitErrorQuark  = liftIO $ do
    result <- g_spawn_exit_error_quark
    return result


-- function g_spawn_error_quark
-- Args : []
-- Lengths : []
-- returnType : Just (TBasicType TUInt32)
-- throws : False
-- Skip return : False

foreign import ccall "g_spawn_error_quark" g_spawn_error_quark :: 
    IO Word32

{- |
/No description available in the introspection data./
-}
spawnErrorQuark ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m Word32
spawnErrorQuark  = liftIO $ do
    result <- g_spawn_error_quark
    return result


-- function g_spawn_command_line_sync
-- Args : [Arg {argCName = "command_line", argType = TBasicType TUTF8, 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 TUTF8
    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) =>
    T.Text
    {- ^ /@commandLine@/: a command line -}
    -> m ((ByteString, ByteString, Int32))
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
spawnCommandLineSync commandLine = liftIO $ do
    commandLine' <- textToCString commandLine
    standardOutput <- allocMem :: IO (Ptr (Ptr Word8))
    standardError <- allocMem :: IO (Ptr (Ptr Word8))
    exitStatus <- allocMem :: IO (Ptr Int32)
    onException (do
        _ <- propagateGError $ g_spawn_command_line_sync commandLine' standardOutput standardError exitStatus
        standardOutput' <- peek standardOutput
        standardOutput'' <- unpackZeroTerminatedByteString standardOutput'
        freeMem standardOutput'
        standardError' <- peek standardError
        standardError'' <- unpackZeroTerminatedByteString standardError'
        freeMem standardError'
        exitStatus' <- peek exitStatus
        freeMem commandLine'
        freeMem standardOutput
        freeMem standardError
        freeMem exitStatus
        return (standardOutput'', standardError'', exitStatus')
     ) (do
        freeMem commandLine'
        freeMem standardOutput
        freeMem standardError
        freeMem exitStatus
     )


-- function g_spawn_command_line_async
-- Args : [Arg {argCName = "command_line", argType = TBasicType TUTF8, 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 TUTF8
    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) =>
    T.Text
    {- ^ /@commandLine@/: a command line -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
spawnCommandLineAsync commandLine = liftIO $ do
    commandLine' <- textToCString commandLine
    onException (do
        _ <- propagateGError $ g_spawn_command_line_async commandLine'
        freeMem commandLine'
        return ()
     ) (do
        freeMem commandLine'
     )


-- function g_spawn_close_pid
-- Args : [Arg {argCName = "pid", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The process reference to close", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_spawn_close_pid" g_spawn_close_pid :: 
    Int32 ->                                -- pid : TBasicType TInt
    IO ()

{- |
On some platforms, notably Windows, the @/GPid/@ type represents a resource
which must be closed to prevent resource leaking. 'GI.GLib.Functions.spawnClosePid'
is provided for this purpose. It should be used on all platforms, even
though it doesn\'t do anything under UNIX.
-}
spawnClosePid ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Int32
    {- ^ /@pid@/: The process reference to close -}
    -> m ()
spawnClosePid pid = liftIO $ do
    g_spawn_close_pid pid
    return ()


-- function g_spawn_check_exit_status
-- Args : [Arg {argCName = "exit_status", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "An exit code as returned from g_spawn_sync()", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "g_spawn_check_exit_status" g_spawn_check_exit_status :: 
    Int32 ->                                -- exit_status : TBasicType TInt
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Set /@error@/ if /@exitStatus@/ indicates the child exited abnormally
(e.g. with a nonzero exit code, or via a fatal signal).

The 'GI.GLib.Functions.spawnSync' and @/g_child_watch_add()/@ family of APIs return an
exit status for subprocesses encoded in a platform-specific way.
On Unix, this is guaranteed to be in the same format @/waitpid()/@ returns,
and on Windows it is guaranteed to be the result of @/GetExitCodeProcess()/@.

Prior to the introduction of this function in GLib 2.34, interpreting
/@exitStatus@/ required use of platform-specific APIs, which is problematic
for software using GLib as a cross-platform layer.

Additionally, many programs simply want to determine whether or not
the child exited successfully, and either propagate a 'GError' or
print a message to standard error. In that common case, this function
can be used. Note that the error message in /@error@/ will contain
human-readable information about the exit status.

The /@domain@/ and /@code@/ of /@error@/ have special semantics in the case
where the process has an \"exit code\", as opposed to being killed by
a signal. On Unix, this happens if @/WIFEXITED()/@ would be true of
/@exitStatus@/. On Windows, it is always the case.

The special semantics are that the actual exit code will be the
code set in /@error@/, and the domain will be @/G_SPAWN_EXIT_ERROR/@.
This allows you to differentiate between different exit codes.

If the process was terminated by some means other than an exit
status, the domain will be @/G_SPAWN_ERROR/@, and the code will be
'GI.GLib.Enums.SpawnErrorFailed'.

This function just offers convenience; you can of course also check
the available platform via a macro such as @/G_OS_UNIX/@, and use
@/WIFEXITED()/@ and @/WEXITSTATUS()/@ on /@exitStatus@/ directly. Do not attempt
to scan or parse the error message string; it may be translated and\/or
change in future versions of GLib.

@since 2.34
-}
spawnCheckExitStatus ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Int32
    {- ^ /@exitStatus@/: An exit code as returned from 'GI.GLib.Functions.spawnSync' -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
spawnCheckExitStatus exitStatus = liftIO $ do
    onException (do
        _ <- propagateGError $ g_spawn_check_exit_status exitStatus
        return ()
     ) (do
        return ()
     )


-- function g_spawn_async_with_pipes
-- Args : [Arg {argCName = "working_directory", argType = TBasicType TFileName, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "child's current working 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 = "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 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
    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 of 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 to
be notified about the death of the child process. 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()/@.

'GI.GLib.Flags.SpawnFlagsLeaveDescriptorsOpen' means that the parent\'s 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 NULL, 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'.

If you are writing a GTK+ application, and the program you
are spawning is a graphical application, too, then you may
want to use @/gdk_spawn_on_screen_with_pipes()/@ instead to ensure that
the spawned program opens its windows on the right screen.
-}
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 -}
    -> [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()/@ -}
    -> m ((Int32, Int32, Int32, Int32))
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
spawnAsyncWithPipes workingDirectory argv envp flags childSetup = liftIO $ do
    maybeWorkingDirectory <- case workingDirectory of
        Nothing -> return nullPtr
        Just jWorkingDirectory -> do
            jWorkingDirectory' <- stringToCString jWorkingDirectory
            return jWorkingDirectory'
    argv' <- packZeroTerminatedUTF8CArray argv
    maybeEnvp <- case envp of
        Nothing -> return nullPtr
        Just jEnvp -> do
            jEnvp' <- packZeroTerminatedUTF8CArray jEnvp
            return jEnvp'
    let flags' = gflagsToWord flags
    ptrchildSetup <- callocMem :: IO (Ptr (FunPtr GLib.Callbacks.C_SpawnChildSetupFunc))
    maybeChildSetup <- case childSetup of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jChildSetup -> do
            jChildSetup' <- GLib.Callbacks.mk_SpawnChildSetupFunc (GLib.Callbacks.wrap_SpawnChildSetupFunc (Just ptrchildSetup) (GLib.Callbacks.drop_closures_SpawnChildSetupFunc jChildSetup))
            poke ptrchildSetup jChildSetup'
            return jChildSetup'
    childPid <- allocMem :: IO (Ptr Int32)
    standardInput <- allocMem :: IO (Ptr Int32)
    standardOutput <- allocMem :: IO (Ptr Int32)
    standardError <- allocMem :: IO (Ptr Int32)
    let userData = nullPtr
    onException (do
        _ <- propagateGError $ g_spawn_async_with_pipes maybeWorkingDirectory argv' maybeEnvp flags' maybeChildSetup userData childPid standardInput standardOutput standardError
        childPid' <- peek childPid
        standardInput' <- peek standardInput
        standardOutput' <- peek standardOutput
        standardError' <- peek standardError
        freeMem maybeWorkingDirectory
        mapZeroTerminatedCArray freeMem argv'
        freeMem argv'
        mapZeroTerminatedCArray freeMem maybeEnvp
        freeMem maybeEnvp
        freeMem childPid
        freeMem standardInput
        freeMem standardOutput
        freeMem standardError
        return (childPid', standardInput', standardOutput', standardError')
     ) (do
        freeMem maybeWorkingDirectory
        mapZeroTerminatedCArray freeMem argv'
        freeMem argv'
        mapZeroTerminatedCArray freeMem maybeEnvp
        freeMem maybeEnvp
        freeMem childPid
        freeMem standardInput
        freeMem standardOutput
        freeMem standardError
     )


-- function g_spawn_async
-- 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", 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", 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", 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 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
    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 you may want to
use @/gdk_spawn_on_screen()/@ instead to ensure that the spawned program
opens its windows on the right screen.

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 -}
    -> [T.Text]
    {- ^ /@argv@/: child\'s argument vector -}
    -> Maybe ([T.Text])
    {- ^ /@envp@/: child\'s environment, or 'Nothing' to inherit parent\'s -}
    -> [GLib.Flags.SpawnFlags]
    {- ^ /@flags@/: flags from 'GI.GLib.Flags.SpawnFlags' -}
    -> Maybe (GLib.Callbacks.SpawnChildSetupFunc)
    {- ^ /@childSetup@/: function to run in the child just before @/exec()/@ -}
    -> m (Int32)
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
spawnAsync workingDirectory argv envp flags childSetup = liftIO $ do
    maybeWorkingDirectory <- case workingDirectory of
        Nothing -> return nullPtr
        Just jWorkingDirectory -> do
            jWorkingDirectory' <- stringToCString jWorkingDirectory
            return jWorkingDirectory'
    argv' <- packZeroTerminatedUTF8CArray argv
    maybeEnvp <- case envp of
        Nothing -> return nullPtr
        Just jEnvp -> do
            jEnvp' <- packZeroTerminatedUTF8CArray jEnvp
            return jEnvp'
    let flags' = gflagsToWord flags
    ptrchildSetup <- callocMem :: IO (Ptr (FunPtr GLib.Callbacks.C_SpawnChildSetupFunc))
    maybeChildSetup <- case childSetup of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jChildSetup -> do
            jChildSetup' <- GLib.Callbacks.mk_SpawnChildSetupFunc (GLib.Callbacks.wrap_SpawnChildSetupFunc (Just ptrchildSetup) (GLib.Callbacks.drop_closures_SpawnChildSetupFunc jChildSetup))
            poke ptrchildSetup jChildSetup'
            return jChildSetup'
    childPid <- allocMem :: IO (Ptr Int32)
    let userData = nullPtr
    onException (do
        _ <- propagateGError $ g_spawn_async maybeWorkingDirectory argv' maybeEnvp flags' maybeChildSetup userData childPid
        childPid' <- peek childPid
        freeMem maybeWorkingDirectory
        mapZeroTerminatedCArray freeMem argv'
        freeMem argv'
        mapZeroTerminatedCArray freeMem maybeEnvp
        freeMem maybeEnvp
        freeMem childPid
        return childPid'
     ) (do
        freeMem maybeWorkingDirectory
        mapZeroTerminatedCArray freeMem argv'
        freeMem argv'
        mapZeroTerminatedCArray freeMem maybeEnvp
        freeMem maybeEnvp
        freeMem childPid
     )


-- function g_spaced_primes_closest
-- Args : [Arg {argCName = "num", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #guint", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUInt)
-- throws : False
-- Skip return : False

foreign import ccall "g_spaced_primes_closest" g_spaced_primes_closest :: 
    Word32 ->                               -- num : TBasicType TUInt
    IO Word32

{- |
Gets the smallest prime number from a built-in array of primes which
is larger than /@num@/. This is used within GLib to calculate the optimum
size of a 'GI.GLib.Structs.HashTable.HashTable'.

The built-in array of primes ranges from 11 to 13845163 such that
each prime is approximately 1.5-2 times the previous prime.
-}
spacedPrimesClosest ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Word32
    {- ^ /@num@/: a @/guint/@ -}
    -> m Word32
    {- ^ __Returns:__ the smallest prime number from a built-in array of primes
    which is larger than /@num@/ -}
spacedPrimesClosest num = liftIO $ do
    result <- g_spaced_primes_closest num
    return result


-- function g_slice_set_config
-- Args : [Arg {argCName = "ckey", argType = TInterface (Name {namespace = "GLib", name = "SliceConfig"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "value", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_slice_set_config" g_slice_set_config :: 
    CUInt ->                                -- ckey : TInterface (Name {namespace = "GLib", name = "SliceConfig"})
    Int64 ->                                -- value : TBasicType TInt64
    IO ()

{- |
/No description available in the introspection data./
-}
sliceSetConfig ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    GLib.Enums.SliceConfig
    -> Int64
    -> m ()
sliceSetConfig ckey value = liftIO $ do
    let ckey' = (fromIntegral . fromEnum) ckey
    g_slice_set_config ckey' value
    return ()


-- function g_slice_get_config_state
-- Args : [Arg {argCName = "ckey", argType = TInterface (Name {namespace = "GLib", name = "SliceConfig"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "address", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "n_values", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TInt64)
-- throws : False
-- Skip return : False

foreign import ccall "g_slice_get_config_state" g_slice_get_config_state :: 
    CUInt ->                                -- ckey : TInterface (Name {namespace = "GLib", name = "SliceConfig"})
    Int64 ->                                -- address : TBasicType TInt64
    Word32 ->                               -- n_values : TBasicType TUInt
    IO Int64

{- |
/No description available in the introspection data./
-}
sliceGetConfigState ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    GLib.Enums.SliceConfig
    -> Int64
    -> Word32
    -> m Int64
sliceGetConfigState ckey address nValues = liftIO $ do
    let ckey' = (fromIntegral . fromEnum) ckey
    result <- g_slice_get_config_state ckey' address nValues
    return result


-- function g_slice_get_config
-- Args : [Arg {argCName = "ckey", argType = TInterface (Name {namespace = "GLib", name = "SliceConfig"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TInt64)
-- throws : False
-- Skip return : False

foreign import ccall "g_slice_get_config" g_slice_get_config :: 
    CUInt ->                                -- ckey : TInterface (Name {namespace = "GLib", name = "SliceConfig"})
    IO Int64

{- |
/No description available in the introspection data./
-}
sliceGetConfig ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    GLib.Enums.SliceConfig
    -> m Int64
sliceGetConfig ckey = liftIO $ do
    let ckey' = (fromIntegral . fromEnum) ckey
    result <- g_slice_get_config ckey'
    return result


-- function g_slice_free_chain_with_offset
-- Args : [Arg {argCName = "block_size", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the size of the blocks", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "mem_chain", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a pointer to the first block of the chain", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "next_offset", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the offset of the @next field in the blocks", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_slice_free_chain_with_offset" g_slice_free_chain_with_offset :: 
    Word64 ->                               -- block_size : TBasicType TUInt64
    Ptr () ->                               -- mem_chain : TBasicType TPtr
    Word64 ->                               -- next_offset : TBasicType TUInt64
    IO ()

{- |
Frees a linked list of memory blocks of structure type /@type@/.

The memory blocks must be equal-sized, allocated via
'GI.GLib.Functions.sliceAlloc' or 'GI.GLib.Functions.sliceAlloc0' and linked together by a
/@next@/ pointer (similar to 'GI.GLib.Structs.SList.SList'). The offset of the /@next@/
field in each block is passed as third argument.
Note that the exact release behaviour can be changed with the
[@G_DEBUG=gc-friendly@][G_DEBUG] environment variable, also see
[@G_SLICE@][G_SLICE] for related debugging options.

If /@memChain@/ is 'Nothing', this function does nothing.

@since 2.10
-}
sliceFreeChainWithOffset ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Word64
    {- ^ /@blockSize@/: the size of the blocks -}
    -> Ptr ()
    {- ^ /@memChain@/: a pointer to the first block of the chain -}
    -> Word64
    {- ^ /@nextOffset@/: the offset of the /@next@/ field in the blocks -}
    -> m ()
sliceFreeChainWithOffset blockSize memChain nextOffset = liftIO $ do
    g_slice_free_chain_with_offset blockSize memChain nextOffset
    return ()


-- function g_slice_free1
-- Args : [Arg {argCName = "block_size", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the size of the block", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "mem_block", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a pointer to the block to free", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_slice_free1" g_slice_free1 :: 
    Word64 ->                               -- block_size : TBasicType TUInt64
    Ptr () ->                               -- mem_block : TBasicType TPtr
    IO ()

{- |
Frees a block of memory.

The memory must have been allocated via 'GI.GLib.Functions.sliceAlloc' or
'GI.GLib.Functions.sliceAlloc0' and the /@blockSize@/ has to match the size
specified upon allocation. Note that the exact release behaviour
can be changed with the [@G_DEBUG=gc-friendly@][G_DEBUG] environment
variable, also see [@G_SLICE@][G_SLICE] for related debugging options.

If /@memBlock@/ is 'Nothing', this function does nothing.

@since 2.10
-}
sliceFree1 ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Word64
    {- ^ /@blockSize@/: the size of the block -}
    -> Ptr ()
    {- ^ /@memBlock@/: a pointer to the block to free -}
    -> m ()
sliceFree1 blockSize memBlock = liftIO $ do
    g_slice_free1 blockSize memBlock
    return ()


-- function g_slice_copy
-- Args : [Arg {argCName = "block_size", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the number of bytes to allocate", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "mem_block", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the memory to copy", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TPtr)
-- throws : False
-- Skip return : False

foreign import ccall "g_slice_copy" g_slice_copy :: 
    Word64 ->                               -- block_size : TBasicType TUInt64
    Ptr () ->                               -- mem_block : TBasicType TPtr
    IO (Ptr ())

{- |
Allocates a block of memory from the slice allocator
and copies /@blockSize@/ bytes into it from /@memBlock@/.

/@memBlock@/ must be non-'Nothing' if /@blockSize@/ is non-zero.

@since 2.14
-}
sliceCopy ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Word64
    {- ^ /@blockSize@/: the number of bytes to allocate -}
    -> Ptr ()
    {- ^ /@memBlock@/: the memory to copy -}
    -> m (Ptr ())
    {- ^ __Returns:__ a pointer to the allocated memory block, which will be 'Nothing' if and
   only if /@memSize@/ is 0 -}
sliceCopy blockSize memBlock = liftIO $ do
    result <- g_slice_copy blockSize memBlock
    return result


-- function g_slice_alloc0
-- Args : [Arg {argCName = "block_size", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the number of bytes to allocate", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TPtr)
-- throws : False
-- Skip return : False

foreign import ccall "g_slice_alloc0" g_slice_alloc0 :: 
    Word64 ->                               -- block_size : TBasicType TUInt64
    IO (Ptr ())

{- |
Allocates a block of memory via 'GI.GLib.Functions.sliceAlloc' and initializes
the returned memory to 0. Note that the underlying slice allocation
mechanism can be changed with the [@G_SLICE=always-malloc@][G_SLICE]
environment variable.

@since 2.10
-}
sliceAlloc0 ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Word64
    {- ^ /@blockSize@/: the number of bytes to allocate -}
    -> m (Ptr ())
    {- ^ __Returns:__ a pointer to the allocated block, which will be 'Nothing' if and only
   if /@memSize@/ is 0 -}
sliceAlloc0 blockSize = liftIO $ do
    result <- g_slice_alloc0 blockSize
    return result


-- function g_slice_alloc
-- Args : [Arg {argCName = "block_size", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the number of bytes to allocate", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TPtr)
-- throws : False
-- Skip return : False

foreign import ccall "g_slice_alloc" g_slice_alloc :: 
    Word64 ->                               -- block_size : TBasicType TUInt64
    IO (Ptr ())

{- |
Allocates a block of memory from the slice allocator.
The block adress handed out can be expected to be aligned
to at least 1 * sizeof (void*),
though in general slices are 2 * sizeof (void*) bytes aligned,
if a @/malloc()/@ fallback implementation is used instead,
the alignment may be reduced in a libc dependent fashion.
Note that the underlying slice allocation mechanism can
be changed with the [@G_SLICE=always-malloc@][G_SLICE]
environment variable.

@since 2.10
-}
sliceAlloc ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Word64
    {- ^ /@blockSize@/: the number of bytes to allocate -}
    -> m (Ptr ())
    {- ^ __Returns:__ a pointer to the allocated memory block, which will be 'Nothing' if and
   only if /@memSize@/ is 0 -}
sliceAlloc blockSize = liftIO $ do
    result <- g_slice_alloc blockSize
    return result


-- function g_shell_unquote
-- Args : [Arg {argCName = "quoted_string", argType = TBasicType TUTF8, 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 TUTF8)
-- throws : True
-- Skip return : False

foreign import ccall "g_shell_unquote" g_shell_unquote :: 
    CString ->                              -- quoted_string : TBasicType TUTF8
    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) =>
    T.Text
    {- ^ /@quotedString@/: shell-quoted string -}
    -> m T.Text
    {- ^ __Returns:__ an unquoted string /(Can throw 'Data.GI.Base.GError.GError')/ -}
shellUnquote quotedString = liftIO $ do
    quotedString' <- textToCString quotedString
    onException (do
        result <- propagateGError $ g_shell_unquote quotedString'
        checkUnexpectedReturnNULL "shellUnquote" result
        result' <- cstringToText result
        freeMem result
        freeMem quotedString'
        return result'
     ) (do
        freeMem quotedString'
     )


-- function g_shell_quote
-- Args : [Arg {argCName = "unquoted_string", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a literal string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []