Created
June 29, 2017 15:44
-
-
Save Varriount/67c23e839851474daa6ad28f8fa4fd10 to your computer and use it in GitHub Desktop.
libtorrent.nim
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const libtorrentDllName = "libtorrent-rasterbar.9.dylib" | |
type | |
Tags* {.size: sizeof(cint).} = enum | |
TAG_END = 0, | |
SES_FINGERPRINT, | |
SES_LISTENPORT, | |
SES_LISTENPORT_END, | |
SES_VERSION_MAJOR, | |
SES_VERSION_MINOR, | |
SES_VERSION_TINY, | |
SES_VERSION_TAG, | |
SES_FLAGS, | |
SES_ALERT_MASK, | |
SES_LISTEN_INTERFACE, | |
TOR_FILENAME = 0x00000100, | |
TOR_TORRENT, | |
TOR_TORRENT_SIZE, | |
TOR_INFOHASH, | |
TOR_INFOHASH_HEX, | |
TOR_MAGNETLINK, | |
TOR_TRACKER_URL, | |
TOR_RESUME_DATA, | |
TOR_RESUME_DATA_SIZE, | |
TOR_SAVE_PATH, TOR_NAME, | |
TOR_PAUSED, | |
TOR_AUTO_MANAGED, | |
TOR_DUPLICATE_IS_ERROR, | |
TOR_USER_DATA, | |
TOR_SEED_MODE, | |
TOR_OVERRIDE_RESUME_DATA, | |
TOR_STORAGE_MODE, | |
SET_UPLOAD_RATE_LIMIT = 0x00000200, | |
SET_DOWNLOAD_RATE_LIMIT, | |
SET_LOCAL_UPLOAD_RATE_LIMIT, | |
SET_LOCAL_DOWNLOAD_RATE_LIMIT, | |
SET_MAX_UPLOAD_SLOTS, | |
SET_MAX_CONNECTIONS, | |
SET_SEQUENTIAL_DOWNLOAD, | |
SET_SUPER_SEEDING, | |
SET_HALF_OPEN_LIMIT, | |
SET_PEER_PROXY, SET_WEB_SEED_PROXY, | |
SET_TRACKER_PROXY, | |
SET_DHT_PROXY, | |
SET_PROXY, | |
SET_ALERT_MASK | |
type | |
ProxySetting* = object | |
hostname*: array[256, char] | |
port*: cint | |
username*: array[256, char] | |
password*: array[256, char] | |
`type`*: cint | |
CategoryT* {.size: sizeof(cint).} = enum | |
catError = 0x00000001, | |
catPeer = 0x00000002, | |
catPortMapping = 0x00000004, | |
catStorage = 0x00000008, | |
catTracker = 0x00000010, | |
catDebug = 0x00000020, | |
catStatus = 0x00000040, | |
catProgress = 0x00000080, | |
catIpBlock = 0x00000100, | |
catPerformanceWarning = 0x00000200, | |
catDht = 0x00000400, | |
catAllCategories = 0xFFFFFFFF | |
type | |
ProxyTypeT* {.size: sizeof(cint).} = enum | |
proxyNone, | |
proxySocks4, | |
proxySocks5, | |
proxySocks5Pw, | |
proxyHttp, | |
proxyHttpPw | |
type | |
StorageModeT* {.size: sizeof(cint).} = enum | |
storageModeAllocate = 0, | |
storageModeSparse | |
type | |
StateT* {.size: sizeof(cint).} = enum | |
queuedForChecking, | |
checkingFiles, | |
downloadingMetadata, | |
downloading, | |
finished, | |
seeding, | |
allocating, | |
checkingResumeData | |
type | |
TorrentStatus* = object | |
state*: StateT | |
paused*: cint | |
progress*: cfloat | |
error*: array[1024, char] | |
nextAnnounce*: cint | |
announceInterval*: cint | |
currentTracker*: array[512, char] | |
totalDownload*: clonglong | |
totalUpload*: clonglong | |
totalPayloadDownload*: clonglong | |
totalPayloadUpload*: clonglong | |
totalFailedBytes*: clonglong | |
totalRedundantBytes*: clonglong | |
downloadRate*: cfloat | |
uploadRate*: cfloat | |
downloadPayloadRate*: cfloat | |
uploadPayloadRate*: cfloat | |
numSeeds*: cint | |
numPeers*: cint | |
numComplete*: cint | |
numIncomplete*: cint | |
listSeeds*: cint | |
listPeers*: cint | |
connectCandidates*: cint | |
numPieces*: cint | |
totalDone*: clonglong | |
totalWantedDone*: clonglong | |
totalWanted*: clonglong | |
distributedCopies*: cfloat | |
blockSize*: cint | |
numUploads*: cint | |
numConnections*: cint | |
uploadsLimit*: cint | |
connectionsLimit*: cint | |
upBandwidthQueue*: cint | |
downBandwidthQueue*: cint | |
allTimeUpload*: clonglong | |
allTimeDownload*: clonglong | |
activeTime*: cint | |
seedingTime*: cint | |
seedRank*: cint | |
lastScrape*: cint | |
hasIncoming*: cint | |
seedMode*: cint | |
SessionStatus* = object | |
hasIncomingConnections*: cint | |
uploadRate*: cfloat | |
downloadRate*: cfloat | |
totalDownload*: clonglong | |
totalUpload*: clonglong | |
payloadUploadRate*: cfloat | |
payloadDownloadRate*: cfloat | |
totalPayloadDownload*: clonglong | |
totalPayloadUpload*: clonglong | |
ipOverheadUploadRate*: cfloat | |
ipOverheadDownloadRate*: cfloat | |
totalIpOverheadDownload*: clonglong | |
totalIpOverheadUpload*: clonglong | |
dhtUploadRate*: cfloat | |
dhtDownloadRate*: cfloat | |
totalDhtDownload*: clonglong | |
totalDhtUpload*: clonglong | |
trackerUploadRate*: cfloat | |
trackerDownloadRate*: cfloat | |
totalTrackerDownload*: clonglong | |
totalTrackerUpload*: clonglong | |
totalRedundantBytes*: clonglong | |
totalFailedBytes*: clonglong | |
numPeers*: cint | |
numUnchoked*: cint | |
allowedUploadSlots*: cint | |
upBandwidthQueue*: cint | |
downBandwidthQueue*: cint | |
upBandwidthBytesQueue*: cint | |
downBandwidthBytesQueue*: cint | |
optimisticUnchokeCounter*: cint | |
unchokeCounter*: cint | |
dhtNodes*: cint | |
dhtNodeCache*: cint | |
dhtTorrents*: cint | |
dhtGlobalNodes*: clonglong | |
proc sessionCreate*(firstTag: cint): pointer {. | |
varargs, stdcall, importc: "session_create", | |
dynlib: libtorrentDllName | |
.} | |
proc sessionClose*(ses: pointer) {. | |
stdcall, importc: "session_close", dynlib: libtorrentDllName | |
.} | |
proc sessionAddTorrent*(ses: pointer; firstTag: cint): cint {. | |
varargs, stdcall, importc: "session_add_torrent", dynlib: libtorrentDllName | |
.} | |
proc sessionRemoveTorrent*(ses: pointer; tor: cint; flags: cint) {. | |
stdcall, importc: "session_remove_torrent", dynlib: libtorrentDllName | |
.} | |
proc sessionPopAlert*(ses: pointer; dest: cstring; len: cint; category: ptr cint): cint {. | |
stdcall, importc: "session_pop_alert", dynlib: libtorrentDllName | |
.} | |
proc sessionGetStatus*(ses: pointer; s: ptr SessionStatus; structSize: cint): cint {. | |
stdcall, importc: "session_get_status", dynlib: libtorrentDllName | |
.} | |
proc sessionSetSettings*(ses: pointer; firstTag: cint): cint {. | |
varargs, stdcall, importc: "session_set_settings", dynlib: libtorrentDllName | |
.} | |
proc sessionGetSetting*(ses: pointer; tag: cint; value: pointer; valueSize: ptr cint): cint {. | |
stdcall, importc: "session_get_setting", dynlib: libtorrentDllName | |
.} | |
proc torrentGetStatus*(tor: cint; s: ptr TorrentStatus; structSize: cint): cint {. | |
stdcall, importc: "torrent_get_status", dynlib: libtorrentDllName | |
.} | |
proc torrentSetSettings*(tor: cint; firstTag: cint): cint {. | |
varargs, stdcall, importc: "torrent_set_settings", dynlib: libtorrentDllName | |
.} | |
proc torrentGetSetting*(tor: cint; tag: cint; value: pointer; valueSize: ptr cint): cint {. | |
stdcall, importc: "torrent_get_setting", dynlib: libtorrentDllName | |
.} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment