Changeset 53
- Timestamp:
- 01/17/06 22:51:03 (6 years ago)
- Location:
- NEWT0/trunk
- Files:
-
- 1 added
- 2 edited
-
ext/protoFILE/protoFILE.c (modified) (3 diffs)
-
sample/nsof.newt (added)
-
src/newt_core/NewtIconv.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
NEWT0/trunk/ext/protoFILE/protoFILE.c
r1 r53 102 102 return NewtThrow(kNErrNotASymbol, whence); 103 103 104 if ( whence == NSSYM("set"))104 if (NewtRefEqual(whence, NSSYM(seek_set))) 105 105 wh = SEEK_SET; 106 else if ( whence == NSSYM("curr"))106 else if (NewtRefEqual(whence, NSSYM(seek_cur))) 107 107 wh = SEEK_CUR; 108 else if ( whence == NSSYM("end"))108 else if (NewtRefEqual(whence, NSSYM(seek_end))) 109 109 wh = SEEK_END; 110 110 else … … 395 395 } 396 396 397 newtRef MyGetc(newtRefArg rcvr) 398 { 399 newtRefVar stream; 400 FILE* theFile; 401 int theResult; 402 403 stream = NcGetSlot(rcvr, NSSYM(_stream)); 404 if (NewtRefIsNIL(stream)) 405 return kNewtRefUnbind; 406 407 theFile = NewtRefToFILE(stream); 408 theResult = fgetc(theFile); 409 return NewtMakeInteger(theResult); 410 } 411 412 newtRef MyPutc(newtRefArg rcvr, newtRefArg byte) 413 { 414 newtRefVar stream; 415 FILE* theFile; 416 char theByte; 417 int theResult; 418 419 stream = NcGetSlot(rcvr, NSSYM(_stream)); 420 if (NewtRefIsNIL(stream)) 421 return kNewtRefUnbind; 422 423 theFile = NewtRefToFILE(stream); 424 theByte = NewtRefToInteger(byte); 425 theResult = fputc(theByte, theFile); 426 return NewtMakeInteger(theResult); 427 } 428 429 newtRef MyWrite(newtRefArg rcvr, newtRefArg binary) 430 { 431 newtRefVar stream; 432 FILE* theFile; 433 void* data; 434 int len; 435 int theResult; 436 437 stream = NcGetSlot(rcvr, NSSYM(_stream)); 438 if (NewtRefIsNIL(stream)) 439 return kNewtRefUnbind; 440 441 theFile = NewtRefToFILE(stream); 442 data = NewtRefToBinary(binary); 443 len = NewtBinaryLength(binary); 444 theResult = fwrite(data, len, 1, theFile); 445 446 return NewtMakeInteger(theResult); 447 } 397 448 398 449 /*------------------------------------------------------------------------*/ … … 427 478 NcSetSlot(r, NSSYM(Print), NewtMakeNativeFunc(MyPrint, 1, "Print(str)")); 428 479 NcSetSlot(r, NSSYM(Gets), NewtMakeNativeFunc(MyGets, 0, "Gets()")); 480 NcSetSlot(r, NSSYM(Getc), NewtMakeNativeFunc(MyGetc, 0, "Getc()")); 481 NcSetSlot(r, NSSYM(Putc), NewtMakeNativeFunc(MyPutc, 1, "Putc(byte)")); 482 NcSetSlot(r, NSSYM(Write), NewtMakeNativeFunc(MyWrite, 1, "Write(binary)")); 429 483 430 484 NcSetSlot(r, NSSYM(_stream), kNewtRefNIL); -
NEWT0/trunk/src/newt_core/NewtIconv.c
r36 r53 42 42 if (dst) 43 43 { 44 c har * inbuf_p = src;44 const char * inbuf_p = src; 45 45 char * outbuf_p = dst; 46 46 size_t inbytesleft = srclen;
Note: See TracChangeset
for help on using the changeset viewer.
