[prev in list] [next in list] [prev in thread] [next in thread] 

List:       klik-devel
Subject:    [klik-devel] [klikclient commit] r1689 -
From:       codesite-noreply () google ! com
Date:       2008-08-29 22:33:26
Message-ID: 0016362835248943a40455a0d7f1 () google ! com
[Download RAW message or body]

Author: cristian.debian
Date: Fri Aug 29 15:33:09 2008
New Revision: 1689

Modified:
    branches/cristian/fusioniso/fusioniso/src/fusioniso_fs.c
    branches/cristian/fusioniso/fusioniso/src/fusioniso_isofs.c
    branches/cristian/fusioniso/fusioniso/src/fusioniso_isofs.h

Log:
isofs_fix_string(): change prototype to return int value and to not require
access to fuse_get_context. code cleanup.


Modified: branches/cristian/fusioniso/fusioniso/src/fusioniso_fs.c
==============================================================================
--- branches/cristian/fusioniso/fusioniso/src/fusioniso_fs.c	(original)
+++ branches/cristian/fusioniso/fusioniso/src/fusioniso_fs.c	Fri Aug 29  
15:33:09 2008
@@ -623,20 +623,19 @@
              {
                  if (inode->NM)                                     // rrip  
NM entry present and in effect
                  {
-                    //                     printf("readdir: NM entry is in  
effect\n");
+                    //FSDEBUG("NM entry is in effect");
                      strncpy(entry, inode->nm, inode->nm_len);
                      entry[inode->nm_len] = '\0';
                  }                                                 //  
regular ISO9660 filename
                  else
                  {
-                    //                     printf("readdir: no NM entry  
found, name len %d\n", name_len);
+                    //FSDEBUG("readdir: no NM entry found, name  
len %d",name_len);
                      // because there can be '\0' characters because using  
of UCS-2 encoding we need to use memcpy
                      memcpy(entry, (char *) record->name, name_len);
                      entry[name_len] = '\0';

                      // fixup entry -- lowercase, strip leading ';', etc..
-                    entry = isofs_fix_entry(entry, name_len);
-                    if (!entry)
+                    if  
(isofs_fix_entry(&entry,name_len,data->isofs->joliet_level,data->iocharset)<0)
                      {
                          FSDEBUG("error during entry fixup");
                          isofs_free_inode(inode);

Modified: branches/cristian/fusioniso/fusioniso/src/fusioniso_isofs.c
==============================================================================
--- branches/cristian/fusioniso/fusioniso/src/fusioniso_isofs.c	(original)
+++ branches/cristian/fusioniso/fusioniso/src/fusioniso_isofs.c	Fri Aug 29  
15:33:09 2008
@@ -771,100 +771,99 @@
  /**
   * Fix string 'entry' (lowercase, charset, ...)
   *
- * @return fixed string on success,
- *         NULL on error
+ * @return 0 on success ('entry' is fixed),
+ *         -1 on error
   */
-char *isofs_fix_entry(char *entry, size_t len)
+int isofs_fix_entry(char **entry, size_t len, int joliet_level, char  
*iocharset)
  {
-    fusioniso_data *data=fusioniso_get_data();
-    if (!data->isofs->joliet_level)                                   //  
iso9660 names
+    if (!joliet_level)                      // iso9660 names
      {
-        char *sep2 = index(entry, ';');                               //  
find SEPARATOR2
-        if (sep2)                                                     //  
remove remaining part
-        {
-            *sep2 = '\0';
-        }
-        char *sep1 = rindex(entry, '.');                              //  
find SEPARATOR1
-        if (sep1 && sep1[1] == '\0')                                  //  
check if SEPARATOR1 is a last symbol in string
-        {
-            *sep1 = '\0';                                             //  
remove it
-        }
+        char *sep1, *sep2, *str;
+
+	str=*entry;

+        sep1=index(str, ';');               // find first occurrence of ';'
+        if (sep1)                           // remove remaining part
+            *sep1 = '\0';
+
+        sep2=rindex(str, '.');              // find last occurrence of '.'
+        if (sep2 && sep2[1] == '\0')        // check if '.' is a last  
symbol in string
+            *sep2 = '\0';                   // remove it
+
+
+        str=*entry;
          // this part is borrowed from linux kernel code
          // convert remaining ';' and '/' characters to dots
          // and lowercase characters in range A-Z
-        char *p = entry;
-        while (*p)
+        while (*str)
          {
-            if (*p == ';' || *p == '/')
-            {
-                *p = '.';
-            }
-            else if (*p >= 'A' && *p <= 'Z')
-            {
-                *p |= 0x20;
-            }
+            if (*str == ';' || *str == '/')
+                *str = '.';
+            else if (*str >= 'A' && *str <= 'Z')
+                *str |= 0x20;

-            p++;
+            str++;
          }

-        return entry;
+        return 0;
      }
      else
      {
+        iconv_t cd;
+	char *inbuf, *outbuf, *outstr;
+	size_t inbytesleft, outbytesleft, outlen;
+	int rc;
+
          // initialize iconv descriptor
-        iconv_t cd = iconv_open(data->iocharset, "UCS-2BE");
+        cd=iconv_open(iocharset, "UCS-2BE");
          if (cd < 0)
          {
-            FSWARNING("iconv error: %s",strerror(errno));
-            return NULL;
+            FSWARNING("iconv_open error: %s",strerror(errno));
+            return -1;
          }

-        char *inbuf = entry;
-        size_t inbytesleft = len;
+        inbuf=*entry;
+        inbytesleft=len;

-        char *outbuf = (char *) malloc(NAME_MAX);                     //  
this should be sufficient for our purposes
+        outbuf=(char *) malloc(NAME_MAX);   // this should be sufficient  
for our purposes
          if (!outbuf)
          {
              FSWARNING("can\'t malloc: %s",strerror(errno));
-            return NULL;
+            return -1;
          }
-        char *outentry = outbuf;
-        size_t outbytesleft = NAME_MAX;
+        outbytesleft=NAME_MAX;

-        int rc = iconv(cd, & inbuf, & inbytesleft, & outbuf, &  
outbytesleft);
-        size_t outlen = NAME_MAX - outbytesleft;
-        outentry[outlen] = '\0';
-        if (rc == -1)
+        outstr=outbuf;
+
+        rc=iconv(cd,&inbuf,&inbytesleft,&outbuf,&outbytesleft);
+        outlen=NAME_MAX-outbytesleft;
+	if (rc<0)
          {
              // incorrect multibyte char or other iconv error -- return as  
much as possible anyway
-            FSWARNING("iconv error on '%s': %s",outentry,strerror(errno));
+            FSWARNING("iconv error on '%s': %s",outstr,strerror(errno));
              if (outlen == 0)
              {
                  iconv_close(cd);
                  free(entry);
-                free(outentry);
-                return NULL;
+                free(outstr);
+                return -1;
              }
              // try to recover
          }
+        outstr[outlen]='\0';

-        //         printf("outlen %d, outbytesleft %d, rc %d,  
outbuf %s\n", outlen, outbytesleft, rc, outentry);
+        //FSDEBUG("outlen %d, outbytesleft %d, rc %d, outbuf %s", outlen,  
outbytesleft, rc, outstr);

          // borrowed from linux kernel isofs joliet code
-        if (outlen > 2 && outentry[outlen - 2] == ';' && outentry[outlen -  
1] == '1')
-        {
-            outentry[outlen - 2] = '\0';
-        }
-        if (outlen >= 2 && outentry[outlen - 1] == '.')
-        {
-            outentry[outlen - 1] = '\0';
-        }
+        if (outlen > 2 && outstr[outlen - 2] == ';' && outstr[outlen - 1]  
== '1')
+            outstr[outlen - 2] = '\0';
+        if (outlen >= 2 && outstr[outlen - 1] == '.')
+            outstr[outlen - 1] = '\0';

-        free(entry);
          iconv_close(cd);
-
-        return outentry;
+        free(*entry);
+	*entry=outstr;
+        return 0;
      }
  }


Modified: branches/cristian/fusioniso/fusioniso/src/fusioniso_isofs.h
==============================================================================
--- branches/cristian/fusioniso/fusioniso/src/fusioniso_isofs.h	(original)
+++ branches/cristian/fusioniso/fusioniso/src/fusioniso_isofs.h	Fri Aug 29  
15:33:09 2008
@@ -155,7 +155,7 @@
  int isofs_init(char* imagefile, isofs_context **isofs);
  int isofs_read_raw_block(int block, char *buf, isofs_context *isofs);
  int isofs_direntry2stat(struct stat *st, isofs_inode *inode);
-char *isofs_fix_entry(char *entry, size_t len);
+int isofs_fix_entry(char **entry, size_t len, int joliet_level, char  
*iocharset);
  int isofs_parse_sa(isofs_inode *inode, char *sa, size_t sa_len);
  int isofs_real_read_zf(isofs_inode *inode, char *out_buf, size_t size,  
off_t offset);

_______________________________________________
klik-devel mailing list
klik-devel@kde.org
https://mail.kde.org/mailman/listinfo/klik-devel
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic