Syscalls: Difference between revisions
Jump to navigation
Jump to search
(→UTF-16 String API: Clarified documentation) |
(→UTF-16 String API: Fixed </tt>) |
||
Line 142: | Line 142: | ||
*<tt>int string_last_indexOf_utf16(String, int start, char *)</tt> : Returns the last index of <tt>pattern</tt> in the String starting at <tt>start</tt>. Returns -1 if not found | *<tt>int string_last_indexOf_utf16(String, int start, char *)</tt> : Returns the last index of <tt>pattern</tt> in the String starting at <tt>start</tt>. Returns -1 if not found | ||
*<tt>int string_compareTo_utf16(String, char *)</tt> : Returns 0 if the given utf16 string is equal to the String, -1 if it is superior, 1 if not | *<tt>int string_compareTo_utf16(String, char *)</tt> : Returns 0 if the given utf16 string is equal to the String, -1 if it is superior, 1 if not | ||
*<tt>char * string_substring(String dst, String src, int start, int end)</tt> : Writes in the <tt>dst</tt> the resulting substring from <tt>start</tt> to <tt>end</tt> (excluded) of <tt>src<tt>. Also returns the utf16 pointer | *<tt>char * string_substring(String dst, String src, int start, int end)</tt> : Writes in the <tt>dst</tt> the resulting substring from <tt>start</tt> to <tt>end</tt> (excluded) of <tt>src</tt>. Also returns the utf16 pointer | ||
*<tt>void string_erase(String, int n)</tt> : Erases characters in the String from beginning to <tt>n</tt> (equivalent to substring(n, len)) | *<tt>void string_erase(String, int n)</tt> : Erases characters in the String from beginning to <tt>n</tt> (equivalent to substring(n, len)) | ||
*<tt>void string_truncate(String, int n)</tt> : Truncates the String to <tt>n</tt> chararacters (equivalent to substring(0, n)) | *<tt>void string_truncate(String, int n)</tt> : Truncates the String to <tt>n</tt> chararacters (equivalent to substring(0, n)) |
Revision as of 00:47, 13 December 2012
Syscalls are OS functions exposed by Ndless to C and assembly programs. This article describes the syscalls currently available with Ndless 3.1. You don't need to include the .h files in your program, only Ndless's standard os.h is required.
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
- fclose
- feof
- ferror
- fflush
- fgetc
- fgets
- fopen
- freopen
- fprintf
- fputs
- fread
- fseek
- ftell (since v3.1)
- fwrite
- puts
- printf
- remove
- rename
- rewind
- stderr
- stdin
- stdout
- sprintf
- ungetc
- vsprintf
stdlib.h
- abort (since v3.1)
- atoi
- atof
- calloc
- exit (*)
- free
- malloc
- rand (since v3.1 r610)
- realloc
- srand (since v3.1 r610)
- strtod
- strtol
- strtoul
string.h
- memcpy
- memcmp
- memmove
- memrev
- memset
- strcat
- strcoll
- strchr
- strcmp
- strcpy
- strcspn
- strerror
- strlen
- strncat
- strncmp
- strncpy
- strpbrk
- strrchr
- strspn
- strstr
- strtok (since v3.1)
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
UTF-16 String API
Since v3.1 r672.
- String : The type of the dynamic-length strings encoded in utf-16 format
Details:
typedef struct { char * str; int len; int chunck_size; int unknown_field; } * String;
- String string_new() : Returns a new String structure
- void string_free(String) : Frees the String structure
- char * string_to_ascii(String) : Returns String converted to ascii
- void string_lower(String) : Lower all characters in the String
- char string_charAt(String, int pos) : Returns the character at pos in the String
- int string_concat_utf16(String, char *) : Concatenates to the String the given utf16 string
- int string_set_ascii(String, char *) : Erases the content of the String with the given ascii string
- int string_set_utf16(String, char *) : Erases the content of the String with the given utf16 string
- int string_indexOf_utf16(String, int start, char *pattern) : Returns the index of pattern in the String starting at start. Returns -1 if not found
- int string_last_indexOf_utf16(String, int start, char *) : Returns the last index of pattern in the String starting at start. Returns -1 if not found
- int string_compareTo_utf16(String, char *) : Returns 0 if the given utf16 string is equal to the String, -1 if it is superior, 1 if not
- char * string_substring(String dst, String src, int start, int end) : Writes in the dst the resulting substring from start to end (excluded) of src. Also returns the utf16 pointer
- void string_erase(String, int n) : Erases characters in the String from beginning to n (equivalent to substring(n, len))
- void string_truncate(String, int n) : Truncates the String to n chararacters (equivalent to substring(0, n))
- char * string_substring_utf16(String, char *pattern, int *ptr) : Returns the beginning of the String (in utf16) until pattern is met (excluded). ptr is modified so that it indicates the ending index of pattern or values -1 if the pattern doesn't exist. In such case the whole string is returned.
- int string_insert_replace_utf16(String, char *, int start, int end) : Inserts the given utf16 string between start and end in the String by erasing its content. If end is -1 it erases the end of the String
- int string_insert_utf16(String, char *, int pos) : Inserts the given utf16 string at pos in the String.
- int string_sprintf_utf16(String, char *, ...) : Fills the String using the utf16 string format and arguments (equivalent to sprintf but with utf16 everywhere)
- 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): Since v3.1 r607. converts the UTF-16 string str to the ASCII string buf of size max_size.
- size_t utf16_strlen(const char * s): Since v3.1 r607. Returns the length in characters of the UTF-16 string s.
Others
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)