update uwproj master
authorOlaf Wintermann <olaf.wintermann@gmail.com>
Tue, 12 Sep 2023 16:11:07 +0000 (18:11 +0200)
committerOlaf Wintermann <olaf.wintermann@gmail.com>
Tue, 12 Sep 2023 16:11:07 +0000 (18:11 +0200)
12 files changed:
configure
make/configure.vm
make/project.xml
mizucp/atomic.h [new file with mode: 0644]
mizucp/main.c
mizucp/main.h
mizucp/vfs.c [new file with mode: 0644]
mizucp/vfs.h [new file with mode: 0644]
mizunara/Makefile
mizunara/main.c
mizunara/menu.c [new file with mode: 0644]
mizunara/menu.h [new file with mode: 0644]

index 44f8e8a..6f2b13a 100755 (executable)
--- a/configure
+++ b/configure
@@ -20,21 +20,21 @@ OS=`uname -s`
 OS_VERSION=`uname -r`
 
 TEMP_DIR=".tmp-`uname -n`"
 OS_VERSION=`uname -r`
 
 TEMP_DIR=".tmp-`uname -n`"
-mkdir -p $TEMP_DIR
+mkdir -p "$TEMP_DIR"
 if [ $? -ne 0 ]; then
 if [ $? -ne 0 ]; then
-       echo "Cannot create tmp dir"
-       echo "Abort"
+    echo "Cannot create tmp dir"
+    echo "Abort"
 fi
 fi
-touch $TEMP_DIR/options
-touch $TEMP_DIR/features
+touch "$TEMP_DIR/options"
+touch "$TEMP_DIR/features"
 
 # features
 
 # help text
 printhelp()
 {
 
 # features
 
 # help text
 printhelp()
 {
-       echo "Usage: $0 [OPTIONS]..."
-       cat << __EOF__
+    echo "Usage: $0 [OPTIONS]..."
+    cat << __EOF__
 Installation directories:
   --prefix=PREFIX         path prefix for architecture-independent files
                           [/usr]
 Installation directories:
   --prefix=PREFIX         path prefix for architecture-independent files
                           [/usr]
@@ -61,63 +61,63 @@ __EOF__
 }
 
 #
 }
 
 #
-# parse arguments 
+# parse arguments
 #
 #
-for ARG in $@
+for ARG in "$@"
 do
     case "$ARG" in
 do
     case "$ARG" in
-               "--prefix="*)         PREFIX=${ARG#--prefix=} ;;
-               "--exec-prefix="*)    EPREFIX=${ARG#--exec-prefix=} ;;
-               "--bindir="*)         BINDIR=${ARG#----bindir=} ;;
-               "--sbindir="*)        SBINDIR=${ARG#--sbindir=} ;;
-               "--libdir="*)         LIBDIR=${ARG#--libdir=} ;;
-               "--libexecdir="*)     LIBEXECDIR=${ARG#--libexecdir=} ;;
-               "--datadir="*)        DATADIR=${ARG#--datadir=} ;;
-               "--sysconfdir="*)     SYSCONFDIR=${ARG#--sysconfdir=} ;;
-               "--sharedstatedir="*) SHAREDSTATEDIR=${ARG#--sharedstatedir=} ;;
-               "--localstatedir="*)  LOCALSTATEDIR=${ARG#--localstatedir=} ;;
-               "--includedir="*)     INCLUDEDIR=${ARG#--includedir=} ;;
-               "--infodir="*)        INFODIR=${ARG#--infodir=} ;;
-               "--mandir"*)          MANDIR=${ARG#--mandir} ;;
-               "--help"*) printhelp; exit 1 ;;
-       "--toolkit="*) OPT_TOOLKIT=${ARG#--toolkit=} ;;
-               "-"*) echo "unknown option: $ARG"; exit 1 ;;
-       esac
+        "--prefix="*)         PREFIX=${ARG#--prefix=} ;;
+        "--exec-prefix="*)    EPREFIX=${ARG#--exec-prefix=} ;;
+        "--bindir="*)         BINDIR=${ARG#----bindir=} ;;
+        "--sbindir="*)        SBINDIR=${ARG#--sbindir=} ;;
+        "--libdir="*)         LIBDIR=${ARG#--libdir=} ;;
+        "--libexecdir="*)     LIBEXECDIR=${ARG#--libexecdir=} ;;
+        "--datadir="*)        DATADIR=${ARG#--datadir=} ;;
+        "--sysconfdir="*)     SYSCONFDIR=${ARG#--sysconfdir=} ;;
+        "--sharedstatedir="*) SHAREDSTATEDIR=${ARG#--sharedstatedir=} ;;
+        "--localstatedir="*)  LOCALSTATEDIR=${ARG#--localstatedir=} ;;
+        "--includedir="*)     INCLUDEDIR=${ARG#--includedir=} ;;
+        "--infodir="*)        INFODIR=${ARG#--infodir=} ;;
+        "--mandir"*)          MANDIR=${ARG#--mandir} ;;
+        "--help"*) printhelp; rm -Rf "$TEMP_DIR"; exit 1 ;;
+        "--toolkit="*) OPT_TOOLKIT=${ARG#--toolkit=} ;;
+        "-"*) echo "unknown option: $ARG"; rm -Rf "$TEMP_DIR"; exit 1 ;;
+    esac
 done
 
 # set dir variables
 if [ -z "$BINDIR" ]; then
 done
 
 # set dir variables
 if [ -z "$BINDIR" ]; then
-       BINDIR=$EPREFIX/bin
+    BINDIR=$EPREFIX/bin
 fi
 if [ -z "$SBINDIR" ]; then
 fi
 if [ -z "$SBINDIR" ]; then
-       SBINDIR=$EPREFIX/sbin
+    SBINDIR=$EPREFIX/sbin
 fi
 if [ -z "$LIBDIR" ]; then
 fi
 if [ -z "$LIBDIR" ]; then
-       LIBDIR=$EPREFIX/lib
+    LIBDIR=$EPREFIX/lib
 fi
 if [ -z "$LIBEXEC" ]; then
 fi
 if [ -z "$LIBEXEC" ]; then
-       LIBEXECDIR=$EPREFIX/libexec
+    LIBEXECDIR=$EPREFIX/libexec
 fi
 if [ -z "$DATADIR" ]; then
 fi
 if [ -z "$DATADIR" ]; then
-       DATADIR=$PREFIX/share
+    DATADIR=$PREFIX/share
 fi
 if [ -z "$SYSCONFDIR" ]; then
 fi
 if [ -z "$SYSCONFDIR" ]; then
-       SYSCONFDIR=$PREFIX/etc
+    SYSCONFDIR=$PREFIX/etc
 fi
 if [ -z "$SHAREDSTATEDIR" ]; then
 fi
 if [ -z "$SHAREDSTATEDIR" ]; then
-       SHAREDSTATEDIR=$PREFIX/com
+    SHAREDSTATEDIR=$PREFIX/com
 fi
 if [ -z "$LOCALSTATEDIR" ]; then
 fi
 if [ -z "$LOCALSTATEDIR" ]; then
-       LOCALSTATEDIR=$PREFIX/var
+    LOCALSTATEDIR=$PREFIX/var
 fi
 if [ -z "$INCLUDEDIR" ]; then
 fi
 if [ -z "$INCLUDEDIR" ]; then
-       INCLUDEDIR=$PREFIX/include
+    INCLUDEDIR=$PREFIX/include
 fi
 if [ -z "$INFODIR" ]; then
 fi
 if [ -z "$INFODIR" ]; then
-       INFODIR=$PREFIX/info
+    INFODIR=$PREFIX/info
 fi
 if [ -z "$MANDIR" ]; then
 fi
 if [ -z "$MANDIR" ]; then
-       MANDIR=$PREFIX/man
+    MANDIR=$PREFIX/man
 fi
 
 which pkg-config > /dev/null
 fi
 
 which pkg-config > /dev/null
@@ -130,19 +130,19 @@ fi
 # Simple uname based platform detection
 # $PLATFORM is used for platform dependent dependency selection
 printf "detect platform... "
 # Simple uname based platform detection
 # $PLATFORM is used for platform dependent dependency selection
 printf "detect platform... "
-if [ $OS = SunOS ]; then
+if [ "$OS" = "SunOS" ]; then
     PLATFORM="solaris sunos unix svr4"
 fi
     PLATFORM="solaris sunos unix svr4"
 fi
-if [ $OS = Linux ]; then
+if [ "$OS" = "Linux" ]; then
     PLATFORM="linux unix"
 fi
     PLATFORM="linux unix"
 fi
-if [ $OS = FreeBSD ]; then
+if [ "$OS" = "FreeBSD" ]; then
     PLATFORM="freebsd bsd unix"
 fi
     PLATFORM="freebsd bsd unix"
 fi
-if [ $OS = Darwin ]; then
+if [ "$OS" = "Darwin" ]; then
     PLATFORM="macos osx bsd unix"
 fi
     PLATFORM="macos osx bsd unix"
 fi
-echo $OS | grep "MINGW" > /dev/null
+echo "$OS" | grep -i "MINGW" > /dev/null
 if [ $? -eq 0 ]; then
     PLATFORM="windows mingw"
 fi
 if [ $? -eq 0 ]; then
     PLATFORM="windows mingw"
 fi
@@ -153,8 +153,8 @@ fi
 
 for p in $PLATFORM
 do
 
 for p in $PLATFORM
 do
-       PLATFORM_NAME=$p
-       break
+    PLATFORM_NAME=$p
+    break
 done
 echo $PLATFORM_NAME
 
 done
 echo $PLATFORM_NAME
 
