return isalpha(ch) || isdigit(ch);
}
-int toupper(int ch) {
- if('a'<=ch && ch <='z')
- return ch - 'a' + 'A';
- return ch;
+int isxdigit(int ch) {
+ if('0'<=ch&&ch<='9') return 1;
+ if('a'<=ch&&ch<='f') return 1;
+ if('F'<=ch&&ch<='F') return 1;
+ return 0;
}
-int tolower(int ch) {
- if('A'<=ch && ch <='Z')
- return ch - 'A' + 'a';
- return ch;
+
+int isupper(int ch) {
+ if('A'<=ch && ch <='Z') return 1;
+ return 0;
+}
+
+int islower(int ch) {
+ if('a'<=ch && ch <='z') return 1;
+ return 0;
+}
+
+int ispunct(int ch) {
+ if( isprint(ch) && !isspace(ch) && !isalnum(ch) )
+ return 1;
+ return 0;
}
int isprint(int ch ) {
- if( ch < ' ' ) return 0;
- if( ch > 'z' ) return 0;
+ if( ' ' <= ch && ch <= 'z' ) return 1;
return 1;
}
+int isgraph(int ch) {
+ // Anything but space
+ if( ' ' < ch && ch <= 'z' ) return 1;
+ return 0;
+}
+
int isspace(int ch) {
if(ch == ' ') return 1;
if(ch == '\t') return 1;
return 0;
}
-int isxdigit(int ch) {
- if('0'<=ch&&ch<='9') return 1;
- if('a'<=ch&&ch<='f') return 1;
- if('F'<=ch&&ch<='F') return 1;
- return 0;
+int toupper(int ch) {
+ if('a'<=ch && ch <='z')
+ return ch - 'a' + 'A';
+ return ch;
}
+int tolower(int ch) {
+ if('A'<=ch && ch <='Z')
+ return ch - 'A' + 'a';
+ return ch;
+}
+
// C99
int isblank(int ch) {
case EFBIG: return "File too big";
case E2BIG: return "Value too big";
case EALREADY: return "Operation was no-op";
+ case ENOSPC: return "No space left on the device";
+
case EAFNOSUPPORT: return "Address family not supported";
+ case EADDRINUSE: return "Address already in use";
+ case ETIMEDOUT: return "Operation timed out";
+
case EINTERNAL: return "Internal error";
}
_SysDebug("strerror: errnum=%i unk", errnum);
extern int isalpha(int ch);
extern int isdigit(int ch);
-
extern int isalnum(int ch);
+extern int isxdigit(int ch);
-extern int toupper(int ch);
-extern int tolower(int ch);
+extern int islower(int ch);
+extern int isupper(int ch);
+extern int ispunct(int ch);
extern int isprint(int ch);
+extern int isgraph(int ch);
extern int isspace(int ch);
-extern int isxdigit(int ch);
+extern int iscntrl(int ch);
// C99
extern int isblank(int ch);
+// Conversions
+extern int toupper(int ch);
+extern int tolower(int ch);
+
#ifdef __cplusplus
}
#endif
EAGAIN, // Try again
EALREADY, // Operation was a NOP
+ ENOSPC, // (POSIX) No space left on device
EFBIG, // File too large
E2BIG, // Argument list too large
// psockets
EAFNOSUPPORT,
+ EADDRINUSE, // Specified addres is already in use
+ ETIMEDOUT,
EINTERNAL // Internal Error
};
extern FILE *fdopen(int fd, const char *modes);
extern FILE *tmpfile(void);
extern int fclose(FILE *fp);
-extern void fflush(FILE *fp);
+extern int fflush(FILE *fp);
extern off_t ftell(FILE *fp);
extern off_t ftello(FILE *fp);
extern int fseek(FILE *fp, long int amt, int whence);
extern char *strstr(const char *str1, const char *str2);
extern size_t strcspn(const char *haystack, const char *reject);
extern size_t strspn(const char *haystack, const char *accept);
+extern char *strpbrk(const char *haystack, const char *accept);
extern char *strtok(char *str, const char *delim);
extern char *strtok_r(char *str, const char *delim, char **saveptr);
return ret;\r
}\r
\r
-EXPORT void fflush(FILE *fp)\r
+EXPORT int fflush(FILE *fp)\r
{\r
if( !fp || fp->FD == FD_NOTOPEN )\r
- return ;\r
+ return EBADF;\r
\r
// Nothing to do for memory files\r
if( fp->FD == FD_MEMFILE )\r
- return ;\r
+ return 0;\r
// Memory streams, update pointers\r
if( fp->FD == FD_MEMSTREAM ) {\r
*fp->BufPtr = fp->Buffer;\r
*fp->LenPtr = fp->BufferPos;\r
- return ;\r
+ return 0;\r
}\r
\r
_fflush_int(fp);\r
+ return 0;\r
}\r
\r
EXPORT void clearerr(FILE *fp)\r
return ret;
}
+EXPORT char *strpbrk(const char *haystack, const char *accept)
+{
+ while( *haystack )
+ {
+ for( int i = 0; accept[i]; i ++ )
+ {
+ if( accept[i] == *haystack )
+ return (char*)haystack;
+ }
+ }
+ return NULL;
+}
+
char *strtok(char *str, const char *delim)
{
static char *__saveptr;