Syscalls: Difference between revisions

From Hackspire
Jump to navigation Jump to search
(→‎TI-Nspire GUI: utf162ascii, utf16_strlen)
No edit summary
Line 117: Line 117:
*<tt>NU_Set_Current_Dir(const char *name)</tt>: Set the current working directory on the default drive.
*<tt>NU_Set_Current_Dir(const char *name)</tt>: Set the current working directory on the default drive.


==TI-Nspire GUI==
==TI-Nspire specific==
*<tt>void ascii2utf16(void *buf, const char *str, int max_size)</tt>: converts the ASCII string <tt>str</tt> to the UTF-8 string <tt>buf</tt> of size <tt>max_size</tt>.
*<tt>void ascii2utf16(void *buf, const char *str, int max_size)</tt>: converts the ASCII string <tt>str</tt> to the UTF-8 string <tt>buf</tt> of size <tt>max_size</tt>.
*<tt>void utf162ascii(void *buf, const char *str, int max_size)</tt>: converts the UTF-16 string <tt>str</tt> to the ASCII string <tt>buf</tt> of size <tt>max_size</tt>.
*<tt>void utf162ascii(void *buf, const char *str, int max_size)</tt>: converts the UTF-16 string <tt>str</tt> to the ASCII string <tt>buf</tt> of size <tt>max_size</tt>.
*<tt>size_t utf16_strlen(const char * s)</tt>: returns the length in characters of the UTF-16 string <tt>s</tt>.
*<tt>size_t utf16_strlen(const char * s)</tt>: returns the length in characters of the UTF-16 string <tt>s</tt>.
*<tt><s>void show_dialog_box2(int winid, const char *utf8_title, const char *utf8_msg)</s></tt>: displays a dialog box of title <tt>utf8_title</tt> containing <tt>utf8_msg</tt>. <tt>utf8_title</tt> and <tt>utf8_msg</tt> are C strings converted with <tt>ascii2utf16()</tt>. <tt>winid</tt> must be 0 (''deprecated since Ndless 2.0 and replaced with libndls's show_msgbox'').
*<tt><s>void show_dialog_box2(int winid, const char *utf8_title, const char *utf8_msg)</s></tt>: displays a dialog box of title <tt>utf8_title</tt> containing <tt>utf8_msg</tt>. <tt>utf8_title</tt> and <tt>utf8_msg</tt> are C strings converted with <tt>ascii2utf16()</tt>. <tt>winid</tt> must be 0 (''deprecated since Ndless 2.0 and replaced with libndls's show_msgbox'').
==Miscellaneous==
*<tt>int read_unaligned_longword(void *ptr)</tt>
*<tt>int read_unaligned_longword(void *ptr)</tt>
*<tt>int read_unaligned_word(void *ptr)</tt>
*<tt>int read_unaligned_word(void *ptr)</tt>

Revision as of 13:25, 14 April 2012

Syscalls are OS functions exposed by Ndless to C and assembly programs. This article describes the syscalls currently available with Ndless 1.7.

Your help is needed to make this list grow to a full-fledged library. Try to find new syscalls, test them and share them for integration in Ndless.

Functions marked with (*) are available only if the program is linked against Newlib, i.e. when the nspire-ld switch -nostdlib is not used.

Functions crossed-out are deprecated and shouldn't be used anymore.

C standard library

ctype.h

errno.h

stdarg.h

stdio.h

stdlib.h

string.h

C POSIX library

dirent.h

sys/stat.h

unistd.h

Nucleus

  • int TCT_Local_Control_Interrupts(int mask): sets the interrupt mask. Returns the previous mask.
  • int NU_Current_Dir(const char *drive, char *path): fills in path with the full path name of the current working directory. Use "A:" as drive. Returns 0 on success.
  • int NU_Get_First(struct dstat *statobj, const char * pattern): given a pattern which contains both a path specifier and a search pattern, fills in the structure at statobj with information about the file and sets up internal parts of statobj to supply appropriate information for calls to NU_Get_Next. Returns non-zero if a match was not found.
  • int NU_Get_Next(struct dstat *statobj): given a pointer to a DSTAT structure that has been set up by a call to NU_Get_First(), searches for the next match of the original pattern in the original path. Returns non-zero if found and updates statobj for subsequent calls to NU_Get_Next.
  • void NU_Done(struct dstat *statobj): given a pointer to a DSTAT structure that has been set up by a call to NU_Get_First(), frees internal elements used by the statobj.
  • NU_Set_Current_Dir(const char *name): Set the current working directory on the default drive.

TI-Nspire specific

  • void ascii2utf16(void *buf, const char *str, int max_size): converts the ASCII string str to the UTF-8 string buf of size max_size.
  • void utf162ascii(void *buf, const char *str, int max_size): converts the UTF-16 string str to the ASCII string buf of size max_size.
  • size_t utf16_strlen(const char * s): returns the length in characters of the UTF-16 string s.
  • void show_dialog_box2(int winid, const char *utf8_title, const char *utf8_msg): displays a dialog box of title utf8_title containing utf8_msg. utf8_title and utf8_msg are C strings converted with ascii2utf16(). winid must be 0 (deprecated since Ndless 2.0 and replaced with libndls's show_msgbox).
  • int read_unaligned_longword(void *ptr)
  • int read_unaligned_word(void *ptr)