[libbluray-devel] Moved string_to_uint32 to strutl.c

hpi1 git at videolan.org
Mon Mar 21 12:30:35 CET 2011


libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Mon Mar 21 13:19:51 2011 +0200| [a103cbce69da0ddd1742cd1c46e7634d38607afb] | committer: hpi1

Moved string_to_uint32 to strutl.c

> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=a103cbce69da0ddd1742cd1c46e7634d38607afb
---

 src/libbluray/bluray.c |   25 ++-----------------------
 src/util/strutl.c      |   20 ++++++++++++++++++++
 src/util/strutl.h      |    4 ++++
 3 files changed, 26 insertions(+), 23 deletions(-)

diff --git a/src/libbluray/bluray.c b/src/libbluray/bluray.c
index 138ab01..f1b55fe 100644
--- a/src/libbluray/bluray.c
+++ b/src/libbluray/bluray.c
@@ -1543,37 +1543,16 @@ int bd_set_player_setting(BLURAY *bd, uint32_t idx, uint32_t value)
     return 0;
 }
 
-static uint32_t _string_to_uint32(const char *s, int n)
-{
-    uint32_t val = 0;
-
-    if (n > 4)
-        n = 4;
-
-    if (!s || !*s) {
-        return (INT64_C(1) << (8*n)) - 1; /* default: all bits one */
-    }
-
-    while (n--) {
-        val = (val << 8) | *s;
-        if (*s) {
-            s++;
-        }
-    }
-
-    return val;
-}
-
 int bd_set_player_setting_str(BLURAY *bd, uint32_t idx, const char *s)
 {
     switch (idx) {
         case BLURAY_PLAYER_SETTING_AUDIO_LANG:
         case BLURAY_PLAYER_SETTING_PG_LANG:
         case BLURAY_PLAYER_SETTING_MENU_LANG:
-            return bd_set_player_setting(bd, idx, _string_to_uint32(s, 3));
+            return bd_set_player_setting(bd, idx, str_to_uint32(s, 3));
 
         case BLURAY_PLAYER_SETTING_COUNTRY_CODE:
-            return bd_set_player_setting(bd, idx, _string_to_uint32(s, 2));
+            return bd_set_player_setting(bd, idx, str_to_uint32(s, 2));
 
         default:
             return 0;
diff --git a/src/util/strutl.c b/src/util/strutl.c
index 28e3154..acc4b06 100644
--- a/src/util/strutl.c
+++ b/src/util/strutl.c
@@ -58,3 +58,23 @@ char * str_printf(const char *fmt, ...)
     }
 }
 
+uint32_t str_to_uint32(const char *s, int n)
+{
+    uint32_t val = 0;
+
+    if (n > 4)
+        n = 4;
+
+    if (!s || !*s) {
+        return (INT64_C(1) << (8*n)) - 1; /* default: all bits one */
+    }
+
+    while (n--) {
+        val = (val << 8) | *s;
+        if (*s) {
+            s++;
+        }
+    }
+
+    return val;
+}
diff --git a/src/util/strutl.h b/src/util/strutl.h
index 0cded16..aa00095 100644
--- a/src/util/strutl.h
+++ b/src/util/strutl.h
@@ -22,6 +22,10 @@
 
 #include "attributes.h"
 
+#include <stdint.h>
+
 BD_PRIVATE char * str_printf(const char *fmt, ...) BD_ATTR_FORMAT_PRINTF(1,2) BD_ATTR_MALLOC;
 
+BD_PRIVATE uint32_t str_to_uint32(const char *s, int n);
+
 #endif // STRUTL_H_



More information about the libbluray-devel mailing list