s3: printing: Rename printing_read_data() -> printing_pread_data() and add an offset...
[nivanova/samba-autobuild/.git] / source3 / printing / nt_printing.c
index 754e04ace911062c6ea3bfecb46c0eb171b4e44f..c5c6e07ec3bc09fdda2f565e624cd4f57f43e5ec 100644 (file)
@@ -316,8 +316,9 @@ const char *get_short_archi(const char *long_archi)
  (note: EINTR re-read differs from vfs_write_data)
 ****************************************************************************/
 
-static ssize_t printing_read_data(files_struct *fsp,
+static ssize_t printing_pread_data(files_struct *fsp,
                                char *buf,
+                               off_t *poff_unused,
                                size_t byte_count)
 {
        size_t total=0;
@@ -365,6 +366,7 @@ static int handle_pe_file(files_struct *fsp,
        ssize_t byte_count;
        off_t oret;
        off_t pos;
+       off_t in_pos = -1;
        int ret = -1;
 
        /* Just skip over optional header to get to section table */
@@ -397,7 +399,7 @@ static int handle_pe_file(files_struct *fsp,
                goto out;
        }
 
-       byte_count = printing_read_data(fsp, buf, section_table_bytes);
+       byte_count = printing_pread_data(fsp, buf, &in_pos, section_table_bytes);
        if (byte_count < section_table_bytes) {
                DBG_NOTICE("PE file [%s] Section header too short, "
                        "bytes read = %lu\n",
@@ -451,8 +453,9 @@ static int handle_pe_file(files_struct *fsp,
                                goto out;
                        }
 
-                       byte_count = printing_read_data(fsp,
+                       byte_count = printing_pread_data(fsp,
                                                buf,
+                                               &in_pos,
                                                section_bytes);
                        if (byte_count < section_bytes) {
                                DBG_NOTICE("PE file "
@@ -545,6 +548,7 @@ static int handle_ne_file(files_struct *fsp,
        unsigned int i;
        ssize_t byte_count;
        int ret = -1;
+       off_t in_pos = -1;
 
        if (CVAL(buf,NE_HEADER_TARGET_OS_OFFSET) != NE_HEADER_TARGOS_WIN ) {
                DBG_NOTICE("NE file [%s] wrong target OS = 0x%x\n",
@@ -574,7 +578,7 @@ static int handle_ne_file(files_struct *fsp,
         * please have at it, but this works. 'NE' files will
         * eventually fade away. JRR
         */
-       byte_count = printing_read_data(fsp, buf, VS_NE_BUF_SIZE);
+       byte_count = printing_pread_data(fsp, buf, &in_pos, VS_NE_BUF_SIZE);
        while (byte_count > 0) {
                /*
                 * Cover case that should not occur in a well
@@ -590,8 +594,9 @@ static int handle_ne_file(files_struct *fsp,
                         * possibly match
                         */
                        if (buf[i] != 'V') {
-                               byte_count = printing_read_data(fsp,
+                               byte_count = printing_pread_data(fsp,
                                                buf,
+                                               &in_pos,
                                                VS_NE_BUF_SIZE);
                                continue;
                        }
@@ -606,8 +611,9 @@ static int handle_ne_file(files_struct *fsp,
                                ssize_t amount_unused = byte_count-i;
 
                                memmove(buf, &buf[i], amount_unused);
-                               amount_read = printing_read_data(fsp,
+                               amount_read = printing_pread_data(fsp,
                                                &buf[amount_unused],
+                                               &in_pos,
                                                VS_NE_BUF_SIZE- amount_unused);
                                if (amount_read < 0) {
                                        DBG_ERR("NE file [%s] Read "
@@ -654,8 +660,9 @@ static int handle_ne_file(files_struct *fsp,
                                if (IVAL(buf,
                                        i+sizeof(VS_SIGNATURE)+skip)
                                                != 0xfeef04bd) {
-                                       byte_count = printing_read_data(fsp,
+                                       byte_count = printing_pread_data(fsp,
                                                        buf,
+                                                       &in_pos,
                                                        VS_NE_BUF_SIZE);
                                        continue;
                                }
@@ -708,6 +715,7 @@ static int get_file_version(files_struct *fsp,
        ssize_t byte_count;
        off_t pos;
        off_t oret;
+       off_t in_pos = -1;
 
        buf=(char *)SMB_MALLOC(DOS_HEADER_SIZE);
        if (buf == NULL) {
@@ -717,7 +725,7 @@ static int get_file_version(files_struct *fsp,
                goto error_exit;
        }
 
-       byte_count = printing_read_data(fsp, buf, DOS_HEADER_SIZE);
+       byte_count = printing_pread_data(fsp, buf, &in_pos, DOS_HEADER_SIZE);
        if (byte_count < DOS_HEADER_SIZE) {
                DBG_NOTICE("File [%s] DOS header too short, bytes read = %lu\n",
                         fname,
@@ -752,7 +760,7 @@ static int get_file_version(files_struct *fsp,
        pos = oret; /* Update new position. */
 
        /* Note: DOS_HEADER_SIZE and NE_HEADER_SIZE are incidentally same */
-       byte_count = printing_read_data(fsp, buf, NE_HEADER_SIZE);
+       byte_count = printing_pread_data(fsp, buf, &in_pos, NE_HEADER_SIZE);
        if (byte_count < NE_HEADER_SIZE) {
                DBG_NOTICE("File [%s] Windows header too short, "
                        "bytes read = %lu\n",