Community discussions

MikroTik App
 
User avatar
horhay
newbie
Topic Author
Posts: 29
Joined: Sat Jun 20, 2015 7:19 pm
Location: Ontario, Canada
Contact:

API written in C

Sun Jan 28, 2018 7:21 pm

I'm continuing to develop an API written in C and wish to share it here.

The API has now been broken out into separate files that can be included thus keeping your main project files small.

Hope someone finds it interesting.

h0rhay.
You do not have the required permissions to view the files attached to this post.
Last edited by horhay on Mon Jan 29, 2018 6:15 am, edited 1 time in total.
 
User avatar
boen_robot
Forum Guru
Forum Guru
Posts: 2400
Joined: Thu Aug 31, 2006 4:43 pm
Location: europe://Bulgaria/Plovdiv

Re: API written in C

Mon Jan 29, 2018 12:55 am

Post it to GitHub maybe?

Also, one note based on a skim of the source:
// ********************************************************************
// readBlock
// ********************************************************************
// READ A BLOCK FROM THE SOCKET.
//
// Read a block of sentences from the socket.  Keep reading sentences
// until we encounter !done, !trap or !fatal from the socket.
// If we encounter !trap or !fatal read one additional sentence
// which contains details of the error.  In this case it will print
// the block to stdout so you can work on the errors in your code.
A block of sentences can (and sometimes does) contain multiple !trap replies, sometimes one after another. Information about the individual error is not in the next sentence, it's within the same sentence. The only sentences that are meant to be the last sentence per command are !done and !fatal, with !done keeping the connection opened, and !fatal terminating it. In other words, a command that causes an error with produce at least a !trap and a !done sentence, maybe a !trap, another !trap and then a !done sentence.
 
User avatar
horhay
newbie
Topic Author
Posts: 29
Joined: Sat Jun 20, 2015 7:19 pm
Location: Ontario, Canada
Contact:

Re: API written in C

Mon Jan 29, 2018 5:03 am

Post it to GitHub maybe?

Also, one note based on a skim of the source:
// ********************************************************************
// readBlock
// ********************************************************************
// READ A BLOCK FROM THE SOCKET.
//
// Read a block of sentences from the socket.  Keep reading sentences
// until we encounter !done, !trap or !fatal from the socket.
// If we encounter !trap or !fatal read one additional sentence
// which contains details of the error.  In this case it will print
// the block to stdout so you can work on the errors in your code.
A block of sentences can (and sometimes does) contain multiple !trap replies, sometimes one after another. Information about the individual error is not in the next sentence, it's within the same sentence. The only sentences that are meant to be the last sentence per command are !done and !fatal, with !done keeping the connection opened, and !fatal terminating it. In other words, a command that causes an error with produce at least a !trap and a !done sentence, maybe a !trap, another !trap and then a !done sentence.
Thanks for the info. I'll update the code accordingly. Cheers!

Who is online

Users browsing this forum: No registered users and 28 guests