Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Convert pointer to zlib stream to string?

Convert pointer to zlib stream to string?

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • O Offline
    O Offline
    o m n i
    wrote on last edited by
    #1

    I have a z_streamp, which is a pointer to a z_stream_s. z_stream_s is defined as follows:

    typedef struct z_stream_s {
    Bytef *next_in; /* next input byte */
    uInt avail_in; /* number of bytes available at next_in */
    uLong total_in; /* total nb of input bytes read so far */

    Bytef    \*next\_out; /\* next output byte should be put there \*/
    uInt     avail\_out; /\* remaining free space at next\_out \*/
    uLong    total\_out; /\* total nb of bytes output so far \*/
    
    char     \*msg;      /\* last error message, NULL if no error \*/
    struct internal\_state FAR \*state; /\* not visible by applications \*/
    
    alloc\_func zalloc;  /\* used to allocate the internal state \*/
    free\_func  zfree;   /\* used to free the internal state \*/
    voidpf     opaque;  /\* private data object passed to zalloc and zfree \*/
    
    int     data\_type;  /\* best guess about the data type: binary or text \*/
    uLong   adler;      /\* adler32 value of the uncompressed data \*/
    uLong   reserved;   /\* reserved for future use \*/
    

    } z_stream;

    I am trying to convery the next_in Byte to a string but I get a c2059 error that doesn't make any sense (it complains about a parenthesis: error C2059: syntax error : ')') Here is my code:

    z_stream_s zs;
    zs = *z_stream_in;

    char dest(StackSizeOf(char));
    strcpy(dest,zs.next_in*);

    (the *z_stream_in it uses is passed to it by the caller) I think I may be defining the char wrong but I don't think that's whats causing the error. Can anyone help please?

    A L 2 Replies Last reply
    0
    • O o m n i

      I have a z_streamp, which is a pointer to a z_stream_s. z_stream_s is defined as follows:

      typedef struct z_stream_s {
      Bytef *next_in; /* next input byte */
      uInt avail_in; /* number of bytes available at next_in */
      uLong total_in; /* total nb of input bytes read so far */

      Bytef    \*next\_out; /\* next output byte should be put there \*/
      uInt     avail\_out; /\* remaining free space at next\_out \*/
      uLong    total\_out; /\* total nb of bytes output so far \*/
      
      char     \*msg;      /\* last error message, NULL if no error \*/
      struct internal\_state FAR \*state; /\* not visible by applications \*/
      
      alloc\_func zalloc;  /\* used to allocate the internal state \*/
      free\_func  zfree;   /\* used to free the internal state \*/
      voidpf     opaque;  /\* private data object passed to zalloc and zfree \*/
      
      int     data\_type;  /\* best guess about the data type: binary or text \*/
      uLong   adler;      /\* adler32 value of the uncompressed data \*/
      uLong   reserved;   /\* reserved for future use \*/
      

      } z_stream;

      I am trying to convery the next_in Byte to a string but I get a c2059 error that doesn't make any sense (it complains about a parenthesis: error C2059: syntax error : ')') Here is my code:

      z_stream_s zs;
      zs = *z_stream_in;

      char dest(StackSizeOf(char));
      strcpy(dest,zs.next_in*);

      (the *z_stream_in it uses is passed to it by the caller) I think I may be defining the char wrong but I don't think that's whats causing the error. Can anyone help please?

      A Offline
      A Offline
      Adam Roderick J
      wrote on last edited by
      #2

      I have few doubts 1. What is the type of z_stream_in? 2. Whether StackSizeOf class is defined by you? 3. In strcpy(dest,zs.next_in*);, Here what zs.next_in* means?

      Величие не Бога может быть недооценена.

      O 1 Reply Last reply
      0
      • A Adam Roderick J

        I have few doubts 1. What is the type of z_stream_in? 2. Whether StackSizeOf class is defined by you? 3. In strcpy(dest,zs.next_in*);, Here what zs.next_in* means?

        Величие не Бога может быть недооценена.

        O Offline
        O Offline
        o m n i
        wrote on last edited by
        #3

        1. z_streamp, which is means it is a pointer to a z_stream_s 2. StackSizeOf is defined as #define StackSizeOf(Type) ((sizeof(Type)<sizeof(PBYTE))?sizeof(PBYTE):(sizeof(Type))) 3. zs is a z_stream_s (see the definition of z_stream_s in my previous post)

        A 1 Reply Last reply
        0
        • O o m n i

          1. z_streamp, which is means it is a pointer to a z_stream_s 2. StackSizeOf is defined as #define StackSizeOf(Type) ((sizeof(Type)<sizeof(PBYTE))?sizeof(PBYTE):(sizeof(Type))) 3. zs is a z_stream_s (see the definition of z_stream_s in my previous post)

          A Offline
          A Offline
          Adam Roderick J
          wrote on last edited by
          #4

          strcpy takes parameter char* as first parameter and const char* as second parameter [^] so i hope Bytef is typedef of char. if so then explicit casting is not needed else needed and i think no need of zs.next_in* instead just zs.next_in is needed.

          Величие не Бога может быть недооценена.

          1 Reply Last reply
          0
          • O o m n i

            I have a z_streamp, which is a pointer to a z_stream_s. z_stream_s is defined as follows:

            typedef struct z_stream_s {
            Bytef *next_in; /* next input byte */
            uInt avail_in; /* number of bytes available at next_in */
            uLong total_in; /* total nb of input bytes read so far */

            Bytef    \*next\_out; /\* next output byte should be put there \*/
            uInt     avail\_out; /\* remaining free space at next\_out \*/
            uLong    total\_out; /\* total nb of bytes output so far \*/
            
            char     \*msg;      /\* last error message, NULL if no error \*/
            struct internal\_state FAR \*state; /\* not visible by applications \*/
            
            alloc\_func zalloc;  /\* used to allocate the internal state \*/
            free\_func  zfree;   /\* used to free the internal state \*/
            voidpf     opaque;  /\* private data object passed to zalloc and zfree \*/
            
            int     data\_type;  /\* best guess about the data type: binary or text \*/
            uLong   adler;      /\* adler32 value of the uncompressed data \*/
            uLong   reserved;   /\* reserved for future use \*/
            

            } z_stream;

            I am trying to convery the next_in Byte to a string but I get a c2059 error that doesn't make any sense (it complains about a parenthesis: error C2059: syntax error : ')') Here is my code:

            z_stream_s zs;
            zs = *z_stream_in;

            char dest(StackSizeOf(char));
            strcpy(dest,zs.next_in*);

            (the *z_stream_in it uses is passed to it by the caller) I think I may be defining the char wrong but I don't think that's whats causing the error. Can anyone help please?

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            Omnicoder wrote:

            z_stream_s zs; zs = *z_stream_in; char dest(StackSizeOf(char)); strcpy(dest,zs.next_in*);

            This code does not appear to make sense. I don't think you can set a z_stream_s to a reference as you are trying to do. Also strcpy() needs a pointer to an array for its source and destination fields. You have set the destination to a single character, and the source to an incomplete expresion.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups