anchor.diff:  // *  returns -1 on failure.
   // */
   //int tox_set_statusmessage(Tox *tox, uint8_t *status, uint16_t length);
  -function tox_set_statusmessage(tox: TTox; status: PByte; length: Word): Integer;
  -
   //int tox_set_userstatus(Tox *tox, TOX_USERSTATUS status);
  -function tox_set_userstatus(tox: TTox; status: TToxUserStatus): Integer;
  +function tox_set_statusmessage(tox: TTox; status: PByte; length: Word): Integer; cdecl; external TOX_LIBRARY;
  +function tox_set_userstatus(tox: TTox; status: TToxUserStatus): Integer; cdecl; external TOX_LIBRARY;
   
   ///*  return the length of friendnumber's status message, including null.
   // *  Pass it into malloc
   // */
   //int tox_get_statusmessage_size(Tox *tox, int friendnumber);
  -function tox_get_statusmessage_size(tox: TTox; friendnumber: Integer): Integer;
  +function tox_get_statusmessage_size(tox: TTox; friendnumber: Integer): Integer; cdecl; external TOX_LIBRARY;
   
   ///* Copy friendnumber's status message into buf, truncating if size is over maxlen.
   // * Get the size you need to allocate from m_get_statusmessage_size.
   // * The self variant will copy our own status message.
  +// *
  +// * returns the length of the copied data on success
  +// * retruns -1 on failure.
   // */
   //int tox_copy_statusmessage(Tox *tox, int friendnumber, uint8_t *buf, uint32_t maxlen);
  -function tox_copy_statusmessage(tox: TTox; friendnumber: Integer; buf: PByte; maxlen: Integer): Integer;
  -
   //int tox_copy_self_statusmessage(Tox *tox, uint8_t *buf, uint32_t maxlen);
  -function tox_copy_self_statusmessage(tox: TTox; buf: PByte; maxlen: Integer): Integer;
  +function tox_copy_statusmessage(tox: TTox; friendnumber: Integer; buf: PByte; maxlen: Integer): Integer; cdecl; external TOX_LIBRARY;
  +function tox_copy_self_statusmessage(tox: TTox; buf: PByte; maxlen: Integer): Integer; cdecl; external TOX_LIBRARY;
   
   ///*  return one of USERSTATUS values.
   // *  Values unknown to your application should be represented as USERSTATUS_NONE.
  
positive.code: //
  //  Copyright (c) 2013 Dmitry
  //
  unit libtox;
  
  interface
  