@@ -162,7 +162,7 @@ isplatform()
 {
     for p in $PLATFORM
     do
 {
     for p in $PLATFORM
     do
-        if [ $p = $1 ]; then
+        if [ "$p" = "$1" ]; then
             return 0
         fi
     done
             return 0
         fi
     done
@@ -172,7 +172,7 @@ isnotplatform()
 {
     for p in $PLATFORM
     do
 {
     for p in $PLATFORM
     do
-        if [ $p = $1 ]; then
+        if [ "$p" = "$1" ]; then
             return 1
         fi
     done
             return 1
         fi
     done
@@ -180,7 +180,7 @@ isnotplatform()
 }
 
 # generate config.mk and config.h
 }
 
 # generate config.mk and config.h
-cat > $TEMP_DIR/config.mk << __EOF__
+cat > "$TEMP_DIR/config.mk" << __EOF__
 #
 # config.mk generated by configure
 #
 #
 # config.mk generated by configure
 #
@@ -204,7 +204,7 @@ MANDIR=$MANDIR
 
 __EOF__
 
 
 __EOF__
 
-echo > $TEMP_DIR/make.mk
+echo > "$TEMP_DIR/make.mk"
 
 ENV_CFLAGS=$CFLAGS
 ENV_LDFLAGS=$LDFLAGS
 
 ENV_CFLAGS=$CFLAGS
 ENV_LDFLAGS=$LDFLAGS
@@ -215,15 +215,15 @@ ENV_CXXFLAGS=$CXXFLAGS
 . make/toolchain.sh
 
 # add user specified flags to config.mk
 . make/toolchain.sh
 
 # add user specified flags to config.mk
-echo >> $TEMP_DIR/config.mk
-if [ ! -z "${ENV_CFLAGS}" ]; then
-    echo "CFLAGS += $ENV_CFLAGS" >> $TEMP_DIR/config.mk
+echo "# project specific flags" >> "$TEMP_DIR/config.mk"
+if [ -n "${ENV_CFLAGS}" ]; then
+    echo "CFLAGS += $ENV_CFLAGS" >> "$TEMP_DIR/config.mk"
 fi
 fi
-if [ ! -z "${ENV_CXXFLAGS}" ]; then
-    echo "CXXFLAGS += $ENV_CXXFLAGS" >> $TEMP_DIR/config.mk
+if [ -n "${ENV_CXXFLAGS}" ]; then
+    echo "CXXFLAGS += $ENV_CXXFLAGS" >> "$TEMP_DIR/config.mk"
 fi
 fi
-if [ ! -z "${ENV_LDFLAGS}" ]; then
-    echo "LDFLAGS += $ENV_LDFLAGS" >> $TEMP_DIR/config.mk
+if [ -n "${ENV_LDFLAGS}" ]; then
+    echo "LDFLAGS += $ENV_LDFLAGS" >> "$TEMP_DIR/config.mk"
 fi
 
 #
 fi
 
 #
@@ -236,102 +236,102 @@ dependency_curl()
     # dependency curl platform="windows"
     while true
     do
     # dependency curl platform="windows"
     while true
     do
-       if isnotplatform "windows"; then
+        if isnotplatform "windows"; then
             break
         fi
             break
         fi
-        CFLAGS="$CFLAGS -I/mingw/include"    
-        LDFLAGS="$LDFLAGS -lcurl"    
-               echo yes
+        TEMP_CFLAGS="$TEMP_CFLAGS -I/mingw/include"
+        TEMP_LDFLAGS="$TEMP_LDFLAGS -lcurl"
+        echo yes
         return 0
     done
         return 0
     done
-       
+
     # dependency curl platform="macos"
     while true
     do
     # dependency curl platform="macos"
     while true
     do
-       if isnotplatform "macos"; then
+        if isnotplatform "macos"; then
             break
         fi
         curl-config --cflags > /dev/null
         if [ $? -eq 0 ]; then
             break
         fi
         curl-config --cflags > /dev/null
         if [ $? -eq 0 ]; then
-            CFLAGS="$CFLAGS `curl-config --cflags`"
+            TEMP_CFLAGS="$TEMP_CFLAGS `curl-config --cflags`"
         else
             break
         fi
         curl-config --ldflags > /dev/null
         if [ $? -eq 0 ]; then
         else
             break
         fi
         curl-config --ldflags > /dev/null
         if [ $? -eq 0 ]; then
-            LDFLAGS="$LDFLAGS `curl-config --ldflags`"
+            TEMP_LDFLAGS="$TEMP_LDFLAGS `curl-config --ldflags`"
         else
             break
         fi
         else
             break
         fi
-               echo yes
+        echo yes
         return 0
     done
         return 0
     done
-       
-    # dependency curl 
+
+    # dependency curl
     while true
     do
         if [ -z "$PKG_CONFIG" ]; then
     while true
     do
         if [ -z "$PKG_CONFIG" ]; then
-               break
+            break
         fi
         fi
-               $PKG_CONFIG libcurl
+        $PKG_CONFIG libcurl
         if [ $? -ne 0 ] ; then
             break
         fi
         if [ $? -ne 0 ] ; then
             break
         fi
-        CFLAGS="$CFLAGS `$PKG_CONFIG --cflags libcurl`"
-        LDFLAGS="$LDFLAGS `$PKG_CONFIG --libs libcurl`"
-               echo yes
+        TEMP_CFLAGS="$TEMP_CFLAGS `$PKG_CONFIG --cflags libcurl`"
+        TEMP_LDFLAGS="$TEMP_LDFLAGS `$PKG_CONFIG --libs libcurl`"
+        echo yes
         return 0
     done
         return 0
     done
-       
-    # dependency curl 
+
+    # dependency curl
     while true
     do
     while true
     do
+        which curl-config > /dev/null
+        if [ $? -ne 0 ]; then
+        break
+        fi
         curl-config --cflags > /dev/null
         if [ $? -eq 0 ]; then
         curl-config --cflags > /dev/null
         if [ $? -eq 0 ]; then
-            CFLAGS="$CFLAGS `curl-config --cflags`"
+            TEMP_CFLAGS="$TEMP_CFLAGS `curl-config --cflags`"
         else
             break
         fi
         curl-config --ldflags > /dev/null
         if [ $? -eq 0 ]; then
         else
             break
         fi
         curl-config --ldflags > /dev/null
         if [ $? -eq 0 ]; then
-            LDFLAGS="$LDFLAGS `curl-config --ldflags`"
+            TEMP_LDFLAGS="$TEMP_LDFLAGS `curl-config --ldflags`"
         else
             break
         fi
         else
             break
         fi
-        which curl-config > /dev/null
-        if [ $? -ne 0 ]; then
-               break
-        fi
-               echo yes
+        echo yes
         return 0
     done
         return 0
     done
-       
-       echo no
-       return 1
+
+    echo no
+    return 1
 }
 dependency_gtk3()
 {
     printf "checking for gtk3... "
 }
 dependency_gtk3()
 {
     printf "checking for gtk3... "
-    # dependency gtk3 
+    # dependency gtk3
     while true
     do
         if [ -z "$PKG_CONFIG" ]; then
     while true
     do
         if [ -z "$PKG_CONFIG" ]; then
-               break
+            break
         fi
         fi
-               $PKG_CONFIG gtk+-3.0
+        $PKG_CONFIG gtk+-3.0
         if [ $? -ne 0 ] ; then
             break
         fi
         if [ $? -ne 0 ] ; then
             break
         fi
-        CFLAGS="$CFLAGS `$PKG_CONFIG --cflags gtk+-3.0`"
-        LDFLAGS="$LDFLAGS `$PKG_CONFIG --libs gtk+-3.0`"
-        CFLAGS="$CFLAGS -DUI_GTK3"    
-        LDFLAGS="$LDFLAGS -lpthread"    
-               echo yes
+        TEMP_CFLAGS="$TEMP_CFLAGS `$PKG_CONFIG --cflags gtk+-3.0`"
+        TEMP_LDFLAGS="$TEMP_LDFLAGS `$PKG_CONFIG --libs gtk+-3.0`"
+        TEMP_CFLAGS="$TEMP_CFLAGS -DUI_GTK3"
+        TEMP_LDFLAGS="$TEMP_LDFLAGS -lpthread"
+        echo yes
         return 0
     done
         return 0
     done
-       
-       echo no
-       return 1
+
+    echo no
+    return 1
 }
 dependency_openssl()
 {
 }
 dependency_openssl()
 {
@@ -339,72 +339,57 @@ dependency_openssl()
     # dependency openssl platform="windows"
     while true
     do
     # dependency openssl platform="windows"
     while true
     do
-       if isnotplatform "windows"; then
+        if isnotplatform "windows"; then
             break
         fi
             break
         fi
-        LDFLAGS="$LDFLAGS -lssl -lcrypto"    
-               echo yes
+        TEMP_LDFLAGS="$TEMP_LDFLAGS -lssl -lcrypto"
+        echo yes
         return 0
     done
         return 0
     done
-       
+
     # dependency openssl platform="macos"
     while true
     do
     # dependency openssl platform="macos"
     while true
     do
-       if isnotplatform "macos"; then
+        if isnotplatform "macos"; then
             break
         fi
             break
         fi
-        LDFLAGS="$LDFLAGS -framework CoreFoundation"    
-               echo yes
+        TEMP_LDFLAGS="$TEMP_LDFLAGS -framework CoreFoundation"
+        echo yes
         return 0
     done
         return 0
     done
-       
+
     # dependency openssl platform="bsd"
     while true
     do
     # dependency openssl platform="bsd"
     while true
     do
-       if isnotplatform "bsd"; then
+        if isnotplatform "bsd"; then
             break
         fi
             break
         fi
-               if isplatform "macos"; then
+        if isplatform "macos"; then
             break
         fi
             break
         fi
-        LDFLAGS="$LDFLAGS -lssl -lcrypto"    
-               echo yes
+        TEMP_LDFLAGS="$TEMP_LDFLAGS -lssl -lcrypto"
+        echo yes
         return 0
     done
         return 0
     done
-       
-    # dependency openssl 
+
+    # dependency openssl
     while true
     do
         if [ -z "$PKG_CONFIG" ]; then
     while true
     do
         if [ -z "$PKG_CONFIG" ]; then
-               break
+            break
         fi
         fi
-               $PKG_CONFIG openssl
+        $PKG_CONFIG openssl
         if [ $? -ne 0 ] ; then
             break
         fi
         if [ $? -ne 0 ] ; then
             break
         fi
-        CFLAGS="$CFLAGS `$PKG_CONFIG --cflags openssl`"
-        LDFLAGS="$LDFLAGS `$PKG_CONFIG --libs openssl`"
-               echo yes
+        TEMP_CFLAGS="$TEMP_CFLAGS `$PKG_CONFIG --cflags openssl`"
+        TEMP_LDFLAGS="$TEMP_LDFLAGS `$PKG_CONFIG --libs openssl`"
+        echo yes
         return 0
     done
         return 0
     done
-       
-       echo no
-       return 1
-}
-dependency_motif()
-{
-    printf "checking for motif... "
-    # dependency motif 
-    while true
-    do
-        CFLAGS="$CFLAGS -DUI_MOTIF"    
-        LDFLAGS="$LDFLAGS -lXm -lXt -lX11 -lpthread"    
-               echo yes
-        return 0
-    done
-       
-       echo no
-       return 1
+
+    echo no
+    return 1
 }
 dependency_libxml2()
 {
 }
 dependency_libxml2()
 {
@@ -412,91 +397,106 @@ dependency_libxml2()
     # dependency libxml2 platform="windows"
     while true
     do
     # dependency libxml2 platform="windows"
     while true
     do
-       if isnotplatform "windows"; then
+        if isnotplatform "windows"; then
             break
         fi
         xml2-config --cflags > /dev/null
         if [ $? -eq 0 ]; then
             break
         fi
         xml2-config --cflags > /dev/null
         if [ $? -eq 0 ]; then
-            CFLAGS="$CFLAGS `xml2-config --cflags`"
+            TEMP_CFLAGS="$TEMP_CFLAGS `xml2-config --cflags`"
         else
             break
         fi
         xml2-config --libs > /dev/null
         if [ $? -eq 0 ]; then
         else
             break
         fi
         xml2-config --libs > /dev/null
         if [ $? -eq 0 ]; then
-            LDFLAGS="$LDFLAGS `xml2-config --libs`"
+            TEMP_LDFLAGS="$TEMP_LDFLAGS `xml2-config --libs`"
         else
             break
         fi
         else
             break
         fi
-               echo yes
+        echo yes
         return 0
     done
         return 0
     done
-       
+
     # dependency libxml2 platform="macos"
     while true
     do
     # dependency libxml2 platform="macos"
     while true
     do
-       if isnotplatform "macos"; then
+        if isnotplatform "macos"; then
             break
         fi
         xml2-config --cflags > /dev/null
         if [ $? -eq 0 ]; then
             break
         fi
         xml2-config --cflags > /dev/null
         if [ $? -eq 0 ]; then
-            CFLAGS="$CFLAGS `xml2-config --cflags`"
+            TEMP_CFLAGS="$TEMP_CFLAGS `xml2-config --cflags`"
         else
             break
         fi
         xml2-config --libs > /dev/null
         if [ $? -eq 0 ]; then
         else
             break
         fi
         xml2-config --libs > /dev/null
         if [ $? -eq 0 ]; then
-            LDFLAGS="$LDFLAGS `xml2-config --libs`"
+            TEMP_LDFLAGS="$TEMP_LDFLAGS `xml2-config --libs`"
         else
             break
         fi
         else
             break
         fi
-               echo yes
+        echo yes
         return 0
     done
         return 0
     done
-       
-    # dependency libxml2 
+
+    # dependency libxml2
     while true
     do
         if [ -z "$PKG_CONFIG" ]; then
     while true
     do
         if [ -z "$PKG_CONFIG" ]; then
-               break
+            break
         fi
         fi
-               $PKG_CONFIG libxml-2.0
+        $PKG_CONFIG libxml-2.0
         if [ $? -ne 0 ] ; then
             break
         fi
         if [ $? -ne 0 ] ; then
             break
         fi
-        CFLAGS="$CFLAGS `$PKG_CONFIG --cflags libxml-2.0`"
-        LDFLAGS="$LDFLAGS `$PKG_CONFIG --libs libxml-2.0`"
-               echo yes
+        TEMP_CFLAGS="$TEMP_CFLAGS `$PKG_CONFIG --cflags libxml-2.0`"
+        TEMP_LDFLAGS="$TEMP_LDFLAGS `$PKG_CONFIG --libs libxml-2.0`"
+        echo yes
         return 0
     done
         return 0
     done
-       
-    # dependency libxml2 
+
+    # dependency libxml2
     while true
     do
         xml2-config --cflags > /dev/null
         if [ $? -eq 0 ]; then
     while true
     do
         xml2-config --cflags > /dev/null
         if [ $? -eq 0 ]; then
-            CFLAGS="$CFLAGS `xml2-config --cflags`"
+            TEMP_CFLAGS="$TEMP_CFLAGS `xml2-config --cflags`"
         else
             break
         fi
         xml2-config --libs > /dev/null
         if [ $? -eq 0 ]; then
         else
             break
         fi
         xml2-config --libs > /dev/null
         if [ $? -eq 0 ]; then
-            LDFLAGS="$LDFLAGS `xml2-config --libs`"
+            TEMP_LDFLAGS="$TEMP_LDFLAGS `xml2-config --libs`"
         else
             break
         fi
         else
             break
         fi
-               echo yes
+        echo yes
+        return 0
+    done
+
+    echo no
+    return 1
+}
+dependency_motif()
+{
+    printf "checking for motif... "
+    # dependency motif
+    while true
+    do
+        TEMP_CFLAGS="$TEMP_CFLAGS -DUI_MOTIF"
+        TEMP_LDFLAGS="$TEMP_LDFLAGS -lXm -lXt -lX11 -lpthread"
+        echo yes
         return 0
     done
         return 0
     done
-       
-       echo no
-       return 1
+
+    echo no
+    return 1
 }
 
 DEPENDENCIES_FAILED=
 ERROR=0
 # general dependencies
 }
 
 DEPENDENCIES_FAILED=
 ERROR=0
 # general dependencies
-CFLAGS=
-LDFLAGS=
+TEMP_CFLAGS=
+TEMP_LDFLAGS=
 while true
 do
     if isnotplatform "unix"; then
 while true
 do
     if isnotplatform "unix"; then
@@ -507,29 +507,29 @@ do
     fi
     while true
     do
     fi
     while true
     do
-        
-               cat >> $TEMP_DIR/make.mk << __EOF__
+
+        cat >> "$TEMP_DIR/make.mk" << __EOF__
 OBJ_EXT = o
 LIB_EXT = a
 PACKAGE_SCRIPT = package_unix.sh
 
 __EOF__
 OBJ_EXT = o
 LIB_EXT = a
 PACKAGE_SCRIPT = package_unix.sh
 
 __EOF__
-        
+
         break
     done
         break
     done
-    
+
     break
 done
 while true
 do
     while true
     do
     break
 done
 while true
 do
     while true
     do
-        
-        LDFLAGS="$LDFLAGS -lpthread"    
-        
+
+        TEMP_LDFLAGS="$TEMP_LDFLAGS -lpthread"
+
         break
     done
         break
     done
-    
+
     break
 done
 while true
     break
 done
 while true
@@ -542,26 +542,26 @@ do
     fi
     while true
     do
     fi
     while true
     do
-        
-        CFLAGS="$CFLAGS -I/usr/local/include"    
-        LDFLAGS="$LDFLAGS -L/usr/local/lib"    
-        
+
+        TEMP_CFLAGS="$TEMP_CFLAGS -I/usr/local/include"
+        TEMP_LDFLAGS="$TEMP_LDFLAGS -L/usr/local/lib"
+
         break
     done
         break
     done
-    
+
     break
 done
 
 # add general dependency flags to config.mk
     break
 done
 
 # add general dependency flags to config.mk
-echo >> $TEMP_DIR/config.mk
-if [ ! -z "${CFLAGS}" ]; then
-    echo "CFLAGS += $CFLAGS" >> $TEMP_DIR/config.mk
+echo >> "$TEMP_DIR/config.mk"
+if [ -n "${TEMP_CFLAGS}" ]; then
+    echo "CFLAGS += $TEMP_CFLAGS" >> $TEMP_DIR/config.mk
 fi
 fi
-if [ ! -z "${CXXFLAGS}" ]; then
-    echo "CXXFLAGS += $CXXFLAGS" >> $TEMP_DIR/config.mk
+if [ -n "${TEMP_CXXFLAGS}" ]; then
+    echo "CXXFLAGS += $TEMP_CXXFLAGS" >> $TEMP_DIR/config.mk
 fi
 fi
-if [ ! -z "${LDFLAGS}" ]; then
-    echo "LDFLAGS += $LDFLAGS" >> $TEMP_DIR/config.mk
+if [ -n "${TEMP_LDFLAGS}" ]; then
+    echo "LDFLAGS += $TEMP_LDFLAGS" >> $TEMP_DIR/config.mk
 fi
 
 #
 fi
 
 #
@@ -569,149 +569,153 @@ fi
 #
 checkopt_toolkit_gtk3()
 {
 #
 checkopt_toolkit_gtk3()
 {
-       VERR=0
-       dependency_gtk3
-       if [ $? -ne 0 ]; then
-               VERR=1
-       fi
-       if [ $VERR -ne 0 ]; then
-               return 1
-       fi
-       cat >> $TEMP_DIR/make.mk << __EOF__
+    VERR=0
+    dependency_gtk3
+    if [ $? -ne 0 ]; then
+        VERR=1
+    fi
+    if [ $VERR -ne 0 ]; then
+        return 1
+    fi
+    cat >> "$TEMP_DIR/make.mk" << __EOF__
 TOOLKIT = gtk
 GTKOBJ = draw_cairo.o
 TOOLKIT = gtk
 GTKOBJ = draw_cairo.o
+MZUI = gtk_pathbar.c
+MZUI += gtk_browser.c
 
 __EOF__
 
 __EOF__
-       return 0
+    return 0
 }
 checkopt_toolkit_motif()
 {
 }
 checkopt_toolkit_motif()
 {
-       VERR=0
-       dependency_motif
-       if [ $? -ne 0 ]; then
-               VERR=1
-       fi
-       if [ $VERR -ne 0 ]; then
-               return 1
-       fi
-       cat >> $TEMP_DIR/make.mk << __EOF__
+    VERR=0
+    dependency_motif
+    if [ $? -ne 0 ]; then
+        VERR=1
+    fi
+    if [ $VERR -ne 0 ]; then
+        return 1
+    fi
+    cat >> "$TEMP_DIR/make.mk" << __EOF__
 TOOLKIT = motif
 TOOLKIT = motif
+MZUI = motif_pathbar.c
+MZUI += motif_browser.c
 
 __EOF__
 
 __EOF__
-       return 0
+    return 0
 }
 
 #
 # TARGETS
 #
 }
 
 #
 # TARGETS
 #
-CFLAGS=
-CXXFLAGS=
-LDFLAGS=
+TEMP_CFLAGS=
+TEMP_CXXFLAGS=
+TEMP_LDFLAGS=
 
 # Target: tk
 
 # Target: tk
-CFLAGS=
-LDFLAGS=
-CXXFLAGS=
+TEMP_CFLAGS=
+TEMP_LDFLAGS=
+TEMP_CXXFLAGS=
 
 
 # Features
 
 # Option: --toolkit
 if [ -z $OPT_TOOLKIT ]; then
 
 
 # Features
 
 # Option: --toolkit
 if [ -z $OPT_TOOLKIT ]; then
-       SAVED_ERROR=$ERROR
-       SAVED_DEPENDENCIES_FAILED=$DEPENDENCIES_FAILED
-       ERROR=0
-       while true
-       do
-               checkopt_toolkit_motif
-               if [ $? -eq 0 ]; then
-                       echo "  toolkit: motif" >> $TEMP_DIR/options
-                       ERROR=0
-                       break
-               fi
-               checkopt_toolkit_gtk3
-               if [ $? -eq 0 ]; then
-                       echo "  toolkit: gtk3" >> $TEMP_DIR/options
-                       ERROR=0
-                       break
-               fi
-               break
-       done
-       if [ $ERROR -ne 0 ]; then
-               SAVED_ERROR=1
-       fi
-       ERROR=$SAVED_ERROR
-       DEPENDENCIES_FAILED=$SAVED_DEPENDENCIES_FAILED=
+    SAVED_ERROR="$ERROR"
+    SAVED_DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED"
+    ERROR=0
+    while true
+    do
+        checkopt_toolkit_motif
+        if [ $? -eq 0 ]; then
+            echo "  toolkit: motif" >> "$TEMP_DIR/options"
+            ERROR=0
+            break
+        fi
+        checkopt_toolkit_gtk3
+        if [ $? -eq 0 ]; then
+            echo "  toolkit: gtk3" >> "$TEMP_DIR/options"
+            ERROR=0
+            break
+        fi
+        break
+    done
+    if [ $ERROR -ne 0 ]; then
+        SAVED_ERROR=1
+    fi
+    ERROR="$SAVED_ERROR"
+    DEPENDENCIES_FAILED="$SAVED_DEPENDENCIES_FAILED"
 else
 else
-       if false; then
-               false
-       elif [ $OPT_TOOLKIT = "gtk3" ]; then
-               echo "  toolkit: $OPT_TOOLKIT" >> $TEMP_DIR/options
-               checkopt_toolkit_gtk3
-               if [ $? -ne 0 ]; then
-                       ERROR=1
-               fi
-       elif [ $OPT_TOOLKIT = "motif" ]; then
-               echo "  toolkit: $OPT_TOOLKIT" >> $TEMP_DIR/options
-               checkopt_toolkit_motif
-               if [ $? -ne 0 ]; then
-                       ERROR=1
-               fi
-       fi
-fi
-
-echo >> $TEMP_DIR/config.mk
-if [ ! -z "${CFLAGS}" ]; then
-    echo "TK_CFLAGS  += $CFLAGS" >> $TEMP_DIR/config.mk
-fi
-if [ ! -z "${CXXFLAGS}" ]; then
-    echo "TK_CXXFLAGS += $CXXFLAGS" >> $TEMP_DIR/config.mk
-fi
-if [ ! -z "${LDFLAGS}" ]; then
-    echo "TK_LDFLAGS += $LDFLAGS" >> $TEMP_DIR/config.mk
+    if false; then
+        false
+    elif [ "$OPT_TOOLKIT" = "gtk3" ]; then
+        echo "  toolkit: $OPT_TOOLKIT" >> $TEMP_DIR/options
+        checkopt_toolkit_gtk3
+        if [ $? -ne 0 ]; then
+            ERROR=1
+        fi
+    elif [ "$OPT_TOOLKIT" = "motif" ]; then
+        echo "  toolkit: $OPT_TOOLKIT" >> $TEMP_DIR/options
+        checkopt_toolkit_motif
+        if [ $? -ne 0 ]; then
+            ERROR=1
+        fi
+    fi
+fi
+
+echo >> "$TEMP_DIR/config.mk"
+if [ -n "${TEMP_CFLAGS}" ]; then
+    echo "TK_CFLAGS  += $TEMP_CFLAGS" >> "$TEMP_DIR/config.mk"
+fi
+if [ -n "${TEMP_CXXFLAGS}" ]; then
+    echo "TK_CXXFLAGS += $TEMP_CXXFLAGS" >> "$TEMP_DIR/config.mk"
+fi
+if [ -n "${TEMP_LDFLAGS}" ]; then
+    echo "TK_LDFLAGS += $TEMP_LDFLAGS" >> "$TEMP_DIR/config.mk"
 fi
 
 # Target: dav
 fi
 
 # Target: dav
-CFLAGS=
-LDFLAGS=
-CXXFLAGS=
+TEMP_CFLAGS=
+TEMP_LDFLAGS=
+TEMP_CXXFLAGS=
 
 dependency_curl
 if [ $? -ne 0 ]; then
 
 dependency_curl
 if [ $? -ne 0 ]; then
-       DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED curl "
-       ERROR=1
+    DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED curl "
+    ERROR=1
 fi
 dependency_libxml2
 if [ $? -ne 0 ]; then
 fi
 dependency_libxml2
 if [ $? -ne 0 ]; then
-       DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED libxml2 "
-       ERROR=1
+    DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED libxml2 "
+    ERROR=1
 fi
 dependency_openssl
 if [ $? -ne 0 ]; then
 fi
 dependency_openssl
 if [ $? -ne 0 ]; then
-       DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED openssl "
-       ERROR=1
+    DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED openssl "
+    ERROR=1
 fi
 
 # Features
 
 
 fi
 
 # Features
 
 
-echo >> $TEMP_DIR/config.mk
-if [ ! -z "${CFLAGS}" ]; then
-    echo "DAV_CFLAGS  += $CFLAGS" >> $TEMP_DIR/config.mk
+echo >> "$TEMP_DIR/config.mk"
+if [ -n "${TEMP_CFLAGS}" ]; then
+    echo "DAV_CFLAGS  += $TEMP_CFLAGS" >> "$TEMP_DIR/config.mk"
 fi
 fi
-if [ ! -z "${CXXFLAGS}" ]; then
-    echo "DAV_CXXFLAGS += $CXXFLAGS" >> $TEMP_DIR/config.mk
+if [ -n "${TEMP_CXXFLAGS}" ]; then
+    echo "DAV_CXXFLAGS += $TEMP_CXXFLAGS" >> "$TEMP_DIR/config.mk"
 fi
 fi
-if [ ! -z "${LDFLAGS}" ]; then
-    echo "DAV_LDFLAGS += $LDFLAGS" >> $TEMP_DIR/config.mk
+if [ -n "${TEMP_LDFLAGS}" ]; then
+    echo "DAV_LDFLAGS += $TEMP_LDFLAGS" >> "$TEMP_DIR/config.mk"
 fi
 
 if [ $ERROR -ne 0 ]; then
 fi
 
 if [ $ERROR -ne 0 ]; then
-       echo
-       echo "Error: Unresolved dependencies"
-       echo $DEPENDENCIES_FAILED
-       rm -Rf $TEMP_DIR
-       exit 1
+    echo
+    echo "Error: Unresolved dependencies"
+    echo "$DEPENDENCIES_FAILED"
+    rm -Rf "$TEMP_DIR"
+    exit 1
 fi
 
 echo "configure finished"
 fi
 
 echo "configure finished"
@@ -720,9 +724,9 @@ echo "Build Config:"
 echo "  PREFIX:    $PREFIX"
 echo "  TOOLCHAIN: $TOOLCHAIN_NAME"
 echo "Options:"
 echo "  PREFIX:    $PREFIX"
 echo "  TOOLCHAIN: $TOOLCHAIN_NAME"
 echo "Options:"
-cat $TEMP_DIR/options
+cat "$TEMP_DIR/options"
 echo
 echo
-cat $TEMP_DIR/config.mk $TEMP_DIR/make.mk > config.mk
-rm -Rf $TEMP_DIR
+cat "$TEMP_DIR/config.mk" "$TEMP_DIR/make.mk" > config.mk
+rm -Rf "$TEMP_DIR"
 
 
 
 
index 80068be..5c88ee9 100644 (file)
@@ -2,9 +2,9 @@
 
 #foreach( $var in $vars )
 #if( $var.exec )
 
 #foreach( $var in $vars )
 #if( $var.exec )
-${var.name}=`${var.value}`
+${var.varName}=`${var.value}`
 #else
 #else
-${var.name}=${var.value}
+${var.varName}=${var.value}
 #end
 #end
 
 #end
 #end
 
@@ -53,13 +53,13 @@ OS=`uname -s`
 OS_VERSION=`uname -r`
 
 TEMP_DIR=".tmp-`uname -n`"
 OS_VERSION=`uname -r`
 
 TEMP_DIR=".tmp-`uname -n`"
-mkdir -p $TEMP_DIR
+mkdir -p "$TEMP_DIR"
 if [ $? -ne 0 ]; then
 if [ $? -ne 0 ]; then
-       echo "Cannot create tmp dir"
-       echo "Abort"
+    echo "Cannot create tmp dir"
+    echo "Abort"
 fi
 fi
-touch $TEMP_DIR/options
-touch $TEMP_DIR/features
+touch "$TEMP_DIR/options"
+touch "$TEMP_DIR/features"
 
 # features
 #foreach( $feature in $features )
 
 # features
 #foreach( $feature in $features )
@@ -71,8 +71,8 @@ ${feature.getVarName()}=on
 # help text
 printhelp()
 {
 # help text
 printhelp()
 {
-       echo "Usage: $0 [OPTIONS]..."
-       cat << __EOF__
+    echo "Usage: $0 [OPTIONS]..."
+    cat << __EOF__
 Installation directories:
   --prefix=PREFIX         path prefix for architecture-independent files
                           [/usr]
 Installation directories:
   --prefix=PREFIX         path prefix for architecture-independent files
                           [/usr]
@@ -114,70 +114,70 @@ __EOF__
 }
 
 #
 }
 
 #
-# parse arguments 
+# parse arguments
 #
 #set( $D = '$' )
 #
 #set( $D = '$' )
-for ARG in $@
+for ARG in "$@"
 do
     case "$ARG" in
 do
     case "$ARG" in
-               "--prefix="*)         PREFIX=${D}{ARG#--prefix=} ;;
-               "--exec-prefix="*)    EPREFIX=${D}{ARG#--exec-prefix=} ;;
-               "--bindir="*)         BINDIR=${D}{ARG#----bindir=} ;;
-               "--sbindir="*)        SBINDIR=${D}{ARG#--sbindir=} ;;
-               "--libdir="*)         LIBDIR=${D}{ARG#--libdir=} ;;
-               "--libexecdir="*)     LIBEXECDIR=${D}{ARG#--libexecdir=} ;;
-               "--datadir="*)        DATADIR=${D}{ARG#--datadir=} ;;
-               "--sysconfdir="*)     SYSCONFDIR=${D}{ARG#--sysconfdir=} ;;
-               "--sharedstatedir="*) SHAREDSTATEDIR=${D}{ARG#--sharedstatedir=} ;;
-               "--localstatedir="*)  LOCALSTATEDIR=${D}{ARG#--localstatedir=} ;;
-               "--includedir="*)     INCLUDEDIR=${D}{ARG#--includedir=} ;;
-               "--infodir="*)        INFODIR=${D}{ARG#--infodir=} ;;
-               "--mandir"*)          MANDIR=${D}{ARG#--mandir} ;;
-               "--help"*) printhelp; exit 1 ;;
-       #foreach( $opt in $options )
-       "--${opt.getArgument()}="*) ${opt.getVarName()}=${D}{ARG#--${opt.getArgument()}=} ;;
+        "--prefix="*)         PREFIX=${D}{ARG#--prefix=} ;;
+        "--exec-prefix="*)    EPREFIX=${D}{ARG#--exec-prefix=} ;;
+        "--bindir="*)         BINDIR=${D}{ARG#----bindir=} ;;
+        "--sbindir="*)        SBINDIR=${D}{ARG#--sbindir=} ;;
+        "--libdir="*)         LIBDIR=${D}{ARG#--libdir=} ;;
+        "--libexecdir="*)     LIBEXECDIR=${D}{ARG#--libexecdir=} ;;
+        "--datadir="*)        DATADIR=${D}{ARG#--datadir=} ;;
+        "--sysconfdir="*)     SYSCONFDIR=${D}{ARG#--sysconfdir=} ;;
+        "--sharedstatedir="*) SHAREDSTATEDIR=${D}{ARG#--sharedstatedir=} ;;
+        "--localstatedir="*)  LOCALSTATEDIR=${D}{ARG#--localstatedir=} ;;
+        "--includedir="*)     INCLUDEDIR=${D}{ARG#--includedir=} ;;
+        "--infodir="*)        INFODIR=${D}{ARG#--infodir=} ;;
+        "--mandir"*)          MANDIR=${D}{ARG#--mandir} ;;
+        "--help"*) printhelp; rm -Rf "$TEMP_DIR"; exit 1 ;;
+    #foreach( $opt in $options )
+        "--${opt.getArgument()}="*) ${opt.getVarName()}=${D}{ARG#--${opt.getArgument()}=} ;;
     #end
     #end
-       #foreach( $feature in $features )
-               "--enable-${feature.arg}") ${feature.getVarName()}=on ;;
-               "--disable-${feature.arg}") unset ${feature.getVarName()} ;;
-       #end
-               "-"*) echo "unknown option: $ARG"; exit 1 ;;
-       esac
+    #foreach( $feature in $features )
+        "--enable-${feature.arg}") ${feature.getVarName()}=on ;;
+        "--disable-${feature.arg}") unset ${feature.getVarName()} ;;
+    #end
+        "-"*) echo "unknown option: $ARG"; rm -Rf "$TEMP_DIR"; exit 1 ;;
+    esac
 done
 
 # set dir variables
 if [ -z "$BINDIR" ]; then
 done
 
 # set dir variables
 if [ -z "$BINDIR" ]; then
