#!/bin/sh

function mycp {

  if [ ! -r $2 ] ; then
    cp $1 $2
  else
    echo "$2 already exist"
  fi
}

echo 
echo "*** Patch: 0001-scp-only-clear-special-bits-for-non-android.patch"
 ${PREFIX} mycp "../scp.c" "../scp.c.org"
 ${PREFIX} patch "../scp.c" "0001-scp-only-clear-special-bits-for-non-android.patch"

echo 
echo "*** Patch: auth.c.patch"
 ${PREFIX} mycp "../auth.c" "../auth.c.org"
 ${PREFIX} patch "../auth.c" "auth.c.patch"

echo 
echo "*** Patch: contrib_ssh-copy-id.patch"
 ${PREFIX} mycp "../contrib/ssh-copy-id" "../contrib/ssh-copy-id.org"
 ${PREFIX} patch "../contrib/ssh-copy-id" "contrib_ssh-copy-id.patch"

echo 
echo "*** Patch: defines.h.patch"
 ${PREFIX} mycp "../defines.h" "../defines.h.org"
 ${PREFIX} patch "../defines.h" "defines.h.patch"

echo 
echo "*** Patch: hostfile.c.patch"
 ${PREFIX} mycp "../hostfile.c" "../hostfile.c.org"
 ${PREFIX} patch "../hostfile.c" "hostfile.c.patch"

echo 
echo "*** Patch: loginrec.c.patch"
 ${PREFIX} mycp "../loginrec.c" "../loginrec.c.org"
 ${PREFIX} patch "../loginrec.c" "loginrec.c.patch"

echo 
echo "*** Patch: misc.c.patch"
 ${PREFIX} mycp "../misc.c" "../misc.c.org"
 ${PREFIX} patch "../misc.c" "misc.c.patch"

echo 
echo "*** Patch: mux.c.patch"
 ${PREFIX} mycp "../mux.c" "../mux.c.org"
 ${PREFIX} patch "../mux.c" "mux.c.patch"

echo 
echo "*** Patch: openbsd-compat_explicit_bzero.c.patch"
 ${PREFIX} mycp "../openbsd-compat/explicit_bzero.c" "../openbsd-compat/explicit_bzero.c.org"
 ${PREFIX} patch "../openbsd-compat/explicit_bzero.c" "openbsd-compat_explicit_bzero.c.patch"

echo 
echo "*** Patch: openbsd-compat_xcrypt.c.patch"
 ${PREFIX} mycp "../openbsd-compat/xcrypt.c" "../openbsd-compat/xcrypt.c.org"
 ${PREFIX} patch "../openbsd-compat/xcrypt.c" "openbsd-compat_xcrypt.c.patch"

echo 
echo "*** Patch: pathnames.h.patch"
 ${PREFIX} mycp "../pathnames.h" "../pathnames.h.org"
 ${PREFIX} patch "../pathnames.h" "pathnames.h.patch"

echo 
echo "*** Patch: readconf.c.patch"
 ${PREFIX} mycp "../readconf.c" "../readconf.c.org"
 ${PREFIX} patch "../readconf.c" "readconf.c.patch"

echo 
echo "*** Patch: servconf.c.patch"
 ${PREFIX} mycp "../servconf.c" "../servconf.c.org"
 ${PREFIX} patch "../servconf.c" "servconf.c.patch"

echo 
echo "*** Patch: session.c.patch"
 ${PREFIX} mycp "../session.c" "../session.c.org"
 ${PREFIX} patch "../session.c" "session.c.patch"

echo 
echo "*** Patch: sftp-server.c.patch"
 ${PREFIX} mycp "../sftp-server.c" "../sftp-server.c.org"
 ${PREFIX} patch "../sftp-server.c" "sftp-server.c.patch"

echo 
echo "*** Patch: ssh-agent.c.patch"
 ${PREFIX} mycp "../ssh-agent.c" "../ssh-agent.c.org"
 ${PREFIX} patch "../ssh-agent.c" "ssh-agent.c.patch"

echo 
echo "*** Patch: ssh_config.patch"
 ${PREFIX} mycp "../ssh_config" "../ssh_config.org"
 ${PREFIX} patch "../ssh_config" "ssh_config.patch"

echo 
echo "*** Patch: sshd.8.patch"
 ${PREFIX} mycp "../sshd.8" "../sshd.8.org"
 ${PREFIX} patch "../sshd.8" "sshd.8.patch"

echo 
echo "*** Patch: sshd-auth.c.patch"
 ${PREFIX} mycp "../sshd-auth.c" "../sshd-auth.c.org"
 ${PREFIX} patch "../sshd-auth.c" "sshd-auth.c.patch"

echo 
echo "*** Patch: sshd_config.5.patch"
 ${PREFIX} mycp "../sshd_config.5" "../sshd_config.5.org"
 ${PREFIX} patch "../sshd_config.5" "sshd_config.5.patch"

echo 
echo "*** Patch: sshd_config.patch"
 ${PREFIX} mycp "../sshd_config" "../sshd_config.org"
 ${PREFIX} patch "../sshd_config" "sshd_config.patch"

echo 
echo "*** Patch: sshd.c.patch"
 ${PREFIX} mycp "../sshd.c" "../sshd.c.org"
 ${PREFIX} patch "../sshd.c" "sshd.c.patch"

echo 
echo "*** Patch: sshd-session.c.patch"
 ${PREFIX} mycp "../sshd-session.c" "../sshd-session.c.org"
 ${PREFIX} patch "../sshd-session.c" "sshd-session.c.patch"

echo 
echo "*** Patch: ssh-keygen.c.patch"
 ${PREFIX} mycp "../ssh-keygen.c" "../ssh-keygen.c.org"
 ${PREFIX} patch "../ssh-keygen.c" "ssh-keygen.c.patch"

echo 
echo "*** Patch: sshpty.c.patch"
 ${PREFIX} mycp "../sshpty.c" "../sshpty.c.org"
 ${PREFIX} patch "../sshpty.c" "sshpty.c.patch"

