Merge branch 'master' of git://git.samba.org/samba into convenience
authorJelmer Vernooij <jelmer@samba.org>
Sun, 1 Mar 2009 15:41:57 +0000 (16:41 +0100)
committerJelmer Vernooij <jelmer@samba.org>
Sun, 1 Mar 2009 15:41:57 +0000 (16:41 +0100)
lib/tevent/pytevent.c
lib/util/util.c
lib/util/util.h
source3/lib/util_str.c
source3/printing/printfsp.c
source3/printing/printing.c
source3/smbd/fileio.c

index 3b45ba192875d6c994fd108e35788e21d84af1da..fe7e7e3e3826b7540fab7a9f54e80cfcfe9f942f 100644 (file)
@@ -29,7 +29,6 @@
 
 #include <tevent.h>
 #include <stdbool.h>
-#include "tevent_util.h"
 
 typedef struct {
        PyObject_HEAD
@@ -54,7 +53,8 @@ static PyObject *py_backend_list(PyObject *self)
     PyObject *ret;
     int i, len;
 
-    len = ev_str_list_length(backends);
+    for (len = 0; backends[len]; len++);
+
     ret = PyList_New(len);
     for (i = 0; i < len; i++)
         PyList_SetItem(ret, i, PyString_FromString(backends[i]));
index 988d8f9fa02a479d05fc81a72af3905c3c35e12b..1f31f55e8b2fd1a39e3c545fe733cf4370682d04 100644 (file)
@@ -836,4 +836,104 @@ _PUBLIC_ size_t utf16_len_n(const void *src, size_t n)
        return len;
 }
 
+/**
+ * @file
+ * @brief String utilities.
+ **/
+
+static bool next_token_internal_talloc(TALLOC_CTX *ctx,
+                               const char **ptr,
+                                char **pp_buff,
+                                const char *sep,
+                                bool ltrim)
+{
+       char *s;
+       char *saved_s;
+       char *pbuf;
+       bool quoted;
+       size_t len=1;
+
+       *pp_buff = NULL;
+       if (!ptr) {
+               return(false);
+       }
+
+       s = (char *)*ptr;
+
+       /* default to simple separators */
+       if (!sep) {
+               sep = " \t\n\r";
+       }
+
+       /* find the first non sep char, if left-trimming is requested */
+       if (ltrim) {
+               while (*s && strchr_m(sep,*s)) {
+                       s++;
+               }
+       }
+
+       /* nothing left? */
+       if (!*s) {
+               return false;
+       }
+
+       /* When restarting we need to go from here. */
+       saved_s = s;
+
+       /* Work out the length needed. */
+       for (quoted = false; *s &&
+                       (quoted || !strchr_m(sep,*s)); s++) {
+               if (*s == '\"') {
+                       quoted = !quoted;
+               } else {
+                       len++;
+               }
+       }
+
+       /* We started with len = 1 so we have space for the nul. */
+       *pp_buff = talloc_array(ctx, char, len);
+       if (!*pp_buff) {
+               return false;
+       }
+
+       /* copy over the token */
+       pbuf = *pp_buff;
+       s = saved_s;
+       for (quoted = false; *s &&
+                       (quoted || !strchr_m(sep,*s)); s++) {
+               if ( *s == '\"' ) {
+                       quoted = !quoted;
+               } else {
+                       *pbuf++ = *s;
+               }
+       }
+
+       *ptr = (*s) ? s+1 : s;
+       *pbuf = 0;
+
+       return true;
+}
+
+bool next_token_talloc(TALLOC_CTX *ctx,
+                       const char **ptr,
+                       char **pp_buff,
+                       const char *sep)
+{
+       return next_token_internal_talloc(ctx, ptr, pp_buff, sep, true);
+}
+
+/*
+ * Get the next token from a string, return false if none found.  Handles
+ * double-quotes.  This version does not trim leading separator characters
+ * before looking for a token.
+ */
+
+bool next_token_no_ltrim_talloc(TALLOC_CTX *ctx,
+                       const char **ptr,
+                       char **pp_buff,
+                       const char *sep)
+{
+       return next_token_internal_talloc(ctx, ptr, pp_buff, sep, false);
+}
+
 
index 27f94cd68583c4bcdc1f03b01dcdee1dd2f88bfe..1f6e3b193b3d0a9f9970428e19c45611e7401fca 100644 (file)
@@ -204,6 +204,21 @@ _PUBLIC_ void display_set_stderr(void);
 
 /* The following definitions come from lib/util/util_str.c  */
 