-       BINDIR=$EPREFIX/bin
+    BINDIR=$EPREFIX/bin
 fi
 if [ -z "$SBINDIR" ]; then
 fi
 if [ -z "$SBINDIR" ]; then
-       SBINDIR=$EPREFIX/sbin
+    SBINDIR=$EPREFIX/sbin
 fi
 if [ -z "$LIBDIR" ]; then
 fi
 if [ -z "$LIBDIR" ]; then
-       LIBDIR=$EPREFIX/lib
+    LIBDIR=$EPREFIX/lib
 fi
 if [ -z "$LIBEXEC" ]; then
 fi
 if [ -z "$LIBEXEC" ]; then
-       LIBEXECDIR=$EPREFIX/libexec
+    LIBEXECDIR=$EPREFIX/libexec
 fi
 if [ -z "$DATADIR" ]; then
 fi
 if [ -z "$DATADIR" ]; then
-       DATADIR=$PREFIX/share
+    DATADIR=$PREFIX/share
 fi
 if [ -z "$SYSCONFDIR" ]; then
 fi
 if [ -z "$SYSCONFDIR" ]; then
-       SYSCONFDIR=$PREFIX/etc
+    SYSCONFDIR=$PREFIX/etc
 fi
 if [ -z "$SHAREDSTATEDIR" ]; then
 fi
 if [ -z "$SHAREDSTATEDIR" ]; then
-       SHAREDSTATEDIR=$PREFIX/com
+    SHAREDSTATEDIR=$PREFIX/com
 fi
 if [ -z "$LOCALSTATEDIR" ]; then
 fi
 if [ -z "$LOCALSTATEDIR" ]; then
-       LOCALSTATEDIR=$PREFIX/var
+    LOCALSTATEDIR=$PREFIX/var
 fi
 if [ -z "$INCLUDEDIR" ]; then
 fi
 if [ -z "$INCLUDEDIR" ]; then
-       INCLUDEDIR=$PREFIX/include
+    INCLUDEDIR=$PREFIX/include
 fi
 if [ -z "$INFODIR" ]; then
 fi
 if [ -z "$INFODIR" ]; then
-       INFODIR=$PREFIX/info
+    INFODIR=$PREFIX/info
 fi
 if [ -z "$MANDIR" ]; then
 fi
 if [ -z "$MANDIR" ]; then
-       MANDIR=$PREFIX/man
+    MANDIR=$PREFIX/man
 fi
 
 which pkg-config > /dev/null
 fi
 
 which pkg-config > /dev/null
@@ -190,19 +190,19 @@ fi
 # Simple uname based platform detection
 # $PLATFORM is used for platform dependent dependency selection
 printf "detect platform... "
 # Simple uname based platform detection
 # $PLATFORM is used for platform dependent dependency selection
 printf "detect platform... "
-if [ $OS = SunOS ]; then
+if [ "$OS" = "SunOS" ]; then
     PLATFORM="solaris sunos unix svr4"
 fi
     PLATFORM="solaris sunos unix svr4"
 fi
-if [ $OS = Linux ]; then
+if [ "$OS" = "Linux" ]; then
     PLATFORM="linux unix"
 fi
     PLATFORM="linux unix"
 fi
-if [ $OS = FreeBSD ]; then
+if [ "$OS" = "FreeBSD" ]; then
     PLATFORM="freebsd bsd unix"
 fi
     PLATFORM="freebsd bsd unix"
 fi
-if [ $OS = Darwin ]; then
+if [ "$OS" = "Darwin" ]; then
     PLATFORM="macos osx bsd unix"
 fi
     PLATFORM="macos osx bsd unix"
 fi
-echo $OS | grep "MINGW" > /dev/null
+echo "$OS" | grep -i "MINGW" > /dev/null
 if [ $? -eq 0 ]; then
     PLATFORM="windows mingw"
 fi
 if [ $? -eq 0 ]; then
     PLATFORM="windows mingw"
 fi
@@ -213,8 +213,8 @@ fi
 
 for p in $PLATFORM
 do
 
 for p in $PLATFORM
 do
-       PLATFORM_NAME=$p
-       break
+    PLATFORM_NAME=$p
+    break
 done
 echo $PLATFORM_NAME
 
 done
 echo $PLATFORM_NAME
 
