static uint32 str_len_uni(UNISTR *source)
{
uint32 i=0;
-
+
+ if (!source->buffer) return 0;
+
while (source->buffer[i]!=0x0000)
{
i++;
size+=size_of_relative_string( &info->defaultdatatype );
string=info->dependentfiles;
-
- for (i=0; (string[i]!=0x0000) || (string[i+1]!=0x0000); i++);
+ if (string) {
+ for (i=0; (string[i]!=0x0000) || (string[i+1]!=0x0000); i++);
+ }
i=i+2; /* to count all chars including the leading zero */
i=2*i; /* because we need the value in bytes */
return False;
if(!prs_uint32("portname_ptr", ps, depth, &il->portname_ptr))
return False;
+
if(!prs_uint32("drivername_ptr", ps, depth, &il->drivername_ptr))
return False;
if(!prs_uint32("comment_ptr", ps, depth, &il->comment_ptr))
dynamically allocate memory
********************************************************************/
-static BOOL uniarray_2_dosarray(BUFFER5 *buf5, char ***ar)
+static BOOL uniarray_2_dosarray(BUFFER5 *buf5, fstring **ar)
{
- char **array;
- char *string;
- char *destend;
- char *dest;
- uint32 n;
- uint32 i;
-
- uint16 *src;
+ fstring f;
+ int n = 0;
+ char *src;
if (buf5==NULL) return False;
- array=NULL;
- n=0;
- i=0;
- src=buf5->buffer;
-
- string=(char *)malloc(sizeof(char)*buf5->buf_len);
- if(string == NULL)
- return False;
+ src = (char *)buf5->buffer;
+ *ar = NULL;
- destend = string + buf5->buf_len;
- dest=string;
-
- while (dest < destend)
- {
- dest += unicode_to_dos_char(dest, (smb_ucs2_t)*(src++));
+ while (src < ((char *)buf5->buffer) + buf5->buf_len*2) {
+ unistr_to_dos(f, src, sizeof(f)-1);
+ src = skip_unibuf(src, 2*buf5->buf_len - PTR_DIFF(src,buf5->buffer));
+ *ar = (fstring *)Realloc(*ar, sizeof(fstring)*(n+2));
+ fstrcpy((*ar)[n], f);
}
-
- /* that ugly for the first one but that's working */
- array=(char **)Realloc(array, sizeof(char *)*(i+1));
- if(array == NULL)
- return False;
- array[i++]=string;
-
- while ( n < buf5->buf_len )
- {
- if ( *(string++) == '\0' )
- {
- array=(char **)Realloc(array, sizeof(char *)*(i+1));
- if(array == NULL)
- return False;
- array[i++]=string;
- }
- n++;
- }
- *ar=array;
-
- DEBUG(10,("Number of dependent files: [%d]\n", i-1));
+ fstrcpy((*ar)[n], "");
return True;
}
unix_to_nt_time(&time_nt, time_unix);
d->changeid=time_nt.low;
-
d->c_setprinter++;
-
+
unistr2_to_ascii(d->servername, &uni->servername, sizeof(d->servername)-1);
unistr2_to_ascii(d->printername, &uni->printername, sizeof(d->printername)-1);
unistr2_to_ascii(d->sharename, &uni->sharename, sizeof(d->sharename)-1);