However, API in C using Winsock that I have posted long time ago is still on the wiki. But without original sources (that was posted on the "API in C" page) it is useless.
I'm posting an updated working (used in production for years) API in C (winsock version) sources updated for a new authentication (post-6.43). The version on the wiki is only working with legacy authentication.
Remember, that if your compiler does not support "#pragma comment", add ws2_32.lib to your linker manually.
Code: Select all
/********************************************************************
* Some definitions
* Word = piece of API code
* Sentence = multiple words
* Block = multiple sentences (usually in response to a sentence request)
*
int fdSock;
int iLoginResult;
struct Sentence stSentence;
struct Block stBlock;
fdSock = apiConnect("10.0.0.1", 8728);
// attempt login
iLoginResult = login(fdSock, "admin", "adminPassword");
if (!iLoginResult)
{
apiDisconnect(fdSock);
printf("Invalid username or password.\n");
exit(1);
}
// initialize, fill and send sentence to the API
initializeSentence(&stSentence);
addWordToSentence(&stSentence, "/interface/getall");
writeSentence(fdSock, &stSentence);
// receive and print block from the API
stBlock = readBlock(fdSock);
printBlock(&stBlock);
apiDisconnect(fdSock);
********************************************************************/