🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.sys.next.programmer
2 messages
2 total messages Started by John W. Wooten Fri, 08 Jan 1993 15:01
Archiving memory streams
#2243
Author: John W. Wooten
Date: Fri, 08 Jan 1993 15:01
13 lines
936 bytes
I have a NXStream that contains information I wish to archive.

I have demonstrated that the Object I am archiving which as
the stream pointer as an instance variable works properly as far as  
being able to set and retreive the contents of the stream pointer.

When archiving the Object, I wish to archive the contents of the stream  
pointer.  How do I do this?  I've tried * as type, and several other  
options, but the stream is a structure, should I have to describe the  
structure?

- - - - - - - - -
J. W. Wooten
Re: Archiving memory streams
#2359
Author: Thomas Burkholder
Date: Wed, 13 Jan 1993 02:21
49 lines
2002 bytes
In article <1993Jan8.150148.6961@ornl.gov> woo@ornl.gov (John W. Wooten)  
writes:
> I have a NXStream that contains information I wish to archive.
> 
> I have demonstrated that the Object I am archiving which as
> the stream pointer as an instance variable works properly as far as  
> being able to set and retreive the contents of the stream pointer.
> 
> When archiving the Object, I wish to archive the contents of the stream  
> pointer.  How do I do this?  I've tried * as type, and several other  
> options, but the stream is a structure, should I have to describe the  
> structure?
> 
> - - - - - - - - -
> J. W. Wooten

Just hacked this up on the fly, so it probably isn't error-free; but you  
get the idea.  A production version should probably be more careful about  
how memory is allocated, not to mention error checking.  Hope it helps.

-thomas
Thomas Burkholder (burkhold@next.com)
NeXT Developer Support Team
* And, no, I don't speak for NeXT, at least, not when I post on the net.*

-----cut here-----
-writeStreamToTypedStream(NXTypedStream *cooked, NXStream *raw)
{
  char formatStr[10], *buf;
  int len, maxLen;

  NXGetMemoryBuffer(raw,&buf,&len,&maxLen);
  sprintf(formatStr,"%c%dc%c",len,'[',']');
  NXWriteTypes(cooked,"i",len);
  NXWriteTypes(cooked,formatStr,buf);
  return self;
}

-NXStream *readStreamFromTypedStream(NXTypedStream *cooked)
{
  int len;
  char *formatStr;

  NXReadTypes(cooked,"i",&len);
  buf = (char *)malloc(len * sizeof(char));
  sprintf(formatStr,"%c%dc%c",len,'[',']');
  NXReadTypes(cooked,formatStr,&buf);
  return NXOpenMemory(buf,len,NX_READONLY);
}
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads