prime/src/Runtime/sscanf.c
Phillip Stephens efb5cb0597 Match and link sscanf, string and mbstring
Former-commit-id: eb14c6e0ad266574dd52aeb99e5cebf70357b0d7
2023-01-18 21:16:39 -08:00

27 lines
602 B
C

#include "stdio.h"
int __StringRead(void* isc, int ch, int Action) {
char ret;
__InStrCtrl* iscp = (__InStrCtrl*)isc;
switch (Action) {
case __GetChar:
ret = *(iscp->NextChar);
if (ret == '\0') {
iscp->NullCharDetected = 1;
return (EOF);
} else {
iscp->NextChar++;
return ((unsigned char)ret);
}
case __UngetChar:
if (!iscp->NullCharDetected)
iscp->NextChar--;
else
iscp->NullCharDetected = 0;
return (ch);
case __CheckForError:
return (iscp->NullCharDetected);
}
return 0;
}