summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2007-11-27 14:35:30 -0800
committerJeremy Allison <jra@samba.org>2007-11-27 14:35:30 -0800
commit6b6655edd90850d09c7711fc3b9fe98271e3e625 (patch)
treefd0247dcf84688d1f6bdba2253d05f6dd0fe0787 /source3/lib
parentf642ae837507e755d5949a61ea5ad70c7b334385 (diff)
downloadsamba-6b6655edd90850d09c7711fc3b9fe98271e3e625.tar.gz
samba-6b6655edd90850d09c7711fc3b9fe98271e3e625.tar.bz2
samba-6b6655edd90850d09c7711fc3b9fe98271e3e625.zip
Remove pstrings from everything except srv_spoolss_nt.c.
Jeremy. (This used to be commit 0002a9e96b0ef78316295a6eb94ff29b64e2f988)
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/substitute.c34
-rw-r--r--source3/lib/util_unistr.c57
2 files changed, 44 insertions, 47 deletions
diff --git a/source3/lib/substitute.c b/source3/lib/substitute.c
index db79a9f2b5..09604f8442 100644
--- a/source3/lib/substitute.c
+++ b/source3/lib/substitute.c
@@ -831,8 +831,8 @@ static char *alloc_sub_advanced(const char *servicename, const char *user,
*/
char *talloc_sub_advanced(TALLOC_CTX *mem_ctx,
- const char *servicename, const char *user,
- const char *connectpath, gid_t gid,
+ const char *servicename, const char *user,
+ const char *connectpath, gid_t gid,
const char *smb_name, const char *domain_name,
const char *str)
{
@@ -848,13 +848,13 @@ char *talloc_sub_advanced(TALLOC_CTX *mem_ctx,
}
-void standard_sub_advanced(const char *servicename, const char *user,
- const char *connectpath, gid_t gid,
+void standard_sub_advanced(const char *servicename, const char *user,
+ const char *connectpath, gid_t gid,
const char *smb_name, const char *domain_name,
char *str, size_t len)
{
char *s;
-
+
s = alloc_sub_advanced(servicename, user, connectpath,
gid, smb_name, domain_name, str);
@@ -865,19 +865,17 @@ void standard_sub_advanced(const char *servicename, const char *user,
}
/****************************************************************************
- * Do some standard substitutions in a string.
- * ****************************************************************************/
+ Do some standard substitutions in a string.
+****************************************************************************/
-void standard_sub_conn(connection_struct *conn, char *str, size_t len)
+char *standard_sub_conn(TALLOC_CTX *ctx, connection_struct *conn, const char *str)
{
- char *s;
-
- s = alloc_sub_advanced(lp_servicename(SNUM(conn)), conn->user, conn->connectpath,
- conn->gid, get_smb_user_name(), "", str);
-
- if ( s ) {
- strncpy( str, s, len );
- SAFE_FREE( s );
- }
+ return talloc_sub_advanced(ctx,
+ lp_servicename(SNUM(conn)),
+ conn->user,
+ conn->connectpath,
+ conn->gid,
+ get_smb_user_name(),
+ "",
+ str);
}
-
diff --git a/source3/lib/util_unistr.c b/source3/lib/util_unistr.c
index bd2cd73cc4..49b0b814f7 100644
--- a/source3/lib/util_unistr.c
+++ b/source3/lib/util_unistr.c
@@ -408,7 +408,7 @@ int rpcstr_push(void *dest, const char *src, size_t dest_len, int flags)
/* Converts a string from internal samba format to unicode. Always terminates.
* Actually just a wrapper round push_ucs2_talloc().
- */
+ */
int rpcstr_push_talloc(TALLOC_CTX *ctx, smb_ucs2_t **dest, const char *src)
{
@@ -428,6 +428,7 @@ void unistr2_to_ascii(char *dest, const UNISTR2 *str, size_t maxlen)
pull_ucs2(NULL, dest, str->buffer, maxlen, str->uni_str_len*2, STR_NOALIGN);
}
+#if 0
/*******************************************************************
Convert a (little-endian) UNISTR3 structure to an ASCII string.
********************************************************************/
@@ -441,53 +442,51 @@ void unistr3_to_ascii(char *dest, const UNISTR3 *str, size_t maxlen)
pull_ucs2(NULL, dest, str->str.buffer, maxlen, str->uni_str_len*2,
STR_NOALIGN);
}
+#endif
/*******************************************************************
- Return a string for displaying a UNISTR2. Guarentees to return a
- valid string - "" if nothing else.
- Changed to use talloc_tos() under the covers.... JRA.
+ Duplicate a UNISTR2 string into a null terminated char*
+ using a talloc context.
********************************************************************/
-const char *unistr2_static(const UNISTR2 *str)
+char *unistr2_to_ascii_talloc(TALLOC_CTX *ctx, const UNISTR2 *str)
{
- size_t ret = (size_t)-1;
- char *dest = NULL;
+ char *s = NULL;
- if ((str == NULL) || (str->uni_str_len == 0)) {
- return "";
+ if (!str || !str->buffer) {
+ return NULL;
}
-
- ret = pull_ucs2_base_talloc(talloc_tos(),
+ if (pull_ucs2_base_talloc(ctx,
NULL,
- &dest,
+ &s,
str->buffer,
str->uni_str_len*2,
- STR_NOALIGN);
- if (ret == (size_t)-1 || dest == NULL) {
- return "";
+ STR_NOALIGN) == (size_t)-1) {
+ return NULL;
}
-
- return dest;
+ return s;
}
/*******************************************************************
- Duplicate a UNISTR2 string into a null terminated char*
- using a talloc context.
+ Return a string for displaying a UNISTR2. Guarentees to return a
+ valid string - "" if nothing else.
+ Changed to use talloc_tos() under the covers.... JRA.
********************************************************************/
-char *unistr2_tdup(TALLOC_CTX *ctx, const UNISTR2 *str)
+const char *unistr2_static(const UNISTR2 *str)
{
- char *s;
- int maxlen = (str->uni_str_len+1)*4;
- if (!str->buffer) {
- return NULL;
+ char *dest = NULL;
+
+ if ((str == NULL) || (str->uni_str_len == 0)) {
+ return "";
}
- s = (char *)TALLOC(ctx, maxlen); /* convervative */
- if (!s) {
- return NULL;
+
+ dest = unistr2_to_ascii_talloc(talloc_tos(), str);
+ if (!dest) {
+ return "";
}
- pull_ucs2(NULL, s, str->buffer, maxlen, str->uni_str_len*2, STR_NOALIGN);
- return s;
+
+ return dest;
}
/*******************************************************************