negative.code: // *  their connection status is offline.
  // */
  //void tox_callback_connectionstatus(Tox *tox, void (*function)(Tox *tox, int, uint8_t, void *), void *userdata);
  procedure tox_callback_connectionstatus(tox: TTox; CallBack: TProcConnectionStatus; UserData: Pointer); cdecl; external TOX_LIBRARY;
  
  ///**********GROUP CHAT FUNCTIONS: WARNING WILL BREAK A LOT************/
  //
  ///* Set the callback for group invites.
  // *
  // *  Function(Tox *tox, int friendnumber, uint8_t *group_public_key, void *userdata)
  // */
  //void tox_callback_group_invite(Tox *tox, void (*function)(Tox *tox, int, uint8_t *, void *), void *userdata);
  procedure tox_callback_group_invite(tox: TTox; CallBack: TProcGroupInvite;
    userdata: Pointer); cdecl; external TOX_LIBRARY;
  
  ///* Set the callback for group messages.
  // *
  // *  tox_callback_group_messageFunction(Tox *tox, int groupnumber, int friendgroupnumber, uint8_t * message, uint16_t length, void *userdata)
  // */
  //void tox_callback_group_message(Tox *tox, void (*function)(Tox *tox, int, int, uint8_t *, uint16_t, void *),
  //                                void *userdata);
  procedure tox_callback_group_message(Tox: TTox; CallBack: TProcGroupMessage;
    userdata: Pointer); cdecl; external TOX_LIBRARY;
  
  ///* Creates a new groupchat and puts it in the chats array.
  // *
  // * return group number on success.
  // * return -1 on failure.
  // */
  //int tox_add_groupchat(Tox *tox);
  function tox_add_groupchat(Tox: TTox): Integer; cdecl; external TOX_LIBRARY;
  
  ///* Delete a groupchat from the chats array.
  // *
  // * return 0 on success.
  // * return -1 if failure.
  // */
  //int tox_del_groupchat(Tox *tox, int groupnumber);
  function tox_del_groupchat(Tox: TTox; groupnumber: Integer): Integer; cdecl; external TOX_LIBRARY;
  
  ///* Copy the name of peernumber who is in groupnumber to name.
  // * name must be at least TOX_MAX_NAME_LENGTH long.
  // *
  // * return length of name if success
  // * return -1 if failure
  // */
  //int tox_group_peername(Tox *tox, int groupnumber, int peernumber, uint8_t *name);
  function tox_group_peername(Tox: TTox; groupnumber: Integer;
    peernumber: Integer; name: PByte): Integer; cdecl; external TOX_LIBRARY;
  
  ///* invite friendnumber to groupnumber
  // * return 0 on success
  // * return -1 on failure
  // */
  //int tox_invite_friend(Tox *tox, int friendnumber, int groupnumber);
  function tox_invite_friend(Tox: TTox; friendnumber: Integer;
    groupnumber: Integer): Integer; cdecl; external TOX_LIBRARY;
  
  ///* Join a group (you need to have been invited first.)
  // *
  // * returns group number on success
  // * returns -1 on failure.
  // */
  //int tox_join_groupchat(Tox *tox, int friendnumber, uint8_t *friend_group_public_key);
  function tox_join_groupchat(Tox: TTox; friendnumber: Integer;
    friend_group_public_key: PByte): Integer; cdecl; external TOX_LIBRARY;
  
  ///* send a group message
  // * return 0 on success
  // * return -1 on failure
  // */
  //int tox_group_message_send(Tox *tox, int groupnumber, uint8_t *message, uint32_t length);
  function tox_group_message_send(Tox: TTox; groupnumber: Integer; message: PByte;
    length: Integer): Integer; cdecl; external TOX_LIBRARY;
  
  ///****************FILE SENDING FUNCTIONS*****************/
  ///* NOTE: This how to will be updated.
  // *
  // * HOW TO SEND FILES CORRECTLY:
  // * 1. Use tox_new_filesender(...) to create a new file sender.
  // * 2. Wait for the callback set with tox_callback_file_control(...) to be called with receive_send == 1 and control_type == TOX_FILECONTROL_ACCEPT
  // * 3. Send the data with tox_file_senddata(...) with chunk size tox_filedata_size(...)
  // * 4. When sending is done, send a tox_file_sendcontrol(...) with send_receive = 0 and message_id = TOX_FILECONTROL_FINISHED
  // *
  // * HOW TO RECEIVE FILES CORRECTLY:
  // * 1. wait for the callback set with tox_callback_file_sendrequest(...)
  // * 2. accept or refuse the connection with tox_file_sendcontrol(...) with send_receive = 1 and message_id = TOX_FILECONTROL_ACCEPT or TOX_FILECONTROL_KILL
  // * 3. save all the data received with the callback set with tox_callback_file_data(...) to a file.
  // * 4. when the callback set with tox_callback_file_control(...) is called with receive_send == 0 and control_type == TOX_FILECONTROL_FINISHED
  // * the file is done transferring.
  // *
  // * tox_file_dataremaining(...) can be used to know how many bytes are left to send/receive.
  // *
  // * More to come...
  // */
  
  ///* Set the callback for file send requests.
  // *
  // *  Function(Tox *tox, int friendnumber, uint8_t filenumber, uint64_t filesize, uint8_t *filename, uint16_t filename_length, void *userdata)
  // */
  //void tox_callback_file_sendrequest(Tox *tox, void (*function)(Tox *m, int, uint8_t, uint64_t, uint8_t *, uint16_t,
  //                                   void *), void *userdata);
  procedure tox_callback_file_sendrequest(Tox: TTox;
    CallBack: TProcFileSendrequest; userdata: Pointer); cdecl;
    external TOX_LIBRARY;
  
  ///* Set the callback for file control requests.
  // *
  // *  receive_send is 1 if the message is for a slot on which we are currently sending a file and 0 if the message
  // *  is for a slot on which we are receiving the file
  // *
  // *  Function(Tox *tox, int friendnumber, uint8_t receive_send, uint8_t filenumber, uint8_t control_type, uint8_t *data, uint16_t length, void *userdata)
  // *
  // */
  //void tox_callback_file_control(Tox *tox, void (*function)(Tox *m, int, uint8_t, uint8_t, uint8_t, uint8_t *,
  //                               uint16_t, void *), void *userdata);
  procedure tox_callback_file_control(Tox: TTox; CallBack: TProcFileControl;
    userdata: Pointer); cdecl; external TOX_LIBRARY;
  
  ///* Set the callback for file data.
  // *
  // *  Function(Tox *tox, int friendnumber, uint8_t filenumber, uint8_t *data, uint16_t length, void *userdata)
  // *
  // */
  //void tox_callback_file_data(Tox *tox, void (*function)(Tox *m, int, uint8_t, uint8_t *, uint16_t length, void *),
  //                            void *userdata);
  procedure tox_callback_file_data(Tox: TTox; CallBack: TProcFileData;
    userdata: Pointer); cdecl; external TOX_LIBRARY;
  
  ///* Send a file send request.
  // * Maximum filename length is 255 bytes.
  // *  return file number on success
  // *  return -1 on failure
  // */
  //int tox_new_filesender(Tox *tox, int friendnumber, uint64_t filesize, uint8_t *filename, uint16_t filename_length);
  function tox_new_filesender(Tox: TTox; friendnumber: Integer; filesize: Int64;
    filename: PByte; filename_length: Word): Integer; cdecl; external TOX_LIBRARY;
  
  ///* Send a file control request.
  // *
  // * send_receive is 0 if we want the control packet to target a file we are currently sending,
  // * 1 if it targets a file we are currently receiving.
  // *
  // *  return 1 on success
  // *  return 0 on failure
  // */
  //int tox_file_sendcontrol(Tox *tox, int friendnumber, uint8_t send_receive, uint8_t filenumber, uint8_t message_id,
  //                         uint8_t *data, uint16_t length);
  function tox_file_sendcontrol(Tox: TTox; friendnumber: Integer;
    send_receive: Byte; filenumber: Byte; message_id: Byte; data: PByte;
    length: Word): Integer; cdecl; external TOX_LIBRARY;
  
  ///* Send file data.
  // *
  // *  return 1 on success
  // *  return 0 on failure
  // */
  //int tox_file_senddata(Tox *tox, int friendnumber, uint8_t filenumber, uint8_t *data, uint16_t length);
  function tox_file_senddata(Tox: TTox; friendnumber: Integer; filenumber: Byte;
    data: PByte; length: Word): Integer; cdecl; external TOX_LIBRARY;
  
  ///* Returns the recommended/maximum size of the filedata you send with tox_file_senddata()
  // *
  // *  return size on success
  // *  return 0 on failure (currently will never return 0)
  // */
  //int tox_filedata_size(Tox *tox, int friendnumber);
  function tox_filedata_size(Tox: TTox; friendnumber: Integer): Integer; cdecl;
    external TOX_LIBRARY;
  
  ///* Give the number of bytes left to be sent/received.
  // *
  // *  send_receive is 0 if we want the sending files, 1 if we want the receiving.
  // *
  // *  return number of bytes remaining to be sent/received on success
  // *  return 0 on failure
  // */
  //uint64_t tox_file_dataremaining(Tox *tox, int friendnumber, uint8_t filenumber, uint8_t send_receive);
  function tox_file_dataremaining(Tox: TTox; friendnumber: Integer;
    filenumber: Byte; send_receive: Byte): Int64; cdecl; external TOX_LIBRARY;
  
  ///***************END OF FILE SENDING FUNCTIONS******************/
  
  
  ///*
  // * Use these two functions to bootstrap the client.
  // */
  ///* Sends a "get nodes" request to the given node with ip, port and public_key
  // *   to setup connections
  // */
  //void tox_bootstrap_from_ip(Tox *tox, tox_IP_Port ip_port, uint8_t *public_key);
  procedure tox_bootstrap_from_ip(Tox: TTox; ip_port: TToxIpPort;
    public_key: PByte); cdecl; external TOX_LIBRARY;
  
  ///* Resolves address into an IP address. If successful, sends a "get nodes"
  // *   request to the given node with ip, port and public_key to setup connections
  