@@ -222,7 +222,7 @@ isplatform()
 {
     for p in $PLATFORM
     do
 {
     for p in $PLATFORM
     do
-        if [ $p = $1 ]; then
+        if [ "$p" = "$1" ]; then
             return 0
         fi
     done
             return 0
         fi
     done
@@ -232,7 +232,7 @@ isnotplatform()
 {
     for p in $PLATFORM
     do
 {
     for p in $PLATFORM
     do
-        if [ $p = $1 ]; then
+        if [ "$p" = "$1" ]; then
             return 1
         fi
     done
             return 1
         fi
     done
@@ -240,14 +240,14 @@ isnotplatform()
 }
 
 # generate config.mk and config.h
 }
 
 # generate config.mk and config.h
-cat > $TEMP_DIR/config.mk << __EOF__
+cat > "$TEMP_DIR/config.mk" << __EOF__
 #
 # config.mk generated by configure
 #
 
 # general vars
 #foreach( $var in $vars )
 #
 # config.mk generated by configure
 #
 
 # general vars
 #foreach( $var in $vars )
-${var.name}=$${var.name}
+${var.varName}=$${var.varName}
 #end
 
 #if ( ! $project.hasVar("PREFIX") )
 #end
 
 #if ( ! $project.hasVar("PREFIX") )
@@ -293,7 +293,7 @@ MANDIR=$MANDIR
 
 __EOF__
 
 
 __EOF__
 
-echo > $TEMP_DIR/make.mk
+echo > "$TEMP_DIR/make.mk"
 
 ENV_CFLAGS=$CFLAGS
 ENV_LDFLAGS=$LDFLAGS
 
 ENV_CFLAGS=$CFLAGS
 ENV_LDFLAGS=$LDFLAGS
@@ -304,15 +304,15 @@ ENV_CXXFLAGS=$CXXFLAGS
 . make/toolchain.sh
 
 # add user specified flags to config.mk
 . make/toolchain.sh
 
 # add user specified flags to config.mk
-echo >> $TEMP_DIR/config.mk
-if [ ! -z "${ENV_CFLAGS}" ]; then
-    echo "CFLAGS += $ENV_CFLAGS" >> $TEMP_DIR/config.mk
+echo "# project specific flags" >> "$TEMP_DIR/config.mk"
+if [ -n "${ENV_CFLAGS}" ]; then
+    echo "CFLAGS += $ENV_CFLAGS" >> "$TEMP_DIR/config.mk"
 fi
 fi
-if [ ! -z "${ENV_CXXFLAGS}" ]; then
-    echo "CXXFLAGS += $ENV_CXXFLAGS" >> $TEMP_DIR/config.mk
+if [ -n "${ENV_CXXFLAGS}" ]; then
+    echo "CXXFLAGS += $ENV_CXXFLAGS" >> "$TEMP_DIR/config.mk"
 fi
 fi
-if [ ! -z "${ENV_LDFLAGS}" ]; then
-    echo "LDFLAGS += $ENV_LDFLAGS" >> $TEMP_DIR/config.mk
+if [ -n "${ENV_LDFLAGS}" ]; then
+    echo "LDFLAGS += $ENV_LDFLAGS" >> "$TEMP_DIR/config.mk"
 fi
 
 #
 fi
 
 #
@@ -324,63 +324,63 @@ dependency_${dependency.name}()
 {
     printf "checking for ${dependency.name}... "
     #foreach( $sub in $dependency.getSubdependencies() )
 {
     printf "checking for ${dependency.name}... "
     #foreach( $sub in $dependency.getSubdependencies() )
-    # dependency $sub.name $sub.getPlatformString()
+    # dependency $sub.getFullName()
     while true
     do
     while true
     do
-       #if( $sub.platform )
-       if isnotplatform "${sub.platform}"; then
+        #if( $sub.platform )
+        if isnotplatform "${sub.platform}"; then
             break
         fi
             break
         fi
-       #end
-               #foreach( $not in $sub.getNotList() )
-               if isplatform "${not}"; then
+        #end
+        #foreach( $not in $sub.getNotList() )
+        if isplatform "${not}"; then
             break
         fi
             break
         fi
-               #end
+        #end
         #if( $sub.pkgconfig.size() > 0 )
         if [ -z "$PKG_CONFIG" ]; then
         #if( $sub.pkgconfig.size() > 0 )
         if [ -z "$PKG_CONFIG" ]; then
-               break
+            break
+        fi
+        #end
+        #foreach( $test in $sub.tests )
+        $test > /dev/null
+        if [ $? -ne 0 ]; then
+        break
         fi
         #end
         #foreach( $pkg in $sub.pkgconfig )
         fi
         #end
         #foreach( $pkg in $sub.pkgconfig )
-               $PKG_CONFIG $pkg.getPkgConfigParam()
+        $pkg.getPkgConfigTestQuery()
         if [ $? -ne 0 ] ; then
             break
         fi
         if [ $? -ne 0 ] ; then
             break
         fi
-        CFLAGS="$CFLAGS `$PKG_CONFIG --cflags $pkg.getPkgConfigParam()`"
-        LDFLAGS="$LDFLAGS `$PKG_CONFIG --libs $pkg.getPkgConfigParam()`"
+        TEMP_CFLAGS="$TEMP_CFLAGS `$PKG_CONFIG --cflags $pkg.name`"
+        TEMP_LDFLAGS="$TEMP_LDFLAGS `$PKG_CONFIG --libs $pkg.name`"
         #end
         #foreach( $flags in $sub.flags )
         #if( $flags.exec )
         $flags.value > /dev/null
         if [ $? -eq 0 ]; then
         #end
         #foreach( $flags in $sub.flags )
         #if( $flags.exec )
         $flags.value > /dev/null
         if [ $? -eq 0 ]; then
-            $flags.varName="$$flags.varName `$flags.value`"
+            TEMP_$flags.varName="$TEMP_$flags.varName `$flags.value`"
         else
             break
         fi
         #else
         else
             break
         fi
         #else
-        $flags.varName="$$flags.varName $flags.value"    
+        TEMP_$flags.varName="$TEMP_$flags.varName $flags.value"
         #end
         #end
         #end
         #end
-        #foreach( $test in $sub.tests )
-        $test > /dev/null
-        if [ $? -ne 0 ]; then
-               break
-        fi
-        #end
-               #if ( $sub.make.length() > 0 )
-               cat >> $TEMP_DIR/make.mk << __EOF__
-# Dependency: $dependency.name         
+        #if ( $sub.make.length() > 0 )
+        cat >> $TEMP_DIR/make.mk << __EOF__
+# Dependency: $dependency.name
 $sub.make
 __EOF__
         #end
 $sub.make
 __EOF__
         #end
-               echo yes
+        echo yes
         return 0
     done
         return 0
     done
-       
-       #end
-       echo no
-       return 1
+
+    #end
+    echo no
+    return 1
 }
 #end
 
 }
 #end
 
@@ -388,21 +388,21 @@ DEPENDENCIES_FAILED=
 ERROR=0
 #if( $dependencies.size() > 0 )
 # general dependencies
 ERROR=0
 #if( $dependencies.size() > 0 )
 # general dependencies
-CFLAGS=
-LDFLAGS=
+TEMP_CFLAGS=
+TEMP_LDFLAGS=
 #foreach( $dependency in $dependencies )
 while true
 do
 #foreach( $dependency in $dependencies )
 while true
 do
-       #if( $dependency.platform )
+    #if( $dependency.platform )
     if isnotplatform "${dependency.platform}"; then
         break
     fi
     #end
     if isnotplatform "${dependency.platform}"; then
         break
     fi
     #end
-       #foreach( $not in $dependency.getNotList() )
+    #foreach( $not in $dependency.getNotList() )
     if isplatform "${not}"; then
         break
     fi
     if isplatform "${not}"; then
         break
     fi
-       #end
+    #end
     while true
     do
         #if( $dependency.pkgconfig.size() > 0 )
     while true
     do
         #if( $dependency.pkgconfig.size() > 0 )
@@ -412,54 +412,54 @@ do
         fi
         #end
         #foreach( $pkg in $dependency.pkgconfig )
         fi
         #end
         #foreach( $pkg in $dependency.pkgconfig )
-        printf "checking for pkg-config package $pkg.getPkgConfigParam()... "
-               $PKG_CONFIG $pkg.getPkgConfigParam()
+        printf "checking for pkg-config package $pkg.name... "
+        $pkg.getPkgConfigTestQuery()
         if [ $? -ne 0 ]; then
             echo no
             ERROR=1
             break
         fi
         echo yes
         if [ $? -ne 0 ]; then
             echo no
             ERROR=1
             break
         fi
         echo yes
-        CFLAGS="$CFLAGS `$PKG_CONFIG --cflags $pkg.getPkgConfigParam()`"
-        LDFLAGS="$LDFLAGS `$PKG_CONFIG --libs $pkg.getPkgConfigParam()`"
+        TEMP_CFLAGS="$TEMP_CFLAGS `$PKG_CONFIG --cflags $pkg.name`"
+        TEMP_LDFLAGS="$TEMP_LDFLAGS `$PKG_CONFIG --libs $pkg.name`"
         #end
         #end
-        
+
         #foreach( $flags in $dependency.flags )
         #if( $flags.exec )
         $flags.value > /dev/null
         if [ $? -ne 0 ]; then
         #foreach( $flags in $dependency.flags )
         #if( $flags.exec )
         $flags.value > /dev/null
         if [ $? -ne 0 ]; then
-            $flags.varName="$$flags.varName `$flags.value`"
+            TEMP_$flags.varName="$TEMP_$flags.varName `$flags.value`"
         else
             ERROR=1
             break
         fi
         #else
         else
             ERROR=1
             break
         fi
         #else
-        $flags.varName="$$flags.varName $flags.value"    
+        TEMP_$flags.varName="$TEMP_$flags.varName $flags.value"
         #end
         #end
         #end
         #end
-               #if ( $dependency.make.length() > 0 )
-               cat >> $TEMP_DIR/make.mk << __EOF__
+        #if ( $dependency.make.length() > 0 )
+        cat >> "$TEMP_DIR/make.mk" << __EOF__
 $dependency.make
 __EOF__
         #end
 $dependency.make
 __EOF__
         #end
-        
+
         break
     done
         break
     done
-    
+
     break
 done
 #end
 
 # add general dependency flags to config.mk
     break
 done
 #end
 
 # add general dependency flags to config.mk
-echo >> $TEMP_DIR/config.mk
-if [ ! -z "${CFLAGS}" ]; then
-    echo "CFLAGS += $CFLAGS" >> $TEMP_DIR/config.mk
+echo >> "$TEMP_DIR/config.mk"
+if [ -n "${TEMP_CFLAGS}" ]; then
+    echo "CFLAGS += $TEMP_CFLAGS" >> $TEMP_DIR/config.mk
 fi
 fi
-if [ ! -z "${CXXFLAGS}" ]; then
-    echo "CXXFLAGS += $CXXFLAGS" >> $TEMP_DIR/config.mk
+if [ -n "${TEMP_CXXFLAGS}" ]; then
+    echo "CXXFLAGS += $TEMP_CXXFLAGS" >> $TEMP_DIR/config.mk
 fi
 fi
-if [ ! -z "${LDFLAGS}" ]; then
-    echo "LDFLAGS += $LDFLAGS" >> $TEMP_DIR/config.mk
+if [ -n "${TEMP_LDFLAGS}" ]; then
+    echo "LDFLAGS += $TEMP_LDFLAGS" >> $TEMP_DIR/config.mk
 fi
 #end
 
 fi
 #end
 
@@ -470,25 +470,25 @@ fi
 #foreach( $val in $opt.values )
 ${val.func}()
 {
 #foreach( $val in $opt.values )
 ${val.func}()
 {
-       VERR=0
-       #foreach( $dep in $val.dependencies )
-       dependency_$dep
-       if [ $? -ne 0 ]; then
-               VERR=1
-       fi
-       #end
-       if [ $VERR -ne 0 ]; then
-               return 1
-       fi
-       #foreach( $def in $val.defines )
-               CFLAGS="$CFLAGS ${def.toFlags()}"
-       #end
-       #if( $val.hasMake() )
-       cat >> $TEMP_DIR/make.mk << __EOF__
+    VERR=0
+    #foreach( $dep in $val.dependencies )
+    dependency_$dep
+    if [ $? -ne 0 ]; then
+        VERR=1
+    fi
+    #end
+    if [ $VERR -ne 0 ]; then
+        return 1
+    fi
+    #foreach( $def in $val.defines )
+        TEMP_CFLAGS="$TEMP_CFLAGS ${def.toFlags()}"
+    #end
+    #if( $val.hasMake() )
+    cat >> "$TEMP_DIR/make.mk" << __EOF__
 $val.make
 __EOF__
 $val.make
 __EOF__
-       #end
-       return 0
+    #end
+    return 0
 }
 #end
 #end
 }
 #end
 #end
@@ -496,9 +496,9 @@ __EOF__
 #
 # TARGETS
 #
 #
 # TARGETS
 #
-CFLAGS=
-CXXFLAGS=
-LDFLAGS=
+TEMP_CFLAGS=
+TEMP_CXXFLAGS=
+TEMP_LDFLAGS=
 
 #foreach( $target in $targets )
 #if ( $target.name )
 
 #foreach( $target in $targets )
 #if ( $target.name )
@@ -506,31 +506,31 @@ LDFLAGS=
 #else
 # Target
 #end
 #else
 # Target
 #end
-CFLAGS=
-LDFLAGS=
-CXXFLAGS=
+TEMP_CFLAGS=
+TEMP_LDFLAGS=
+TEMP_CXXFLAGS=
 
 #foreach( $dependency in $target.dependencies )
 dependency_$dependency
 if [ $? -ne 0 ]; then
 
 #foreach( $dependency in $target.dependencies )
 dependency_$dependency
 if [ $? -ne 0 ]; then
-       DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED ${dependency} "
-       ERROR=1
+    DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED ${dependency} "
+    ERROR=1
 fi
 #end
 
 # Features
 #foreach( $feature in $target.features )
 fi
 #end
 
 # Features
 #foreach( $feature in $target.features )
-if [ ! -z "$${feature.getVarName()}" ]; then
+if [ -n "$${feature.getVarName()}" ]; then
 #foreach( $dependency in $feature.dependencies )
 #foreach( $dependency in $feature.dependencies )
-       # check dependency
-       dependency_$dependency
-       if [ $? -ne 0 ]; then
-               # "auto" features can fail and are just disabled in this case
-               if [ $${feature.getVarName()} != "auto" ]; then
-                       DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED ${dependency} "
-                       ERROR=1
-               fi
-       fi
+    # check dependency
+    dependency_$dependency
+    if [ $? -ne 0 ]; then
+        # "auto" features can fail and are just disabled in this case
+        if [ "$${feature.getVarName()}" != "auto" ]; then
+            DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED ${dependency} "
+            ERROR=1
+        fi
+    fi
 #end
 fi
 #end
 #end
 fi
 #end
@@ -538,65 +538,65 @@ fi
 #foreach( $opt in $target.options )
 # Option: --${opt.argument}
 if [ -z ${D}${opt.getVarName()} ]; then
 #foreach( $opt in $target.options )
 # Option: --${opt.argument}
 if [ -z ${D}${opt.getVarName()} ]; then
-       SAVED_ERROR=$ERROR
-       SAVED_DEPENDENCIES_FAILED=$DEPENDENCIES_FAILED
-       ERROR=0
-       while true
-       do
-               #foreach( $optdef in $opt.defaults )
-               #if( $optdef.platform )
-               if isplatform "$optdef.platform"; then
-               #end
-               $optdef.func
-               if [ $? -eq 0 ]; then
-                       echo "  ${opt.argument}: ${optdef.valueName}" >> $TEMP_DIR/options
-                       ERROR=0
-                       break
-               fi
-               #if( $optdef.platform )
-               fi
-               #end
-               #end
-               break
-       done
-       if [ $ERROR -ne 0 ]; then
-               SAVED_ERROR=1
-       fi
-       ERROR=$SAVED_ERROR
-       DEPENDENCIES_FAILED=$SAVED_DEPENDENCIES_FAILED=
+    SAVED_ERROR="$ERROR"
+    SAVED_DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED"
+    ERROR=0
+    while true
+    do
+        #foreach( $optdef in $opt.defaults )
+        #if( $optdef.platform )
+        if isplatform "$optdef.platform"; then
+        #end
+        $optdef.func
+        if [ $? -eq 0 ]; then
+            echo "  ${opt.argument}: ${optdef.valueName}" >> "$TEMP_DIR/options"
+            ERROR=0
+            break
+        fi
+        #if( $optdef.platform )
+        fi
+        #end
+        #end
+        break
+    done
+    if [ $ERROR -ne 0 ]; then
+        SAVED_ERROR=1
+    fi
+    ERROR="$SAVED_ERROR"
+    DEPENDENCIES_FAILED="$SAVED_DEPENDENCIES_FAILED"
 else
 else
-       if false; then
-               false
-       #foreach( $optval in $opt.values )
-       elif [ ${D}${opt.getVarName()} = "${optval.value}" ]; then
-               echo "  ${opt.argument}: ${D}${opt.getVarName()}" >> $TEMP_DIR/options
-               $optval.func
-               if [ $? -ne 0 ]; then
-                       ERROR=1
-               fi
-       #end
-       fi
+    if false; then
+        false
+    #foreach( $optval in $opt.values )
+    elif [ "${D}${opt.getVarName()}" = "${optval.value}" ]; then
+        echo "  ${opt.argument}: ${D}${opt.getVarName()}" >> $TEMP_DIR/options
+        $optval.func
+        if [ $? -ne 0 ]; then
+            ERROR=1
+        fi
+    #end
+    fi
 fi
 #end
 
 fi
 #end
 
-echo >> $TEMP_DIR/config.mk
-if [ ! -z "${CFLAGS}" ]; then
-    echo "${target.getCFlags()}  += $CFLAGS" >> $TEMP_DIR/config.mk
+echo >> "$TEMP_DIR/config.mk"
+if [ -n "${TEMP_CFLAGS}" ]; then
+    echo "${target.getCFlags()}  += $TEMP_CFLAGS" >> "$TEMP_DIR/config.mk"
 fi
 fi
-if [ ! -z "${CXXFLAGS}" ]; then
-    echo "${target.getCXXFlags()} += $CXXFLAGS" >> $TEMP_DIR/config.mk
+if [ -n "${TEMP_CXXFLAGS}" ]; then
+    echo "${target.getCXXFlags()} += $TEMP_CXXFLAGS" >> "$TEMP_DIR/config.mk"
 fi
 fi
-if [ ! -z "${LDFLAGS}" ]; then
-    echo "${target.getLDFlags()} += $LDFLAGS" >> $TEMP_DIR/config.mk
+if [ -n "${TEMP_LDFLAGS}" ]; then
+    echo "${target.getLDFlags()} += $TEMP_LDFLAGS" >> "$TEMP_DIR/config.mk"
 fi
 
 #end
 if [ $ERROR -ne 0 ]; then
 fi
 
 #end
 if [ $ERROR -ne 0 ]; then
-       echo
-       echo "Error: Unresolved dependencies"
-       echo $DEPENDENCIES_FAILED
-       rm -Rf $TEMP_DIR
-       exit 1
+    echo
+    echo "Error: Unresolved dependencies"
+    echo "$DEPENDENCIES_FAILED"
+    rm -Rf "$TEMP_DIR"
+    exit 1
 fi
 
 echo "configure finished"
 fi
 
 echo "configure finished"
@@ -606,10 +606,10 @@ echo "  PREFIX:    $PREFIX"
 echo "  TOOLCHAIN: $TOOLCHAIN_NAME"
 #if ( $options.size() > 0 )
 echo "Options:"
 echo "  TOOLCHAIN: $TOOLCHAIN_NAME"
 #if ( $options.size() > 0 )
 echo "Options:"
-cat $TEMP_DIR/options
+cat "$TEMP_DIR/options"
 #end
 echo
 #end
 echo
-cat $TEMP_DIR/config.mk $TEMP_DIR/make.mk > config.mk
-rm -Rf $TEMP_DIR
+cat "$TEMP_DIR/config.mk" "$TEMP_DIR/make.mk" > config.mk
+rm -Rf "$TEMP_DIR"
 
 
 
 
index cc20939..d1087da 100644 (file)
                <ldflags>-lcurl</ldflags>
        </dependency>
        <dependency name="curl" platform="macos">
                <ldflags>-lcurl</ldflags>
        </dependency>
        <dependency name="curl" platform="macos">
-               <cflags type="exec">curl-config --cflags</cflags>
-               <ldflags type="exec">curl-config --ldflags</ldflags>
+               <cflags exec="true">curl-config --cflags</cflags>
+               <ldflags exec="true">curl-config --ldflags</ldflags>
        </dependency>
        <dependency name="curl">
                <pkgconfig>libcurl</pkgconfig>
        </dependency>
        <dependency name="curl">
                <test>which curl-config</test>
        </dependency>
        <dependency name="curl">
                <pkgconfig>libcurl</pkgconfig>
        </dependency>
        <dependency name="curl">
                <test>which curl-config</test>
-               <cflags type="exec">curl-config --cflags</cflags>
-               <ldflags type="exec">curl-config --ldflags</ldflags>
+               <cflags exec="true">curl-config --cflags</cflags>
+               <ldflags exec="true">curl-config --ldflags</ldflags>
        </dependency>
        
        <dependency name="libxml2" platform="windows">
        </dependency>
        
        <dependency name="libxml2" platform="windows">
-               <cflags type="exec">xml2-config --cflags</cflags>
-               <ldflags type="exec">xml2-config --libs</ldflags>
+               <cflags exec="true">xml2-config --cflags</cflags>
+               <ldflags exec="true">xml2-config --libs</ldflags>
        </dependency>
        <dependency name="libxml2" platform="macos">
        </dependency>
        <dependency name="libxml2" platform="macos">
-               <cflags type="exec">xml2-config --cflags</cflags>
-               <ldflags type="exec">xml2-config --libs</ldflags>
+               <cflags exec="true">xml2-config --cflags</cflags>
+               <ldflags exec="true">xml2-config --libs</ldflags>
        </dependency>
        <dependency name="libxml2">
                <pkgconfig>libxml-2.0</pkgconfig>
        </dependency>
        <dependency name="libxml2">
        </dependency>
        <dependency name="libxml2">
                <pkgconfig>libxml-2.0</pkgconfig>
        </dependency>
        <dependency name="libxml2">
-               <cflags type="exec">xml2-config --cflags</cflags>
-               <ldflags type="exec">xml2-config --libs</ldflags>
+               <cflags exec="true">xml2-config --cflags</cflags>
+               <ldflags exec="true">xml2-config --libs</ldflags>
        </dependency>
        
        <dependency name="openssl" platform="windows">
        </dependency>
        
        <dependency name="openssl" platform="windows">
@@ -99,6 +99,9 @@
                                <dependencies>gtk3</dependencies>
                                <make>TOOLKIT = gtk</make>
                                <make>GTKOBJ = draw_cairo.o</make>
                                <dependencies>gtk3</dependencies>
                                <make>TOOLKIT = gtk</make>
                                <make>GTKOBJ = draw_cairo.o</make>
+                               <!-- toolkit specific mizunara source files -->
+                               <make>MZUI = gtk_pathbar.c</make>
+                               <make>MZUI += gtk_browser.c</make>
                        </value>
                        <!--
                        <value str="gtk2">
                        </value>
                        <!--
                        <value str="gtk2">
                        <value str="motif">
                                <dependencies>motif</dependencies>
                                <make>TOOLKIT = motif</make>
                        <value str="motif">
                                <dependencies>motif</dependencies>
                                <make>TOOLKIT = motif</make>
+                               <!-- toolkit specific mizunara source files -->
+                               <make>MZUI = motif_pathbar.c</make>
+                               <make>MZUI += motif_browser.c</make>
                        </value>
                        <!--
                        <default value="wpf" platform="windows" />
                        </value>
                        <!--
                        <default value="wpf" platform="windows" />
diff --git a/mizucp/atomic.h b/mizucp/atomic.h
new file mode 100644 (file)
index 0000000..f624e7e
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2021 Olaf Wintermann
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a 
+ * copy of this software and associated documentation files (the "Software"), 
+ * to deal in the Software without restriction, including without limitation 
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense, 
+ * and/or sell copies of the Software, and to permit persons to whom the 
+ * Software is furnished to do so, subject to the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be included in 
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef MZCP_ATOMIC_H
+#define MZCP_ATOMIC_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if defined(__clang__) || defined(__GNUC__)
+    
+#define mz_atomic_inc64(intptr) __sync_fetch_and_add(intptr, 1)
+#define mz_atomic_dec64(intptr) __sync_fetch_and_sub(intptr, 1)
+#define mz_atomic_add64(intptr, val) __sync_fetch_and_add(intptr, val)
+    
+#elif defined(__sun)
+    
+#include <atomic.h>
+
+#define mz_atomic_inc64(intptr) atomic_inc_64_nv(intptr)
+#define mz_atomic_dec64(intptr) atomic_dec_64_nv(intptr)
+#define mz_atomic_add64(intptr, val) atomic_add_64_nv(intptr, val)
+    
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* MZCP_ATOMIC_H */
+
index 18aaf5a..f590dc7 100644 (file)
 #include "main.h"
 
 #include "srvctrl.h"
 #include "main.h"
 
 #include "srvctrl.h"
+#include "atomic.h"
 
 #include <stdio.h>
 #include <stdlib.h>
 
 #include <stdio.h>
 #include <stdlib.h>
+#include <inttypes.h>
 #include <string.h>
 #include <unistd.h>
 #include <signal.h>
 #include <string.h>
 #include <unistd.h>
 #include <signal.h>
@@ -61,6 +63,13 @@ static MZQueue         *queue_end;
 
 static int scan_complete;
 
 
 static int scan_complete;
 
+
+static uint64_t stat_num_files;
+static uint64_t stat_copied_files;
+static uint64_t stat_error_files;
+static uint64_t stat_total_size;
+static uint64_t stat_copied_size;
+
 int main(int argc, char** argv) { 
     int ret = 1;
     
 int main(int argc, char** argv) { 
     int ret = 1;
     
@@ -215,13 +224,12 @@ int mzcp_copy(CPSettings *settings) {
 
 
 int mzcp_start_scan(CPSettings *settings) {
 
 
 int mzcp_start_scan(CPSettings *settings) {
-    struct stat s;
-    if(stat(settings->from, &s)) {
+    if(stat(settings->from, &settings->root_stat)) {
         // TODO: error
         return 1;
     }
     
         // TODO: error
         return 1;
     }
     
-    if(!S_ISDIR(s.st_mode)) {
+    if(!S_ISDIR(settings->root_stat.st_mode)) {
         // queue single file
         queue_begin = queue_root_elm_new();
         if(!queue_begin) {
         // queue single file
         queue_begin = queue_root_elm_new();
         if(!queue_begin) {
@@ -259,6 +267,7 @@ void* scan_run(void *data) {
     }
     file->path = root;
     file->isdir = 1;
     }
     file->path = root;
     file->isdir = 1;
+    file->mode = settings->root_stat.st_mode;
     if(enqueue_file(file)) {
         scan_complete = 1;
         // TODO: error
     if(enqueue_file(file)) {
         scan_complete = 1;
         // TODO: error
@@ -298,12 +307,18 @@ void* scan_run(void *data) {
             SrcFile *f = calloc(1, sizeof(SrcFile));
             f->path = util_concat_path(elm->path, name);
             f->isdir = S_ISDIR(s.st_mode);
             SrcFile *f = calloc(1, sizeof(SrcFile));
             f->path = util_concat_path(elm->path, name);
             f->isdir = S_ISDIR(s.st_mode);
+            f->size = s.st_size;
+            f->mode = s.st_mode;
             f->depends_on = elm;
             
             if(enqueue_file(f)) {
                 // TODO: error?
                 fprintf(stderr, "enqueue failed\n");
                 break;
             f->depends_on = elm;
             
             if(enqueue_file(f)) {
                 // TODO: error?
                 fprintf(stderr, "enqueue failed\n");
                 break;
+            } else {
+                mz_atomic_inc64(&stat_num_files);
+                int64_t sz = s.st_size;
+                mz_atomic_add64(&stat_total_size, sz);
             }
             
             // put dir on stack
             }
             
             // put dir on stack
@@ -399,17 +414,60 @@ static SrcFile* queue_get_file(void) {
 
 void* copy_run(void *data) {
     CPSettings *settings = data;
 
 void* copy_run(void *data) {
     CPSettings *settings = data;
+    
+    char *buffer = malloc(MZ_COPY_BUFSIZE);
+    size_t bufsize = MZ_COPY_BUFSIZE;
+    
     for(;;) {
         SrcFile *file = queue_get_file();
         if(!file) {
             break;
         }
         
     for(;;) {
         SrcFile *file = queue_get_file();
         if(!file) {
             break;
         }
         
-        char *from = file->path ? util_concat_path(settings->from, file->path) : settings->from;
-        printf("src: %s\n", from);
-        
+        char *from = file->path ? util_concat_path(settings->from, file->path) : settings->from;  
         char *to = util_concat_path(settings->to, file->path ? file->path : util_resource_name(settings->from));
         char *to = util_concat_path(settings->to, file->path ? file->path : util_resource_name(settings->from));
-        printf("dst: %s\n", to);
+        
+        size_t from_len = strlen(from);
+        size_t to_len = strlen(to);
+        
+        if(from[from_len-1] == '/') {
+            from[from_len-1] = 0;
+        }
+        if(to[to_len-1] == '/') {
+            to[to_len-1] = 0;
+        }
+        
+        if(file->depends_on) {
+            SrcFile *dep = file->depends_on;
+            // check first without lock
+            if(dep->status == 0) {
+                if(dep->lock) {
+                    pthread_mutex_lock(&dep->lock->mutex);
+                    if(file->depends_on->status == 0) {
+                        pthread_cond_wait(&dep->lock->cond, &dep->lock->mutex);
+                    }
+                    pthread_mutex_unlock(&dep->lock->mutex);
+                } else {
+                    // locking disabled (because we have only one thread)
+                    // but in that case the file status can't be 0
+                    // therefore this case here should not happen
+                    file->status = -1;
+                }
+            }
+            // check again
+            if(dep->status == -1) {
+                file->status = -1;
+            }
+        }
+        
+        int ret;
+        if(file->status == 0) {
+            if(file->isdir) {
+            ret = mz_copy_dir(settings, file, from, to);
+            } else {
+                ret = mz_copy_file(settings, file, from, to, buffer, bufsize);
+            }
+        }
         
         free(to);
         if(from != settings->from) {
         
         free(to);
         if(from != settings->from) {
@@ -420,3 +478,86 @@ void* copy_run(void *data) {
     return NULL;
 }
 
     return NULL;
 }
 
+static void file_set_status(SrcFile *file, int status) {
+    if(file->lock) {
+        pthread_mutex_lock(&file->lock->mutex);
+        file->status = status;
+        pthread_cond_broadcast(&file->lock->cond);
+        pthread_mutex_unlock(&file->lock->mutex);
+    } else {
+        file->status = status;
+    }
+}
+
+int mz_copy_dir(CPSettings *settings, SrcFile *file, const char *from, const char *to) {
+    printf("mkdir %s\n", to);
+    int ret = mkdir(to, file->mode);
+    if(ret) {
+        if(errno == EEXIST) {
+            struct stat s;
+            if(!stat(to, &s)) {
+                if(S_ISDIR(s.st_mode)) {
+                    ret = 0;
+                }
+            }
+        }
+    }
+    file_set_status(file, !ret ? 1 : -1);
+    return ret;
+}
+
+int mz_copy_file(CPSettings *settings, SrcFile *file, const char *from, const char *to, char *buffer, size_t bufsize) {
+    printf("cp %s %s\n", from, to);
+    int fin = open(from, O_RDONLY);
+    if(fin < 0) {
+        file_set_status(file, -1);
+        return 1;
+    }
+    
+    int ret = 0;
+    
+    int fout = open(to, O_WRONLY|O_CREAT, file->mode);
+    if(fout < 0) {
+        perror("open");
+        close(fin);
+        file_set_status(file, -1);
+        return 1;
+    }
+    
+    int64_t copied = 0;
+    ssize_t r;
+    while((r = read(fin, buffer, bufsize)) > 0) {
+        ssize_t w = write(fout, buffer, r);
+        if(w > 0) {
+            mz_atomic_add64(&stat_copied_size, w);
+            copied += w;
+        }
+        if(w != r) {
+            ret = 1;
+            break;
+        }
+    }
+    
+    close(fin);
+    close(fout);
+    
+    if(!ret) {
+        file_set_status(file, 1);
+        mz_atomic_inc64(&stat_copied_files);
+        if(copied != file->size) {
+            // size changed after scan -> readjust total size
+            int64_t filesz_diff = copied - file->size;
+            mz_atomic_add64(&stat_total_size, filesz_diff);
+        }
+    } else {
+        file_set_status(file, -1);
+        mz_atomic_inc64(&stat_error_files);
+        if(copied != file->size) {
+            // count the full file size as copied, although we had an error
+            int64_t filesz_diff = file->size - copied;
+            mz_atomic_add64(&stat_copied_size, filesz_diff);
+        }
+    }
+    
+    return ret;
+}
index 872b06f..e5537e5 100644 (file)
@@ -24,6 +24,8 @@
 #define MAIN_H
 
 #include <stdlib.h>
 #define MAIN_H
 
 #include <stdlib.h>
+#include <unistd.h>
+#include <sys/stat.h>
 
 #include <ucx/string.h>
 
 
 #include <ucx/string.h>
 
@@ -41,6 +43,7 @@ extern "C" {
 #define CLIENT_MSG_BUFSIZE 512
     
 #define MAX_COPY_THREADS 32
 #define CLIENT_MSG_BUFSIZE 512
     
 #define MAX_COPY_THREADS 32
+#define MZ_COPY_BUFSIZE 4 * 1024 * 1024
     
 typedef char CPBool;
 
     
 typedef char CPBool;
 
@@ -55,6 +58,7 @@ typedef struct {
     CPBool url;
     CPBool pause;
     CPBool printsocket;
     CPBool url;
     CPBool pause;
     CPBool printsocket;
+    struct stat root_stat;
 } CPSettings;
 
 struct MZLock {
 } CPSettings;
 
 struct MZLock {
@@ -74,9 +78,22 @@ struct SrcFile {
     CPBool isdir;
     
     /*
     CPBool isdir;
     
     /*
-     * file successfully copied
+     * copy status
+     *  0:  unprocessed
+     *  1:  success
+     * -1:  failure 
      */
      */
-    CPBool finished;
+    int status;
+    
+    /*
+     * file mode
+     */
+    mode_t mode;
+    
+    /*
+     * file size
+     */
+    uint64_t size;
     
     /*
      * processing this file depends on another file (directory)
     
     /*
      * processing this file depends on another file (directory)
@@ -107,6 +124,8 @@ int enqueue_file(SrcFile *file);
 int mzcp_start_copy_threads(CPSettings *settings);
 void* copy_run(void *data);
 
 int mzcp_start_copy_threads(CPSettings *settings);
 void* copy_run(void *data);
 
+int mz_copy_dir(CPSettings *settings, SrcFile *file, const char *from, const char *to);
+int mz_copy_file(CPSettings *settings, SrcFile *file, const char *from, const char *to, char *buffer, size_t bufsize);
 
     
 #ifdef __cplusplus
 
     
 #ifdef __cplusplus
diff --git a/mizucp/vfs.c b/mizucp/vfs.c
new file mode 100644 (file)
index 0000000..3a3b199
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2019 Olaf Wintermann
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a 
+ * copy of this software and associated documentation files (the "Software"), 
+ * to deal in the Software without restriction, including without limitation 
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense, 
+ * and/or sell copies of the Software, and to permit persons to whom the 
+ * Software is furnished to do so, subject to the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be included in 
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#include "vfs.h"
diff --git a/mizucp/vfs.h b/mizucp/vfs.h
new file mode 100644 (file)
index 0000000..7e09c30
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2019 Olaf Wintermann
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a 
+ * copy of this software and associated documentation files (the "Software"), 
+ * to deal in the Software without restriction, including without limitation 
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense, 
+ * and/or sell copies of the Software, and to permit persons to whom the 
+ * Software is furnished to do so, subject to the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be included in 
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef VFS_H
+#define VFS_H
+
+#include <stdlib.h>
+#include <unistd.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* VFS_H */
+
index 5656808..136b523 100644 (file)
@@ -32,6 +32,9 @@ include $(BUILD_ROOT)/config.mk
 CFLAGS += -I../ui/ -I../ucx -I..
 
 SRC = main.c
 CFLAGS += -I../ui/ -I../ucx -I..
 
 SRC = main.c
+SRC += menu.c
+
+SRC += $(MZUI)
 
 OBJ = $(SRC:%.c=$(BUILD_ROOT)/build/mizunara/%.$(OBJ_EXT))
 
 
 OBJ = $(SRC:%.c=$(BUILD_ROOT)/build/mizunara/%.$(OBJ_EXT))
 
index ba20e28..9500f65 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
  *
 /*
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
  *
- * Copyright 2017 Olaf Wintermann. All rights reserved.
+ * Copyright 2021 Olaf Wintermann. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are met:
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are met:
 #include <ucx/buffer.h>
 #include <ucx/utils.h>
 
 #include <ucx/buffer.h>
 #include <ucx/utils.h>
 
-void action_menu(UiEvent *event, void *userdata) {
-    
-}
+#include "menu.h"
+
 
 
 void application_startup(UiEvent *event, void *data) {
 
 
 void application_startup(UiEvent *event, void *data) {
+    setup_menu();
     
     UiObject *obj = ui_window("Test", NULL);
     
     
     UiObject *obj = ui_window("Test", NULL);
     
@@ -50,18 +50,6 @@ int main(int argc, char** argv) {
     ui_init("app1", argc, argv);
     ui_onstartup(application_startup, NULL);
     
     ui_init("app1", argc, argv);
     ui_onstartup(application_startup, NULL);
     
-    // menu
-    ui_menu("File");
-    ui_menuitem("Hello", action_menu, NULL);
-    ui_submenu("Submenu1");
-    ui_submenu("Submenu2");
-    ui_menuitem("item2", action_menu, NULL);
-    ui_submenu_end();
-    ui_menuitem("item3", action_menu, NULL);
-    ui_submenu_end();
-    ui_menuitem("item4", action_menu, NULL);
-
-    
     ui_main();
     
     return (EXIT_SUCCESS);
     ui_main();
     
     return (EXIT_SUCCESS);
diff --git a/mizunara/menu.c b/mizunara/menu.c
new file mode 100644 (file)
index 0000000..2ba886b
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2021 Olaf Wintermann. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ *   1. Redistributions of source code must retain the above copyright
+ *      notice, this list of conditions and the following disclaimer.
+ *
+ *   2. Redistributions in binary form must reproduce the above copyright
+ *      notice, this list of conditions and the following disclaimer in the
+ *      documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "menu.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+static void action_menu(UiEvent *event, void *userdata) {
+    
+}
+
+
+
+void setup_menu(void) {
+    ui_menu("File");
+    ui_menuitem("Test", action_menu, NULL);
+}
diff --git a/mizunara/menu.h b/mizunara/menu.h
new file mode 100644 (file)
index 0000000..1aba01e
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2021 Olaf Wintermann. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ *   1. Redistributions of source code must retain the above copyright
+ *      notice, this list of conditions and the following disclaimer.
+ *
+ *   2. Redistributions in binary form must reproduce the above copyright
+ *      notice, this list of conditions and the following disclaimer in the
+ *      documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef MZ_MENU_H
+#define MZ_MENU_H
+
+#include <ui/ui.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void setup_menu(void);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* MZ_MENU_H */
+