+bool next_token_talloc(TALLOC_CTX *ctx,
+                       const char **ptr,
+                       char **pp_buff,
+                       const char *sep);
+
+/**
+ * Get the next token from a string, return false if none found.  Handles
+ * double-quotes.  This version does not trim leading separator characters
+ * before looking for a token.
+ */
+bool next_token_no_ltrim_talloc(TALLOC_CTX *ctx,
+                       const char **ptr,
+                       char **pp_buff,
+                       const char *sep);
+
 
 /**
  Trim the specified elements off the front and back of a string.
index 9358061797abd36cf9f811eb1d5e45cc7703468f..b9ccb83e556134a2a54a717b7f3811d943c7870d 100644 (file)
@@ -35,118 +35,6 @@ const char toupper_ascii_fast_table[128] = {
        0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f
 };
 
-/**
- * @file
- * @brief String utilities.
- **/
-
-static bool next_token_internal_talloc(TALLOC_CTX *ctx,
-                               const char **ptr,
-                                char **pp_buff,
-                                const char *sep,
-                                bool ltrim)
-{
-       char *s;
-       char *saved_s;
-       char *pbuf;
-       bool quoted;
-       size_t len=1;
-
-       *pp_buff = NULL;
-       if (!ptr) {
-               return(false);
-       }
-
-       s = (char *)*ptr;
-
-       /* default to simple separators */
-       if (!sep) {
-               sep = " \t\n\r";
-       }
-
-       /* find the first non sep char, if left-trimming is requested */
-       if (ltrim) {
-               while (*s && strchr_m(sep,*s)) {
-                       s++;
-               }
-       }
-
-       /* nothing left? */
-       if (!*s) {
-               return false;
-       }
-
-       /* When restarting we need to go from here. */
-       saved_s = s;
-
-       /* Work out the length needed. */
-       for (quoted = false; *s &&
-                       (quoted || !strchr_m(sep,*s)); s++) {
-               if (*s == '\"') {
-                       quoted = !quoted;
-               } else {
-                       len++;
-               }
-       }
-
-       /* We started with len = 1 so we have space for the nul. */
-       *pp_buff = TALLOC_ARRAY(ctx, char, len);
-       if (!*pp_buff) {
-               return false;
-       }
-
-       /* copy over the token */
-       pbuf = *pp_buff;
-       s = saved_s;
-       for (quoted = false; *s &&
-                       (quoted || !strchr_m(sep,*s)); s++) {
-               if ( *s == '\"' ) {
-                       quoted = !quoted;
-               } else {
-                       *pbuf++ = *s;
-               }
-       }
-
-       *ptr = (*s) ? s+1 : s;
-       *pbuf = 0;
-
-       return true;
-}
-
-#if 0
-/*
- * Get the next token from a string, return false if none found.  Handles
- * double-quotes.  This version trims leading separator characters before
- * looking for a token.
- */
-bool next_token(const char **ptr, char *buff, const char *sep, size_t bufsize)
-{
-       return next_token_internal(ptr, buff, sep, bufsize, true);
-}
-#endif
-
-bool next_token_talloc(TALLOC_CTX *ctx,
-                       const char **ptr,
-                       char **pp_buff,
-                       const char *sep)
-{
-       return next_token_internal_talloc(ctx, ptr, pp_buff, sep, true);
-}
-
-/*
- * Get the next token from a string, return false if none found.  Handles
- * double-quotes.  This version does not trim leading separator characters
- * before looking for a token.
- */
-
-bool next_token_no_ltrim_talloc(TALLOC_CTX *ctx,
-                       const char **ptr,
-                       char **pp_buff,
-                       const char *sep)
-{
-       return next_token_internal_talloc(ctx, ptr, pp_buff, sep, false);
-}
-
 /**
  * Case insensitive string compararison.
  *
index b485711f910bd67203f80463e67c4780501c62ad..243b8ea03b7763538bcdb53427b1ca4daa624aba 100644 (file)
@@ -88,7 +88,6 @@ NTSTATUS print_fsp_open(struct smb_request *req, connection_struct *conn,
 void print_fsp_end(files_struct *fsp, enum file_close_type close_type)
 {
        uint32 jobid;
-       fstring sharename;
 
        if (fsp->fh->private_options & FILE_DELETE_ON_CLOSE) {
                /*
@@ -102,7 +101,7 @@ void print_fsp_end(files_struct *fsp, enum file_close_type close_type)
                string_free(&fsp->fsp_name);
        }
 
-       if (!rap_to_pjobid(fsp->rap_print_jobid, sharename, &jobid)) {
+       if (!rap_to_pjobid(fsp->rap_print_jobid, NULL, &jobid)) {
                DEBUG(3,("print_fsp_end: Unable to convert RAP jobid %u to print jobid.\n",
                        (unsigned int)fsp->rap_print_jobid ));
                return;
index 49bd5ac8ba829cfe9143fad3b28b994d91658353..fc3667ea3a959ff5a0041ed28ab6a4d99be34d56 100644 (file)
@@ -117,7 +117,9 @@ bool rap_to_pjobid(uint16 rap_jobid, fstring sharename, uint32 *pjobid)
        if ( data.dptr && data.dsize == sizeof(struct rap_jobid_key) )
        {
                struct rap_jobid_key *jinfo = (struct rap_jobid_key*)data.dptr;
-               fstrcpy( sharename, jinfo->sharename );
+               if (sharename != NULL) {
+                       fstrcpy( sharename, jinfo->sharename );
+               }
                *pjobid = jinfo->jobid;
                DEBUG(10,("rap_to_pjobid: jobid %u maps to RAP jobid %u\n",
                        (unsigned int)*pjobid, (unsigned int)rap_jobid));
index a9a97a2d14a133759dff5f54778c2dca769b2bd5..adf664b3960301da1713a81589b8b8e75a6f9307 100644 (file)
@@ -256,10 +256,9 @@ ssize_t write_file(struct smb_request *req,
        int write_path = -1;
 
        if (fsp->print_file) {
-               fstring sharename;
                uint32 jobid;
 
-               if (!rap_to_pjobid(fsp->rap_print_jobid, sharename, &jobid)) {
+               if (!rap_to_pjobid(fsp->rap_print_jobid, NULL, &jobid)) {
                        DEBUG(3,("write_file: Unable to map RAP jobid %u to jobid.\n",
                                                (unsigned int)fsp->rap_print_jobid ));
                        errno = EBADF;