Initial IBM OpenAFS 1.0 tree

This commit is contained in:
IBM 2000-11-04 02:13:13 +00:00 committed by Derrick Brashear
commit 87c10e8d7f
3456 changed files with 968066 additions and 0 deletions

0
src/..wow.3 Normal file
View File

532
src/Makefile Normal file
View File

@ -0,0 +1,532 @@
#/* Copyright (C) 1990, 1989 Transarc Corporation - All rights reserved */
SHELL=/bin/sh
DESTDIR=dest/
SRCDIR=${DESTDIR}
INSTALL=${SRCDIR}bin/install
WASHTOOL=${SRCDIR}bin/washtool
#WASHTOOLRCSUPDATE=${WASHTOOL} rcsupdate
WASHTOOLCMD=make
WASHTOOLFLAGS=-argument install
COMPILE_PART1=${WASHTOOL} ${WASHTOOLCMD}
COMPILE_PART2=${WASHTOOLFLAGS}
MKDIR_IF_NEEDED=[ -d $$1 ] || mkdir -p $$1
# To compile AFS from scratch in the src tree run "make SYS_NAME=<type>".
# This recursively calls "make install ..." and does not depend on the
# existence of any non-standard programs.
# To compile a package and all its predecessors using washtool run
# "make <package>". This requires that @sys works, and that washtool,
# rcsupdate and our version of ci and co exist.
# To compile for the kernel type "make blibafs". This assumes washtool,
# install, rxgen, compile_et and others already exist and runs it with
# "-argument kinstall".
all:
set ${SYS_NAME}/dest; $(MKDIR_IF_NEEDED)
$(MAKE) install "COMPILE_PART1=cd obj; cd" "COMPILE_PART2=; $(MAKE) install SYS_NAME=${SYS_NAME} DESTDIR=`pwd`/${SYS_NAME}/dest/ SRCDIR=`pwd`/${SYS_NAME}/dest/" SYS_NAME=${SYS_NAME} "WASHTOOL=echo No washtool: "
basics:
-if test -f "${WASHTOOL}"; \
then \
${WASHTOOL} project . . -noretarget; \
${WASHTOOL} destdir; \
fi
# test -d ${DESTDIR}
minproject: basics
${WASHTOOL} project . . -noretarget
${WASHTOOL} destdir
project: basics cmd comerr minproject # try and initialize project
config: basics
${COMPILE_PART1} config ${COMPILE_PART2}
pinstall: basics config
${COMPILE_PART1} pinstall ${COMPILE_PART2}
procmgmt: basics config pinstall
${COMPILE_PART1} procmgmt ${COMPILE_PART2}
util: basics pinstall procmgmt
${COMPILE_PART1} util ${COMPILE_PART2}
audit: basics pinstall rx rxkad fsint
${COMPILE_PART1} audit ${COMPILE_PART2}
comerr: basics util
${COMPILE_PART1} comerr ${COMPILE_PART2}
cmd: basics comerr
${COMPILE_PART1} cmd ${COMPILE_PART2}
@case ${SYS_NAME} in \
sgi_6* | sun4x_57 | hp_ux11* ) \
${COMPILE_PART1} cmd ${COMPILE_PART2} install64 ;; \
esac
lwp: project util
${COMPILE_PART1} lwp ${COMPILE_PART2}
rxgen: minproject pinstall
${COMPILE_PART1} rxgen ${COMPILE_PART2}
rxobj:
${WASHTOOL} object rx
kernrx:
${COMPILE_PART1} rx ${COMPILE_PART2}
rx: project lwp rxgen
${COMPILE_PART1} rx ${COMPILE_PART2}
rxstat: rx
${COMPILE_PART1} rxstat ${COMPILE_PART2}
rxincls: rxobj
${COMPILE_PART1} rx ${COMPILE_PART2}
rxtests: rxobj
${COMPILE_PART1} rx ${COMPILE_PART2}
fsint: project kfsint
kfsint: rxgen rxincls lwp
${COMPILE_PART1} fsint ${COMPILE_PART2}
export2: project fsint
export: minproject fsint
@case ${SYS_NAME} in \
rs_aix*) \
${COMPILE_PART1} export ${COMPILE_PART2} ;; \
* ) echo skipping export for ${SYS_NAME} ;; \
esac
afs: minproject export
${COMPILE_PART1} afs ${COMPILE_PART2}
des: minproject config
if [ -f "obj/des/Makefile" ] ; then \
${COMPILE_PART1} des ${COMPILE_PART2} ; \
else \
${COMPILE_PART1} des_stub ${COMPILE_PART2} ; \
fi
sys: project des rx rxstat fsint
${COMPILE_PART1} sys ${COMPILE_PART2}
rxkad: project des
${WASHTOOL} object rxkad
${WASHTOOL} object rxkad/domestic
${COMPILE_PART1} rxkad ${COMPILE_PART2}
kernauth:
${COMPILE_PART1} auth ${COMPILE_PART2}
auth: project comerr des lwp rx sys rxkad audit
${COMPILE_PART1} auth ${COMPILE_PART2}
ubik: project auth
${COMPILE_PART1} ubik ${COMPILE_PART2}
ubiktests: ubik sys
cd obj/ubik; $(MAKE) test SYS_NAME=${SYS_NAME}
ptserver: project ubik cmd comerr auth audit
${COMPILE_PART1} ptserver ${COMPILE_PART2}
kauth: project ubik cmd auth comerr ptserver audit libacl
${COMPILE_PART1} kauth ${COMPILE_PART2}
dauth: project ubik cmd auth comerr
${COMPILE_PART1} dauth ${COMPILE_PART2}
libacl: project ptserver
${COMPILE_PART1} libacl ${COMPILE_PART2}
kerndir: minproject
${COMPILE_PART1} dir ${COMPILE_PART2}
dir: project libacl
${COMPILE_PART1} dir ${COMPILE_PART2}
# Removed from sgi_* case below:
# ${COMPILE_PART1} sgiefs ${COMPILE_PART2};;
sgiefs:
case ${SYS_NAME} in \
sgi_*) \
echo "SGI efs not supported" ;; \
*) \
echo No efs stuff for ${SYS_NAME};; \
esac
vol: project dir afs sgiefs
${COMPILE_PART1} vol ${COMPILE_PART2}
vlserver: project vol audit
${COMPILE_PART1} vlserver ${COMPILE_PART2}
viced: project vlserver audit
${COMPILE_PART1} viced ${COMPILE_PART2}
tviced: project viced vlserver libafsrpc libafsauthent
case ${SYS_NAME} in \
alpha_dux*|sgi_*|sun4x_*|rs_aix*|*linux*|hp_ux*) \
${COMPILE_PART1} tviced ${COMPILE_PART2} ;; \
*) \
echo Not building MT viced for ${SYS_NAME} ;; \
esac
volser: project tviced usd kauth audit
${COMPILE_PART1} volser ${COMPILE_PART2}
venus: project volser ptserver
${COMPILE_PART1} venus ${COMPILE_PART2}
${COMPILE_PART1} venus/test ${COMPILE_PART2}
afsd: project sys kauth
${COMPILE_PART1} afsd ${COMPILE_PART2}
null: project
${COMPILE_PART1} null ${COMPILE_PART2}
gtx: project null auth # kauth rxkad ?
case ${SYS_NAME} in \
rs_aix* | sun4x_5? | sgi_6? | *linux*) \
rm -f ${DESTDIR}lib/afs/libtermlib.a; \
ln -s libnull.a ${DESTDIR}lib/afs/libtermlib.a; \
${COMPILE_PART1} gtx ${COMPILE_PART2};; \
*) \
rm -f ${DESTDIR}lib/afs/libtermlib.a; \
ln -s /usr/lib/libtermlib.a ${DESTDIR}lib/afs/libtermlib.a; \
${COMPILE_PART1} gtx ${COMPILE_PART2};; \
esac
fsprobe: project util fsint
${COMPILE_PART1} fsprobe ${COMPILE_PART2}
scout: project gtx fsprobe
${COMPILE_PART1} scout ${COMPILE_PART2}
mpp: project
${COMPILE_PART1} mpp ${COMPILE_PART2}
package: project mpp
${COMPILE_PART1} package ${COMPILE_PART2}
package.files: package
${DESTDIR}/bin/makepkgfiles afs.dev
uss: des kauth project rx vlserver vol
${COMPILE_PART1} uss ${COMPILE_PART2}
ntp: project volser
case ${SYS_NAME} in \
*linux* ) echo skipping ntp for ${SYS_NAME} ;; \
* ) ${COMPILE_PART1} ntp ${COMPILE_PART2} ;; \
esac
#convert: project ntp
# ${COMPILE_PART1} convert ${COMPILE_PART2}
bozo: project ntp audit
${COMPILE_PART1} bozo ${COMPILE_PART2}
# Removed from respective case statements below:
# ${COMPILE_PART1} vfsckaix42 ${COMPILE_PART2} ;;
# ${COMPILE_PART1} vfscksol25 ${COMPILE_PART2} ;;
# ${COMPILE_PART1} vfscksol26 ${COMPILE_PART2} ;;
# ${COMPILE_PART1} vfscksol27 ${COMPILE_PART2} ;;
vfsck: minproject vol
set -x; \
case ${SYS_NAME} in \
sgi_* | *linux*) \
echo skip vfsck for ${SYS_NAME} ;; \
rs_aix42) \
echo skip vfsck for ${SYS_NAME} ;; \
sun4x_55 ) \
echo skip vfsck for ${SYS_NAME} ;; \
sun4x_56 ) \
echo skip vfsck for ${SYS_NAME} ;; \
sun4x_57 ) \
echo skip vfsck for ${SYS_NAME} ;; \
* ) \
${COMPILE_PART1} vfsck ${COMPILE_PART2} ;; \
esac
login: project kauth rxkad
set -x; \
case ${SYS_NAME} in \
sgi_* ) \
${COMPILE_PART1} sgistuff ${COMPILE_PART2} ;; \
rs_aix42 ) \
${WASHTOOL} object login ; \
${COMPILE_PART1} tsm41 ${COMPILE_PART2} ;; \
alpha_dux* ) \
${COMPILE_PART1} sia ${COMPILE_PART2} ;; \
sun4x_55 ) \
${COMPILE_PART1} login ${COMPILE_PART2} ;; \
sun4x_* | hp_ux11* | *linux* ) \
${COMPILE_PART1} pam ${COMPILE_PART2} ;; \
* ) \
${COMPILE_PART1} login ${COMPILE_PART2} ;; \
esac
ftpd43+: project kauth rxkad
case ${SYS_NAME} in \
rs_aix* | sun4x_55 | *linux*) \
${COMPILE_PART1} ftpd43+ ${COMPILE_PART2} ;; \
* ) echo skip ftpd43+ for ${SYS_NAME} ;; \
esac
inetd: project kauth rxkad
${COMPILE_PART1} inetd ${COMPILE_PART2}
rsh: project inetd
${COMPILE_PART1} rsh ${COMPILE_PART2}
rlogind: project rsh ftpd43+ login
case ${SYS_NAME} in \
rs_aix*) \
${COMPILE_PART1} rlogind ${COMPILE_PART2} ;; \
* ) echo skipping rlogind for ${SYS_NAME} ;; \
esac
sgistuff: project rlogind
case ${SYS_NAME} in \
sgi_* ) ${COMPILE_PART1} sgistuff ${COMPILE_PART2} ;; \
* ) echo skipping sgistuff for ${SYS_NAME} ;; \
esac
rcp: project rsh inetd
case ${SYS_NAME} in \
sgi_* ) echo skip rcp for ${SYS_NAME} ;; \
*) ${COMPILE_PART1} rcp ${COMPILE_PART2} ;; \
esac
allrcmds: project rcp rlogind
KERNELDIR= \
afs \
dir \
rx \
fsint \
auth \
rxkad \
util \
libacl \
vlserver \
sgiefs \
rxstat
UKERNELDIR= \
afs \
dir \
rx \
fsint \
util \
auth \
rxkad \
vlserver \
kauth \
des \
afsweb \
rxstat
libafs: minproject libafs_setup ${KERNELDIR}
${COMPILE_PART1} libafs ${COMPILE_PART2}
libuafs: minproject libuafs_setup ${UKERNELDIR}
${COMPILE_PART1} libuafs ${COMPILE_PART2}
afsweb: minproject kauth dauth
${COMPILE_PART1} afsweb ${COMPILE_PART2}
update: project auth
${COMPILE_PART1} update ${COMPILE_PART2}
log: project auth
${COMPILE_PART1} log ${COMPILE_PART2}
bu_utils: project
${COMPILE_PART1} bu_utils ${COMPILE_PART2}
usd: project
${COMPILE_PART1} usd ${COMPILE_PART2}
bubasics: project comerr
${COMPILE_PART1} bubasics ${COMPILE_PART2}
butm: project bubasics usd
${COMPILE_PART1} butm ${COMPILE_PART2}
butc: project bubasics butm budb bucoord cmd
${COMPILE_PART1} butc ${COMPILE_PART2}
tbutc: project bubasics butm budb bucoord cmd butc
case ${SYS_NAME} in \
alpha_dux*|sgi_*|sun4x_*|rs_aix4*|*linux*|hp_ux*) \
${COMPILE_PART1} tbutc ${COMPILE_PART2} ;; \
*) \
echo Not building MT butc for ${SYS_NAME} ;; \
esac
budb: project bubasics
${COMPILE_PART1} budb ${COMPILE_PART2}
bucoord: project bubasics budb volser
${COMPILE_PART1} bucoord ${COMPILE_PART2}
xstat: project
${COMPILE_PART1} xstat ${COMPILE_PART2}
afsmonitor: project gtx xstat
${COMPILE_PART1} afsmonitor ${COMPILE_PART2}
ircs: project
case ${SYS_NAME} in \
sgi_* ) \
echo skip ircs for ${SYS_NAME} ;; \
*) \
${COMPILE_PART1} ircs ${COMPILE_PART2} ;; \
esac
wash: project
case ${SYS_NAME} in \
sgi_* ) \
echo skip wash for ${SYS_NAME} ;; \
*) \
${COMPILE_PART1} wash ${COMPILE_PART2} ;; \
esac
tests: rxtests ubiktests
# pthread based user space RX library
libafsrpc: rx rxkad des
${COMPILE_PART1} libafsrpc ${COMPILE_PART2}
libafsauthent: ubik auth kauth libafsrpc
${COMPILE_PART1} libafsauthent ${COMPILE_PART2}
libadmin: libafsauthent bozo
${COMPILE_PART1} libadmin ${COMPILE_PART2}
${COMPILE_PART1} libadmin/adminutil ${COMPILE_PART2}
${COMPILE_PART1} libadmin/vos ${COMPILE_PART2}
${COMPILE_PART1} libadmin/client ${COMPILE_PART2}
${COMPILE_PART1} libadmin/kas ${COMPILE_PART2}
${COMPILE_PART1} libadmin/pts ${COMPILE_PART2}
${COMPILE_PART1} libadmin/bos ${COMPILE_PART2}
${COMPILE_PART1} libadmin/cfg ${COMPILE_PART2}
${COMPILE_PART1} libadmin/test ${COMPILE_PART2}
${COMPILE_PART1} libadmin/samples ${COMPILE_PART2}
finale: project cmd comerr afsd allrcmds butc tbutc libafs libuafs audit kauth log package \
ptserver scout bu_utils ubik uss bozo vfsck volser \
venus update xstat afsmonitor dauth tests libafsrpc \
libafsauthent libadmin
${COMPILE_PART1} finale ${COMPILE_PART2}
# Use washtool to ensure MakefileProto is current and obj/libafs exists.
libafs_setup: config minproject export
# How about if no RCSUPDATE exists?
# Well then you're going to lose. Or, if you insist, set
# WASHTOOLRCSUPDATE to be a no-op
# Warning: The next few lines are _extremely_ sensitive to spaces and tabs.
${WASHTOOL} object libafs
case ${SYS_NAME} in \
alpha_dux4* ) \
MKAFS_OSTYPE=DUX;; \
hp_ux* ) \
MKAFS_OSTYPE=HPUX;; \
*linux*) \
MKAFS_OSTYPE=LINUX;; \
rs_aix* ) \
MKAFS_OSTYPE=AIX;; \
sgi_* ) \
MKAFS_OSTYPE=IRIX;; \
sun4x_5* ) \
MKAFS_OSTYPE=SOLARIS;; \
* ) \
echo WARNING: No MakefileProto for sys ${SYS_NAME} ; \
esac; \
obj/config/config src/libafs/MakefileProto.$$MKAFS_OSTYPE obj/libafs/Makefile ${SYS_NAME}
libuafs_setup: config minproject export
# How about if no RCSUPDATE exists?
# Well then you're going to lose. Or, if you insist, set
# WASHTOOLRCSUPDATE to be a no-op
${WASHTOOL} object libuafs
case ${SYS_NAME} in \
hp_ux* ) \
MKAFS_OSTYPE=HPUX;; \
*linux*) \
MKAFS_OSTYPE=LINUX;; \
rs_aix* ) \
MKAFS_OSTYPE=AIX;; \
sun4x_5* ) \
MKAFS_OSTYPE=SOLARIS;; \
alpha_dux4* ) \
MKAFS_OSTYPE=DUX;; \
sgi_6* ) \
MKAFS_OSTYPE=IRIX;; \
* ) \
echo WARNING: No MakefileProto for sys ${SYS_NAME} ; \
esac; \
obj/config/config src/libuafs/MakefileProto.$$MKAFS_OSTYPE obj/libuafs/Makefile ${SYS_NAME}
# "COMPILE_PART1=${COMPILE_PART1}" "COMPILE_PART2=${COMPILE_PART2}" SYS_NAME=${SYS_NAME} ;;
install:
$(MAKE) finale "SYS_NAME=${SYS_NAME}" "WASHTOOL=${WASHTOOL}" \
"COMPILE_PART1=${COMPILE_PART1}" \
"COMPILE_PART2=${COMPILE_PART2}" \
DESTDIR=`pwd`/${SYS_NAME}/dest/ \
SRCDIR=`pwd`/${SYS_NAME}/dest/ \
"DBG_DEFS=${DBG_DEFS}"
# sgi: "NON_SHARED=-non_shared"
#updatekdir:
# ${WASHTOOL} rcsupdate ${KERNELDIR} libafs
kupdate: updatekdir libafs_setup libuafs_setup
blibafs:
$(MAKE) libafs "WASHTOOL=${WASHTOOL}" "WASHTOOLFLAGS=-argument kinstall" SYS_NAME=${SYS_NAME} "CPUARCH=${CPUARCH}" "MPSP=${MPSP}" "DBG_DEFS=${DBG_DEFS}"
blibuafs:
$(MAKE) libuafs "WASHTOOL=${WASHTOOL}" "WASHTOOLFLAGS=-argument ukinstall" SYS_NAME=${SYS_NAME} "CPUARCH=${CPUARCH}" "MPSP=${MPSP}" "DBG_DEFS=${DBG_DEFS}"
bwebafs: sys
$(MAKE) libuafs "WASHTOOL=${WASHTOOL}" "WASHTOOLFLAGS=-argument webinstall" SYS_NAME=${SYS_NAME} "CPUARCH=${CPUARCH}" "MPSP=${MPSP}" "DBG_DEFS=${DBG_DEFS}"
clean:
${WASHTOOL} every "cd obj/%s; $(MAKE) clean" -rootd obj
checklist:
${WASHTOOL} every -command \
'cd rcs/%s; echo ; echo In %s:; if test x = "x`/bin/ls RCS/*,v`"; then exit 0; else rlog -I RCS/*,v; fi'
links:
echo "Remove the obj directory"
- /bin/rm -rf @sys/obj/* ;
- /bin/rm -rf @sys/dest/* ;
- /bin/mkdir @sys/obj ;
echo "Create the obj directories"
cd src; \
for file in `find [!NW]* -type d -print` ; do \
/bin/mkdir ../obj/$${file} ; \
done;
echo "Create the obj file links"
cd src; \
for file in `find [!NW]* -type f -print` ; do \
/bin/ln -s `pwd`/$${file} ../obj/$${file} ; \
done;

419
src/NTMakefile Normal file
View File

@ -0,0 +1,419 @@
# Copyright (C) 1998 Transarc Corporation. All rights reserved.
#
# Top level nmake NTMakefile driver for building AFS.
#
# This file simply imposes a reasonable total ordering on the set of
# directories to build; this ordering is of course more strict than the
# partial ordering established by the actual directory dependencies.
#
# When porting a new directory, simply add the directory into the
# dependence chain at the earliest point possible, updating its successor
# appropriately; if the new directory is the last in the chain, then
# update the 'finale' dependency to be the new directory.
CD = cd
NTMAKE = nmake /nologo /f ntmakefile install
NTMAKE_HEADERS = nmake /nologo /f ntmakefile install_headers
MKDIR = mkdir
# Standard install directory.
!IFDEF AFSDEV_DESTDIR
DESTDIR = $(AFSDEV_DESTDIR)
!ELSE
DESTDIR = $(AFSROOT)\DEST
!ENDIF
start:
! IF (!EXIST(src))
! ERROR Execute nmake from directory above src, e.g., afs\3.5.
! ENDIF
! IF (!EXIST($(DESTDIR)))
$(MKDIR) $(DESTDIR)
! ENDIF
config:
$(CD) src\$@
$(NTMAKE)
$(CD) ..\..
procmgmt_headers: config
$(CD) src\procmgmt
$(NTMAKE_HEADERS)
$(CD) ..\..
afsreg_headers: config
$(CD) src\WINNT\afsreg
$(NTMAKE_HEADERS)
$(CD) ..\..\..
util: procmgmt_headers afsreg_headers
$(CD) src\$@
$(NTMAKE)
$(CD) ..\..
comerr: util
$(CD) src\$@
$(NTMAKE)
$(CD) ..\..
cmd: comerr
$(CD) src\$@
$(NTMAKE)
$(CD) ..\..
afsreg: cmd
$(CD) src\WINNT\$@
$(NTMAKE)
$(CD) ..\..\..
eventlog: afsreg
$(CD) src\WINNT\$@
$(NTMAKE)
$(CD) ..\..\..
lwp: eventlog
$(CD) src\$@
$(NTMAKE)
$(CD) ..\..
rxgen: lwp
$(CD) src\$@
$(NTMAKE)
$(CD) ..\..
des: rxgen
! IF (EXIST(src\des\NTMakefile))
$(CD) src\des
$(NTMAKE)
$(CD) ..\..
! ELSE
$(CD) src\des_stub
$(NTMAKE)
$(CD) ..\..
! ENDIF
rx: des
$(CD) src\$@
$(NTMAKE)
$(CD) ..\..
rxstat: rx
$(CD) src\$@
$(NTMAKE)
$(CD) ..\..
rxkad: rxstat
$(CD) src\$@
$(NTMAKE)
$(CD) ..\..
pthread: rxkad
$(CD) src\WINNT\$@
$(NTMAKE)
$(CD) ..\..\..
procmgmt: pthread
$(CD) src\$@
$(NTMAKE)
$(CD) ..\..
fsint: procmgmt
$(CD) src\$@
$(NTMAKE)
$(CD) ..\..
audit: fsint
$(CD) src\$@
$(NTMAKE)
$(CD) ..\..
osi_headers: audit
$(CD) src\WINNT\client_osi
$(NTMAKE_HEADERS)
$(CD) ..\..\..
libacl_headers: osi_headers
$(CD) src\libacl
$(NTMAKE_HEADERS)
$(CD) ..\..
cm_headers: libacl_headers
$(CD) src\WINNT\afsd
$(NTMAKE_HEADERS)
$(CD) ..\..\..
sys: cm_headers
$(CD) src\$@
$(NTMAKE)
$(CD) ..\..
auth: sys
$(CD) src\$@
$(NTMAKE)
$(CD) ..\..
ubik: auth
$(CD) src\$@
$(NTMAKE)
$(CD) ..\..
ptserver: ubik
$(CD) src\$@
$(NTMAKE)
$(CD) ..\..
libacl: ptserver
$(CD) src\$@
$(NTMAKE)
$(CD) ..\..
kauth: libacl
$(CD) src\$@
$(NTMAKE)
$(CD) ..\..
vlserver: kauth
$(CD) src\$@
$(NTMAKE)
$(CD) ..\..
usd: vlserver
$(CD) src\$@
$(NTMAKE)
$(CD) ..\..
bubasics: usd
$(CD) src\$@
$(NTMAKE)
$(CD) ..\..
budb: bubasics
$(CD) src\$@
$(NTMAKE)
$(CD) ..\..
butm: budb
$(CD) src\$@
$(NTMAKE)
$(CD) ..\..
dir: butm
$(CD) src\$@
$(NTMAKE)
$(CD) ..\..
vol: dir
$(CD) src\$@
$(NTMAKE)
$(CD) ..\..
volser: vol
$(CD) src\$@
$(NTMAKE)
$(CD) ..\..
viced: volser
$(CD) src\$@
$(NTMAKE)
$(CD) ..\..
update: viced
$(CD) src\$@
$(NTMAKE)
$(CD) ..\..
bucoord: update
$(CD) src\$@
$(NTMAKE)
$(CD) ..\..
butc: bucoord
$(CD) src\$@
$(NTMAKE)
$(CD) ..\..
bozo: butc
$(CD) src\$@
$(NTMAKE)
$(CD) ..\..
bosctlsvc: bozo
$(CD) src\WINNT\$@
$(NTMAKE)
$(CD) ..\..\..
bu_utils: bosctlsvc
$(CD) src\$@
$(NTMAKE)
$(CD) ..\..
libafsrpc: bu_utils
$(CD) src\$@
$(NTMAKE)
$(CD) ..\..
libafsauthent: libafsrpc
$(CD) src\$@
$(NTMAKE)
$(CD) ..\..
tviced: libafsauthent
$(CD) src\$@
$(NTMAKE)
$(CD) ..\..
tbutc: tviced
$(CD) src\$@
$(NTMAKE)
$(CD) ..\..
libadmin: tbutc
$(CD) src\$@
$(NTMAKE)
$(CD) ..\..
adminutil: libadmin
$(CD) src\libadmin\$@
$(NTMAKE)
$(CD) ..\..\..
vos: adminutil
$(CD) src\libadmin\$@
$(NTMAKE)
$(CD) ..\..\..
client: vos
$(CD) src\libadmin\$@
$(NTMAKE)
$(CD) ..\..\..
kas: client
$(CD) src\libadmin\$@
$(NTMAKE)
$(CD) ..\..\..
pts: kas
$(CD) src\libadmin\$@
$(NTMAKE)
$(CD) ..\..\..
bos: pts
$(CD) src\libadmin\$@
$(NTMAKE)
$(CD) ..\..\..
cfg: bos
$(CD) src\libadmin\$@
$(NTMAKE)
$(CD) ..\..\..
admintest: cfg
$(CD) src\libadmin\test
$(NTMAKE)
$(CD) ..\..\..
talocale: admintest
$(CD) src\WINNT\$@
$(NTMAKE)
$(CD) ..\..\..
license: talocale
$(CD) src\WINNT\$@
$(NTMAKE)
$(CD) ..\..\..
afsadmsvr: license
$(CD) src\WINNT\$@
$(NTMAKE)
$(CD) ..\..\..
afsusrmgr: afsadmsvr
$(CD) src\WINNT\$@
$(NTMAKE)
$(CD) ..\..\..
afssvrmgr: afsusrmgr
$(CD) src\WINNT\$@
$(NTMAKE)
$(CD) ..\..\..
afssvrcfg: afssvrmgr
$(CD) src\WINNT\$@
$(NTMAKE)
$(CD) ..\..\..
afssvrcpa: afssvrcfg
$(CD) src\WINNT\$@
$(NTMAKE)
$(CD) ..\..\..
afs_setup_utils: afssvrcpa
$(CD) src\WINNT\$@
$(NTMAKE)
$(CD) ..\..\..
client_talocale: afs_setup_utils
$(CD) src\WINNT\talocale
$(NTMAKE)
$(CD) ..\..\..
client_osi: client_talocale
$(CD) src\WINNT\$@
$(NTMAKE)
$(CD) ..\..\..
afsd: client_osi
$(CD) src\WINNT\$@
$(NTMAKE)
$(CD) ..\..\..
client_cpa: afsd
$(CD) src\WINNT\$@
$(NTMAKE)
$(CD) ..\..\..
client_config: client_cpa
$(CD) src\WINNT\$@
$(NTMAKE)
$(CD) ..\..\..
client_exp: client_config
$(CD) src\WINNT\$@
$(NTMAKE)
$(CD) ..\..\..
client_creds: client_exp
$(CD) src\WINNT\$@
$(NTMAKE)
$(CD) ..\..\..
finale: client_creds
$(CD) src\$@
$(NTMAKE)
$(CD) ..\..
install: start finale
# InstallShield dependencies
InstallShield5: install
$(CD) src\WINNT\install\$@
$(NTMAKE)
$(CD) ..\..\..\..
media: InstallShield5
# Clean target for src tree
clean: start
nmake /nologo /f ntmakefile "NTMAKE = nmake /nologo /f ntmakefile clean" "NTMAKE_HEADERS = nmake /nologo /f ntmakefile clean" install
$(CD) src\config
nmake /nologo /f ntmakefile clean_version
$(CD) ..\..
# Language-only build target
lang:
nmake /nologo /f ntmakefile "NTMAKE = nmake /nologo /f ntmakefile lang" "NTMAKE_HEADERS = nmake /nologo /f ntmakefile lang" install

230
src/NTObjdir Executable file
View File

@ -0,0 +1,230 @@
#!/usr/bin/sh
# Copyright (C) 1998 Transarc Corporation. All rights reserved.
#
#
# Temporary NT obj directory creation utility; will be obsoleted when
# washtool is ported to NT.
#
# Execute on a Unix box in the directory above src (e.g., afs/3.5).
dirs="\
config \
WINNT \
WINNT/afsreg \
WINNT/afsreg/test \
WINNT/eventlog \
WINNT/eventlog/test \
WINNT/pthread \
WINNT/pthread/test \
WINNT/license \
WINNT/license/lang \
WINNT/bosctlsvc \
WINNT/talocale \
WINNT/afsadmsvr \
WINNT/afsapplib \
WINNT/afsapplib/resource \
WINNT/afsapplib/test \
WINNT/afsclass \
WINNT/afssvrmgr \
WINNT/afssvrmgr/resource \
WINNT/afsusrmgr \
WINNT/afsusrmgr/resource \
WINNT/afssvrcfg \
WINNT/afssvrcpa \
WINNT/afs_setup_utils \
WINNT/afs_setup_utils/lang \
WINNT/afs_setup_utils/lang/de_DE \
WINNT/afs_setup_utils/lang/en_US \
WINNT/afs_setup_utils/lang/es_ES \
WINNT/afs_setup_utils/lang/ja_JP \
WINNT/afs_setup_utils/lang/ko_KR \
WINNT/afs_setup_utils/lang/pt_BR \
WINNT/afs_setup_utils/lang/zh_CN \
WINNT/afs_setup_utils/lang/zh_TW \
WINNT/install \
WINNT/install/InstallShield5 \
WINNT/install/InstallShield5/lang \
WINNT/install/InstallShield5/lang/de_DE \
WINNT/install/InstallShield5/lang/en_US \
WINNT/install/InstallShield5/lang/es_ES \
WINNT/install/InstallShield5/lang/ja_JP \
WINNT/install/InstallShield5/lang/ko_KR \
WINNT/install/InstallShield5/lang/pt_BR \
WINNT/install/InstallShield5/lang/zh_CN \
WINNT/install/InstallShield5/lang/zh_TW \
WINNT/client_osi \
WINNT/client_cpa \
WINNT/client_config \
WINNT/client_exp \
WINNT/client_creds \
WINNT/client_ddk \
WINNT/afsd \
WINNT/afsapplib/lang \
WINNT/afsapplib/lang/de_DE \
WINNT/afsapplib/lang/en_US \
WINNT/afsapplib/lang/es_ES \
WINNT/afsapplib/lang/ja_JP \
WINNT/afsapplib/lang/ko_KR \
WINNT/afsapplib/lang/pt_BR \
WINNT/afsapplib/lang/zh_CN \
WINNT/afsapplib/lang/zh_TW \
WINNT/afssvrmgr/lang \
WINNT/afssvrmgr/lang/de_DE \
WINNT/afssvrmgr/lang/en_US \
WINNT/afssvrmgr/lang/es_ES \
WINNT/afssvrmgr/lang/ja_JP \
WINNT/afssvrmgr/lang/ko_KR \
WINNT/afssvrmgr/lang/pt_BR \
WINNT/afssvrmgr/lang/zh_CN \
WINNT/afssvrmgr/lang/zh_TW \
WINNT/afsusrmgr/lang \
WINNT/afsusrmgr/lang/de_DE \
WINNT/afsusrmgr/lang/en_US \
WINNT/afsusrmgr/lang/es_ES \
WINNT/afsusrmgr/lang/ja_JP \
WINNT/afsusrmgr/lang/ko_KR \
WINNT/afsusrmgr/lang/pt_BR \
WINNT/afsusrmgr/lang/zh_CN \
WINNT/afsusrmgr/lang/zh_TW \
WINNT/afssvrcfg/lang \
WINNT/afssvrcfg/lang/de_DE \
WINNT/afssvrcfg/lang/en_US \
WINNT/afssvrcfg/lang/es_ES \
WINNT/afssvrcfg/lang/ja_JP \
WINNT/afssvrcfg/lang/ko_KR \
WINNT/afssvrcfg/lang/pt_BR \
WINNT/afssvrcfg/lang/zh_CN \
WINNT/afssvrcfg/lang/zh_TW \
WINNT/afssvrcpa/lang \
WINNT/afssvrcpa/lang/de_DE \
WINNT/afssvrcpa/lang/en_US \
WINNT/afssvrcpa/lang/es_ES \
WINNT/afssvrcpa/lang/ja_JP \
WINNT/afssvrcpa/lang/ko_KR \
WINNT/afssvrcpa/lang/pt_BR \
WINNT/afssvrcpa/lang/zh_CN \
WINNT/afssvrcpa/lang/zh_TW \
WINNT/client_cpa/lang \
WINNT/client_cpa/lang/de_DE \
WINNT/client_cpa/lang/en_US \
WINNT/client_cpa/lang/es_ES \
WINNT/client_cpa/lang/ja_JP \
WINNT/client_cpa/lang/ko_KR \
WINNT/client_cpa/lang/pt_BR \
WINNT/client_cpa/lang/zh_CN \
WINNT/client_cpa/lang/zh_TW \
WINNT/client_config/lang \
WINNT/client_config/lang/de_DE \
WINNT/client_config/lang/en_US \
WINNT/client_config/lang/es_ES \
WINNT/client_config/lang/ja_JP \
WINNT/client_config/lang/ko_KR \
WINNT/client_config/lang/pt_BR \
WINNT/client_config/lang/zh_CN \
WINNT/client_config/lang/zh_TW \
WINNT/client_exp/lang \
WINNT/client_exp/lang/de_DE \
WINNT/client_exp/lang/en_US \
WINNT/client_exp/lang/es_ES \
WINNT/client_exp/lang/ja_JP \
WINNT/client_exp/lang/ko_KR \
WINNT/client_exp/lang/pt_BR \
WINNT/client_exp/lang/zh_CN \
WINNT/client_exp/lang/zh_TW \
WINNT/client_creds/lang \
WINNT/client_creds/lang/de_DE \
WINNT/client_creds/lang/en_US \
WINNT/client_creds/lang/es_ES \
WINNT/client_creds/lang/ja_JP \
WINNT/client_creds/lang/ko_KR \
WINNT/client_creds/lang/pt_BR \
WINNT/client_creds/lang/zh_CN \
WINNT/client_creds/lang/zh_TW \
WINNT/eventlog/lang \
WINNT/eventlog/lang/de_DE \
WINNT/eventlog/lang/en_US \
WINNT/eventlog/lang/es_ES \
WINNT/eventlog/lang/ja_JP \
WINNT/eventlog/lang/ko_KR \
WINNT/eventlog/lang/pt_BR \
WINNT/eventlog/lang/zh_CN \
WINNT/eventlog/lang/zh_TW \
procmgmt \
procmgmt/test \
util \
util/test \
lwp \
lwp/test \
rx \
rx/test \
comerr \
comerr/test \
des \
des_stub \
cmd \
rxgen \
rxstat \
rxkad \
rxkad/domestic \
rxkad/test \
fsint \
audit \
sys \
auth \
auth/test \
ubik \
ptserver \
libacl \
libacl/test \
kauth \
kauth/test \
vlserver \
usd \
bubasics \
budb \
butm \
bucoord \
butc \
tbutc \
dir \
vol \
volser \
viced \
tviced \
bozo \
update \
bu_utils \
finale \
libafsrpc \
libafsauthent \
libadmin \
libadmin/adminutil \
libadmin/bos \
libadmin/client \
libadmin/kas \
libadmin/pts \
libadmin/vos \
libadmin/cfg \
libadmin/test \
libadmin/cfg/test"
if [ ! -d src ]; then
echo $0: Execute from directory above src, e.g., afs/3.5.
exit 1
fi
if [ ! -d i386_nt40 ]; then
echo $0: Directory i386_nt40 does not exist.
exit 1
fi
if [ ! -x src/WINNT/docs/build/ntobjdirs ]; then
echo $0: script src/WINNT/docs/build/ntobjdirs not found.
exit 1
fi
for d in $dirs; do
echo src/WINNT/docs/build/ntobjdirs -d $d
src/WINNT/docs/build/ntobjdirs -d $d
done

86
src/README Normal file
View File

@ -0,0 +1,86 @@
Building OpenAFS on UNIX and LINUX
----------------------------------
A. Creating the proper directory structure.
Uncompress the source into a directory of your choice.
Preferrably, afs space. In the directory that you uncompressed the
source in, you will only have an src directory.
1. Make a directory for each system type that you plan on
building. Current tested system types include the following
(this step is skipped for the i386_nt40 system type):
alpha_dux40/
i386_linux22/
rs_aix42/
sun4x_56/
sun4x_57/
Example:
% mkdir i386_linux22
% ls -CF
i386_linux22/ src/
Builds for the following platforms will not fully compile:
hp_ux110/
sgi_65/
2. Within each of those directories, create a dest/ and obj/ directory.
Example:
% mkdir i386_linux22/dest
% mkdir i386_linux22/obj
3. Create symbolic links to the system type you are about to build
Example:
% ln -s @sys/dest dest
% ln -s @sys/obj obj
% ls -CF
Makefile@ dest@ i386_linux22/ obj@ src/
4. If this source is NOT in AFS space, You must make a link from
@sys to your current system type.
Example:
% ln -s i386_linux22 @sys
Within AFS space, the AFS Cache Manager automatically
substitutes the local machine's AFS system name (CPU/operating
system type [ie: alpha_dux40, i386_linux22, ...]) for the @sys
variable.
5. Create the top level Makefile:
a. For LINUX and UNIX versions
Example:
% ln -s src/Makefile Makefile
% ls -CF
Makefile@ i386_linux22/ src/
B Building
1. Make the obj links. This creates links from the @sys/obj/ tree
back to the source tree. The source tree remains unchanged and
builds are done in the platform specific object tree.
% make links
2. Begin building
a. For Linux
% make SYS_NAME="i386_linux22" LINUX_VERSION="2.2.14"
b. For UNIX versions, specify the system name as given by
the system type defined in step A1.
% make SYS_NAME="<system_name>"
Example for the rs_aix42 operating system:
% make SYS_NAME="rs_aix42"
C Problems
If you have a problem building this source, you may want to visit
http://oss.software.ibm.com/developerworks/opensource/afs/ to see
if any problems have been reported or to find out how to get more
help.

170
src/README-NT Normal file
View File

@ -0,0 +1,170 @@
Building OpenAFS on Windows NT
------------------------------
There are several steps that must be performed before a successful
build of AFS on Windows NT can be completed. These steps are as follows:
A. Install a compiler
B. Add missing header files
C. Optional: Install Installshield 5.x
D. Optional: Install flex and bison
E. Configure the OpenAFS build environment
F. Begin the build
Each step is explained in detail below:
A. Install a compiler
You must install a copy of Microsoft Visual C++ 5.0 (6 might also
work). The "Typical" install setting is sufficient. It may be
possible to use other compilers, but the source code as provided
will work with MS VC++ 5.0.
B. Add missing header files
Files from Microsoft's Device Driver Development kits for NT and
Windows 9x are required to complete a build on NT. They are
copyrighted by Microsoft and so cannot be included with the OpenAFS
source tree. These files are:
netmpr.h
netspi.h
npapi.h
These files come from Microsoft DDKs as follows:
January 1997 Windows NT Workstation DDK - /ddk/frc/network/inc/npapi.h
July 1998 Windows 95 DDK - net/inc/netmpr.h and net/inc/netspi.h
The may also be available on more recent releases of the DDKs.
These files must live on the include path.
C. Optional: Install Installshield 5.x
There are two ways to build OpenAFS on NT:
1. Build of the product, or
2. build of the product plus an installer package
In order to do the build that includes the installer package, a
copy of InstallShield 5.x must be installed. NOTE: InstallShield
versions 6 and higher WILL NOT WORK.
D. Optional: Install flex and bison
There are two files in the source tree that are processed with lex
and yacc on UNIX systems, src/comerr/et_lex.lex.l and
src/comerr/error_table.y, that when processed produce the files
et_lex.lex_nt.c, error_table_nt.c, and error_table_nt.h.
Since NT does not include lex and yacc or any equivalent tools, we
have provided the output files that lex and yacc produce (using
Win32 ports of flex and bison). This will allow builds to work for
anyone who does not need to change the .l and .y files.
If you do need to change et_lex.lex.l, then you will need to
install Win32 port of flex on your system. Put flex.exe in a
directory on the path and rebuild.
If you do need to change error_table.y, then you will need to
install a Win32 port of bison on your system. Put bison.exe in a
directory on the path, configure bison as explained in step 5, and
rebuild.
You can also attempt to use other replacements for lex and yacc.
This will require modifying the LEX and YACC settings in
src/config/NTMakefile.i386_nt40. If the replacements require
different command line options than flex and bison, then you may
also need to change src/comerr/NTMakefile.
E. Configure the OpenAFS build environment
A set of environment variables used by the OpenAFS makefiles must
be properly set for a build to successfully complete. The file
src/ntbuild.bat is a DOS-style batch file that will configure these
settings for you. Within this file there are the following lines
that must be set to match your system settings:
set MSVCDIR=<path to vc directory of MS Visual C++>
Ex: set MSVCDIR=c:\progra~1\DevStudio\vc
This is the path to the compiler directory of the Microsot Visual
C++ installation.
set AFSDEV_INCLUDE=<default include directories>
Ex: set AFSDEV_INCLUDE=%MSVCDIR%\include;%MSVCDIR%\mfc\include
This contains a semicolon separated list of directories that
contain compiler provided include files. You do not need to add paths
here of AFS include files.
set AFSDEV_LIB=<default library directories>
Ex: set AFSDEV_LIB=%MSVCDIR%\lib;%MSVCDIR%\mfc\lib
This contains a semicolon separated list of directories that
contain compiler provided library files. You do not need to add
paths here of AFS library files.
set AFSDEV_BIN=<compiler binaries directory>
Ex: set AFSDEV_BIN=%MSVCDIR%\bin
This is the path to the compiler binary files.
set AFSROOT=<Root directory of OpenAFS - parent of the src directory>
Ex: set AFSROOT=d:\OpenAFS
This is the root directory of OpenAFS, which is the parent
directory of the src directory.
set IS5ROOT=<root directory of the InstallShield5 program files>
Ex: set IS5ROOT=d:\progra~1\instal~1\instal~1.1pr
This is the path to the InstallShield5 program directory. You
should only define this if you have InstallShield installed on
your computer and want to create the install package as part of
the build.
set BISON_SIMPLE=<path to bison.simple>
set BISON_HAIRY=<path to bison.hairy>
Ex: set BISON_SIMPLE=c:\bin\bison.simple
Ex: set BISON_HAIRY=c:\bin\bison.hairy
bison has two files (in addition to the bison executable) that
must be on the system. In order for bison to find these files,
you must set the environment variables listed above to the paths
to these files. There are other ways to do this, but this is
what the build system expects.
NOTE: There are other settings in ntbuild.bat, but the ones listed
above must be set correctly for the build to succeed.
As can be seen in the examples above, all paths in ntbuild.bat must
be in the old MSDOS 8.3 format.
F. Begin the build
1. Make sure you are running the default NT command shell, cmd.exe.
Other shells may work, but many do not.
2. Run the ntbuild.bat file that was configured in step 5. You can
include the word "checked" on the command line to create binaries
that include debug information, or the word "free" to create
binaries that do not include debug information.
For a debug build, run:
ntbuild checked
For a release build, run:
ntbuild free
3. Copy the file src/NTMakefile to the parent of the src directory.
You only need to do this once.
4. Begin the build. You can choose to build just the product bits,
or, if InstallShield is installed, the product bits and the
install package.
To build just the product bits, run:
nmake /f NTMakefile install
To build the product bits and the install package, run:
nmake /f NTMakefile media

View File

@ -0,0 +1,164 @@
# Copyright (C) 1998 Transarc Corporation. All rights reserved.
############################################################################
# make compiler warnings fatal
AFSDEV_AUXCDEFINES = $(AFSDEV_AUXCDEFINES) -WX
# include the primary makefile
!INCLUDE ..\..\config\NTMakefile.$(SYS_NAME)
!INCLUDE ..\..\config\NTMakefile.version
############################################################################
ILIBDIR = $(DESTDIR)\lib\afs
############################################################################
# Build targets - one for each dll we need to make
INSTALL_UTILS_DLLFILE = $(DESTDIR)\root.server\usr\afs\bin\InstallUtils.dll
SERVER_UNINST_DLLFILE = $(DESTDIR)\root.server\usr\afs\bin\ServerUninst.dll
CLIENT_UNINST_DLLFILE = $(DESTDIR)\root.server\usr\afs\bin\ClientUninst.dll
CC_UNINST_DLLFILE = $(DESTDIR)\root.server\usr\afs\bin\CCUninst.dll
LIGHT_CLIENT_UNINST_DLLFILE = $(DESTDIR)\root.server\usr\afs\bin\LightClientUninst.dll
DOCS_UNINST_DLLFILE = $(DESTDIR)\root.server\usr\afs\bin\DocsUninst.dll
############################################################################
# Source files and libraries that are shared by all of the targets.
AFSAPPLIBOBJS = \
subclass.obj
DLLOBJS = \
$(AFSAPPLIBOBJS) \
progress_dlg.obj \
animate_icon.obj \
sutil.obj \
forceremove.obj \
afs_setup_utils_stub.res
VCLIBS = \
comctl32.lib \
shell32.lib
DLLLIBS = \
$(DESTDIR)\lib\afs\TaLocale.lib \
$(DESTDIR)\lib\afs\afsreg.lib \
$(DESTDIR)\lib\afs\afsutil.lib
############################################################################
# Definitions for building afsapplib objects
AFSAPPLIBDIR = ..\..\WINNT\afsapplib
subclass.obj: $(AFSAPPLIBDIR)\subclass.cpp
$(C2OBJ) -I$(AFSAPPLIBDIR) $(AFSAPPLIBDIR)\subclass.cpp
############################################################################
# Definitions for building afsrm.exe
AFSRM_EXEFILE = $(DESTDIR)\bin\afsrm.exe
AFSRM_EXEOBJS =\
afsrm.obj \
forceremove.obj \
sutil.obj \
AFS_component_version_number.obj
AFSRM_EXELIBS =\
$(DESTDIR)\lib\afs\afsreg.lib \
$(DESTDIR)\lib\afs\afscmd.lib \
$(DESTDIR)\lib\afs\afscom_err.lib \
$(DESTDIR)\lib\afs\afsutil.lib
$(AFSRM_EXEFILE): $(AFSRM_EXEOBJS) $(AFSRM_EXELIBS)
$(EXECONLINK)
############################################################################
install : $(INSTALL_UTILS_DLLFILE) $(SERVER_UNINST_DLLFILE) $(CLIENT_UNINST_DLLFILE) \
$(CC_UNINST_DLLFILE) $(LIGHT_CLIENT_UNINST_DLLFILE) $(DOCS_UNINST_DLLFILE) \
$(AFSRM_EXEFILE) lang
lang ::
$(CD) lang
for /f %l in ('dir /B ??_??') do @$(NTLANG) %l $(MAKECMD) /nologo /f NTMakefile install
$(CD) ..
############################################################################
# How to build the shared source file for each uninstall dll
s_afs_setup_utils.obj: afs_setup_utils.cpp
$(C2OBJ) afs_setup_utils.cpp -DSERVER_UNINST /Fos_afs_setup_utils.obj
c_afs_setup_utils.obj: afs_setup_utils.cpp
$(C2OBJ) afs_setup_utils.cpp -DCLIENT_UNINST /Foc_afs_setup_utils.obj
cc_afs_setup_utils.obj: afs_setup_utils.cpp
$(C2OBJ) afs_setup_utils.cpp -DCC_UNINST /Focc_afs_setup_utils.obj
lc_afs_setup_utils.obj: afs_setup_utils.cpp
$(C2OBJ) afs_setup_utils.cpp -DLIGHT_CLIENT_UNINST /Folc_afs_setup_utils.obj
d_afs_setup_utils.obj: afs_setup_utils.cpp
$(C2OBJ) afs_setup_utils.cpp -DDOCS_UNINST /Fod_afs_setup_utils.obj
############################################################################
$(INSTALL_UTILS_DLLFILE) : afs_setup_utils.obj $(DLLOBJS) $(DLLLIBS)
$(DLLGUILINK) -entry:DllEntryPoint /DEF:install_utils.def $(VCLIBS)
$(DLLPREP)
$(COPY) $*.lib $(ILIBDIR)
$(DEL) $*.lib $*.exp
$(SERVER_UNINST_DLLFILE) : s_afs_setup_utils.obj $(DLLOBJS) $(DLLLIBS)
$(DLLGUILINK) -entry:DllEntryPoint /DEF:server_uninst.def $(VCLIBS)
$(DLLPREP)
$(COPY) $*.lib $(ILIBDIR)
$(DEL) $*.lib $*.exp
$(CLIENT_UNINST_DLLFILE) : c_afs_setup_utils.obj $(DLLOBJS) $(DLLLIBS)
$(DLLGUILINK) -entry:DllEntryPoint /DEF:client_uninst.def $(VCLIBS)
$(DLLPREP)
$(COPY) $*.lib $(ILIBDIR)
$(DEL) $*.lib $*.exp
$(CC_UNINST_DLLFILE) : cc_afs_setup_utils.obj $(DLLOBJS) $(DLLLIBS)
$(DLLGUILINK) -entry:DllEntryPoint /DEF:cc_uninst.def $(VCLIBS)
$(DLLPREP)
$(COPY) $*.lib $(ILIBDIR)
$(DEL) $*.lib $*.exp
$(LIGHT_CLIENT_UNINST_DLLFILE) : lc_afs_setup_utils.obj $(DLLOBJS) $(DLLLIBS)
$(DLLGUILINK) -entry:DllEntryPoint /DEF:light_client_uninst.def $(VCLIBS)
$(DLLPREP)
$(COPY) $*.lib $(ILIBDIR)
$(DEL) $*.lib $*.exp
$(DOCS_UNINST_DLLFILE) : d_afs_setup_utils.obj $(DLLOBJS) $(DLLLIBS)
$(DLLGUILINK) -entry:DllEntryPoint /DEF:docs_uninst.def $(VCLIBS)
$(DLLPREP)
$(COPY) $*.lib $(ILIBDIR)
$(DEL) $*.lib $*.exp
############################################################################
clean::
############################################################################
#
# Dependencies
#
afs_setup_utils_stub.res : afs_setup_utils_stub.rc AFS_component_version_number.h

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,28 @@
/*
* Copyright (C) 1998 Transarc Corporation.
* All rights reserved.
*
*/
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include <windows.h>
#define AFS_VERINFO_FILE_DESCRIPTION "AFS Setup Utilities DLL"
#include "AFS_component_version_number.h"
#include "..\..\config\NTVersioninfo.rc"
//////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_SPINSTOP ICON DISCARDABLE "..\\afsapplib\\resource\\spinstop.ico"

View File

@ -0,0 +1,55 @@
/* Copyright (C) 1999 Transarc Corporation - All rights reserved.
*
*/
/* Utility to forcibly remove AFS software without using InstallShield */
#include <afs/param.h>
#include <afs/stds.h>
#include <afs/cmd.h>
#include <windows.h>
#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include "forceremove.h"
static int DoClient34(struct cmd_syndesc *as, char *arock)
{
DWORD status = Client34Eradicate(FALSE);
if (status == ERROR_SUCCESS) {
printf("Client 3.4a removal succeeded\n");
} else {
printf("Client 3.4a removal failed (%d)\n", (int)status);
}
return 0;
}
static void
SetupCmd(void)
{
struct cmd_syndesc *ts;
ts = cmd_CreateSyntax("client34", DoClient34, 0,
"remove AFS 3.4a client");
}
int main(int argc, char *argv[])
{
int code;
/* initialize command syntax */
initialize_cmd_error_table();
SetupCmd();
/* execute command */
code = cmd_Dispatch(argc, argv);
return (code);
}

View File

@ -0,0 +1,101 @@
/*
* Copyright (C) 1998 Transarc Corporation.
* All rights reserved.
*
*/
/*
* INCLUDES ___________________________________________________________________
*
*/
extern "C" {
#include <afs/param.h>
#include <afs/stds.h>
}
#include <windows.h>
#include <WINNT/talocale.h>
#include "../afsapplib/subclass.h"
#include "animate_icon.h"
#include "resource.h"
/*
* Definitions ___________________________________________________________________
*
*/
#define GWD_ANIMATIONFRAME TEXT("afsapplib/al_misc.cpp - next animation frame")
/*
* ANIMATION __________________________________________________________________
*
*/
void AnimateIcon (HWND hIcon, int *piFrameLast)
{
static HICON hiStop;
static HICON hiFrame[8];
static BOOL fLoaded = FALSE;
if (!fLoaded)
{
hiStop = TaLocale_LoadIcon (IDI_SPINSTOP);
hiFrame[0] = TaLocale_LoadIcon (IDI_SPIN1);
hiFrame[1] = TaLocale_LoadIcon (IDI_SPIN2);
hiFrame[2] = TaLocale_LoadIcon (IDI_SPIN3);
hiFrame[3] = TaLocale_LoadIcon (IDI_SPIN4);
hiFrame[4] = TaLocale_LoadIcon (IDI_SPIN5);
hiFrame[5] = TaLocale_LoadIcon (IDI_SPIN6);
hiFrame[6] = TaLocale_LoadIcon (IDI_SPIN7);
hiFrame[7] = TaLocale_LoadIcon (IDI_SPIN8);
fLoaded = TRUE;
}
if (piFrameLast)
{
*piFrameLast = (*piFrameLast == 7) ? 0 : (1+*piFrameLast);
}
SendMessage (hIcon, STM_SETICON, (WPARAM)((piFrameLast) ? hiFrame[ *piFrameLast ] : hiStop), 0);
}
BOOL CALLBACK AnimationHook (HWND hIcon, UINT msg, WPARAM wp, LPARAM lp)
{
PVOID oldProc = Subclass_FindNextHook (hIcon, AnimationHook);
static int iFrame = 0;
switch (msg)
{
case WM_TIMER:
AnimateIcon (hIcon, &iFrame);
break;
case WM_DESTROY:
Subclass_RemoveHook (hIcon, AnimationHook);
break;
}
if (oldProc)
return CallWindowProc ((WNDPROC)oldProc, hIcon, msg, wp, lp);
else
return DefWindowProc (hIcon, msg, wp, lp);
}
void StartAnimation (HWND hIcon, int fps)
{
Subclass_AddHook (hIcon, AnimationHook);
SetTimer (hIcon, 0, 1000/((fps) ? fps : 8), NULL);
AnimateIcon (hIcon);
}
void StopAnimation (HWND hIcon)
{
KillTimer (hIcon, 0);
AnimateIcon (hIcon);
Subclass_RemoveHook (hIcon, AnimationHook);
}

View File

@ -0,0 +1,12 @@
/*
* Copyright (C) 1998 Transarc Corporation.
* All rights reserved.
*
*/
void AnimateIcon (HWND hIcon, int *piFrameLast = NULL);
void StartAnimation (HWND hIcon, int fps);
void StopAnimation (HWND hIcon);

View File

@ -0,0 +1,10 @@
LIBRARY CCUninst.dll
CODE PRELOAD MOVEABLE DISCARDABLE
DATA PRELOAD SINGLE
EXPORTS
DllEntryPoint
UninstInitialize
UninstUnInitialize

View File

@ -0,0 +1,10 @@
LIBRARY ClientUninst.dll
CODE PRELOAD MOVEABLE DISCARDABLE
DATA PRELOAD SINGLE
EXPORTS
DllEntryPoint
UninstInitialize
UninstUnInitialize

View File

@ -0,0 +1,10 @@
LIBRARY DocsUninst.dll
CODE PRELOAD MOVEABLE DISCARDABLE
DATA PRELOAD SINGLE
EXPORTS
DllEntryPoint
UninstInitialize
UninstUnInitialize

View File

@ -0,0 +1,558 @@
/* Copyright (C) 1999 Transarc Corporation - All rights reserved.
*
*/
#include <afs/param.h>
#include <afs/stds.h>
#include <windows.h>
#include <stdlib.h>
#include <stddef.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <WINNT/afsreg.h>
#include "forceremove.h"
#include "sutil.h"
/* Functions to forcibly remove AFS software without using InstallShield. */
#define CLIENT34_FME_VALUE "HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows NT\\CurrentVersion\\File Manager\\AddOns\\AFS Client FME"
#define MS_UNINSTALL_KEY "HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall"
static DWORD
ClientSoftwareGet(DWORD *version, char *dir, DWORD dirSize);
static DWORD
ClientServiceDelete(void);
static DWORD
FileForceRemove(const char *filePath);
static DWORD
DirectoryForceRemove(const char *dir);
static DWORD
FolderLocateInTree(const char *dir, const char *folderName, char *buf);
static DWORD
Client34ZapUninstallKeys(void);
/* ------------------ exported functions ---------------------- */
/*
* Client34Eradicate() -- remove AFS 3.4a client, if extant.
*
* If keepConfig is TRUE then the following are not removed:
*
* a) file %WINDIR%\afsdcell.ini - CellServDB
* b) file %WINDIR%\afsdsbmt.ini - submount settings
* c) file %WINDIR%\afsd.ini - client parameter settings
*/
DWORD Client34Eradicate(BOOL keepConfig)
{
DWORD rc = ERROR_SUCCESS;
DWORD status, version;
BOOL installPathValid = FALSE;
char installPath[MAX_PATH];
char winPath[MAX_PATH];
char sysPath[MAX_PATH];
char filePath[MAX_PATH];
/* check client version and fetch install directory */
status = ClientSoftwareGet(&version, installPath, MAX_PATH);
if (status == ERROR_SUCCESS) {
if (version == 34) {
/* 3.4 client to eradicate */
installPathValid = TRUE;
} else {
/* 3.5 or later client installed */
return ERROR_SUCCESS;
}
}
/* If no client info found then assume partial unconfigure and keep
* trying. Save errors as proceed but keep going to maximize removal.
*/
/* stop and delete client service */
status = ClientServiceDelete();
if (status != ERROR_SUCCESS) {
rc = status;
}
/* remove client files */
status = GetWindowsDirectory(winPath, MAX_PATH);
if (status == 0 || status > MAX_PATH) {
/* this should never happen */
winPath[0] = '\0';
}
status = GetSystemDirectory(sysPath, MAX_PATH);
if (status == 0 || status > MAX_PATH) {
/* this should never happen */
sysPath[0] = '\0';
}
if (installPathValid) {
status = DirectoryForceRemove(installPath);
if (status != ERROR_SUCCESS && status != ERROR_PATH_NOT_FOUND) {
rc = status;
}
}
sprintf(filePath, "%s\\%s", winPath, "afsd.log");
status = FileForceRemove(filePath);
if (status != ERROR_SUCCESS && status != ERROR_FILE_NOT_FOUND) {
rc = status;
}
sprintf(filePath, "%s\\%s", winPath, "afsd_init.log");
status = FileForceRemove(filePath);
if (status != ERROR_SUCCESS && status != ERROR_FILE_NOT_FOUND) {
rc = status;
}
sprintf(filePath, "%s\\%s", sysPath, "afs_cpa.cpl");
status = FileForceRemove(filePath);
if (status != ERROR_SUCCESS && status != ERROR_FILE_NOT_FOUND) {
rc = status;
}
sprintf(filePath, "%s\\%s", sysPath, "afs_shl_ext.dll");
status = FileForceRemove(filePath);
if (status != ERROR_SUCCESS && status != ERROR_FILE_NOT_FOUND) {
rc = status;
}
if (!keepConfig) {
sprintf(filePath, "%s\\%s", winPath, "afsdcell.ini");
status = FileForceRemove(filePath);
if (status != ERROR_SUCCESS && status != ERROR_FILE_NOT_FOUND) {
rc = status;
}
sprintf(filePath, "%s\\%s", winPath, "afsdsbmt.ini");
status = FileForceRemove(filePath);
if (status != ERROR_SUCCESS && status != ERROR_FILE_NOT_FOUND) {
rc = status;
}
sprintf(filePath, "%s\\%s", winPath, "afsd.ini");
status = FileForceRemove(filePath);
if (status != ERROR_SUCCESS && status != ERROR_FILE_NOT_FOUND) {
rc = status;
}
}
do { /* locate all start menu entries (common or for a user) */
status = FolderLocateInTree(winPath, "Transarc AFS Client", filePath);
if (status == ERROR_SUCCESS) {
status = DirectoryForceRemove(filePath);
}
} while (status == ERROR_SUCCESS);
if (status != ERROR_FILE_NOT_FOUND) {
rc = status;
}
/* update relevant Microsoft registry entries */
status = RegDeleteEntryAlt(CLIENT34_FME_VALUE, REGENTRY_VALUE);
if (status != ERROR_SUCCESS && status != ERROR_FILE_NOT_FOUND) {
rc = status;
}
status = Client34ZapUninstallKeys();
if (status != ERROR_SUCCESS) {
rc = status;
}
if (!RemoveFromProviderOrder(AFSREG_CLT_SVC_NAME)) {
/* function does not supply an error value; make one up */
rc = ERROR_FILE_NOT_FOUND;
}
if (installPathValid) {
status = GetShortPathName(installPath, filePath, MAX_PATH);
if (status == 0 || status > MAX_PATH) {
strcpy(filePath, installPath);
}
strcat(filePath, "\\Program");
if (!RemoveFromSystemPath(filePath)) {
/* function does not supply an error value; make one up */
rc = ERROR_FILE_NOT_FOUND;
}
}
/* remove client registry entries */
status = RegDeleteEntryAlt(AFSREG_CLT_SVC_KEY, REGENTRY_KEY);
if (status != ERROR_SUCCESS && status != ERROR_FILE_NOT_FOUND) {
rc = status;
}
status = RegDeleteEntryAlt(AFSREG_CLT_SW_KEY, REGENTRY_KEY);
if (status != ERROR_SUCCESS && status != ERROR_FILE_NOT_FOUND) {
rc = status;
}
return rc;
}
/* ------------------ utility functions ---------------------- */
/*
* ClientSoftwareGet() -- fetch client software installation information.
*/
static DWORD
ClientSoftwareGet(DWORD *version, char *dir, DWORD dirSize)
{
HKEY key;
DWORD rc = ERROR_SUCCESS;
/* get client version and install directory */
rc = RegOpenKeyAlt(AFSREG_NULL_KEY, AFSREG_CLT_SW_VERSION_KEY,
KEY_READ, 0, &key, NULL);
if (rc == ERROR_SUCCESS) {
DWORD major, minor, dataSize;
dataSize = sizeof(DWORD);
rc = RegQueryValueEx(key, AFSREG_CLT_SW_VERSION_MAJOR_VALUE,
NULL, NULL, (void*)&major, &dataSize);
if (rc == ERROR_SUCCESS) {
dataSize = sizeof(DWORD);
rc = RegQueryValueEx(key, AFSREG_CLT_SW_VERSION_MINOR_VALUE,
NULL, NULL, (void*)&minor, &dataSize);
if (rc == ERROR_SUCCESS) {
dataSize = dirSize;
rc = RegQueryValueEx(key, AFSREG_CLT_SW_VERSION_DIR_VALUE,
NULL, NULL, dir, &dataSize);
}
}
(void)RegCloseKey(key);
if (rc == ERROR_SUCCESS) {
*version = (major * 10) + minor;
}
}
return rc;
}
/*
* ClientServiceDelete() -- stop and delete the client service.
*/
static DWORD
ClientServiceDelete(void)
{
SC_HANDLE scmHandle, svcHandle;
DWORD rc = ERROR_SUCCESS;
if ((scmHandle = OpenSCManager(NULL,
NULL, SC_MANAGER_ALL_ACCESS)) == NULL ||
(svcHandle = OpenService(scmHandle,
AFSREG_CLT_SVC_NAME,
SERVICE_ALL_ACCESS)) == NULL) {
/* can't connect to SCM or can't open service */
DWORD status = GetLastError();
if (status != ERROR_SERVICE_DOES_NOT_EXIST) {
rc = status;
}
if (scmHandle != NULL) {
CloseServiceHandle(scmHandle);
}
} else {
SERVICE_STATUS svcStatus;
if (!ControlService(svcHandle, SERVICE_CONTROL_STOP, &svcStatus)) {
/* service stop failed */
DWORD status = GetLastError();
if (status != ERROR_SERVICE_NOT_ACTIVE) {
rc = status;
}
}
if (rc == ERROR_SUCCESS) {
if (!DeleteService(svcHandle)) {
/* service delete failed */
DWORD status = GetLastError();
if (status != ERROR_SERVICE_MARKED_FOR_DELETE) {
rc = status;
}
}
}
CloseServiceHandle(svcHandle);
CloseServiceHandle(scmHandle);
if (rc == ERROR_SUCCESS) {
/* let client state settle; not mandatory so don't do query */
Sleep(2000);
}
}
return rc;
}
/*
* DirectoryForceRemove() -- forcibly, and recursively, remove a directory
* and its contents; this may require moving in-use files to a temp
* directory and marking them for delete on reboot.
*/
static DWORD
DirectoryForceRemove(const char *dir)
{
DWORD rc = ERROR_SUCCESS;
HANDLE enumHandle;
WIN32_FIND_DATA enumResult;
char filePath[MAX_PATH];
/* enumerate directory and delete contents */
sprintf(filePath, "%s\\*.*", dir);
enumHandle = FindFirstFile(filePath, &enumResult);
if (enumHandle == INVALID_HANDLE_VALUE) {
DWORD status = GetLastError();
if (status != ERROR_NO_MORE_FILES) {
/* failure other than contents already deleted */
rc = status;
}
} else {
while (1) {
DWORD status;
sprintf(filePath, "%s\\%s", dir, enumResult.cFileName);
if (enumResult.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
if (strcmp(enumResult.cFileName, ".") == 0 ||
strcmp(enumResult.cFileName, "..") == 0) {
/* ignore these special directories */
status = ERROR_SUCCESS;
} else {
status = DirectoryForceRemove(filePath);
}
} else {
status = FileForceRemove(filePath);
}
if (status != ERROR_SUCCESS && status != ERROR_FILE_NOT_FOUND) {
/* save error but keep on truckin' */
rc = status;
}
if (!FindNextFile(enumHandle, &enumResult)) {
status = GetLastError();
if (status != ERROR_NO_MORE_FILES) {
rc = status;
}
break;
}
}
FindClose(enumHandle);
}
if (rc == ERROR_SUCCESS) {
if (!RemoveDirectory(dir)) {
rc = GetLastError();
}
}
return rc;
}
/*
* FileForceRemove() -- forcibly remove a file; if the file is in-use then
* move the file to a temp directory and mark it for delete on reboot.
*/
static DWORD
FileForceRemove(const char *filePath)
{
DWORD rc = ERROR_SUCCESS;
if (!DeleteFile(filePath)) {
rc = GetLastError();
if (rc != ERROR_FILE_NOT_FOUND) {
/* couldn't just delete; probably in use; try to move */
char filePathFull[MAX_PATH];
char *dummy;
DWORD status;
rc = ERROR_SUCCESS;
status = GetFullPathName(filePath, MAX_PATH, filePathFull, &dummy);
if (status == 0 || status > MAX_PATH) {
if (status == 0) {
rc = GetLastError();
} else {
rc = ERROR_INVALID_PARAMETER;
}
}
if (rc == ERROR_SUCCESS) {
char tempDir[MAX_PATH];
char tempPath[MAX_PATH];
status = GetTempPath(MAX_PATH, tempDir);
if ((status == 0 || status > MAX_PATH) ||
(_strnicmp(tempDir, filePathFull, 3))) {
/* failed getting temp dir, or temp dir is on different
* drive than file (so can't do a true move to there).
*/
sprintf(tempDir, "%c:\\", filePathFull[0]);
}
if (!GetTempFileName(tempDir, "AFS", 0, tempPath)) {
rc = GetLastError();
} else {
if (MoveFileEx(filePathFull, tempPath,
MOVEFILE_REPLACE_EXISTING)) {
(void)SetFileAttributes(tempPath,
FILE_ATTRIBUTE_NORMAL);
(void)MoveFileEx(tempPath, NULL,
MOVEFILE_DELAY_UNTIL_REBOOT);
} else {
rc = GetLastError();
}
}
}
}
}
return rc;
}
/*
* FolderLocateInTree() -- find an instance of named directory in specified
* tree; folderName is presumed to be a directory name only (i.e., not
* a path); buf is presumed to be at least MAX_PATH characters.
*/
static DWORD
FolderLocateInTree(const char *dir, const char *folderName, char *buf)
{
DWORD rc = ERROR_SUCCESS;
HANDLE enumHandle;
WIN32_FIND_DATA enumResult;
char filePath[MAX_PATH];
/* enumerate directory recursively looking for folder */
sprintf(filePath, "%s\\*.*", dir);
enumHandle = FindFirstFile(filePath, &enumResult);
if (enumHandle == INVALID_HANDLE_VALUE) {
DWORD status = GetLastError();
if (status == ERROR_NO_MORE_FILES) {
rc = ERROR_FILE_NOT_FOUND;
} else {
rc = status;
}
} else {
while (1) {
DWORD status = ERROR_FILE_NOT_FOUND;
if (enumResult.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
if (_stricmp(enumResult.cFileName, folderName) == 0) {
/* is folder that we're looking for */
sprintf(buf, "%s\\%s", dir, enumResult.cFileName);
status = ERROR_SUCCESS;
} else if (strcmp(enumResult.cFileName, ".") != 0 &&
strcmp(enumResult.cFileName, "..") != 0) {
/* is not folder that we're looking for; search it */
sprintf(filePath, "%s\\%s", dir, enumResult.cFileName);
status = FolderLocateInTree(filePath, folderName, buf);
}
}
if (status != ERROR_FILE_NOT_FOUND) {
/* found folder or encountered an error; quit */
rc = status;
break;
} else {
/* folder not found; keep looking */
if (!FindNextFile(enumHandle, &enumResult)) {
status = GetLastError();
if (status == ERROR_NO_MORE_FILES) {
rc = ERROR_FILE_NOT_FOUND;
} else {
rc = status;
}
break;
}
}
}
FindClose(enumHandle);
}
return rc;
}
/*
* Client34ZapUninstallKeys() -- delete all of the client uninstall keys
*/
static DWORD
Client34ZapUninstallKeys(void)
{
DWORD rc = ERROR_SUCCESS;
HKEY key;
/* enumerate all uninstall registry keys looking for client's */
rc = RegOpenKeyAlt(AFSREG_NULL_KEY,
MS_UNINSTALL_KEY, KEY_ALL_ACCESS, 0, &key, NULL);
if (rc == ERROR_SUCCESS) {
char *keyEnum;
rc = RegEnumKeyAlt(key, &keyEnum);
if (rc == ERROR_SUCCESS && keyEnum != NULL) {
char *keyEnumName;
for (keyEnumName = keyEnum;
*keyEnumName != '\0';
keyEnumName += strlen(keyEnumName) + 1) {
if (_stricmp(keyEnumName, "AFSDeinstKey") == 0 ||
_strnicmp(keyEnumName, "AFSV34", 6) == 0) {
/* found an AFS uninstall key */
DWORD status = RegDeleteKeyAlt(key, keyEnumName);
if (status != ERROR_SUCCESS) {
rc = status;
}
}
}
free(keyEnum);
}
(void) RegCloseKey(key);
}
return rc;
}

View File

@ -0,0 +1,20 @@
/* Copyright (C) 1999 Transarc Corporation. All rights reserved.
*
*/
#ifndef AFS_FORCEREMOVE_H
#define AFS_FORCEREMOVE_H
/* Functions to forcibly remove AFS software without using InstallShield. */
#ifdef __cplusplus
extern "C" {
#endif
extern DWORD Client34Eradicate(BOOL keepConfig);
#ifdef __cplusplus
};
#endif
#endif /* AFS_FORCEREMOVE_H */

View File

@ -0,0 +1,21 @@
LIBRARY InstallUtils.dll
CODE PRELOAD MOVEABLE DISCARDABLE
DATA PRELOAD SINGLE
EXPORTS
DllEntryPoint
InstallServerService
InstallClientService
AddToPath
AddToNetworkProviderOrder
CheckIfAdmin
SetSilentMode
WriteToInstallErrorLog
RestoreConfigInfo
Eradicate34Client
Upgrade34ClientConfigInfo
IsWin98
ShowLicense

View File

@ -0,0 +1,59 @@
# Copyright (C) 1998 Transarc Corporation. All rights reserved.
############################################################################
# allow the resource compiler to search the dest\include tree
AFSDEV_AUXRCFLAGS = $(AFSDEV_AUXRCFLAGS) -I$(DESTDIR)\include -I..
# include the primary makefile
!INCLUDE ..\..\..\config\NTMakefile.$(SYS_NAME)
!INCLUDE ..\..\..\config\NTMakefile.version
############################################################################
#
# LANGUAGE
#
# To select which language to build, run the ntlang.bat batch file
# before performing a build.
#
!IF ("$(LANGID)" == "") || ("$(LANGNAME)" == "") || ("$(LANGCP)" == "")
!ERROR Must select language before building (run NTLANG.BAT)
!ENDIF
############################################################################
#
# BUILD TARGETS
#
DLLFILE = $(DESTDIR)\root.server\usr\afs\bin\afs_setup_utils_$(LANGID).dll
RCFILE = $(LANGNAME)\afs_setup_utils.rc
RESFILE = afs_setup_utils_$(LANGID).res
DLLOBJS = $(RESFILE)
############################################################################
$(DLLFILE) : $(DLLOBJS)
$(DLLRESLINK)
$(DLLPREP)
install : $(DLLFILE)
clean ::
@if exist *.res del *.res
@if exist RC*. del RC*.
@if exist RD*. del RD*.
############################################################################
#
# Dependencies
#
$(RESFILE) : $(RCFILE) AFS_component_version_number.h
$(RC) /fo$(RESFILE) /c$(LANGCP) $(RCFILE)

View File

@ -0,0 +1,113 @@
/*
* Copyright (C) 1998 Transarc Corporation.
* All rights reserved.
*
*/
#include <resource.h>
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include <windows.h>
#define AFS_VERINFO_FILE_DESCRIPTION "AFS Setup Utilities DLL"
#include "AFS_component_version_number.h"
#include "..\..\..\..\config\NTVersioninfo.rc"
/////////////////////////////////////////////////////////////////////////////
//
// String Table
//
STRINGTABLE DISCARDABLE
BEGIN
IDS_INSTALLATION_FAILURE "Ein Fehler ist aufgetreten: %s (%ld)."
IDS_SCM_OPEN_FAILED "Service Control Manager komnnte nicht geöffnet werden"
IDS_SERVICE_CREATE_FAILED "Service konnte nicht erstellt werden"
IDS_SERVICE_OPEN_FAILED "Service konnte nicht geöffnet werden"
IDS_SERVICE_QUERY_FAILED "Der Status des Service konnte nicht abgefragt werden"
IDS_SERVICE_STOP_FAILED "Service konnte nicht gestoppt werden"
IDS_SERVICE_DELETE_FAILED "Service konnte nicht gelöscht werden"
IDS_REG_DELETE_VALUE_ERROR "Registrierungseinträge konnten nicht gelöscht werden"
IDS_SERVICE_ENABLE_FAILED "Service konnte nicht aktiviert werden"
IDS_OLE_DLL_INSTALL_FAILED "Eine OLE-DLL konnte nicht installiert werden"
IDS_OLE_DLL_UNINSTALL_FAILED "Eine OLE-DLL konnte nicht deinstalliert werden"
IDS_EXTENSION_DLL_UNINSTALL_FAILED
"Die Shellerweiterung für das Mounten/Unmounten von Dateigruppen konnte nicht deinstalliert werden"
IDS_EXTENSION_DLL_INSTALL_FAILED
"Die Shellerweiterung für das Mounten/Unmounten von Dateigruppen konnte nicht installiert werden"
IDS_CANT_DETERMINE_PRODUCT
"Zu deinstallierendes AFS-Produkt konnte nicht ermittelt werden"
IDS_TITLE "AFS® für Windows"
IDS_CANT_DETERMINE_APP_PATH
"Installationsverzeichnis der Anwendung konnte nicht ermittelt werden"
IDS_CLIENT_APP_NAME "AFS Client"
IDS_SERVER_APP_NAME "AFS Server"
IDS_CC_APP_NAME "AFS Control Center"
IDS_CANT_LOAD_RESOURCES "Produkt kann nicht deinstalliert werden: Fehler beim Laden der Deinstallionsressourcen."
IDS_CANT_UNINSTALL_AFSCREDS "Fehler beim dekonfigurieren des AFS Client."
IDS_MUST_STOP_SERVER "Der AFS Server muß gestoppt werden, bevor die Installation fortgesetzt werden kann. Dieser Vorgang kann einige Zeit in Anspruch nehmen. Soll der Server jetzt gestoppt werden?"
IDS_MUST_STOP_CLIENT "Der AFS Client muß gestoppt werden, bevor die Installation fortgesetzt werden kann. Soll der Client jetzt gestoppt werden? "
IDS_LIGHT_CLIENT_APP_NAME "AFS Light"
IDS_WAITING_FOR_CLIENT_TO_STOP "AFS Client wird gestoppt. Bitte warten..."
IDS_WAITING_FOR_SERVER_TO_STOP "AFS Server wird gestoppt. Bitte warten..."
IDS_CLIENT_NEEDED_BY_SERVER "Wenn Sie den AFS Client deinstallieren, wird der AFS Server nicht mehr ordnungsgemäß funktionieren. Deinstallation fortsetzen?"
IDS_PRESERVE_CLIENT_CONFIG_INFO "Möchten Sie die Konfigurationsdaten des Clients erhalten? Dies kann bei einer Erweiterung oder erneuten Installation sinnvoll sein."
IDS_PRESERVE_SERVER_CONFIG_INFO "Möchten Sie die Konfigurationsdaten des Servers erhalten? Dies kann bei einer Erweiterung oder erneuten Installation sinnvoll sein."
IDS_RESTORE_OF_PREVIOUS_CONFIG_FAILED "Frühere Konfigurationsdaten konnten nicht wiederhergestellt werden"
IDS_SAVE_OF_CONFIG_INFO_FAILED "Konfigurationsdaten konnten nicht gesichert werden. Deinstallation fortsetzen?"
IDS_PRESERVE_LIGHT_CLIENT_CONFIG_INFO "Möchten Sie die Konfigurationsdaten des AFS Light Clients erhalten? Dies kann bei einer Erweiterung oder erneuten Installation sinnvoll sein."
IDS_PRESERVE_CC_CONFIG_INFO "Möchten Sie die Konfigurationsdaten des Control Center erhalten? Dies kann bei einer Erweiterung oder erneuten Installation sinnvoll sein."
END
/////////////////////////////////////////////////////////////////////////////
//
// Dialog Boxes
//
IDD_PROGRESS DIALOGEX 0, 0, 226, 52
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | DS_CENTER
EXSTYLE WS_EX_TOOLWINDOW
CAPTION "AFS® für Windows"
FONT 9, "MS Shell Dlg"
BEGIN
ICON "",IDC_LOGO,17,16,21,20
LTEXT "AFS Server wird gestoppt. Bitte warten...",IDC_MSG,50,23,
163,10
GROUPBOX "",IDC_STATIC,7,4,212,40
END
IDD_LICENSE DIALOGEX 0, 0, 315, 204
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Lizenzvereinbarung"
FONT 9, "MS Shell Dlg", 0, 0, 0x1
BEGIN
DEFPUSHBUTTON "&Akzeptieren",IDOK,197,185,50,14
PUSHBUTTON "Abbrechen",IDC_STATIC,255,185,50,14,WS_DISABLED
CONTROL "",IDC_TEXT,"RichEdit20A",ES_MULTILINE | ES_AUTOVSCROLL |
ES_READONLY | WS_VSCROLL,10,10,295,161,WS_EX_STATICEDGE
PUSHBUTTON "&Drucken",IDC_PRINT,10,185,50,14
PUSHBUTTON "A&blehnen",IDCANCEL,147,185,50,14
CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,10,178,296,1
END
//////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_SPIN1 ICON DISCARDABLE "..\\..\\..\\afsapplib\\resource\\spin1.ico"
IDI_SPIN2 ICON DISCARDABLE "..\\..\\..\\afsapplib\\resource\\spin2.ico"
IDI_SPIN3 ICON DISCARDABLE "..\\..\\..\\afsapplib\\resource\\spin3.ico"
IDI_SPIN4 ICON DISCARDABLE "..\\..\\..\\afsapplib\\resource\\spin4.ico"
IDI_SPIN5 ICON DISCARDABLE "..\\..\\..\\afsapplib\\resource\\spin5.ico"
IDI_SPIN6 ICON DISCARDABLE "..\\..\\..\\afsapplib\\resource\\spin6.ico"
IDI_SPIN7 ICON DISCARDABLE "..\\..\\..\\afsapplib\\resource\\spin7.ico"
IDI_SPIN8 ICON DISCARDABLE "..\\..\\..\\afsapplib\\resource\\spin8.ico"
IDI_SPINSTOP ICON DISCARDABLE "..\\..\\..\\afsapplib\\resource\\spinstop.ico"

View File

@ -0,0 +1,113 @@
/*
* Copyright (C) 1998 Transarc Corporation.
* All rights reserved.
*
*/
#include <resource.h>
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include <windows.h>
#define AFS_VERINFO_FILE_DESCRIPTION "AFS Setup Utilities DLL"
#include "AFS_component_version_number.h"
#include "..\..\..\..\config\NTVersioninfo.rc"
/////////////////////////////////////////////////////////////////////////////
//
// String Table
//
STRINGTABLE DISCARDABLE
BEGIN
IDS_INSTALLATION_FAILURE "An error has occurred: %s (%ld)."
IDS_SCM_OPEN_FAILED "Failed to open Service Control Manager"
IDS_SERVICE_CREATE_FAILED "Failed to create service"
IDS_SERVICE_OPEN_FAILED "Failed to open service"
IDS_SERVICE_QUERY_FAILED "Failed to query service status"
IDS_SERVICE_STOP_FAILED "Failed to stop service"
IDS_SERVICE_DELETE_FAILED "Failed to delete service"
IDS_REG_DELETE_VALUE_ERROR "Failed to delete registry entries"
IDS_SERVICE_ENABLE_FAILED "Failed to enable service"
IDS_OLE_DLL_INSTALL_FAILED "Failed to install an OLE DLL"
IDS_OLE_DLL_UNINSTALL_FAILED "Failed to uninstall an OLE DLL"
IDS_EXTENSION_DLL_UNINSTALL_FAILED
"Failed to uninstall the fileset mount/unmount shell extension"
IDS_EXTENSION_DLL_INSTALL_FAILED
"Failed to install the fileset mount/unmount shell extension"
IDS_CANT_DETERMINE_PRODUCT
"Cannot determine which AFS product to uninstall"
IDS_TITLE "AFS® for Windows"
IDS_CANT_DETERMINE_APP_PATH
"Failed to determine the application's installation directory"
IDS_CLIENT_APP_NAME "AFS Client"
IDS_SERVER_APP_NAME "AFS Server"
IDS_CC_APP_NAME "AFS Control Center"
IDS_CANT_LOAD_RESOURCES "Cannot uninstall this product: Load of uninstall resources has failed."
IDS_CANT_UNINSTALL_AFSCREDS "Failed to unconfigure the AFS Client."
IDS_MUST_STOP_SERVER "The AFS Server must be stopped before uninstallation can continue. This can be a very lengthy process. Stop the Server now?"
IDS_MUST_STOP_CLIENT "The AFS Client must be stopped before uninstallation can continue. Stop the Client now?"
IDS_LIGHT_CLIENT_APP_NAME "AFS Light"
IDS_WAITING_FOR_CLIENT_TO_STOP "Stopping the AFS Client. Please wait..."
IDS_WAITING_FOR_SERVER_TO_STOP "Stopping the AFS Server. Please wait..."
IDS_CLIENT_NEEDED_BY_SERVER "Uninstalling the AFS Client will prevent the AFS Server from functioning properly. Proceed with the uninstall?"
IDS_PRESERVE_CLIENT_CONFIG_INFO "Do you wish to preserve the Client's configuration information? You may want to do this if you are upgrading or reinstalling."
IDS_PRESERVE_SERVER_CONFIG_INFO "Do you wish to preserve the Server's configuration information? You may want to do this if you are upgrading or reinstalling."
IDS_RESTORE_OF_PREVIOUS_CONFIG_FAILED "Failed to restore previous configuration information"
IDS_SAVE_OF_CONFIG_INFO_FAILED "Failed to save the configuration information. Proceed with the uninstall?"
IDS_PRESERVE_LIGHT_CLIENT_CONFIG_INFO "Do you wish to preserve AFS Light's configuration information? You may want to do this if you are upgrading or reinstalling."
IDS_PRESERVE_CC_CONFIG_INFO "Do you wish to preserve the Control Center's configuration information? You may want to do this if you are upgrading or reinstalling."
END
/////////////////////////////////////////////////////////////////////////////
//
// Dialog Boxes
//
IDD_PROGRESS DIALOGEX 0, 0, 226, 52
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | DS_CENTER
EXSTYLE WS_EX_TOOLWINDOW
CAPTION "AFS® for Windows"
FONT 9, "MS Shell Dlg"
BEGIN
ICON "",IDC_LOGO,17,16,21,20
LTEXT "Stopping the AFS Server. Please wait...",IDC_MSG,50,23,
163,10
GROUPBOX "",IDC_STATIC,7,4,212,40
END
IDD_LICENSE DIALOGEX 0, 0, 315, 204
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "License Agreement"
FONT 9, "MS Shell Dlg", 0, 0, 0x1
BEGIN
DEFPUSHBUTTON "I &Agree",IDOK,197,185,50,14
PUSHBUTTON "Cancel",IDC_STATIC,255,185,50,14,WS_DISABLED
CONTROL "",IDC_TEXT,"RichEdit20A",ES_MULTILINE | ES_AUTOVSCROLL |
ES_READONLY | WS_VSCROLL,10,10,295,161,WS_EX_STATICEDGE
PUSHBUTTON "&Print",IDC_PRINT,10,185,50,14
PUSHBUTTON "I &Disagree",IDCANCEL,147,185,50,14
CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,10,178,296,1
END
//////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_SPIN1 ICON DISCARDABLE "..\\..\\..\\afsapplib\\resource\\spin1.ico"
IDI_SPIN2 ICON DISCARDABLE "..\\..\\..\\afsapplib\\resource\\spin2.ico"
IDI_SPIN3 ICON DISCARDABLE "..\\..\\..\\afsapplib\\resource\\spin3.ico"
IDI_SPIN4 ICON DISCARDABLE "..\\..\\..\\afsapplib\\resource\\spin4.ico"
IDI_SPIN5 ICON DISCARDABLE "..\\..\\..\\afsapplib\\resource\\spin5.ico"
IDI_SPIN6 ICON DISCARDABLE "..\\..\\..\\afsapplib\\resource\\spin6.ico"
IDI_SPIN7 ICON DISCARDABLE "..\\..\\..\\afsapplib\\resource\\spin7.ico"
IDI_SPIN8 ICON DISCARDABLE "..\\..\\..\\afsapplib\\resource\\spin8.ico"
IDI_SPINSTOP ICON DISCARDABLE "..\\..\\..\\afsapplib\\resource\\spinstop.ico"

View File

@ -0,0 +1,101 @@
/*
* Copyright (C) 1998 Transarc Corporation.
* All rights reserved.
*
*/
#include <resource.h>
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include <windows.h>
#define AFS_VERINFO_FILE_DESCRIPTION "AFS Setup Utilities DLL"
#include "AFS_component_version_number.h"
#include "..\..\..\..\config\NTVersioninfo.rc"
/////////////////////////////////////////////////////////////////////////////
//
// String Table
//
STRINGTABLE DISCARDABLE
BEGIN
IDS_INSTALLATION_FAILURE "Se ha producido un error: %s (%ld)."
IDS_SCM_OPEN_FAILED "Anomalía al abrir el Gestor de control de servicio"
IDS_SERVICE_CREATE_FAILED "Anomalía al crear el servicio"
IDS_SERVICE_OPEN_FAILED "Anomalía al abrir el servicio"
IDS_SERVICE_QUERY_FAILED "Anomalía al consultar el estado del servicio"
IDS_SERVICE_STOP_FAILED "Anomalía al detener el servicio"
IDS_SERVICE_DELETE_FAILED "Anomalía al suprimir el servicio"
IDS_REG_DELETE_VALUE_ERROR "Anomalía al suprimir entradas de registro"
IDS_SERVICE_ENABLE_FAILED "Anomalía al habilitar el servicio"
IDS_OLE_DLL_INSTALL_FAILED "Anomalía al instalar una DLL OLE"
IDS_OLE_DLL_UNINSTALL_FAILED "Anomalía al desinstalar una DLL OLE"
IDS_EXTENSION_DLL_UNINSTALL_FAILED
"Anomalía al desinstalar la extensión de shell de montaje/desmontaje de conjunto de archivos"
IDS_EXTENSION_DLL_INSTALL_FAILED
"Anomalía al instalar la extensión de shell de montaje/desmontaje de conjunto de archivos"
IDS_CANT_DETERMINE_PRODUCT
"No se puede determinar qué producto de AFS se va a desinstalar"
IDS_TITLE "AFS« para Windows"
IDS_CANT_DETERMINE_APP_PATH
"No se ha podido determinar el directorio de instalación de la aplicación"
IDS_CLIENT_APP_NAME "AFS Client"
IDS_SERVER_APP_NAME "AFS Server"
IDS_CC_APP_NAME "AFS Control Center"
IDS_CANT_LOAD_RESOURCES "No se puede desinstalar este producto: la carga de los recursos de desinstalación ha fallado."
IDS_CANT_UNINSTALL_AFSCREDS "Anomalía al desconfigurar AFS Client."
IDS_MUST_STOP_SERVER "AFS Server debe detenerse antes de que pueda continuar la desinstalación. Este proceso puede ser muy largo. ¿Detener el Server ahora?"
IDS_MUST_STOP_CLIENT "AFS Client debe detenerse antes de que pueda continuar la desinstalación. Este proceso puede ser muy largo. ¿Detener el Client ahora?"
IDS_LIGHT_CLIENT_APP_NAME "AFS Light"
IDS_WAITING_FOR_CLIENT_TO_STOP "Deteniendo AFS Client. Espere, por favor..."
IDS_WAITING_FOR_SERVER_TO_STOP "Deteniendo AFS Server. Espere, por favor..."
IDS_CLIENT_NEEDED_BY_SERVER "La desinstalación de AFS Client impedirá que AFS Server funcione correctamente. ¿Continuar con la desinstalación?"
IDS_PRESERVE_CLIENT_CONFIG_INFO "¿Desea conservar la información de configuración de Client? Es recomendable si va a actualizarlo o instalarlo de nuevo."
IDS_PRESERVE_SERVER_CONFIG_INFO "¿Desea conservar la información de configuración de Server? Es recomendable si va a actualizarlo o instalarlo de nuevo."
IDS_RESTORE_OF_PREVIOUS_CONFIG_FAILED "Anomalía al restaurar la información de configuración anterior"
IDS_SAVE_OF_CONFIG_INFO_FAILED "Anomalía al guardar la información de configuración. ¿Continuar con la desinstalación?"
IDS_PRESERVE_LIGHT_CLIENT_CONFIG_INFO "¿Desea conservar la información de configuración de AFS Light? Es recomendable si va a actualizarlo o instalarlo de nuevo."
IDS_PRESERVE_CC_CONFIG_INFO "¿Desea conservar la información de configuración de Control Center? Es recomendable si va a actualizarlo o instalarlo de nuevo."
END
/////////////////////////////////////////////////////////////////////////////
//
// Dialog Boxes
//
IDD_PROGRESS DIALOGEX 0, 0, 226, 52
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | DS_CENTER
EXSTYLE WS_EX_TOOLWINDOW
CAPTION "AFS« para Windows"
FONT 9, "MS Shell Dlg"
BEGIN
ICON "",IDC_LOGO,17,16,21,20
LTEXT "Deteniendo AFS Server. Espere, por favor...",IDC_MSG,50,23,
163,10
GROUPBOX "",IDC_STATIC,7,4,212,40
END
//////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_SPIN1 ICON DISCARDABLE "..\\..\\..\\afsapplib\\resource\\spin1.ico"
IDI_SPIN2 ICON DISCARDABLE "..\\..\\..\\afsapplib\\resource\\spin2.ico"
IDI_SPIN3 ICON DISCARDABLE "..\\..\\..\\afsapplib\\resource\\spin3.ico"
IDI_SPIN4 ICON DISCARDABLE "..\\..\\..\\afsapplib\\resource\\spin4.ico"
IDI_SPIN5 ICON DISCARDABLE "..\\..\\..\\afsapplib\\resource\\spin5.ico"
IDI_SPIN6 ICON DISCARDABLE "..\\..\\..\\afsapplib\\resource\\spin6.ico"
IDI_SPIN7 ICON DISCARDABLE "..\\..\\..\\afsapplib\\resource\\spin7.ico"
IDI_SPIN8 ICON DISCARDABLE "..\\..\\..\\afsapplib\\resource\\spin8.ico"
IDI_SPINSTOP ICON DISCARDABLE "..\\..\\..\\afsapplib\\resource\\spinstop.ico"


View File

@ -0,0 +1,114 @@
/*
* Copyright (C) 1998 Transarc Corporation.
* All rights reserved.
*
*/
#include <resource.h>
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include <windows.h>
#define AFS_VERINFO_FILE_DESCRIPTION "AFS セットアップ・ユーティリティー DLL"
#include "AFS_component_version_number.h"
#include "..\..\..\..\config\NTVersioninfo.rc"
/////////////////////////////////////////////////////////////////////////////
//
// String Table
//
STRINGTABLE DISCARDABLE
BEGIN
IDS_INSTALLATION_FAILURE "エラーが起こりました: %s (%ld)."
IDS_SCM_OPEN_FAILED "サービス・コントロール・マネージャーのオープンに失敗しました"
IDS_SERVICE_CREATE_FAILED "サービスの作成に失敗しました"
IDS_SERVICE_OPEN_FAILED "サービスのオープンに失敗しました"
IDS_SERVICE_QUERY_FAILED "サービス状況の照会に失敗しました"
IDS_SERVICE_STOP_FAILED "サービスの停止に失敗しました"
IDS_SERVICE_DELETE_FAILED "サービスの削除に失敗しました"
IDS_REG_DELETE_VALUE_ERROR "レジストリー項目の削除に失敗しました"
IDS_SERVICE_ENABLE_FAILED "サービスを使用可能にできませんでした"
IDS_OLE_DLL_INSTALL_FAILED "OLE DLL のインストールに失敗しました"
IDS_OLE_DLL_UNINSTALL_FAILED "OLE DLL のアンインストールに失敗しました"
IDS_EXTENSION_DLL_UNINSTALL_FAILED
"ファイル・セットのマウント/マウント解除シェル拡張のアンインストールに失敗しました"
IDS_EXTENSION_DLL_INSTALL_FAILED
"ファイル・セットのマウント/マウント解除シェル拡張のインストールに失敗しました"
IDS_CANT_DETERMINE_PRODUCT
"アンインストールする AFS プロダクトを判別できません"
IDS_TITLE "AFS(R) for Windows"
IDS_CANT_DETERMINE_APP_PATH
"アプリケーションがインストールされているディレクトリーを判別できません"
IDS_CLIENT_APP_NAME "AFS クライアント"
IDS_SERVER_APP_NAME "AFS サーバー"
IDS_CC_APP_NAME "AFS コントロール・センター"
IDS_CANT_LOAD_RESOURCES "このプロダクトをアンインストールできません。アンインストール・リソースのロードに失敗しました。"
IDS_CANT_UNINSTALL_AFSCREDS "AFS クライアントの構成解除に失敗しました。"
IDS_MUST_STOP_SERVER "アンインストールを続行できるように AFS サーバーを停止してください。これには長時間かかります。サーバーをただちに停止しますか?"
IDS_MUST_STOP_CLIENT "アンインストールを続行できるように AFS クライアントを停止してください。クライアントをただちに停止しますか?"
IDS_LIGHT_CLIENT_APP_NAME "AFS Light"
IDS_WAITING_FOR_CLIENT_TO_STOP "AFS クライアントを停止中です。お待ちください..."
IDS_WAITING_FOR_SERVER_TO_STOP "AFS サーバーを停止中です。お待ちください..."
IDS_CLIENT_NEEDED_BY_SERVER "AFS クライアントをアンインストールすると、AFS サーバーが正常に機能しなくなる可能性があります。アンインストールを続行しますか?"
IDS_PRESERVE_CLIENT_CONFIG_INFO "クライアントの構成情報を保持しますか? アップグレードまたは再インストールの場合には、これを行うと有用です。"
IDS_PRESERVE_SERVER_CONFIG_INFO "サーバーの構成情報を保持しますか? アップグレードまたは再インストールの場合には、これを行うと有用です。"
IDS_RESTORE_OF_PREVIOUS_CONFIG_FAILED "前の構成情報の復元に失敗しました"
IDS_SAVE_OF_CONFIG_INFO_FAILED "構成情報の保管に失敗しました。アンインストールを続行しますか?"
IDS_PRESERVE_LIGHT_CLIENT_CONFIG_INFO "AFS Light の構成情報を保持しますか? アップグレードまたは再インストールの場合には、これを行うと有用です。"
IDS_PRESERVE_CC_CONFIG_INFO "コントロール・センターの構成情報を保持しますか? アップグレードまたは再インストールの場合には、これを行うと有用です。"
END
/////////////////////////////////////////////////////////////////////////////
//
// Dialog Boxes
//
IDD_PROGRESS DIALOGEX 0, 0, 226, 52
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | DS_CENTER
EXSTYLE WS_EX_TOOLWINDOW
CAPTION "AFS(R) for Windows"
FONT 9, " Pゴシック"
BEGIN
ICON "",IDC_LOGO,17,16,21,20
LTEXT "AFS サーバーを停止中です。お待ちください...",IDC_MSG,50,23,
163,10
GROUPBOX "",IDC_STATIC,7,4,212,40
END
IDD_LICENSE DIALOGEX 0, 0, 315, 204
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "ご使用条件"
FONT 9, " Pゴシック", 0, 0, 0x1
BEGIN
DEFPUSHBUTTON "同意する(&A)",IDOK,197,185,50,14
PUSHBUTTON "取消し",IDC_STATIC,255,185,50,14,WS_DISABLED
CONTROL "",IDC_TEXT,"RichEdit20A",ES_MULTILINE | ES_AUTOVSCROLL |
ES_READONLY | WS_VSCROLL,10,10,295,161,WS_EX_STATICEDGE
PUSHBUTTON "印刷(&P)",IDC_PRINT,10,185,50,14
PUSHBUTTON "同意しない(&D)",IDCANCEL,147,185,50,14
CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,10,178,296,1
END
//////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_SPIN1 ICON DISCARDABLE "..\\..\\..\\afsapplib\\resource\\spin1.ico"
IDI_SPIN2 ICON DISCARDABLE "..\\..\\..\\afsapplib\\resource\\spin2.ico"
IDI_SPIN3 ICON DISCARDABLE "..\\..\\..\\afsapplib\\resource\\spin3.ico"
IDI_SPIN4 ICON DISCARDABLE "..\\..\\..\\afsapplib\\resource\\spin4.ico"
IDI_SPIN5 ICON DISCARDABLE "..\\..\\..\\afsapplib\\resource\\spin5.ico"
IDI_SPIN6 ICON DISCARDABLE "..\\..\\..\\afsapplib\\resource\\spin6.ico"
IDI_SPIN7 ICON DISCARDABLE "..\\..\\..\\afsapplib\\resource\\spin7.ico"
IDI_SPIN8 ICON DISCARDABLE "..\\..\\..\\afsapplib\\resource\\spin8.ico"
IDI_SPINSTOP ICON DISCARDABLE "..\\..\\..\\afsapplib\\resource\\spinstop.ico"

View File

@ -0,0 +1,179 @@
//Microsoft Developer Studio generated resource script.
//
#include <resource.h>
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include <windows.h>
#define AFS_VERINFO_FILE_DESCRIPTION "AFS Setup Utilities DLL"
#include "AFS_component_version_number.h"
#include "..\..\..\..\config\NTVersioninfo.rc"
/////////////////////////////////////////////////////////////////////////////
// Korean resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_KOR)
#ifdef _WIN32
LANGUAGE LANG_KOREAN, SUBLANG_DEFAULT
#endif //_WIN32
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_PROGRESS DIALOGEX 0, 0, 251, 53
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION
EXSTYLE WS_EX_TOOLWINDOW
CAPTION "Windows용 AFS"
FONT 9, "굴림"
BEGIN
ICON "",IDC_LOGO,17,16,20,21
LTEXT "AFS 서버를 중지하고 있습니다. 잠시 기다리십시오...",
IDC_MSG,50,23,184,10
GROUPBOX "",IDC_STATIC,7,4,237,40
END
IDD_LICENSE DIALOGEX 0, 0, 315, 204
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "사용권 계약 "
FONT 9, "굴림"
BEGIN
DEFPUSHBUTTON "동의함(&A)",IDOK,197,185,50,14
PUSHBUTTON "취소",IDC_STATIC,255,185,50,14,WS_DISABLED
CONTROL "",IDC_TEXT,"RichEdit20A",WS_VSCROLL | 0x844,10,10,295,
161,WS_EX_STATICEDGE
PUSHBUTTON "인쇄(&P)",IDC_PRINT,10,185,50,14
PUSHBUTTON "동의하지 않음(&D)",IDCANCEL,135,185,62,14
CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,10,178,296,1
END
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_SPIN1 ICON DISCARDABLE "..\\..\\..\\afsapplib\\resource\\spin1.ico"
IDI_SPIN2 ICON DISCARDABLE "..\\..\\..\\afsapplib\\resource\\spin2.ico"
IDI_SPIN3 ICON DISCARDABLE "..\\..\\..\\afsapplib\\resource\\spin3.ico"
IDI_SPIN4 ICON DISCARDABLE "..\\..\\..\\afsapplib\\resource\\spin4.ico"
IDI_SPIN5 ICON DISCARDABLE "..\\..\\..\\afsapplib\\resource\\spin5.ico"
IDI_SPIN6 ICON DISCARDABLE "..\\..\\..\\afsapplib\\resource\\spin6.ico"
IDI_SPIN7 ICON DISCARDABLE "..\\..\\..\\afsapplib\\resource\\spin7.ico"
IDI_SPIN8 ICON DISCARDABLE "..\\..\\..\\afsapplib\\resource\\spin8.ico"
IDI_SPINSTOP ICON DISCARDABLE "..\\..\\..\\afsapplib\\resource\\spinstop.ico"
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"#include ""resource.h""\r\n"
"#define APSTUDIO_HIDDEN_SYMBOLS\r\n"
"#include ""windows.h""\r\n"
"#undef APSTUDIO_HIDDEN_SYMBOLS\r\n"
"#include ""afs_component_version_number.h""\r\n"
"\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// String Table
//
STRINGTABLE DISCARDABLE
BEGIN
IDS_INSTALLATION_FAILURE "오류가 발생하였습니다. %s (%ld)."
IDS_SCM_OPEN_FAILED "서비스 제어 관리 프로그램을 여는데 실패하였습니다. "
IDS_SERVICE_CREATE_FAILED "서비스 작성에 실패하였습니다. "
IDS_SERVICE_OPEN_FAILED "서비스를 여는데 실패하였습니다."
IDS_SERVICE_QUERY_FAILED "서비스 상태 조회에 실패하였습니다. "
IDS_SERVICE_STOP_FAILED "서비스 정지에 실패하였습니다. "
IDS_SERVICE_DELETE_FAILED "서비스 삭제에 실패하였습니다. "
IDS_REG_DELETE_VALUE_ERROR "레지스트리 입력 항목 삭제에 실패하였습니다. "
IDS_SERVICE_ENABLE_FAILED "서비스 사용 가능화에 실패하였습니다. "
IDS_OLE_DLL_INSTALL_FAILED "OLE DLL 설치에 실패하였습니다. "
IDS_OLE_DLL_UNINSTALL_FAILED "OLE DLL 설치 해제에 실패하였습니다. "
IDS_EXTENSION_DLL_UNINSTALL_FAILED
"파일세트 마운트/언마운트 쉘 확장 설치 해제에 실패하였습니다. "
IDS_EXTENSION_DLL_INSTALL_FAILED
"파일세트 마운트/언마운트 쉘 확장 설치에 실패하였습니다."
IDS_CANT_DETERMINE_PRODUCT "AFS 제품 설치 해제를 결정할 수 없습니다."
END
STRINGTABLE DISCARDABLE
BEGIN
IDS_TITLE "Windows용 AFS"
IDS_CANT_DETERMINE_APP_PATH
"응용프로그램의 설치 디렉토리를 결정하는데 실패하였습니다. "
IDS_CLIENT_APP_NAME "AFS 클라이언트"
IDS_SERVER_APP_NAME "AFS 서버"
IDS_CC_APP_NAME "AFS 제어 센터"
IDS_CANT_LOAD_RESOURCES "이 제품을 설치 해제할 수 없습니다. 설치 해제할 자원을 로드하는데 실패하였습니다. "
IDS_CANT_UNINSTALL_AFSCREDS
"AFS 클라이언트를 구성 해제하는 데 실패하였습니다. "
IDS_MUST_STOP_SERVER "설치 해제를 계속하기 전에 AFS 서버를 중지해야 합니다. 이 프로세스는 오래 걸릴 수 있습니다. 지금 서버를 중지하시겠습니까? "
IDS_MUST_STOP_CLIENT "설치 해제를 계속하기 전에 AFS 클라이언트를 중지해야 합니다. 지금 클라이언트를 중지하시겠습니까?"
IDS_LIGHT_CLIENT_APP_NAME "AFS 라이트"
IDS_WAITING_FOR_CLIENT_TO_STOP
"AFS 클라이언트를 중지하고 있습니다. 잠시 기다리십시오..."
IDS_WAITING_FOR_SERVER_TO_STOP
"AFS 서버를 중지하고 있습니다. 잠시 기다리십시오..."
IDS_CLIENT_NEEDED_BY_SERVER
"AFS 클라이언트를 설치 해제하면 AFS 서버가 올바르게 기능하지 않을 것입니다. 설치 해제를 계속하시겠습니까?"
IDS_PRESERVE_CLIENT_CONFIG_INFO
"클라이언트 구성 정보를 보존하시겠습니까? 업그레이드 또는 재설치하는 경우 이를 선택할 수 있습니다. "
IDS_PRESERVE_SERVER_CONFIG_INFO
"서버 구성 정보를 보존하시겠습니까? 업그레이드 또는 재설치하는 경우 이를 선택할 수 있습니다."
END
STRINGTABLE DISCARDABLE
BEGIN
IDS_RESTORE_OF_PREVIOUS_CONFIG_FAILED
"기존 구성 정보를 복원하는데 실패하였습니다. "
IDS_SAVE_OF_CONFIG_INFO_FAILED
"구성 정보를 저장하는데 실패하였습니다. 설치 해제를 계속하시겠습니까? "
IDS_PRESERVE_LIGHT_CLIENT_CONFIG_INFO
"AFS 라이트 구성 정보를 보존하시겠습니까? 업그레이드 또는 재설치하는 경우 이를 선택할 수 있습니다."
IDS_PRESERVE_CC_CONFIG_INFO
"제어 센터 구성 정보를 보존하시겠습니까? 업그레이드 또는 재설치하는 경우 이를 선택할 수 있습니다."
END
#endif // Korean resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View File

@ -0,0 +1,115 @@
/*
* Copyright (C) 1998 Transarc Corporation.
* All rights reserved.
*
*/
#include <resource.h>
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include <windows.h>
#define AFS_VERINFO_FILE_DESCRIPTION "DLL dos Utilitários de Configuração do AFS"
#include "AFS_component_version_number.h"
#include "..\..\..\..\config\NTVersioninfo.rc"
/////////////////////////////////////////////////////////////////////////////
//
// String Table
//
STRINGTABLE DISCARDABLE
BEGIN
IDS_INSTALLATION_FAILURE "Um erro ocorreu: %s (%ld)."
IDS_SCM_OPEN_FAILED "Falha ao abrir o Gerenciador de Controle de Serviços"
IDS_SERVICE_CREATE_FAILED "Falha ao criar serviço"
IDS_SERVICE_OPEN_FAILED "Falha ao abrir serviço"
IDS_SERVICE_QUERY_FAILED "Falha ao consultar status do serviço"
IDS_SERVICE_STOP_FAILED "Falha ao parar serviço"
IDS_SERVICE_DELETE_FAILED "Falha ao excluir serviço"
IDS_REG_DELETE_VALUE_ERROR "Falha ao excluir entradas no registro"
IDS_SERVICE_ENABLE_FAILED "Falha ao ativar serviço"
IDS_OLE_DLL_INSTALL_FAILED "Falha ao instalar uma DLL de OLE"
IDS_OLE_DLL_UNINSTALL_FAILED "Falha ao remover a instalação de uma DLL de OLE"
IDS_EXTENSION_DLL_UNINSTALL_FAILED
"Falha ao remover a instalação da extensão do shell de montagem/desmontagem do conjunto de arquivos"
IDS_EXTENSION_DLL_INSTALL_FAILED
"Falha ao instalar a extensão do shell de montagem/desmontagem do conjunto de arquivos"
IDS_CANT_DETERMINE_PRODUCT
"Impossível determinar qual produto do AFS deve ser desinstalado"
IDS_TITLE "AFS® para Windows"
IDS_CANT_DETERMINE_APP_PATH
"Falha ao determinar o diretório de instalação da aplicação"
IDS_CLIENT_APP_NAME "AFS Client"
IDS_SERVER_APP_NAME "AFS Server"
IDS_CC_APP_NAME "Centro de Controle do AFS"
IDS_CANT_LOAD_RESOURCES "Impossível remover a instalação deste produto: falha na carga dos recursos de remoção de instalação."
IDS_CANT_UNINSTALL_AFSCREDS "Falha ao remover a configuração do AFS Client."
IDS_MUST_STOP_SERVER "O AFS Server deve ser parado para que a remoção da instalação possa continuar. Isto pode ser um processo demorado. Parar o Servidor agora?"
IDS_MUST_STOP_CLIENT "O AFS Client deve ser parado para que a remoção da instalação possa continuar. Parar o Cliente agora?"
IDS_LIGHT_CLIENT_APP_NAME "AFS Básico"
IDS_WAITING_FOR_CLIENT_TO_STOP "Parando o AFS Client. Aguarde..."
IDS_WAITING_FOR_SERVER_TO_STOP "Parando o AFS Server. Aguarde..."
IDS_CLIENT_NEEDED_BY_SERVER "Remover a instalação do AFS Client impedirá que o AFS Server funcione corretamente. Continuar a remoção da instalação?"
IDS_PRESERVE_CLIENT_CONFIG_INFO "Deseja preservar as informações de configuração do Cliente? Isto pode ser desejável se estiver atualizando ou reinstalando."
IDS_PRESERVE_SERVER_CONFIG_INFO "Deseja preservar as informações de configuração do Servidor? Isto pode ser desejável se estiver atualizando ou reinstalando."
IDS_RESTORE_OF_PREVIOUS_CONFIG_FAILED "Não foi possível restaurar as informações da configuração anterior."
IDS_SAVE_OF_CONFIG_INFO_FAILED "Não foi possível salvar as informações da configuração. Prosseguir a remoção da instalação?"
IDS_PRESERVE_LIGHT_CLIENT_CONFIG_INFO "Deseja preservar as informações de configuração do AFS Básico? Isto pode ser desejável se estiver atualizando ou reinstalando."
IDS_PRESERVE_CC_CONFIG_INFO "Deseja preservar as informações de configuração do Centro de Controle? Isto pode ser desejável se estiver atualizando ou reinstalando."
END
/////////////////////////////////////////////////////////////////////////////
//
// Dialog Boxes
//
IDD_PROGRESS DIALOGEX 0, 0, 226, 52
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | DS_CENTER
EXSTYLE WS_EX_TOOLWINDOW
CAPTION "AFS® para Windows"
FONT 9, "MS Shell Dlg"
BEGIN
ICON "",IDC_LOGO,17,16,21,20
LTEXT "Parando o AFS Server. Aguarde...",IDC_MSG,50,23,
163,10
GROUPBOX "",IDC_STATIC,7,4,212,40
END
IDD_LICENSE DIALOGEX 0, 0, 315, 204
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Acordo de Licenciamento"
FONT 9, "MS Shell Dlg", 0, 0, 0x1
BEGIN
DEFPUSHBUTTON "&Concordo",IDOK,197,185,50,14
PUSHBUTTON "Cancelar",IDC_STATIC,255,185,50,14,WS_DISABLED
CONTROL "",IDC_TEXT,"RichEdit20A",ES_MULTILINE | ES_AUTOVSCROLL |
ES_READONLY | WS_VSCROLL,10,10,295,161,WS_EX_STATICEDGE
PUSHBUTTON "&Imprimir",IDC_PRINT,10,185,50,14
PUSHBUTTON "&Discordo",IDCANCEL,147,185,50,14
CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,10,178,296,1
END
//////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_SPIN1 ICON DISCARDABLE "..\\..\\..\\afsapplib\\resource\\spin1.ico"
IDI_SPIN2 ICON DISCARDABLE "..\\..\\..\\afsapplib\\resource\\spin2.ico"
IDI_SPIN3 ICON DISCARDABLE "..\\..\\..\\afsapplib\\resource\\spin3.ico"
IDI_SPIN4 ICON DISCARDABLE "..\\..\\..\\afsapplib\\resource\\spin4.ico"
IDI_SPIN5 ICON DISCARDABLE "..\\..\\..\\afsapplib\\resource\\spin5.ico"
IDI_SPIN6 ICON DISCARDABLE "..\\..\\..\\afsapplib\\resource\\spin6.ico"
IDI_SPIN7 ICON DISCARDABLE "..\\..\\..\\afsapplib\\resource\\spin7.ico"
IDI_SPIN8 ICON DISCARDABLE "..\\..\\..\\afsapplib\\resource\\spin8.ico"
IDI_SPINSTOP ICON DISCARDABLE "..\\..\\..\\afsapplib\\resource\\spinstop.ico"


View File

@ -0,0 +1,114 @@
/*
* Copyright (C) 1998 Transarc Corporation.
* All rights reserved.
*
*/
#include <resource.h>
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include <windows.h>
#define AFS_VERINFO_FILE_DESCRIPTION "AFS 安装实用程序 DLL"
#include "AFS_component_version_number.h"
#include "..\..\..\..\config\NTVersioninfo.rc"
/////////////////////////////////////////////////////////////////////////////
//
// String Table
//
STRINGTABLE DISCARDABLE
BEGIN
IDS_INSTALLATION_FAILURE "发生一个错误:%s (%ld)。"
IDS_SCM_OPEN_FAILED "打开“服务控制管理器”失败"
IDS_SERVICE_CREATE_FAILED "创建服务失败"
IDS_SERVICE_OPEN_FAILED "打开服务失败"
IDS_SERVICE_QUERY_FAILED "查询服务状态失败"
IDS_SERVICE_STOP_FAILED "停止服务失败"
IDS_SERVICE_DELETE_FAILED "删除服务失败"
IDS_REG_DELETE_VALUE_ERROR "删除注册表条目失败"
IDS_SERVICE_ENABLE_FAILED "启用服务失败"
IDS_OLE_DLL_INSTALL_FAILED "安装 OLE DLL 失败"
IDS_OLE_DLL_UNINSTALL_FAILED "卸装 OLE DLL 失败"
IDS_EXTENSION_DLL_UNINSTALL_FAILED
"卸装文件集安装/卸装 shell 扩展失败"
IDS_EXTENSION_DLL_INSTALL_FAILED
"安装文件集安装/卸装 shell 扩展失败"
IDS_CANT_DETERMINE_PRODUCT
"无法确定要卸装的 AFS 产品"
IDS_TITLE "AFS(R) Windows 版"
IDS_CANT_DETERMINE_APP_PATH
"确定应用程序安装目录失败"
IDS_CLIENT_APP_NAME "AFS 客户机"
IDS_SERVER_APP_NAME "AFS 服务器"
IDS_CC_APP_NAME "AFS 控制中心"
IDS_CANT_LOAD_RESOURCES "无法卸装此产品:装入卸装资源已失败。"
IDS_CANT_UNINSTALL_AFSCREDS "取消 AFS 客户机的配置失败。"
IDS_MUST_STOP_SERVER "AFS 服务器必须在卸装可继续之前停止。这可能是一个很长的过程。现在要停止服务器吗?"
IDS_MUST_STOP_CLIENT "AFS 客户机必须在卸装可继续之前停止。现在要停止客户机吗?"
IDS_LIGHT_CLIENT_APP_NAME "AFS Light"
IDS_WAITING_FOR_CLIENT_TO_STOP "正在停止 AFS 客户机。请等待..."
IDS_WAITING_FOR_SERVER_TO_STOP "正在停止 AFS 服务器。请等待..."
IDS_CLIENT_NEEDED_BY_SERVER "卸装 AFS 客户机会使 AFS 服务器不能正常工作。要继续卸装吗?"
IDS_PRESERVE_CLIENT_CONFIG_INFO "您希望保留客户机的配置信息吗? 您可能会在升级或重新安装时这样做。"
IDS_PRESERVE_SERVER_CONFIG_INFO "您希望保留服务器的配置信息吗? 您可能会在升级或重新安装时这样做。"
IDS_RESTORE_OF_PREVIOUS_CONFIG_FAILED "恢复以前的配置信息失败"
IDS_SAVE_OF_CONFIG_INFO_FAILED "保存配置信息失败。要继续卸装吗?"
IDS_PRESERVE_LIGHT_CLIENT_CONFIG_INFO "您希望保留 AFS Light 的配置信息吗? 您可能会在升级或重新安装时这样做。"
IDS_PRESERVE_CC_CONFIG_INFO "您希望保留控制中心的配置信息吗? 您可能会在升级或重新安装时这样做。"
END
/////////////////////////////////////////////////////////////////////////////
//
// Dialog Boxes
//
IDD_PROGRESS DIALOGEX 0, 0, 226, 52
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | DS_CENTER
EXSTYLE WS_EX_TOOLWINDOW
CAPTION "AFS(R) Windows 版"
FONT 9, "宋体"
BEGIN
ICON "",IDC_LOGO,17,16,21,20
LTEXT "正在停止 AFS 服务器。请等待...",IDC_MSG,50,23,
163,10
GROUPBOX "",IDC_STATIC,7,4,212,40
END
IDD_LICENSE DIALOGEX 0, 0, 315, 204
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "许可证协议"
FONT 9, "宋体", 0, 0, 0x1
BEGIN
DEFPUSHBUTTON "我同意(&A)",IDOK,197,185,50,14
PUSHBUTTON "取消",IDC_STATIC,255,185,50,14,WS_DISABLED
CONTROL "",IDC_TEXT,"RichEdit20A",ES_MULTILINE | ES_AUTOVSCROLL |
ES_READONLY | WS_VSCROLL,10,10,295,161,WS_EX_STATICEDGE
PUSHBUTTON "打印(&P)",IDC_PRINT,10,185,50,14
PUSHBUTTON "我不同意(&D)",IDCANCEL,147,185,50,14
CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,10,178,296,1
END
//////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_SPIN1 ICON DISCARDABLE "..\\..\\..\\afsapplib\\resource\\spin1.ico"
IDI_SPIN2 ICON DISCARDABLE "..\\..\\..\\afsapplib\\resource\\spin2.ico"
IDI_SPIN3 ICON DISCARDABLE "..\\..\\..\\afsapplib\\resource\\spin3.ico"
IDI_SPIN4 ICON DISCARDABLE "..\\..\\..\\afsapplib\\resource\\spin4.ico"
IDI_SPIN5 ICON DISCARDABLE "..\\..\\..\\afsapplib\\resource\\spin5.ico"
IDI_SPIN6 ICON DISCARDABLE "..\\..\\..\\afsapplib\\resource\\spin6.ico"
IDI_SPIN7 ICON DISCARDABLE "..\\..\\..\\afsapplib\\resource\\spin7.ico"
IDI_SPIN8 ICON DISCARDABLE "..\\..\\..\\afsapplib\\resource\\spin8.ico"
IDI_SPINSTOP ICON DISCARDABLE "..\\..\\..\\afsapplib\\resource\\spinstop.ico"

View File

@ -0,0 +1,115 @@
/*
* Copyright (C) 1998 Transarc Corporation.
* All rights reserved.
*
*/
#include <resource.h>
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include <windows.h>
#define AFS_VERINFO_FILE_DESCRIPTION "AFS Setup Utilities DLL"
#include "AFS_component_version_number.h"
#include "..\..\..\..\config\NTVersioninfo.rc"
/////////////////////////////////////////////////////////////////////////////
//
// String Table
//
STRINGTABLE DISCARDABLE
BEGIN
IDS_INSTALLATION_FAILURE "發生錯誤: %s (%ld)."
IDS_SCM_OPEN_FAILED "無法開啟「服務控制管理程式」"
IDS_SERVICE_CREATE_FAILED "無法建立服務"
IDS_SERVICE_OPEN_FAILED "無法開啟服務"
IDS_SERVICE_QUERY_FAILED "無法查詢服務狀態"
IDS_SERVICE_STOP_FAILED "無法停止服務"
IDS_SERVICE_DELETE_FAILED "無法刪除服務"
IDS_REG_DELETE_VALUE_ERROR "無法刪除登錄項目"
IDS_SERVICE_ENABLE_FAILED "無法啟動服務"
IDS_OLE_DLL_INSTALL_FAILED "無法安裝 OLE DLL"
IDS_OLE_DLL_UNINSTALL_FAILED "無法解除安裝 OLE DLL"
IDS_EXTENSION_DLL_UNINSTALL_FAILED
"無法解除安裝檔案集裝載/解除裝載 shell 延伸"
IDS_EXTENSION_DLL_INSTALL_FAILED
"無法安裝檔案集裝載/解除裝載 shell 延伸"
IDS_CANT_DETERMINE_PRODUCT
"無法判斷解除安裝那項 AFS 產品"
IDS_TITLE "AFS for Windows"
IDS_CANT_DETERMINE_APP_PATH
"無法判斷應用程式的安裝目錄"
IDS_CLIENT_APP_NAME "AFS 用戶端"
IDS_SERVER_APP_NAME "AFS 伺服器"
IDS_CC_APP_NAME "AFS 控制中心"
IDS_CANT_LOAD_RESOURCES "無法解除安裝此項產品:解除安裝資源的載入已失敗。"
IDS_CANT_UNINSTALL_AFSCREDS "無法取消架構 AFS 用戶端。"
IDS_MUST_STOP_SERVER "必須先停止 AFS 伺服器,才能繼續解除安裝。此將需要一些時間來處理,要現在停止 Server 嗎?"
IDS_MUST_STOP_CLIENT "必須先停止 AFS 用戶端,才能繼續解除安裝。此將需要一些時間來處理,要現在停止 Client 嗎?"
IDS_LIGHT_CLIENT_APP_NAME "AFS Light"
IDS_WAITING_FOR_CLIENT_TO_STOP "正在停止 AFS 用戶端。請稍候..."
IDS_WAITING_FOR_SERVER_TO_STOP "正在停止 AFS 伺服器。請稍候..."
IDS_CLIENT_NEEDED_BY_SERVER "解除安裝 AFS 用戶端將防止 AFS 伺服器正常地運作。繼續解除安裝嗎?"
IDS_PRESERVE_CLIENT_CONFIG_INFO "您要保留用戶端的架構資訊嗎?若您要升級或重新安裝,就可能需要保留資訊。"
IDS_PRESERVE_SERVER_CONFIG_INFO "您要保留伺服器的架構資訊嗎?若您要升級或重新安裝,就可能需要保留資訊。"
IDS_RESTORE_OF_PREVIOUS_CONFIG_FAILED "無法恢復先前的架構資訊"
IDS_SAVE_OF_CONFIG_INFO_FAILED "無法儲存架構資訊。繼續解除安裝嗎?"
IDS_PRESERVE_LIGHT_CLIENT_CONFIG_INFO "您要保留 AFS Light 的架構資訊嗎?若您要升級或重新安裝,就可能需要保留資訊。"
IDS_PRESERVE_CC_CONFIG_INFO "您要保留控制中心的架構資訊嗎?若您要升級或重新安裝,就可能需要保留資訊。"
END
/////////////////////////////////////////////////////////////////////////////
//
// Dialog Boxes
//
IDD_PROGRESS DIALOGEX 0, 0, 226, 52
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | DS_CENTER
EXSTYLE WS_EX_TOOLWINDOW
CAPTION "AFS for Windows"
FONT 9, "新細明體"
BEGIN
ICON "",IDC_LOGO,17,16,21,20
LTEXT "正在停止 AFS 伺服器。請稍候...",IDC_MSG,50,23,
163,10
GROUPBOX "",IDC_STATIC,7,4,212,40
END
IDD_LICENSE DIALOGEX 0, 0, 315, 204
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "授權合約"
FONT 9, "新細明體", 0, 0, 0x1
BEGIN
DEFPUSHBUTTON "我同意(&A)",IDOK,197,185,50,14
PUSHBUTTON "取消",IDC_STATIC,255,185,50,14,WS_DISABLED
CONTROL "",IDC_TEXT,"RichEdit20A",ES_MULTILINE | ES_AUTOVSCROLL |
ES_READONLY | WS_VSCROLL,10,10,295,161,WS_EX_STATICEDGE
PUSHBUTTON "列印(&P)",IDC_PRINT,10,185,50,14
PUSHBUTTON "我不同意(&D)",IDCANCEL,147,185,50,14
CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,10,178,296,1
END
//////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_SPIN1 ICON DISCARDABLE "..\\..\\..\\afsapplib\\resource\\spin1.ico"
IDI_SPIN2 ICON DISCARDABLE "..\\..\\..\\afsapplib\\resource\\spin2.ico"
IDI_SPIN3 ICON DISCARDABLE "..\\..\\..\\afsapplib\\resource\\spin3.ico"
IDI_SPIN4 ICON DISCARDABLE "..\\..\\..\\afsapplib\\resource\\spin4.ico"
IDI_SPIN5 ICON DISCARDABLE "..\\..\\..\\afsapplib\\resource\\spin5.ico"
IDI_SPIN6 ICON DISCARDABLE "..\\..\\..\\afsapplib\\resource\\spin6.ico"
IDI_SPIN7 ICON DISCARDABLE "..\\..\\..\\afsapplib\\resource\\spin7.ico"
IDI_SPIN8 ICON DISCARDABLE "..\\..\\..\\afsapplib\\resource\\spin8.ico"
IDI_SPINSTOP ICON DISCARDABLE "..\\..\\..\\afsapplib\\resource\\spinstop.ico"


View File

@ -0,0 +1,10 @@
LIBRARY LightClientUninst.dll
CODE PRELOAD MOVEABLE DISCARDABLE
DATA PRELOAD SINGLE
EXPORTS
DllEntryPoint
UninstInitialize
UninstUnInitialize

View File

@ -0,0 +1,128 @@
/*
* Copyright (C) 1998 Transarc Corporation.
* All rights reserved.
*
*/
/*
* INCLUDES ___________________________________________________________________
*
*/
extern "C" {
#include <afs/param.h>
#include <afs/stds.h>
}
#include <windows.h>
#include <WINNT/talocale.h>
#include "resource.h"
#include "progress_dlg.h"
#include "animate_icon.h"
/*
* DEFINITIONS _________________________________________________________________
*
*/
/*
* Variables _________________________________________________________________
*
*/
static HWND hDlg = 0; // HWND for this page's dialog
static char *pszProgressMsg = 0;
static HWND hLogo;
/*
* PROTOTYPES _________________________________________________________________
*
*/
BOOL CALLBACK ProgressDlgProc(HWND hRHS, UINT msg, WPARAM wp, LPARAM lp);
static DWORD WINAPI DisplayProgressDlg(LPVOID param);
static void OnInitDialog(HWND hwndDlg);
static void OnQuit();
/*
* EXPORTED FUNCTIONS _________________________________________________________
*
*/
BOOL ShowProgressDialog(char *pszMsg)
{
DWORD dwThreadID;
pszProgressMsg = pszMsg;
// Create a thread to show the dialog
HANDLE hThread = CreateThread(0, 0, DisplayProgressDlg, 0, 0, &dwThreadID);
CloseHandle(hThread);
return (hThread != 0);
}
void HideProgressDialog(void)
{
PostMessage(hDlg, WM_QUIT, 0, 0);
}
/*
* Dialog Proc _________________________________________________________________
*
*/
static BOOL CALLBACK ProgressDlgProc(HWND hwndDlg, UINT msg, WPARAM wp, LPARAM lp)
{
switch (msg) {
case WM_INITDIALOG:
OnInitDialog(hwndDlg);
hDlg = hwndDlg;
SetWindowText(GetDlgItem(hDlg, IDC_MSG), pszProgressMsg);
break;
case WM_QUIT:
OnQuit();
break;
}
return FALSE;
}
/*
* Event Handler Functions __________________________________________________________
*
*/
static void OnInitDialog(HWND hwndDlg)
{
hDlg = hwndDlg;
SetWindowText(GetDlgItem(hDlg, IDC_MSG), pszProgressMsg);
hLogo = GetDlgItem(hDlg, IDC_LOGO);
StartAnimation(hLogo, 8);
}
static void OnQuit()
{
StopAnimation(hLogo);
EndDialog(hDlg, IDOK);
}
/*
* OTHER FUNCTIONS _________________________________________________________________
*
*/
static DWORD WINAPI DisplayProgressDlg(LPVOID param)
{
ModalDialog (IDD_PROGRESS, 0, (DLGPROC)ProgressDlgProc);
return 0;
}

View File

@ -0,0 +1,18 @@
/*
* Copyright (C) 1998 Transarc Corporation.
* All rights reserved.
*
*/
#ifdef __cplusplus
extern "C" {
#endif
BOOL ShowProgressDialog(char *pszMsg);
void HideProgressDialog(void);
#ifdef __cplusplus
}
#endif

View File

@ -0,0 +1,70 @@
/*
* Copyright (C) 1998 Transarc Corporation.
* All rights reserved.
*
*/
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by SetupUtils.rc
//
#define IDC_STATIC -1
#define IDS_INSTALLATION_FAILURE 1
#define IDS_SCM_OPEN_FAILED 2
#define IDS_SERVICE_CREATE_FAILED 3
#define IDS_SERVICE_OPEN_FAILED 4
#define IDS_SERVICE_QUERY_FAILED 5
#define IDS_SERVICE_STOP_FAILED 6
#define IDS_SERVICE_DELETE_FAILED 7
#define IDS_REG_DELETE_VALUE_ERROR 8
#define IDS_SERVICE_ENABLE_FAILED 10
#define IDS_OLE_DLL_INSTALL_FAILED 11
#define IDS_OLE_DLL_UNINSTALL_FAILED 12
#define IDS_EXTENSION_DLL_UNINSTALL_FAILED 13
#define IDS_EXTENSION_DLL_INSTALL_FAILED 14
#define IDS_CANT_DETERMINE_PRODUCT 15
#define IDS_TITLE 16
#define IDS_CANT_DETERMINE_APP_PATH 17
#define IDS_CLIENT_APP_NAME 18
#define IDS_SERVER_APP_NAME 19
#define IDS_CC_APP_NAME 20
#define IDS_CANT_LOAD_RESOURCES 21
#define IDS_CANT_UNINSTALL_AFSCREDS 22
#define IDS_MUST_STOP_SERVER 23
#define IDS_MUST_STOP_CLIENT 24
#define IDS_LIGHT_CLIENT_APP_NAME 25
#define IDS_WAITING_FOR_CLIENT_TO_STOP 26
#define IDS_WAITING_FOR_SERVER_TO_STOP 27
#define IDD_PROGRESS 28
#define IDS_CLIENT_NEEDED_BY_SERVER 29
#define IDS_PRESERVE_CLIENT_CONFIG_INFO 30
#define IDS_PRESERVE_SERVER_CONFIG_INFO 31
#define IDS_RESTORE_OF_PREVIOUS_CONFIG_FAILED 32
#define IDS_SAVE_OF_CONFIG_INFO_FAILED 33
#define IDS_PRESERVE_LIGHT_CLIENT_CONFIG_INFO 34
#define IDS_PRESERVE_CC_CONFIG_INFO 35
#define IDD_LICENSE 36
#define IDC_LOGO 1000
#define IDC_MSG 1001
#define IDC_PRINT 1002
#define IDC_TEXT 1003
#define IDI_SPIN1 20001
#define IDI_SPIN2 20002
#define IDI_SPIN3 20003
#define IDI_SPIN4 20004
#define IDI_SPIN5 20005
#define IDI_SPIN6 20006
#define IDI_SPIN7 20007
#define IDI_SPIN8 20008
#define IDI_SPINSTOP 20009
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 37
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1004
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

View File

@ -0,0 +1,10 @@
LIBRARY ServerUninst.dll
CODE PRELOAD MOVEABLE DISCARDABLE
DATA PRELOAD SINGLE
EXPORTS
DllEntryPoint
UninstInitialize
UninstUnInitialize

View File

@ -0,0 +1,525 @@
/* Copyright (C) 1999 Transarc Corporation - All rights reserved.
*
*/
#include <afs/param.h>
#include <afs/stds.h>
#include <windows.h>
#include <stdlib.h>
#include <stddef.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <WINNT/afsreg.h>
#include "sutil.h"
/* Some install/uninstall related utilities. */
#define NETWORK_PROVIDER_ORDER_KEY "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\NetworkProvider\\Order"
#define PROVIDER_ORDER_VALUE_NAME "ProviderOrder"
#define ENVIRONMENT_KEY "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment"
#define AUTOEXEC_PATH "c:\\autoexec.bat"
#define AUTOEXEC_TMP_PATH "c:\\TaAfsAutoexec.tmp"
static BOOL ReadRegEnv(char **ppszEnvValue, char *pszRegValueName);
static BOOL WriteRegEnv(char *pszEnvValue, char *pszEnvName);
static BOOL ReadAutoExec(char **ppszEnvValue, char *pszEnvName);
static BOOL WriteAutoExec(char *pszEnvValue, char *pszEnvName);
static BOOL FindSubString(const char *s1, const char *s2);
/* ------------------ exported functions ---------------------- */
BOOL InNetworkProviderOrder(char *pszNetworkProvider, BOOL *pbIn)
{
HKEY hKey;
LONG bResult;
DWORD dwType;
char *pszProviderOrder = 0;
DWORD dwSize;
bResult = FALSE; // Assume failure
if (RegOpenKeyAlt(AFSREG_NULL_KEY, NETWORK_PROVIDER_ORDER_KEY, KEY_READ, FALSE, &hKey, 0) == ERROR_SUCCESS) {
if (RegQueryValueAlt(hKey, PROVIDER_ORDER_VALUE_NAME, &dwType, &pszProviderOrder, &dwSize) == ERROR_SUCCESS) {
*pbIn = strstr(pszProviderOrder, pszNetworkProvider) != 0;
bResult = TRUE;
free(pszProviderOrder);
}
RegCloseKey(hKey);
}
return bResult;
}
/*
* AddToProviderOrder() -- add entry to network provider order
*/
BOOL AddToProviderOrder(char *pszWhatToAdd)
{
HKEY hKey;
DWORD dwType;
LONG result;
int nLen;
char *pszValue = 0;
char *pszNewValue;
BOOL bAlreadyAdded = FALSE;
/* Open the key, creating it if necessary (but should always be there). */
result = RegOpenKeyAlt(AFSREG_NULL_KEY,
NETWORK_PROVIDER_ORDER_KEY,
KEY_SET_VALUE | KEY_ALL_ACCESS, TRUE, &hKey, 0);
if (result != ERROR_SUCCESS)
return FALSE;
/* Get the old value */
result = RegQueryValueAlt(hKey,
PROVIDER_ORDER_VALUE_NAME,
&dwType, &pszValue, &nLen);
if (result != ERROR_SUCCESS) {
nLen = 0;
}
pszNewValue = malloc(nLen + strlen(pszWhatToAdd) + 1);/* Add 1 for comma */
*pszNewValue = 0;
/* Add the new value */
if (result == ERROR_SUCCESS) {
if (strstr(pszValue, pszWhatToAdd) != 0)
bAlreadyAdded = TRUE;
else {
if (pszValue && *pszValue) {
strcpy(pszNewValue, pszValue);
strcat(pszNewValue, ",");
}
strcat(pszNewValue, pszWhatToAdd);
}
} else if (result == ERROR_FILE_NOT_FOUND)
strcpy(pszNewValue, pszWhatToAdd);
/* Set the new value in the registry */
if (((result == ERROR_SUCCESS) ||
(result == ERROR_FILE_NOT_FOUND)) && !bAlreadyAdded)
result = RegSetValueEx(hKey, PROVIDER_ORDER_VALUE_NAME, 0,
REG_SZ, pszNewValue, strlen(pszNewValue) + 1);
free(pszNewValue);
free(pszValue);
RegCloseKey(hKey);
return (result == ERROR_SUCCESS);
}
/*
* RemoveFromProviderOrder() -- remove entry from network provider order
*/
BOOL RemoveFromProviderOrder(char *pszWhatToDel)
{
HKEY hKey;
DWORD dwType;
LONG result;
int nLen;
char *pszValue = 0;
char *pszNewValue;
BOOL bAlreadyRemoved = FALSE;
/* Open the key, creating if necessary (but should always be there). */
result = RegOpenKeyAlt(AFSREG_NULL_KEY, NETWORK_PROVIDER_ORDER_KEY,
KEY_SET_VALUE | KEY_ALL_ACCESS, TRUE, &hKey, 0);
if (result != ERROR_SUCCESS)
return FALSE;
/* Get the old value */
result = RegQueryValueAlt(hKey, PROVIDER_ORDER_VALUE_NAME,
&dwType, &pszValue, &nLen);
if (result == ERROR_SUCCESS) {
pszNewValue = malloc(nLen); /* bigger than we need, but that's ok */
*pszNewValue = 0;
if (strstr(pszValue, pszWhatToDel) == 0)
bAlreadyRemoved = TRUE;
else {
char *pszCur;
pszCur = strtok(pszValue, ",");
while (pszCur) {
if (strcmp(pszCur, pszWhatToDel) != 0) {
if (*pszNewValue)
strcat(pszNewValue, ",");
strcat(pszNewValue, pszCur);
}
pszCur = strtok(0, ",");
}
}
/* Set the new value in the registry */
if (!bAlreadyRemoved)
result = RegSetValueEx(hKey, PROVIDER_ORDER_VALUE_NAME, 0, REG_SZ,
pszNewValue, strlen(pszNewValue) + 1);
free(pszNewValue);
free(pszValue);
}
RegCloseKey(hKey);
return (result == ERROR_SUCCESS);
}
/*
* ReadSystemEnv() -- read system environment variable
*/
BOOL ReadSystemEnv(char **ppszEnvValue, char *pszEnvName)
{
if (IsWinNT())
return ReadRegEnv(ppszEnvValue, pszEnvName);
else
return ReadAutoExec(ppszEnvValue, pszEnvName);
}
/*
* WriteSystemEnv() -- write system environment variable
*/
BOOL WriteSystemEnv(char *pszEnvValue, char *pszEnvName)
{
if (IsWinNT())
return WriteRegEnv(pszEnvValue, pszEnvName);
else
return WriteAutoExec(pszEnvValue, pszEnvName);
}
/*
* AddToSystemPath() -- add specified entry to system PATH variable.
*/
BOOL AddToSystemPath(char *pszPath)
{
char *pszCurPath = 0;
char *pszNewPath = 0;
BOOL bStatus = TRUE;
if (!ReadSystemEnv(&pszCurPath, "Path"))
return FALSE;
/* Do we need to add it? */
if (!pszCurPath || !FindSubString(pszCurPath, pszPath)) {
/* Old path + a semicolon + the new path entry + a null */
pszNewPath = malloc((pszCurPath ? strlen(pszCurPath) + 1 : 0) +
strlen(pszPath) + 1);
if (pszNewPath == 0) {
if (pszCurPath)
free(pszCurPath);
return FALSE;
}
pszNewPath[0] = 0;
if (pszCurPath) {
strcpy(pszNewPath, pszCurPath);
strcat(pszNewPath, ";");
}
strcat(pszNewPath, pszPath);
bStatus = WriteSystemEnv(pszNewPath, "Path");
free(pszNewPath);
}
if (pszCurPath)
free(pszCurPath);
return bStatus;
}
/*
* RemoveFromSystemPath() -- remove specified entry from system PATH variable.
*/
BOOL RemoveFromSystemPath(char *pszPath)
{
char *pszCurNls = 0;
char *pszNewNls = 0;
char *pSemi = 0;
char *pCurPath = 0;
BOOL bStatus = TRUE;
if (!ReadSystemEnv(&pszCurNls, "Path"))
return FALSE;
/* Is it already not in the path? */
if (!pszCurNls || !FindSubString(pszCurNls, pszPath)) {
if (pszCurNls)
free(pszCurNls);
return TRUE;
}
pszNewNls = (char *)malloc(strlen(pszCurNls) + 1);
if (pszNewNls == 0) {
free(pszCurNls);
return FALSE;
}
pszNewNls[0] = 0;
pCurPath = pszCurNls;
while (1) {
pSemi = strchr(pCurPath, ';');
if (pSemi)
*pSemi = 0;
if (_stricmp(pCurPath, pszPath) != 0) {
if (pszNewNls[0] != 0)
strcat(pszNewNls, ";");
strcat(pszNewNls, pCurPath);
}
if (!pSemi)
break;
pSemi++;
pCurPath = pSemi;
}
bStatus = WriteSystemEnv(pszNewNls, "Path");
free(pszNewNls);
free(pszCurNls);
return bStatus;
}
/*
* IsWinNT() -- determine if system is NT or other (95/98).
*/
BOOL IsWinNT()
{
DWORD dwVersion = GetVersion();
return (dwVersion < 0x80000000);
}
/* ------------------ utility functions ---------------------- */
/*
* ReadRegEnv() -- read system enviornment variable from registry (NT only).
*/
static BOOL ReadRegEnv(char **ppszEnvValue, char *pszRegValueName)
{
HKEY hKey;
DWORD dwType;
LONG result;
int nLen = 512;
result = RegOpenKeyAlt(AFSREG_NULL_KEY, ENVIRONMENT_KEY,
KEY_SET_VALUE | KEY_ALL_ACCESS, FALSE, &hKey, 0);
if (result != ERROR_SUCCESS)
return FALSE;
*ppszEnvValue = 0;
do {
if (*ppszEnvValue)
free(*ppszEnvValue);
*ppszEnvValue = (char *)malloc(nLen);
if (*ppszEnvValue == 0) {
RegCloseKey(hKey);
return FALSE;
}
/* If function fails to open the value and the error code says that
* the value doesn't exist, then we will attempt to make it.
*/
result = RegQueryValueEx(hKey, pszRegValueName, 0,
&dwType, *ppszEnvValue, &nLen);
if (result == ERROR_FILE_NOT_FOUND) {
result = RegSetValueEx(hKey, pszRegValueName, 0,
REG_EXPAND_SZ, "", 0);
**ppszEnvValue = '\0'; /* zero length string "read" */
}
} while (result == ERROR_MORE_DATA);
RegCloseKey(hKey);
if (result != ERROR_SUCCESS || strlen(*ppszEnvValue) == 0) {
/* Don't return empty strings; instead set buffer pointer to 0. */
free(*ppszEnvValue);
*ppszEnvValue = 0;
}
return (result == ERROR_SUCCESS);
}
/*
* WriteRegEnv() -- write system environment variable to registry (NT only).
*/
static BOOL WriteRegEnv(char *pszEnvValue, char *pszEnvName)
{
LONG result;
HKEY hKey;
result = RegOpenKeyAlt(AFSREG_NULL_KEY, ENVIRONMENT_KEY,
KEY_ALL_ACCESS, FALSE, &hKey, 0);
if (result != ERROR_SUCCESS)
return FALSE;
result = RegSetValueEx(hKey, pszEnvName, 0, REG_EXPAND_SZ,
pszEnvValue, strlen(pszEnvValue) + 1);
RegCloseKey(hKey);
return (result == ERROR_SUCCESS);
}
/*
* ReadAutoExec() -- read environment variable from autoexec.bat (95/98).
*/
static BOOL ReadAutoExec(char **ppszEnvValue, char *pszEnvName)
{
char szSetCmd[256];
char szLine[2048];
FILE *fp;
*ppszEnvValue = 0;
fp = fopen(AUTOEXEC_PATH, "rt");
if (fp == 0)
return FALSE;
/* Create the string we are looking for */
sprintf(szSetCmd, "SET %s", pszEnvName);
/* Now read each line and look for our SetCmd string */
while (1) {
int nLineLen;
fgets(szLine, sizeof(szLine), fp);
if (feof(fp))
break;
/* Strip off the trailing newline */
nLineLen = strlen(szLine);
if (szLine[nLineLen - 1] == '\n') {
nLineLen--;
szLine[nLineLen] = 0;
}
if (_strnicmp(szSetCmd, szLine, strlen(szSetCmd)) == 0) {
char *value = strchr(szLine, '=');
if (value)
*ppszEnvValue = _strdup(++value);
break;
}
}
/* Don't return empty strings; instead set buffer to 0. */
if (*ppszEnvValue && (strlen(*ppszEnvValue) == 0)) {
free(*ppszEnvValue);
*ppszEnvValue = 0;
}
fclose(fp);
return TRUE;
}
/*
* WriteAutoExec() -- write environment variable to autoexec.bat (95/98).
*/
static BOOL WriteAutoExec(char *pszEnvValue, char *pszEnvName)
{
char szSetCmd[256];
char szLine[512];
BOOL bValueWritten = FALSE;
FILE *fpIn, *fpOut;
BOOL bResult;
fpOut = fopen(AUTOEXEC_TMP_PATH, "wt");
if (fpOut == 0)
return FALSE;
sprintf(szSetCmd, "SET %s", pszEnvName);
fpIn = fopen(AUTOEXEC_PATH, "rt");
if (fpIn != 0) {
/* Now read each line and look for our SetCmd string */
while (1) {
fgets(szLine, sizeof(szLine), fpIn);
if (feof(fpIn))
break;
if (!bValueWritten &&
(_strnicmp(szSetCmd, szLine, strlen(szSetCmd)) == 0)) {
fprintf(fpOut, "%s=%s\n", szSetCmd, pszEnvValue);
bValueWritten = TRUE;
} else
fputs(szLine, fpOut);
}
fclose(fpIn);
}
/* If the value didn't previously exist, then add it to the end */
if (!bValueWritten)
fprintf(fpOut, "%s=%s\n", szSetCmd, pszEnvValue);
fclose(fpOut);
bResult = CopyFile(AUTOEXEC_TMP_PATH, AUTOEXEC_PATH, FALSE);
/* Try to delete this even if the copy fails. Tie the return code
* to the copy and not the delete.
*/
DeleteFile(AUTOEXEC_TMP_PATH);
return bResult;
}
/*
* FindSubString() -- basically a case-insensitive strstr().
*/
static BOOL FindSubString(const char *s1, const char *s2)
{
char *ls1, *ls2;
BOOL bFound = FALSE;
ls1 = _strdup(s1);
if (!ls1)
return FALSE;
ls2 = _strdup(s2);
if (!ls2) {
free(ls1);
return FALSE;
}
bFound = strstr(_strlwr(ls1), _strlwr(ls2)) != 0;
free(ls2);
free(ls1);
return bFound;
}

View File

@ -0,0 +1,27 @@
/* Copyright (C) 1999 Transarc Corporation. All rights reserved.
*
*/
#ifndef AFS_SUTIL_H
#define AFS_SUTIL_H
/* Some install/uninstall related utilities */
#ifdef __cplusplus
extern "C" {
#endif
extern BOOL InNetworkProviderOrder(char *pszNetworkProvider, BOOL *pbIn);
extern BOOL AddToProviderOrder(char *pszWhatToAdd);
extern BOOL RemoveFromProviderOrder(char *pszWhatToDel);
extern BOOL ReadSystemEnv(char **ppszEnvValue, char *pszEnvName);
extern BOOL WriteSystemEnv(char *pszEnvValue, char *pszEnvName);
extern BOOL AddToSystemPath(char *pszPath);
extern BOOL RemoveFromSystemPath(char *pszPath);
extern BOOL IsWinNT();
#ifdef __cplusplus
};
#endif
#endif /* AFS_SUTIL_H */

View File

@ -0,0 +1,448 @@
[
uuid(ae274620-dea3-11d1-bfb3-00a024c0d1ef),
version(1.0),
pointer_default(unique),
implicit_handle(handle_t hBindTaAfsAdminSvr)
]
interface ITaAfsAdminSvr
{
import "ITaAfsAdmSvrTypes.idl";
// AfsAdmSvr_Connect
// ...obtains a cookie to represent the calling process. The cookie should
// be freed with AfsAdmSvr_Disconnect when the process disconnects.
//
int AfsAdmSvr_Connect (
[in] STRING szClientAddress,
[out] DWORD *pidClient,
[out] ULONG *pStatus
);
// AfsAdmSvr_Disconnect
// ...releases and invalidates the cookie representing the calling process.
//
int AfsAdmSvr_Disconnect (
[in] DWORD idClient,
[out] ULONG *pStatus
);
// AfsAdmSvr_Ping
// ...reminds the admin server that the specified client is still around.
// this call should be made at least every csecAFSADMSVR_CLIENT_PING
// seconds, lest the admin server think you've disconnected. (The client
// library TaAfsAdmSvrClient.lib automatically handles this.)
//
int AfsAdmSvr_Ping (
[in] DWORD idClient,
[out] ULONG *pStatus
);
const DWORD csecAFSADMSVR_CLIENT_PING = (2L * 60L); // 2 minutes
// AfsAdmSvr_CrackCredentials
// ...obtains information about the supplied credentials token.
//
int AfsAdmSvr_CrackCredentials (
[in] DWORD idClient,
[in] DWORD hCreds,
[out] STRING pszCell,
[out] STRING pszUser,
[out] SYSTEMTIME *pstExpiration,
[out] ULONG *pStatus
);
// AfsAdmSvr_GetCredentials
// ...queries the user's current AFS credentials for the specified cell.
// if the user already has credentials in the cell, returns a nonzero
// token {hCreds}, suitable for use in AfsAdmSvr_OpenCell().
//
DWORD AfsAdmSvr_GetCredentials (
[in] DWORD idClient,
[in] STRING pszCell,
[out] ULONG *pStatus
);
// AfsAdmSvr_SetCredentials
// ...obtains new AFS credentials within the administrative server process
// on behalf of the specified user. if successful, returns a nonzero
// token {hCreds}, suitable for use in AfsAdmSvr_OpenCell().
//
DWORD AfsAdmSvr_SetCredentials (
[in] DWORD idClient,
[in] STRING pszCell,
[in] STRING pszUser,
[in] STRING pszPassword,
[out] ULONG *pStatus
);
// AfsAdmSvr_PushCredentials
// ...requests that the specified AFS credentials be used hereafter
// when manipulating the specified cell. You should follow this
// call with a Refresh request if necessary.
//
int AfsAdmSvr_PushCredentials (
[in] DWORD idClient,
[in] DWORD hCreds,
[in] ASID idCell,
[out] ULONG *pStatus
);
// AfsAdmSvr_GetLocalCell
// ...obtains the name of the primary cell used by the admin server
//
int AfsAdmSvr_GetLocalCell (
[in] DWORD idClient,
[out] STRING pszCellName,
[out] ULONG *pStatus
);
// AfsAdmSvr_ErrorCodeTranslate
// ...translates an error code into a readable string
//
int AfsAdmSvr_ErrorCodeTranslate (
[in] DWORD idClient,
[in] ULONG code,
[in] LANGID idLanguage, // pass 0 for default language at server
[out] STRING pszErrorText,
[out] ULONG *pStatus
);
// AfsAdmSvr_GetAction
// ...returns information about a particular operation in progress.
//
int AfsAdmSvr_GetAction (
[in] DWORD idClient,
[in] DWORD idAction,
[out] LPASACTION pAction,
[out] ULONG *pStatus
);
// AfsAdmSvr_GetActions
// ...returns a list of operations in progress. The list returned can
// be constrained to only including those operations initiated by
// a particular client and/or performed in a particular cell.
//
int AfsAdmSvr_GetActions (
[in] DWORD idClient,
[in] DWORD idClientSearch, // 0 to return for all clients
[in] ASID idCellSearch, // 0 to return for all cells
[out] LPASACTIONLIST *ppList,
[out] ULONG *pStatus
);
// AfsAdmSvr_OpenCell
// ...opens a cell for administration.
//
int AfsAdmSvr_OpenCell (
[in] DWORD idClient,
[in] DWORD hCreds,
[in] STRING pszCellName,
[in] DWORD dwScopeFlags,
[out] ASID *pidCell,
[out] ULONG *pStatus
);
const DWORD AFSADMSVR_SCOPE_VOLUMES = 0x00000001;
const DWORD AFSADMSVR_SCOPE_USERS = 0x00000002;
// AfsAdmSvr_CloseCell
// ...used by client to open a cell for administration.
//
int AfsAdmSvr_CloseCell (
[in] DWORD idClient,
[in] ASID idCell,
[out] ULONG *pStatus
);
// AfsAdmSvr_FindObject
// AfsAdmSvr_FindObjects
// ...used to search through all objects in the cell, obtaining a list
// of those which match the specified criteria. For FindObjects, the
// {*ppList} parameter will be filled in with an allocated list of ASID
// objects, and should be freed using the AfsAdmSvr_FreeAsidList()
// routine (clients using the TaAfsAdmSvrClient.lib library should call
// asc_AsidListFree(), which is a wrapper for the former routine).
// The _FindObject routine can be used to find exactly one object--for
// instance, finding the ASID for a particular user or volume--while
// the _FindObjects routine returns a list of all objects which
// match the specified criteria--all volumes on a partition, or all
// users named "b*" within a cell.
//
int AfsAdmSvr_FindObject (
[in] DWORD idClient,
[in] ASID idSearchScope,
[in] ASOBJTYPE ObjectType,
[in] AFSADMSVR_SEARCH_REFRESH SearchRefresh,
[in] STRING szName,
[out] ASID *pidObject,
[out] ULONG *pStatus
);
int AfsAdmSvr_FindObjects (
[in] DWORD idClient,
[in] ASID idSearchScope,
[in] ASOBJTYPE ObjectType,
[in] AFSADMSVR_SEARCH_REFRESH SearchRefresh,
[in] STRING szPattern,
[in] LPAFSADMSVR_SEARCH_PARAMS pSearchParams,
[out] LPASIDLIST *ppList,
[out] ULONG *pStatus
);
// AfsAdmSvr_GetObject
// AfsAdmSvr_GetObjects
// ...returns server-cached information about the specified object (or
// objects).
//
int AfsAdmSvr_GetObject (
[in] DWORD idClient,
[in] AFSADMSVR_GET_TYPE GetType,
[in] AFSADMSVR_GET_LEVEL GetLevel,
[in] ASID idObject,
[in] DWORD verProperties, // can be 0 if not RETURN_IF_OUT_OF_DATE
[out] LPASOBJPROP pProperties,
[out] ULONG *pStatus
);
int AfsAdmSvr_GetObjects (
[in] DWORD idClient,
[in] AFSADMSVR_GET_TYPE GetType,
[in] AFSADMSVR_GET_LEVEL GetLevel,
[in] LPASIDLIST pListObjects, // lParam used as verProperties
[out] LPASOBJPROPLIST *ppListObjectProperties,
[out] ULONG *pStatus
);
// AfsAdmSvr_RefreshObject
// AfsAdmSvr_RefreshObjects
// ...invalidates the server's cache of information about the specified
// object or objects.
//
int AfsAdmSvr_RefreshObject (
[in] DWORD idClient,
[in] ASID idObject,
[out] ULONG *pStatus
);
int AfsAdmSvr_RefreshObjects (
[in] DWORD idClient,
[in] LPASIDLIST pListObjects,
[out] ULONG *pStatus
);
// AfsAdmSvr_CallbackHost
// ...provides a context in which the server can issue callback functions
// via the AfsAdmSvrCallBack_* routines, which the client must implement.
// This routine will only return if the server is shut down. It should
// be called on a dedicated thread by the client. (TaAfsAdmSvrClient.lib
// automatically handles this.)
//
void AfsAdmSvr_CallbackHost (void);
// AfsAdmSvrCallback_Action
// ...called by the server in the context of the CallbackHost() routine;
// this routine is used to notify the client whenever an action is
// initiated or completed.
//
[callback] void AfsAdmSvrCallback_Action (
[in] LPASACTION pAction,
[in] BOOL fFinished
);
// AfsAdmSvr_GetRandomKey
// ...returns a randomly-generated 8-byte encryption key
//
int AfsAdmSvr_GetRandomKey (
[in] DWORD idClient,
[in] ASID idCell,
[out] BYTE keyData[ ENCRYPTIONKEYLENGTH ],
[out] ULONG *pStatus
);
// AfsAdmSvr_ChangeUser
// ...changes a user account's properties.
//
int AfsAdmSvr_ChangeUser (
[in] DWORD idClient,
[in] ASID idCell,
[in] ASID idUser,
[in] LPAFSADMSVR_CHANGEUSER_PARAMS pChange,
[out] ULONG *pStatus
);
// AfsAdmSvr_GetGroupMembership
// ...retrieves the list of groups to which a user or group belongs
//
int AfsAdmSvr_GetGroupMembership (
[in] DWORD idClient,
[in] ASID idCell,
[in] ASID idMember,
[out] LPASIDLIST *ppAsidList,
[out] ULONG *pStatus
);
// AfsAdmSvr_GetGroupOwnership
// ...retrieves the list of groups which a user or group owns
//
int AfsAdmSvr_GetGroupOwnership (
[in] DWORD idClient,
[in] ASID idCell,
[in] ASID idOwner,
[out] LPASIDLIST *ppAsidList,
[out] ULONG *pStatus
);
// AfsAdmSvr_ChangeGroup
// ...changes a PTS group's properties.
//
int AfsAdmSvr_ChangeGroup (
[in] DWORD idClient,
[in] ASID idCell,
[in] ASID idGroup,
[in] LPAFSADMSVR_CHANGEGROUP_PARAMS pChange,
[out] ULONG *pStatus
);
// AfsAdmSvr_GetGroupMembers
// ...retrieves the list of users which belong to a group
//
int AfsAdmSvr_GetGroupMembers (
[in] DWORD idClient,
[in] ASID idCell,
[in] ASID idGroup,
[out] LPASIDLIST *ppAsidList,
[out] ULONG *pStatus
);
// AfsAdmSvr_AddGroupMember
// ...adds a member to the specified group
//
int AfsAdmSvr_AddGroupMember (
[in] DWORD idClient,
[in] ASID idCell,
[in] ASID idGroup,
[in] ASID idMember,
[out] ULONG *pStatus
);
// AfsAdmSvr_RemoveGroupMember
// ...removes a member from the specified group
//
int AfsAdmSvr_RemoveGroupMember (
[in] DWORD idClient,
[in] ASID idCell,
[in] ASID idGroup,
[in] ASID idMember,
[out] ULONG *pStatus
);
// AfsAdmSvr_RenameGroup
// ...changes a group's name
//
int AfsAdmSvr_RenameGroup (
[in] DWORD idClient,
[in] ASID idCell,
[in] ASID idGroup,
[in] STRING szNewGroupName,
[out] ULONG *pStatus
);
// AfsAdmSvr_CreateGroup
// ...creates a new PTS group
//
int AfsAdmSvr_CreateGroup (
[in] DWORD idClient,
[in] ASID idCell,
[in] LPAFSADMSVR_CREATEGROUP_PARAMS pCreate,
[out] ASID *pidGroup,
[out] ULONG *pStatus
);
// AfsAdmSvr_DeleteGroup
// ...deletes a PTS group
//
int AfsAdmSvr_DeleteGroup (
[in] DWORD idClient,
[in] ASID idCell,
[in] ASID idGroup,
[out] ULONG *pStatus
);
// AfsAdmSvr_SetUserPassword
// ...changes the password for the specified user account. Pass a non-empty
// string in {keyString} to encrypt the specified string; otherwise,
// pass a valid encryption key in {keyData}.
//
int AfsAdmSvr_SetUserPassword (
[in] DWORD idClient,
[in] ASID idCell,
[in] ASID idUser,
[in] int keyVersion,
[in] STRING keyString,
[in] BYTE keyData[ ENCRYPTIONKEYLENGTH ],
[out] ULONG *pStatus
);
// AfsAdmSvr_UnlockUser
// ...unlocks a user's account
//
int AfsAdmSvr_UnlockUser (
[in] DWORD idClient,
[in] ASID idCell,
[in] ASID idUser,
[out] ULONG *pStatus
);
// AfsAdmSvr_CreateUser
// ...creates a new user account
//
int AfsAdmSvr_CreateUser (
[in] DWORD idClient,
[in] ASID idCell,
[in] LPAFSADMSVR_CREATEUSER_PARAMS pCreate,
[out] ASID *pidUser,
[out] ULONG *pStatus
);
// AfsAdmSvr_DeleteUser
// ...deletes a user account
//
int AfsAdmSvr_DeleteUser (
[in] DWORD idClient,
[in] ASID idCell,
[in] ASID idUser,
[in] LPAFSADMSVR_DELETEUSER_PARAMS pDelete,
[out] ULONG *pStatus
);
// AfsAdmSvr_ChangeCell
// ...changes a cell's properties.
//
int AfsAdmSvr_ChangeCell (
[in] DWORD idClient,
[in] ASID idCell,
[in] LPAFSADMSVR_CHANGECELL_PARAMS pChange,
[out] ULONG *pStatus
);
// AfsAdmSvr_SetRefreshRate
// ...changes the refresh rate for a specific cell
//
int AfsAdmSvr_SetRefreshRate (
[in] DWORD idClient,
[in] ASID idCell,
[in] ULONG cminRefreshRate,
[out] ULONG *pStatus
);
}

View File

@ -0,0 +1,506 @@
import "wtypes.idl";
cpp_quote ("#ifndef _WINNT_")
typedef WORD LANGID;
cpp_quote ("#endif // _WINNT_")
const int ENCRYPTIONKEYLENGTH = 8;
// ASID - Admin Server ID
// ...Type used for unique object identifiers throughout these adm
//
typedef DWORD ASID, *LPASID;
// ASOBJTYPE - Admin Server Object Type
// ...Enumeration used to classify a particular object within a cell.
// The types' values don't overlap, so they can be specified in
// combination during searches.
//
typedef enum {
TYPE_CELL = 0x00000001,
TYPE_SERVER = 0x00000002,
TYPE_SERVICE = 0x00000004,
TYPE_PARTITION = 0x00000008,
TYPE_VOLUME = 0x00000010,
TYPE_USER = 0x00000020,
TYPE_GROUP = 0x00000040,
TYPE_ANY = 0x0000FFFF
} ASOBJTYPE;
// STRING - Default String Definition
//
cpp_quote ("#ifdef _WINDOWS_")
cpp_quote ("typedef char stringchar;")
cpp_quote ("#else // _WINDOWS_")
typedef char stringchar;
cpp_quote ("#endif // _WINDOWS_")
const int cchSTRING = 256;
typedef stringchar STRING [ cchSTRING ];
// VOLUMEID - Volume ID
// ...Type used to hold an AFS volume identifier.
//
cpp_quote ("#ifndef AFSCLASS_H")
typedef unsigned int VOLUMEID, *LPVOLUMEID;
cpp_quote ("#endif // AFSCLASS_H")
// ACCOUNTACCESS - Indicator of who is allowed to manipulate an object
// ...An enumeration used to indicate the security level around an
// object. The admin server does not use this information directly,
// but passes it on to the AFS server processes.
//
cpp_quote ("#ifndef AFSCLASS_H")
typedef enum {
aaOWNER_ONLY,
aaGROUP_ONLY,
aaANYONE,
} ACCOUNTACCESS;
cpp_quote ("#endif // AFSCLASS_H")
// ASACTIONTYPE - Operation Type Identifier
// ...Enumeration used to classify a particular operation in progress
// by its type. Together with the ASACTION structure and ASACTLIST
// structure, this type is used to indicate the operations being
// performed on the admin server
//
typedef enum {
ACTION_REFRESH, // Refreshing cache for cell or object
ACTION_SCOUT, // Testing for problems in cell
ACTION_USER_CHANGE, // Changing user's properties
ACTION_USER_PW_CHANGE, // Changing user's password
ACTION_USER_UNLOCK, // Unlocking user's account
ACTION_USER_CREATE, // Creating user account
ACTION_USER_DELETE, // Deleting user account
ACTION_GROUP_CHANGE, // Changing group's properties
ACTION_GROUP_MEMBER_ADD, // Adding a member to a group
ACTION_GROUP_MEMBER_REMOVE, // Removing a member from a group
ACTION_GROUP_RENAME, // Renaming a group
ACTION_GROUP_CREATE, // Creating group
ACTION_GROUP_DELETE, // Deleting group
ACTION_CELL_CHANGE, // Changing a cell's properties
} ASACTIONTYPE;
// ASACTION - Operation Identifier
// ...Provides a structure encapsulating all known information about an
// operation currently in progress.
//
typedef struct {
ASID idScope; // Scope of refresh (cell or object)
} ASACTION_REFRESH;
typedef struct {
ASID idScope; // Scope of scout (cell or object)
} ASACTION_SCOUT;
typedef struct {
ASID idUser; // User whose properties are changing
} ASACTION_USER_CHANGE;
typedef struct {
ASID idUser; // User whose password is changing
} ASACTION_USER_PW_CHANGE;
typedef struct {
ASID idUser; // User whose account is being unlocked
} ASACTION_USER_UNLOCK;
typedef struct {
STRING szUser; // Name of new user account
STRING szInstance; // Name of new user account
} ASACTION_USER_CREATE;
typedef struct {
ASID idUser; // User being deleted
} ASACTION_USER_DELETE;
typedef struct {
ASID idGroup; // Group whose properties are changing
} ASACTION_GROUP_CHANGE;
typedef struct {
ASID idGroup; // Group which is changing
ASID idUser; // User who is being added as a member
} ASACTION_GROUP_MEMBER_ADD;
typedef struct {
ASID idGroup; // Group which is changing
ASID idUser; // Member who is being removed
} ASACTION_GROUP_MEMBER_REMOVE;
typedef struct {
ASID idGroup; // Group which is changing
STRING szNewName; // Member who is being removed
} ASACTION_GROUP_RENAME;
typedef struct {
STRING szGroup; // Name of new PTS group
} ASACTION_GROUP_CREATE;
typedef struct {
ASID idGroup; // Group being deleted
} ASACTION_GROUP_DELETE;
typedef struct {
ASACTIONTYPE Action; // The operation in progress
DWORD idAction; // Unique action identifier
DWORD idClient; // Client which initiated the operation
ASID idCell; // Cell in which operation is occurring
DWORD csecActive; // Elapsed active time for operation
[switch_is(Action)] union {
[case(ACTION_REFRESH)] ASACTION_REFRESH Refresh;
[case(ACTION_SCOUT)] ASACTION_SCOUT Scout;
[case(ACTION_USER_CHANGE)] ASACTION_USER_CHANGE User_Change;
[case(ACTION_USER_PW_CHANGE)] ASACTION_USER_PW_CHANGE User_Pw_Change;
[case(ACTION_USER_UNLOCK)] ASACTION_USER_UNLOCK User_Unlock;
[case(ACTION_USER_CREATE)] ASACTION_USER_CREATE User_Create;
[case(ACTION_USER_DELETE)] ASACTION_USER_DELETE User_Delete;
[case(ACTION_GROUP_CHANGE)] ASACTION_GROUP_CHANGE Group_Change;
[case(ACTION_GROUP_MEMBER_ADD)] ASACTION_GROUP_MEMBER_ADD Group_Member_Add;
[case(ACTION_GROUP_MEMBER_REMOVE)] ASACTION_GROUP_MEMBER_REMOVE Group_Member_Remove;
[case(ACTION_GROUP_RENAME)] ASACTION_GROUP_RENAME Group_Rename;
[case(ACTION_GROUP_CREATE)] ASACTION_GROUP_CREATE Group_Create;
[case(ACTION_GROUP_DELETE)] ASACTION_GROUP_DELETE Group_Delete;
[default] ;
} u;
} ASACTION, *LPASACTION;
// ASOBJPROP - Object Properties Structure
// ...A union of the different object properties structures, with an
// ASOBJTYPE identifier to indicate which one is valid. Each such
// structure has an associated version; as new information is obtained
// on the server, the internal version number is incremented.
//
const DWORD verPROP_NO_OBJECT = 0; // object deleted or otherwise invalid
const DWORD verPROP_RUDIMENTARY = 1; // only asked to obtain name etc
const DWORD verPROP_FIRST_SCAN = 2; // first properties obtained for object
const DWORD ASOBJPROP_SERVER_MAXADDRESS = 16; // AFS uses <=16 addrs per server
typedef struct {
DWORD idUserMax;
DWORD idGroupMax;
} ASOBJPROP_CELL, *LPASOBJPROP_CELL;
typedef struct {
ULONG nAddresses;
DWORD aAddresses[ ASOBJPROP_SERVER_MAXADDRESS ];
} ASOBJPROP_SERVER, *LPASOBJPROP_SERVER;
cpp_quote ("#ifndef AFSCLASS_H")
typedef enum {
SERVICETYPE_SIMPLE,
SERVICETYPE_FS,
SERVICETYPE_CRON
} SERVICETYPE;
cpp_quote ("#endif // AFSCLASS_H")
cpp_quote ("#ifndef AFSCLASS_H")
typedef enum {
SERVICESTATE_RUNNING,
SERVICESTATE_STOPPED,
SERVICESTATE_STARTING,
SERVICESTATE_STOPPING
} SERVICESTATE;
cpp_quote ("#endif // AFSCLASS_H")
typedef struct {
SERVICETYPE ServiceType;
SERVICESTATE ServiceState;
STRING szAuxStatus;
STRING szParams;
STRING szNotifier;
SYSTEMTIME timeLastStart;
SYSTEMTIME timeLastStop;
SYSTEMTIME timeLastFail;
ULONG nStarts;
ULONG dwErrLast;
ULONG dwSigLast;
} ASOBJPROP_SERVICE, *LPASOBJPROP_SERVICE;
typedef struct {
ULONG dwID;
ULONG ckStorageTotal;
ULONG ckStorageFree;
ULONG ckStorageAllocated;
} ASOBJPROP_PARTITION, *LPASOBJPROP_PARTITION;
cpp_quote ("#ifndef AFSCLASS_H")
typedef enum {
ftREADWRITE,
ftREPLICA,
ftCLONE
} FILESETTYPE;
cpp_quote ("#endif // AFSCLASS_H")
typedef struct {
VOLUMEID id;
VOLUMEID idReadWrite;
VOLUMEID idReplica;
VOLUMEID idClone;
SYSTEMTIME timeCreation;
SYSTEMTIME timeLastUpdate;
SYSTEMTIME timeLastAccess;
SYSTEMTIME timeLastBackup;
SYSTEMTIME timeCopyCreation;
ULONG nFiles;
ULONG ckQuota;
ULONG ckUsed;
FILESETTYPE FilesetType;
DWORD FilesetState;
} ASOBJPROP_VOLUME, *LPASOBJPROP_VOLUME;
const DWORD FILESETSTATE_NORMAL = 0x00000000;
const DWORD FILESETSTATE_SALVAGE = 0x00000001;
const DWORD FILESETSTATE_NO_VNODE = 0x00000002;
const DWORD FILESETSTATE_NO_VOL = 0x00000004;
const DWORD FILESETSTATE_NO_SERVICE = 0x00000008;
const DWORD FILESETSTATE_OFFLINE = 0x00000010;
const DWORD FILESETSTATE_DISK_FULL = 0x00000020;
const DWORD FILESETSTATE_OVER_QUOTA = 0x00000040;
const DWORD FILESETSTATE_BUSY = 0x00000080;
const DWORD FILESETSTATE_MOVED = 0x00000100;
const DWORD FILESETSTATE_LOCKED = 0x00010000; // see afsclass/c_set.h
typedef struct {
BOOL fHaveKasInfo;
BOOL fHavePtsInfo;
STRING szInstance;
struct
{
BOOL fIsAdmin;
BOOL fCanGetTickets;
BOOL fEncrypt;
BOOL fCanChangePassword;
BOOL fCanReusePasswords;
SYSTEMTIME timeExpires;
SYSTEMTIME timeLastPwChange;
SYSTEMTIME timeLastMod;
STRING szUserLastMod;
LONG csecTicketLifetime;
int keyVersion;
BYTE keyData[ENCRYPTIONKEYLENGTH];
DWORD dwKeyChecksum;
LONG cdayPwExpire;
LONG cFailLogin;
LONG csecFailLoginLock;
} KASINFO;
struct
{
LONG cgroupCreationQuota;
LONG cgroupMember;
int uidName;
int uidOwner;
int uidCreator;
STRING szOwner;
STRING szCreator;
ACCOUNTACCESS aaListStatus;
ACCOUNTACCESS aaGroupsOwned;
ACCOUNTACCESS aaMembership;
} PTSINFO;
} ASOBJPROP_USER, *LPASOBJPROP_USER;
typedef struct {
int nMembers;
int uidName;
int uidOwner;
int uidCreator;
ACCOUNTACCESS aaListStatus;
ACCOUNTACCESS aaListGroupsOwned;
ACCOUNTACCESS aaListMembers;
ACCOUNTACCESS aaAddMember;
ACCOUNTACCESS aaDeleteMember;
STRING szOwner;
STRING szCreator;
} ASOBJPROP_GROUP, *LPASOBJPROP_GROUP;
typedef struct {
ASOBJTYPE Type;
ASID idObject;
ASID idParentCell;
ASID idParentServer;
ASID idParentPartition;
STRING szName;
DWORD verProperties; // if > verPROP_RUDIMENTARY, union information valid
LPARAM lParam;
[switch_is(Type)] union {
[case(TYPE_CELL)] ASOBJPROP_CELL CellProperties;
[case(TYPE_SERVER)] ASOBJPROP_SERVER ServerProperties;
[case(TYPE_SERVICE)] ASOBJPROP_SERVICE ServiceProperties;
[case(TYPE_PARTITION)] ASOBJPROP_PARTITION PartitionProperties;
[case(TYPE_VOLUME)] ASOBJPROP_VOLUME VolumeProperties;
[case(TYPE_USER)] ASOBJPROP_USER UserProperties;
[case(TYPE_GROUP)] ASOBJPROP_GROUP GroupProperties;
[default] ;
} u;
} ASOBJPROP, *LPASOBJPROP;
// ASIDLIST - Managed type for lists of cell objects
// ...Both the server and client libraries use TaAfsAdmSvrCommon.cpp,
// which contains (among other things) routines for manipulating
// ASIDLIST structures. This structure represents a list of ASIDs--
// that is, references to objects within a specific cell. Different
// APIs which use ASIDLIST structures may have different uses for the
// {ASIDLIST.aEntries[].lParam} parameter.
//
typedef struct {
ULONG cEntries;
ULONG cEntriesAllocated; // (used internally)
[size_is(cEntriesAllocated), length_is(cEntriesAllocated)] struct {
ASID idObject;
LPARAM lParam;
} aEntries[*];
} ASIDLIST, *LPASIDLIST;
// ASOBJPROPLIST - Managed type for lists of object properties
// ...This structure represents a list of ASOBJPROPs.
//
typedef struct {
ULONG cEntries;
ULONG cEntriesAllocated; // (used internally)
[size_is(cEntriesAllocated), length_is(cEntriesAllocated)] struct {
ASOBJPROP ObjectProperties;
LPARAM lParam;
} aEntries[*];
} ASOBJPROPLIST, *LPASOBJPROPLIST;
// ASACTIONLIST - Managed type for lists of actions in progress
// ...This structure represents a list of ASACTION objects.
//
typedef struct {
ULONG cEntries;
ULONG cEntriesAllocated; // (used internally)
[size_is(cEntriesAllocated), length_is(cEntriesAllocated)] struct {
ASACTION Action;
} aEntries[*];
} ASACTIONLIST, *LPASACTIONLIST;
// AFSADMSVR_SEARCH_REFRESH - Defines search parameters
// ...This structure is used when calling AfsAdmSvr_Search.
//
typedef enum {
SEARCH_KNOWN_OBJECTS, // test only already-found objects
SEARCH_ALL_OBJECTS // ensure cell scanned for all such objects first
} AFSADMSVR_SEARCH_REFRESH;
// AFSADMSVR_GET_TYPE - Defines data retrieval parameters
// AFSADMSVR_GET_LEVEL - Defines data retrieval parameters
// ...These structures are used when calling AfsAdmSvr_GetObject
//
typedef enum {
RETURN_DATA_ALWAYS, // only need to return name etc
RETURN_IF_OUT_OF_DATE, // always returns information for all objects
} AFSADMSVR_GET_TYPE;
typedef enum {
GET_RUDIMENTARY_DATA, // only need to return name etc
GET_ALL_DATA // always returns information for all objects
} AFSADMSVR_GET_LEVEL;
// AFSADMSVR_CHANGECELL_PARAMS - Parameters for changing a cell
//
typedef struct {
DWORD idUserMax;
DWORD idGroupMax;
} AFSADMSVR_CHANGECELL_PARAMS, *LPAFSADMSVR_CHANGECELL_PARAMS;
// AFSADMSVR_CHANGEUSER_PARAMS - Parameters for changing users' properties
//
typedef struct {
BOOL fIsAdmin;
BOOL fCanGetTickets;
BOOL fEncrypt;
BOOL fCanChangePassword;
BOOL fCanReusePasswords;
SYSTEMTIME timeExpires;
LONG cdayPwExpire;
LONG csecTicketLifetime;
LONG cFailLogin;
LONG csecFailLoginLock;
LONG cgroupCreationQuota;
ACCOUNTACCESS aaListStatus;
ACCOUNTACCESS aaGroupsOwned;
ACCOUNTACCESS aaMembership;
} AFSADMSVR_CHANGEUSER_PARAMS, *LPAFSADMSVR_CHANGEUSER_PARAMS;
// AFSADMSVR_CHANGEGROUP_PARAMS - Parameters for changing groups
//
typedef struct {
STRING szOwner;
ACCOUNTACCESS aaListStatus;
ACCOUNTACCESS aaListGroupsOwned;
ACCOUNTACCESS aaListMembers;
ACCOUNTACCESS aaAddMember;
ACCOUNTACCESS aaDeleteMember;
} AFSADMSVR_CHANGEGROUP_PARAMS, *LPAFSADMSVR_CHANGEGROUP_PARAMS;
// AFSADMSVR_CREATEUSER_PARAMS - Parameters for creating user accounts
//
typedef struct
{
STRING szName;
STRING szInstance;
STRING szPassword;
int idUser;
BOOL fCreateKAS;
BOOL fCreatePTS;
} AFSADMSVR_CREATEUSER_PARAMS, *LPAFSADMSVR_CREATEUSER_PARAMS;
// AFSADMSVR_CREATEGROUP_PARAMS - Parameters for creating PTS groups
//
typedef struct
{
STRING szName;
STRING szOwner;
int idGroup;
} AFSADMSVR_CREATEGROUP_PARAMS, *LPAFSADMSVR_CREATEGROUP_PARAMS;
// AFSADMSVR_DELETEUSER_PARAMS - Parameters for deleting user accounts
//
typedef struct
{
BOOL fDeleteKAS;
BOOL fDeletePTS;
} AFSADMSVR_DELETEUSER_PARAMS, *LPAFSADMSVR_DELETEUSER_PARAMS;
// AFSADMSVR_SEARCH_TYPE - Advanced search types
//
typedef enum
{
SEARCH_NO_LIMITATIONS,
SEARCH_EXPIRES_BEFORE,
SEARCH_PASSWORD_EXPIRES_BEFORE
} AFSADMSVR_SEARCH_TYPE;
// AFSADMSVR_SEARCH_PARAMS - Advanced search parameters
//
typedef struct
{
AFSADMSVR_SEARCH_TYPE SearchType;
SYSTEMTIME SearchTime;
} AFSADMSVR_SEARCH_PARAMS, *LPAFSADMSVR_SEARCH_PARAMS;

View File

@ -0,0 +1,152 @@
# Copyright (C) 1998 Transarc Corporation. All rights reserved.
############################################################################
# make compiler warnings fatal
AFSDEV_AUXCDEFINES = $(AFSDEV_AUXCDEFINES) -WX
# since we're using rpcndr.h, we can't include <afs/stds.h>'s "hyper" type.
AFSDEV_AUXCDEFINES = $(AFSDEV_AUXCDEFINES) -DIGNORE_STDS_H
# include the primary makefile
!INCLUDE ..\..\config\NTMakefile.$(SYS_NAME)
!INCLUDE ..\..\config\NTMakefile.version
############################################################################
#
# BUILD TARGETS
#
INCFILEDIR = $(DESTDIR)\include\WINNT
EXEFILE = $(DESTDIR)\root.server\usr\afs\bin\TaAfsAdmSvr.exe
LIBFILE = $(DESTDIR)\lib\afs\TaAfsAdmSvrClient.lib
INCFILES = \
$(INCFILEDIR)\TaAfsAdmSvr.h \
$(INCFILEDIR)\TaAfsAdmSvrClient.h \
$(INCFILEDIR)\TaAfsAdmSvrCommon.h \
$(INCFILEDIR)\iTaAfsAdmSvr.h \
$(INCFILEDIR)\iTaAfsAdmSvrTypes.h
IDLFILES = \
iTaAfsAdmSvr.h \
iTaAfsAdmSvrTypes.h
LIBOBJS = \
TaAfsAdmSvrClient.obj \
TaAfsAdmSvrClientBind.obj \
TaAfsAdmSvrClientCache.obj \
TaAfsAdmSvrClientCell.obj \
TaAfsAdmSvrClientGroup.obj \
TaAfsAdmSvrClientInternal.obj \
TaAfsAdmSvrClientNotify.obj \
TaAfsAdmSvrClientPing.obj \
TaAfsAdmSvrClientUser.obj \
TaAfsAdmSvrCommon.obj \
iTaAfsAdmSvr_c.obj
EXEOBJS = \
AfsAdmSvr.res \
TaAfsAdmSvr.obj \
TaAfsAdmSvrCallback.obj \
TaAfsAdmSvrCell.obj \
TaAfsAdmSvrCommon.obj \
TaAfsAdmSvrDebug.obj \
TaAfsAdmSvrGeneral.obj \
TaAfsAdmSvrGroup.obj \
TaAfsAdmSvrMain.obj \
TaAfsAdmSvrProperties.obj \
TaAfsAdmSvrSearch.obj \
TaAfsAdmSvrUser.obj \
iTaAfsAdmSvr_s.obj
VCLIBS =\
gdi32.lib \
user32.lib \
rpcns4.lib \
rpcrt4.lib \
comctl32.lib \
gdi32.lib
EXELIBS = \
$(DESTDIR)\lib\afs\AfsClass.lib \
$(DESTDIR)\lib\afs\TaAfsAppLib.lib \
$(DESTDIR)\lib\afs\AfsKasAdmin.lib \
$(DESTDIR)\lib\afs\AfsPtsAdmin.lib \
$(DESTDIR)\lib\afs\AfsVosAdmin.lib \
$(DESTDIR)\lib\afs\AfsBosAdmin.lib \
$(DESTDIR)\lib\afs\AfsAdminUtil.lib \
$(DESTDIR)\lib\afs\AfsClientAdmin.lib
############################################################################
#
# IDL COMPILATION
#
MIDL_FLAGS=/ms_ext \
/app_config \
/I $(INCFILEDIR) \
/I . \
/env win32 \
/win32 \
/align 8 \
/pack 8 \
/W3 \
/WX \
/nologo
.SUFFIXES: .h .idl
.idl.h:
midl $(MIDL_FLAGS) $<
############################################################################
afsapplib_headers :
$(CD) ..\afsapplib
nmake /nologo /f ntmakefile headers
$(CD) ..\afsadmsvr
$(LIBFILE) : $(LIBOBJS)
$(LIBARCH)
afsapplib_primary :
$(CD) ..\afsapplib
nmake /nologo /f ntmakefile primary
$(CD) ..\afsadmsvr
afsclass_primary :
$(CD) ..\afsclass
nmake /nologo /f ntmakefile primary
$(CD) ..\afsadmsvr
$(EXEFILE) : $(EXEOBJS) $(EXELIBS)
$(EXECONLINK) $(VCLIBS)
$(EXEPREP)
install : \
$(IDLFILES) \
$(INCFILES) \
afsapplib_headers \
$(LIBFILE) \
afsapplib_primary \
afsclass_primary \
$(EXEFILE)
clean::
if exist ITaAfsAdmSvr*.cpp del ITaAfsAdmSvr*.cpp
if exist ITaAfsAdmSvr*.c del ITaAfsAdmSvr*.c
if exist ITaAfsAdmSvr*.h del ITaAfsAdmSvr*.h
############################################################################
#
# Dependencies
#
AfsAdmSvr.res : AfsAdmSvr.rc AFS_component_version_number.h

View File

@ -0,0 +1,693 @@
#include <afs/param.h>
#include <afs/stds.h>
#include "TaAfsAdmSvrInternal.h"
/*
* ROUTINES ___________________________________________________________________
*
*/
// AfsAdmSvr_Connect
// ...obtains a cookie to represent the calling process. The cookie should
// be freed with AfsAdmSvr_Disconnect when the process disconnects.
//
int AfsAdmSvr_Connect (STRING szClientAddress, DWORD *pidClient, ULONG *pStatus)
{
// Make sure AfsClass initialized properly. If it's already init'd,
// this won't hurt at all.
//
ULONG status;
if (!AfsClass_Initialize (&status))
{
Print (TEXT("Denying client %s due to AfsClass initialization failure"), szClientAddress);
return FALSE_(status, pStatus);
}
// Find a free CLIENTINFO structure for this caller
//
if (!AfsAdmSvr_AttachClient (szClientAddress, pidClient, pStatus))
return FALSE;
Print (TEXT("Connected to client %s (ID 0x%08lX)"), AfsAdmSvr_GetClientName (*pidClient), *pidClient);
return TRUE;
}
// AfsAdmSvr_Ping
// ...reminds the admin server that the specified client is still around.
// this call should be made at least every csecAFSADMSVR_CLIENT_PING
// seconds, lest the admin server think you've disconnected. (The
// client library TaAfsAdmSvrClient.lib automatically handles this.)
//
int AfsAdmSvr_Ping (DWORD idClient, ULONG *pStatus)
{
AfsAdmSvr_Enter();
if (!AfsAdmSvr_fIsValidClient (idClient))
return Leave_FALSE_(ERROR_INVALID_PARAMETER, pStatus);
AfsAdmSvr_PingClient (idClient);
AfsAdmSvr_Leave();
return TRUE;
}
// AfsAdmSvr_Disconnect
// ...releases and invalidates the cookie representing the calling process.
//
int AfsAdmSvr_Disconnect (DWORD idClient, ULONG *pStatus)
{
AfsAdmSvr_Enter();
// Make sure this is a valid client, and free its l.aClients[] entry if so.
//
if (!AfsAdmSvr_fIsValidClient (idClient))
return Leave_FALSE_(ERROR_INVALID_PARAMETER, pStatus);
Print (TEXT("Disconnected from client %s (ID 0x%08lX)"), AfsAdmSvr_GetClientName (idClient), idClient);
AfsAdmSvr_DetachClient (idClient);
AfsAdmSvr_Leave();
return TRUE;
}
// AfsAdmSvr_CrackCredentials
// ...queries the specified AFS credentials token for its cell, user
// and expiration date.
//
int AfsAdmSvr_CrackCredentials (DWORD idClient, DWORD hCreds, STRING pszCell, STRING pszUser, SYSTEMTIME *pstExpiration, ULONG *pStatus)
{
ULONG status;
size_t iOp = AfsAdmSvr_BeginOperation (idClient);
if (!AfsAdmSvr_fIsValidClient (idClient))
return FALSE_(ERROR_INVALID_PARAMETER,pStatus,iOp);
Print (dlDETAIL, TEXT("Client 0x%08lX: CrackCredentials (0x%08lX)"), idClient, hCreds);
unsigned long dateExpirationQuery;
int fHasKasTokenQuery;
char szUser[ cchSTRING ];
char szUser2[ cchSTRING ];
char szCell[ cchSTRING ];
char *pszCellQuery = (pszCell) ? (char *)pszCell : szCell;
char *pszUserQuery = (pszUser) ? (char *)pszUser : szUser;
if (!afsclient_TokenQuery ((PVOID)hCreds, &dateExpirationQuery, pszUserQuery, szUser2, pszCellQuery, &fHasKasTokenQuery, (afs_status_p)&status))
return FALSE_(status, pStatus, iOp);
if (pstExpiration)
AfsAppLib_UnixTimeToSystemTime (pstExpiration, dateExpirationQuery);
AfsAdmSvr_EndOperation (iOp);
return TRUE;
}
// AfsAdmSvr_GetCredentials
// ...queries the user's current AFS credentials for the specified cell
// if the user already has credentials in the cell, returns a nonzero
// token {hCreds}, suitable for use in AfsAdmSvr_OpenCell().
//
DWORD AfsAdmSvr_GetCredentials (DWORD idClient, STRING pszCell, ULONG *pStatus)
{
ULONG status;
size_t iOp = AfsAdmSvr_BeginOperation (idClient);
if (!AfsAdmSvr_fIsValidClient (idClient))
return FALSE_(ERROR_INVALID_PARAMETER,pStatus,iOp);
Print (dlDETAIL, TEXT("Client 0x%08lX: GetCredentials (%s)"), idClient, pszCell);
const char *pszCellTest = (pszCell && *pszCell) ? (const char *)pszCell : NULL;
PVOID hCreds = NULL;
if (!afsclient_TokenGetExisting (pszCellTest, &hCreds, (afs_status_p)&status))
return FALSE_(status, pStatus, iOp);
AfsAdmSvr_EndOperation (iOp);
return (DWORD)hCreds;
}
// AfsAdmSvr_SetCredentials
// ...obtains new AFS credentials within the administrative server process
// on behalf of the specified user. if successful, returns a nonzero
// token {hCreds}, suitable for use in AfsAdmSvr_OpenCell().
//
DWORD AfsAdmSvr_SetCredentials (DWORD idClient, STRING pszCell, STRING pszUser, STRING pszPassword, ULONG *pStatus)
{
ULONG status;
size_t iOp = AfsAdmSvr_BeginOperation (idClient);
Print (dlDETAIL, TEXT("Client 0x%08lX: SetCredentials (%s,%s)"), idClient, pszCell, pszUser);
if (!AfsAdmSvr_fIsValidClient (idClient))
return FALSE_(ERROR_INVALID_PARAMETER,pStatus,iOp);
const char *pszCellSet = (pszCell && *pszCell) ? (const char *)pszCell : NULL;
PVOID hCreds;
if (!afsclient_TokenGetNew (pszCellSet, (const char *)pszUser, (const char *)pszPassword, &hCreds, (afs_status_p)&status))
return FALSE_(status,pStatus,iOp);
AfsAdmSvr_EndOperation (iOp);
return (DWORD)hCreds;
}
// AfsAdmSvr_PushCredentials
// ...requests that the specified AFS credentials be used hereafter
// when manipulating the specified cell. You should follow this
// call with a Refresh request if necessary.
//
int AfsAdmSvr_PushCredentials (DWORD idClient, DWORD hCreds, ASID idCell, ULONG *pStatus)
{
ULONG status;
size_t iOp = AfsAdmSvr_BeginOperation (idClient);
Print (dlDETAIL, TEXT("Client 0x%08lX: PushCredentials (hCreds=0x%08lX, idCell=0x%08lX)"), idClient, hCreds, idCell);
if (!AfsAdmSvr_fIsValidClient (idClient))
return FALSE_(ERROR_INVALID_PARAMETER,pStatus,iOp);
if (GetAsidType (idCell) != itCELL)
return FALSE_(ERROR_INVALID_PARAMETER,pStatus,iOp);
LPCELL lpCell;
if ((lpCell = ((LPIDENT)idCell)->OpenCell (&status)) == NULL)
return FALSE_(ERROR_INVALID_PARAMETER,pStatus,iOp);
lpCell->SetCurrentCredentials ((PVOID)hCreds);
lpCell->Close();
AfsAdmSvr_EndOperation (iOp);
return TRUE;
}
// AfsAdmSvr_GetLocalCell
// ...obtains the name of the primary cell used by the admin server
//
int AfsAdmSvr_GetLocalCell (DWORD idClient, STRING pszCellName, ULONG *pStatus)
{
size_t iOp = AfsAdmSvr_BeginOperation (idClient);
Print (dlDETAIL, TEXT("Client 0x%08lX: GetLocalCell"), idClient);
if (!AfsAdmSvr_fIsValidClient (idClient))
return FALSE_(ERROR_INVALID_PARAMETER,pStatus,iOp);
if (!CELL::GetDefaultCell (pszCellName, pStatus))
{
AfsAdmSvr_EndOperation (iOp);
return FALSE;
}
AfsAdmSvr_EndOperation (iOp);
return TRUE;
}
// AfsAdmSvr_ErrorCodeTranslate
// ...translates an error code into an English string
//
int AfsAdmSvr_ErrorCodeTranslate (DWORD idClient, ULONG code, LANGID idLanguage, STRING pszErrorText, ULONG *pStatus)
{
if (!AfsAppLib_TranslateError (pszErrorText, code, idLanguage))
return FALSE_(ERROR_INVALID_PARAMETER,pStatus);
LPTSTR pch;
if ((pch = (LPTSTR)lstrrchr (pszErrorText, TEXT('('))) != NULL)
*pch = TEXT('\0');
while (lstrlen(pszErrorText) && pszErrorText[ lstrlen(pszErrorText)-1 ] == TEXT(' '))
pszErrorText[ lstrlen(pszErrorText)-1 ] = TEXT('\0');
return TRUE;
}
// AfsAdmSvr_GetAction
// ...returns information about a particular operation in progress.
//
int AfsAdmSvr_GetAction (DWORD idClient, DWORD idAction, LPASACTION pAction, ULONG *pStatus)
{
Print (dlDETAIL, TEXT("Client 0x%08lX: GetAction (idAction=0x%08lX)"), idClient, idAction);
if (!AfsAdmSvr_fIsValidClient (idClient))
return FALSE_(ERROR_INVALID_PARAMETER,pStatus);
if (!AfsAdmSvr_GetOperation (idAction, pAction))
return FALSE_(ERROR_INVALID_PARAMETER,pStatus);
Print (dlERROR, TEXT("Client 0x%08lX: GetAction succeeded"));
return TRUE;
}
// AfsAdmSvr_GetActions
// ...returns a list of operations in progress. The list returned can
// be constrained to only including those operations initiated by
// a particular client and/or performed in a particular cell.
//
int AfsAdmSvr_GetActions (DWORD idClient, DWORD idClientSearch, ASID idCellSearch, LPASACTIONLIST *ppList, ULONG *pStatus)
{
Print (dlDETAIL, TEXT("Client 0x%08lX: GetActions (idClientSearch=0x%08lX, idCellSearch=0x%08lX)"), idClient, idClientSearch, idCellSearch);
if (!AfsAdmSvr_fIsValidClient (idClient))
return FALSE_(ERROR_INVALID_PARAMETER,pStatus);
if ((*ppList = AfsAdmSvr_GetOperations (idClientSearch, idCellSearch)) == NULL)
{
Print (dlERROR, TEXT("Client 0x%08lX: GetActions failed"), idClient);
return FALSE_(ERROR_NOT_ENOUGH_MEMORY,pStatus);
}
Print (dlERROR, TEXT("Client 0x%08lX: GetActions succeeded; %ld actions"), idClient, (*ppList) ? (*ppList)->cEntries : 0);
return TRUE;
}
// AfsAdmSvr_OpenCell
// ...opens a cell for administration.
//
int AfsAdmSvr_OpenCell (DWORD idClient, DWORD hCreds, STRING pszCellName, DWORD dwScopeFlags, ASID *pidCell, ULONG *pStatus)
{
size_t iOp = AfsAdmSvr_BeginOperation (idClient);
if (!AfsAdmSvr_fIsValidClient (idClient))
return FALSE_(ERROR_INVALID_PARAMETER,pStatus,iOp);
Print (dlDETAIL, TEXT("Client 0x%08lX: OpenCell"), idClient);
AfsAdmSvr_AddToMinScope (dwScopeFlags);
LPIDENT lpiCell;
if ((lpiCell = CELL::OpenCell ((LPTSTR)pszCellName, (PVOID)hCreds, pStatus)) == NULL)
{
AfsAdmSvr_EndOperation (iOp);
return FALSE;
}
Print (dlDETAIL, TEXT("Client 0x%08lX: OpenCell succeeded (idCell=0x%08lX)"), idClient, (DWORD)lpiCell);
*pidCell = (ASID)lpiCell;
AfsAdmSvr_EndOperation (iOp);
return TRUE;
}
// AfsAdmSvr_CloseCell
// ...used by client to open a cell for administration.
//
int AfsAdmSvr_CloseCell (DWORD idClient, ASID idCell, ULONG *pStatus)
{
size_t iOp = AfsAdmSvr_BeginOperation (idClient);
Print (dlDETAIL, TEXT("Client 0x%08lX: CloseCell (idCell=0x%08lX)"), idClient, idCell);
if (!AfsAdmSvr_fIsValidClient (idClient))
return FALSE_(ERROR_INVALID_PARAMETER,pStatus,iOp);
if (GetAsidType (idCell) != itCELL)
return FALSE_(ERROR_INVALID_PARAMETER,pStatus,iOp);
CELL::CloseCell ((LPIDENT)idCell);
AfsAdmSvr_EndOperation (iOp);
return TRUE;
}
// AfsAdmSvr_FindObject
// AfsAdmSvr_FindObjects
// ...used to search through all objects in the cell, obtaining a list
// of those which match the specified criteria. For FindObjects, the
// {*ppList} parameter will be filled in with an allocated list of
// ASIDs, and should be freed using the AfsAdmSvr_FreeAsidList()
// routine (clients using the TaAfsAdmSvrClient.lib library should
// call asc_AsidListFree(), which is a wrapper for that routine).
// The _FindObject routine can be used to find exactly one object--
// for instance, finding the ASID for a particular user or volume--
// while the _FindObjects routine returns a list of all objects
// which match the specified criteria--all volumes on a partition,
// or all users named "b*" within a cell.
//
int AfsAdmSvr_FindObject (DWORD idClient, ASID idSearchScope, ASOBJTYPE ObjectType, AFSADMSVR_SEARCH_REFRESH SearchRefresh, STRING szName, ASID *pidObject, ULONG *pStatus)
{
BOOL rc = TRUE;
ULONG status = 0;
size_t iOp = AfsAdmSvr_BeginOperation (idClient);
Print (dlDETAIL, TEXT("Client 0x%08lX: FindObject (scope=0x%08lX, type=%lu, name='%s')"), idClient, idSearchScope, ObjectType, szName);
if (!AfsAdmSvr_fIsValidClient (idClient))
return FALSE_(ERROR_INVALID_PARAMETER,pStatus,iOp);
if (GetAsidType (idSearchScope) == itUNUSED)
return FALSE_(ERROR_INVALID_PARAMETER,pStatus,iOp);
// We've got a special case here: if possible, we don't want to have to
// refresh the contents of the entire cell. So if the client is looking
// for a user or group, we can just try to grab that object by its name;
// afsclass supports an interface for just this case.
//
switch (ObjectType)
{
case TYPE_USER:
rc = AfsAdmSvr_Search_OneUser (pidObject, idSearchScope, szName, &status);
break;
case TYPE_GROUP:
rc = AfsAdmSvr_Search_OneGroup (pidObject, idSearchScope, szName, &status);
break;
default:
// We'll have to do the search the hard way. First
// see if we need to refresh this cell/server.
//
if (!AfsAdmSvr_SearchRefresh (idSearchScope, ObjectType, SearchRefresh, &status))
return FALSE_(status,pStatus,iOp);
// Look for the specified object.
//
switch (GetAsidType (idSearchScope))
{
case itCELL:
if (ObjectType == TYPE_SERVER)
rc = AfsAdmSvr_Search_ServerInCell (pidObject, idSearchScope, szName, &status);
else if (ObjectType == TYPE_SERVICE)
rc = AfsAdmSvr_Search_ServiceInCell (pidObject, idSearchScope, szName, &status);
else if (ObjectType == TYPE_PARTITION)
rc = AfsAdmSvr_Search_PartitionInCell (pidObject, idSearchScope, szName, &status);
else if (ObjectType == TYPE_VOLUME)
rc = AfsAdmSvr_Search_VolumeInCell (pidObject, idSearchScope, szName, &status);
else if (ObjectType == TYPE_USER)
rc = AfsAdmSvr_Search_UserInCell (pidObject, idSearchScope, szName, &status);
else if (ObjectType == TYPE_GROUP)
rc = AfsAdmSvr_Search_GroupInCell (pidObject, idSearchScope, szName, &status);
else
{
rc = FALSE;
status = ERROR_INVALID_PARAMETER;
}
break;
case itSERVER:
if (ObjectType == TYPE_SERVICE)
rc = AfsAdmSvr_Search_ServiceInServer (pidObject, idSearchScope, szName, &status);
else if (ObjectType == TYPE_PARTITION)
rc = AfsAdmSvr_Search_PartitionInServer (pidObject, idSearchScope, szName, &status);
else if (ObjectType == TYPE_VOLUME)
rc = AfsAdmSvr_Search_VolumeInServer (pidObject, idSearchScope, szName, &status);
else
{
rc = FALSE;
status = ERROR_INVALID_PARAMETER;
}
break;
case itAGGREGATE:
if (ObjectType == TYPE_VOLUME)
rc = AfsAdmSvr_Search_VolumeInPartition (pidObject, idSearchScope, szName, &status);
else
{
rc = FALSE;
status = ERROR_INVALID_PARAMETER;
}
break;
}
break;
}
if (!rc && pStatus)
*pStatus = status;
if (!rc)
Print (dlERROR, TEXT("Client 0x%08lX: FindObject failed (status=0x%08lX)"), idClient, status);
else // (rc)
Print (dlDETAIL, TEXT("Client 0x%08lX: FindObject succeeded; returning idObject=0x%08lX"), idClient, *pidObject);
AfsAdmSvr_EndOperation (iOp);
return rc;
}
int AfsAdmSvr_FindObjects (DWORD idClient, ASID idSearchScope, ASOBJTYPE ObjectType, AFSADMSVR_SEARCH_REFRESH SearchRefresh, STRING szPattern, LPAFSADMSVR_SEARCH_PARAMS pSearchParams, LPASIDLIST *ppList, ULONG *pStatus)
{
BOOL rc = TRUE;
ULONG status = 0;
size_t iOp = AfsAdmSvr_BeginOperation (idClient);
Print (dlDETAIL, TEXT("Client 0x%08lX: FindObjects (scope=0x%08lX, type=%lu, pat='%s')"), idClient, idSearchScope, ObjectType, szPattern);
if (!AfsAdmSvr_fIsValidClient (idClient))
return FALSE_(ERROR_INVALID_PARAMETER,pStatus,iOp);
if (GetAsidType (idSearchScope) == itUNUSED)
return FALSE_(ERROR_INVALID_PARAMETER,pStatus,iOp);
// First see if we need to refresh this cell/server
//
if (!AfsAdmSvr_SearchRefresh (idSearchScope, ObjectType, SearchRefresh, &status))
return FALSE_(status,pStatus,iOp);
// Prepare an ASIDLIST, and call whatever subroutine is necessary to
// perform the actual search.
//
if ((*ppList = AfsAdmSvr_CreateAsidList()) == NULL)
return FALSE_(ERROR_NOT_ENOUGH_MEMORY,pStatus,iOp);
LPTSTR pszPattern = (szPattern && szPattern[0]) ? (LPTSTR)szPattern : NULL;
switch (GetAsidType (idSearchScope))
{
case itCELL:
if (ObjectType == TYPE_ANY)
rc = AfsAdmSvr_Search_AllInCell (ppList, idSearchScope, pszPattern, &status);
else if (ObjectType == TYPE_SERVER)
rc = AfsAdmSvr_Search_ServersInCell (ppList, idSearchScope, pszPattern, &status);
else if (ObjectType == TYPE_SERVICE)
rc = AfsAdmSvr_Search_ServicesInCell (ppList, idSearchScope, pszPattern, &status);
else if (ObjectType == TYPE_PARTITION)
rc = AfsAdmSvr_Search_PartitionsInCell (ppList, idSearchScope, pszPattern, &status);
else if (ObjectType == TYPE_VOLUME)
rc = AfsAdmSvr_Search_VolumesInCell (ppList, idSearchScope, pszPattern, &status);
else if (ObjectType == TYPE_USER)
rc = AfsAdmSvr_Search_UsersInCell (ppList, idSearchScope, pszPattern, &status);
else if (ObjectType == TYPE_GROUP)
rc = AfsAdmSvr_Search_GroupsInCell (ppList, idSearchScope, pszPattern, &status);
else
{
rc = FALSE;
status = ERROR_INVALID_PARAMETER;
}
break;
case itSERVER:
if (ObjectType == TYPE_ANY)
rc = AfsAdmSvr_Search_AllInServer (ppList, idSearchScope, pszPattern, &status);
else if (ObjectType == TYPE_SERVICE)
rc = AfsAdmSvr_Search_ServicesInServer (ppList, idSearchScope, pszPattern, &status);
else if (ObjectType == TYPE_PARTITION)
rc = AfsAdmSvr_Search_PartitionsInServer (ppList, idSearchScope, pszPattern, &status);
else if (ObjectType == TYPE_VOLUME)
rc = AfsAdmSvr_Search_VolumesInServer (ppList, idSearchScope, pszPattern, &status);
else
{
rc = FALSE;
status = ERROR_INVALID_PARAMETER;
}
break;
case itAGGREGATE:
if (ObjectType == TYPE_ANY)
rc = AfsAdmSvr_Search_VolumesInPartition (ppList, idSearchScope, pszPattern, &status);
else if (ObjectType == TYPE_VOLUME)
rc = AfsAdmSvr_Search_VolumesInPartition (ppList, idSearchScope, pszPattern, &status);
else
{
rc = FALSE;
status = ERROR_INVALID_PARAMETER;
}
break;
}
if (rc && (*ppList) && (pSearchParams))
AfsAdmSvr_Search_Advanced (ppList, pSearchParams);
if (!rc && (*ppList))
AfsAdmSvr_FreeAsidList (ppList);
if (!rc && pStatus)
*pStatus = status;
if (!rc)
Print (dlERROR, TEXT("Client 0x%08lX: FindObjects failed (status=0x%08lX)"), idClient, status);
else // (rc)
Print (dlDETAIL, TEXT("Client 0x%08lX: FindObjects succeeded; returning %lu item(s)"), idClient, (*ppList)->cEntries);
AfsAdmSvr_EndOperation (iOp);
return rc;
}
// AfsAdmSvr_GetObject
// AfsAdmSvr_GetObjects
// ...returns server-cached information about the specified object (or
// objects).
//
int AfsAdmSvr_GetObject (DWORD idClient, AFSADMSVR_GET_TYPE GetType, AFSADMSVR_GET_LEVEL GetLevel, ASID idObject, DWORD verProperties, LPASOBJPROP pProperties, ULONG *pStatus)
{
size_t iOp = AfsAdmSvr_BeginOperation (idClient);
Print (dlDETAIL2, TEXT("Client 0x%08lX: GetObject (Type=%lu, Level=%lu, idObject=0x%08lX, ver=%ld)"), idClient, (LONG)GetType, (LONG)GetLevel, idObject, verProperties);
memset (pProperties, 0x00, sizeof(ASOBJPROP));
if (!AfsAdmSvr_fIsValidClient (idClient))
return FALSE_(ERROR_INVALID_PARAMETER,pStatus,iOp);
LPASOBJPROP pCurrentProperties;
if ((pCurrentProperties = AfsAdmSvr_GetCurrentProperties (idObject, pStatus)) == NULL)
{
Print (dlERROR, TEXT("Client 0x%08lX: GetObject failed; no properties"), idClient, idObject);
AfsAdmSvr_EndOperation (iOp);
return FALSE;
}
// At this point pCurrentProperties may just be rudimentary properties.
// If the user has requested GET_ALL_DATA, we'll have to get full properties.
//
if ( (GetLevel == GET_ALL_DATA) && (pCurrentProperties->verProperties < verPROP_FIRST_SCAN) )
{
if (!AfsAdmSvr_ObtainFullProperties (pCurrentProperties, pStatus))
{
Print (dlERROR, TEXT("Client 0x%08lX: GetObject failed; no full properties"), idClient, idObject);
AfsAdmSvr_EndOperation (iOp);
return FALSE;
}
}
// Now determine if we need to return anything at all; if the user specified
// RETURN_IF_OUT_OF_DATE, it's possible that there's no need to do so.
//
if ((pCurrentProperties->verProperties > verProperties) || (GetType == RETURN_DATA_ALWAYS))
{
memcpy (pProperties, pCurrentProperties, sizeof(ASOBJPROP));
}
Print (dlDETAIL2, TEXT("Client 0x%08lX: GetObject succeeded (idObject=0x%08lX)"), idClient, idObject);
AfsAdmSvr_EndOperation (iOp);
return TRUE;
}
int AfsAdmSvr_GetObjects (DWORD idClient, AFSADMSVR_GET_TYPE GetType, AFSADMSVR_GET_LEVEL GetLevel, LPASIDLIST pListObjects, LPASOBJPROPLIST *ppListObjectProperties, ULONG *pStatus)
{
size_t iOp = AfsAdmSvr_BeginOperation (idClient);
Print (dlDETAIL, TEXT("Client 0x%08lX: GetObjects (Type=%lu, Level=%lu, nObjects=%lu)"), idClient, (LONG)GetType, (LONG)GetLevel, (pListObjects) ? (pListObjects->cEntries) : 0);
if (!AfsAdmSvr_fIsValidClient (idClient))
return FALSE_(ERROR_INVALID_PARAMETER,pStatus,iOp);
*ppListObjectProperties = NULL;
for (size_t iObject = 0; iObject < pListObjects->cEntries; ++iObject)
{
ASOBJPROP ObjectProperties;
ULONG status;
if (AfsAdmSvr_GetObject (idClient, GetType, GetLevel, pListObjects->aEntries[ iObject ].idObject, pListObjects->aEntries[ iObject ].lParam, &ObjectProperties, &status))
{
if (ObjectProperties.idObject == pListObjects->aEntries[ iObject ].idObject)
{
if (!*ppListObjectProperties)
*ppListObjectProperties = AfsAdmSvr_CreateObjPropList();
if (*ppListObjectProperties)
AfsAdmSvr_AddToObjPropList (ppListObjectProperties, &ObjectProperties, 0);
}
}
}
Print (dlDETAIL, TEXT("Client 0x%08lX: GetObjects succeeded; returning %lu properties"), idClient, (*ppListObjectProperties) ? ((*ppListObjectProperties)->cEntries) : 0);
AfsAdmSvr_EndOperation (iOp);
return TRUE;
}
// AfsAdmSvr_RefreshObject
// AfsAdmSvr_RefreshObjects
// ...invalidates the server's cache of information about the specified
// object or objects.
//
int AfsAdmSvr_RefreshObject (DWORD idClient, ASID idObject, ULONG *pStatus)
{
size_t iOp = AfsAdmSvr_BeginOperation (idClient);
Print (dlDETAIL, TEXT("Client 0x%08lX: RefreshObject (idObject=0x%08lX)"), idClient, idObject);
if (!AfsAdmSvr_fIsValidClient (idClient))
return FALSE_(ERROR_INVALID_PARAMETER,pStatus,iOp);
if (!AfsAdmSvr_InvalidateObjectProperties (idObject, pStatus))
{
AfsAdmSvr_EndOperation (iOp);
return FALSE;
}
AfsAdmSvr_EndOperation (iOp);
return TRUE;
}
int AfsAdmSvr_RefreshObjects (DWORD idClient, LPASIDLIST pListObjects, ULONG *pStatus)
{
size_t iOp = AfsAdmSvr_BeginOperation (idClient);
Print (dlDETAIL, TEXT("Client 0x%08lX: RefreshObjects (nObjects=%lu)"), idClient, (pListObjects) ? (pListObjects->cEntries) : 0);
if (!AfsAdmSvr_fIsValidClient (idClient))
return FALSE_(ERROR_INVALID_PARAMETER,pStatus,iOp);
for (size_t iObject = 0; iObject < pListObjects->cEntries; ++iObject)
{
ULONG status;
AfsAdmSvr_RefreshObject (idClient, pListObjects->aEntries[ iObject ].idObject, &status);
}
AfsAdmSvr_EndOperation (iOp);
return TRUE;
}
// AfsAdmSvr_CallbackHost
// ...provides a context in which the server can issue callback functions
// via the AfsAdmSvrCallBack_* routines, which the client must implement.
// This routine will only return if the server is shut down. It should
// be called on a dedicated thread by the client. (TaAfsAdmSvrClient.lib
// automatically handles this.)
//
void AfsAdmSvr_CallbackHost (void)
{
AfsAdmSvr_CallbackManager();
}
// AfsAdmSvr_GetRandomKey
// ...returns a randomly-generated 8-byte encryption key
//
int AfsAdmSvr_GetRandomKey (DWORD idClient, ASID idCell, BYTE keyData[ ENCRYPTIONKEYLENGTH ], ULONG *pStatus)
{
if (!AfsAdmSvr_fIsValidClient (idClient))
return FALSE_(ERROR_INVALID_PARAMETER,pStatus);
return AfsClass_GetRandomKey ((LPIDENT)idCell, (LPENCRYPTIONKEY)keyData, pStatus);
}

View File

@ -0,0 +1,64 @@
#ifndef TAAFSADMSVR_H
#define TAAFSADMSVR_H
/*
* INCLUSIONS _________________________________________________________________
*
*/
#include <rpc.h>
#include <rpcndr.h>
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <WINNT/TaLocale.h>
#include <WINNT/iTaAfsAdmSvr.h>
#include <WINNT/TaAfsAdmSvrCommon.h>
#ifndef TAAFSADMSVRCLIENT_H
#include <WINNT/AfsAppLib.h>
#endif // TAAFSADMSVRCLIENT_H
/*
* DEFINITIONS ________________________________________________________________
*
*/
// The admin server can be started on a machine just by running
// its .EXE; if the "timed" keyword is given on its command-line,
// it will shut itself down if it's idle for N minutes. If the "Manual"
// keyword is not present, the local cell will automatically be opened
// for administration and its contents refreshed (the scope of the auto-
// refresh can be limited to users or volumes by also adding one of
// the Scope keywords)
//
#define AFSADMSVR_PROGRAM "TaAfsAdmSvr.exe"
#define AFSADMSVR_KEYWORD_TIMED "Timed"
#define AFSADMSVR_KEYWORD_MANUAL "Manual"
#define AFSADMSVR_KEYWORD_SCOPE_USERS "Users"
#define AFSADMSVR_KEYWORD_SCOPE_VOLUMES "Volumes"
#define AFSADMSVR_KEYWORD_DEBUG "Debug"
// Ordinarily, the admin server will export its binding handles
// under the following identity:
//
#define AFSADMSVR_ENTRYNAME_DEFAULT "/.:/Autohandle_TaAfsAdmSvr"
// On my Win98 box, RpcNsBindingExport() always fails for some
// inexplicable reason (error 6BF, RPC_S_CALL_FAILED_DNE, which
// is about as generic a "didn't work" error code as you can get.)
// Presuming that this is not the only box in the world which can't
// do this--even though it's documented to work on Win95, perhaps
// it's widespread?--the admin server will detect failure of this
// routine and attempt to bind to a particular default endpoint;
// if the client can't find any valid binding handles through
// RpcNsBinding* lookups, it will try this well-known endpoint as
// a last-ditch effort.
//
#define AFSADMSVR_ENDPOINT_DEFAULT 1025
#endif // TAAFSADMSVR_H

View File

@ -0,0 +1,156 @@
#include <afs/param.h>
#include <afs/stds.h>
#include "TaAfsAdmSvrInternal.h"
/*
* VARIABLES __________________________________________________________________
*
*/
typedef struct
{
CALLBACKTYPE Type;
BOOL fFinished;
LPASACTION pAction;
} CALLBACKDATA, *LPCALLBACKDATA;
static struct
{
HANDLE heCallback;
LPHASHLIST pListCallbacks;
BOOL fStopManagers;
size_t cManagers;
} l;
/*
* CALLBACKS __________________________________________________________________
*
*/
void AfsAdmSvr_FreeCallbackData (LPCALLBACKDATA pData)
{
if (pData)
{
if (pData->pAction)
Delete (pData->pAction);
Delete (pData);
}
}
void AfsAdmSvr_CallbackManager (void)
{
AfsAdmSvr_Enter();
if ((++l.cManagers) == 1)
{
l.heCallback = CreateEvent (NULL, TRUE, FALSE, NULL);
l.pListCallbacks = New (HASHLIST);
}
AfsAdmSvr_Leave();
for (;;)
{
WaitForSingleObjectEx (l.heCallback, INFINITE, FALSE);
if (l.fStopManagers)
break;
// We must ensure that we don't block the server's operations because
// a callback doesn't go through; since other operations may need
// access to the l.pListCallbacks structure in order to queue new
// callbacks, we can't leave it locked by issuing callbacks while
// enumerating it. Instead we'll copy the list into a local copy,
// clear it, and enumerate that local copy--other threads can then
// continue to add new requests to l.pListCallbacks.
//
AfsAdmSvr_Enter();
LPHASHLIST pList = New (HASHLIST);
for (LPENUM pEnum = l.pListCallbacks->FindFirst(); pEnum; pEnum = pEnum->FindNext())
{
LPCALLBACKDATA pData = (LPCALLBACKDATA)( pEnum->GetObject() );
pList->Add (pData);
l.pListCallbacks->Remove (pData);
}
ResetEvent (l.heCallback);
AfsAdmSvr_Leave();
// Now enumerate that copied list, and issue callbacks for each item.
//
for (pEnum = pList->FindFirst(); pEnum; pEnum = pEnum->FindNext())
{
LPCALLBACKDATA pData = (LPCALLBACKDATA)( pEnum->GetObject() );
try {
switch (pData->Type)
{
case cbtACTION:
AfsAdmSvrCallback_Action (pData->pAction, pData->fFinished);
break;
}
} catch(...) {
;
}
pList->Remove (pData);
AfsAdmSvr_FreeCallbackData (pData);
}
Delete (pList);
}
AfsAdmSvr_Enter();
if ((--l.cManagers) == 0)
{
Delete (l.pListCallbacks);
l.pListCallbacks = NULL;
CloseHandle (l.heCallback);
l.heCallback = NULL;
}
AfsAdmSvr_Leave();
}
void AfsAdmSvr_PostCallback (CALLBACKTYPE Type, BOOL fFinished, LPASACTION pAction, DWORD dwRemoveMe)
{
AfsAdmSvr_Enter();
if (l.pListCallbacks)
{
LPCALLBACKDATA pData = New (CALLBACKDATA);
memset (pData, 0x00, sizeof(CALLBACKDATA));
pData->Type = Type;
pData->fFinished = fFinished;
if (pAction)
{
pData->pAction = New (ASACTION);
memcpy (pData->pAction, pAction, sizeof(ASACTION));
}
l.pListCallbacks->Add (pData);
SetEvent (l.heCallback);
}
AfsAdmSvr_Leave();
}
void AfsAdmSvr_PostCallback (CALLBACKTYPE Type, BOOL fFinished, LPASACTION pAction)
{
AfsAdmSvr_PostCallback (Type, fFinished, pAction, 0);
}
void AfsAdmSvr_StopCallbackManagers (void)
{
AfsAdmSvr_Enter();
if (l.cManagers)
{
l.fStopManagers = TRUE;
SetEvent (l.heCallback);
}
AfsAdmSvr_Leave();
}

View File

@ -0,0 +1,30 @@
#ifndef TAAFSADMSVRCALLBACK_H
#define TAAFSADMSVRCALLBACK_H
#include <WINNT/TaAfsAdmSvr.h>
/*
* DEFINITIONS ________________________________________________________________
*
*/
typedef enum
{
cbtACTION
} CALLBACKTYPE;
/*
* PROTOTYPES _________________________________________________________________
*
*/
void AfsAdmSvr_CallbackManager (void);
void AfsAdmSvr_PostCallback (CALLBACKTYPE Type, BOOL fFinished, LPASACTION pAction);
void AfsAdmSvr_StopCallbackManagers (void);
#endif // TAAFSADMSVRCALLBACK_H

View File

@ -0,0 +1,69 @@
#include <afs/param.h>
#include <afs/stds.h>
#include "TaAfsAdmSvrInternal.h"
/*
* ROUTINES ___________________________________________________________________
*
*/
// AfsAdmSvr_ChangeCell
// ...changes a cell's properties.
//
int AfsAdmSvr_ChangeCell (DWORD idClient, ASID idCell, LPAFSADMSVR_CHANGECELL_PARAMS pChange, ULONG *pStatus)
{
ASACTION Action;
Action.Action = ACTION_CELL_CHANGE;
Action.idClient = idClient;
Action.idCell = idCell;
size_t iOp = AfsAdmSvr_BeginOperation (idClient, &Action);
Print (dlDETAIL, TEXT("Client 0x%08lX: ChangeCell (idCell=0x%08lX)"), idClient, idCell);
if (!AfsAdmSvr_fIsValidClient (idClient))
return FALSE_(ERROR_INVALID_PARAMETER,pStatus,iOp);
// Call AfsClass to actually do it
//
PTSPROPERTIES PtsProperties;
PtsProperties.idUserMax = (int)(pChange->idUserMax);
PtsProperties.idGroupMax = (int)(pChange->idGroupMax);
ULONG status;
if (!AfsClass_SetPtsProperties ((LPIDENT)idCell, &PtsProperties, &status))
{
Print (dlERROR, TEXT("Client 0x%08lX: ChangeCell failed; error 0x%08lX"), idClient, status);
return FALSE_(status,pStatus,iOp);
}
AfsAdmSvr_TestProperties (idCell);
Print (dlDETAIL, TEXT("Client 0x%08lX: ChangeCell succeeded"), idClient);
AfsAdmSvr_EndOperation (iOp);
return TRUE;
}
// AfsAdmSvr_SetRefreshRate
// ...changes the refresh rate for a specific cell
//
int AfsAdmSvr_SetRefreshRate (DWORD idClient, ASID idCell, ULONG cminRefreshRate, ULONG *pStatus)
{
if (!AfsAdmSvr_fIsValidClient (idClient))
return FALSE_(ERROR_INVALID_PARAMETER,pStatus);
Print (dlDETAIL, TEXT("Client 0x%08lX: Setting refresh rate to %lu minutes"), idClient, cminRefreshRate);
if (!cminRefreshRate)
AfsAdmSvr_StopCellRefreshThread (idCell);
else
AfsAdmSvr_SetCellRefreshRate (idCell, cminRefreshRate);
return TRUE;
}

View File

@ -0,0 +1,882 @@
extern "C" {
#include <afs/param.h>
#include <afs/stds.h>
}
#include "TaAfsAdmSvrClientInternal.h"
/*
* VARIABLES __________________________________________________________________
*
*/
static struct
{
BOOL fInitializedSockets;
size_t cReqForAdminServer;
} l;
/*
* ROUTINES ___________________________________________________________________
*
*/
void __RPC_FAR * __RPC_USER MIDL_user_allocate (size_t cbAllocate)
{
return (void __RPC_FAR *)Allocate (cbAllocate);
}
void __RPC_USER MIDL_user_free (void __RPC_FAR *pData)
{
Free (pData);
}
/*
* DATA STRUCTURES ____________________________________________________________
*
*/
BOOL ADMINAPI asc_AsidListCreate (LPASIDLIST *ppList)
{
return ((*ppList = AfsAdmSvr_CreateAsidList()) != NULL);
}
BOOL ADMINAPI asc_AsidListCopy (LPASIDLIST *ppListTarget, LPASIDLIST *ppListSource)
{
return ((*ppListTarget = AfsAdmSvr_CopyAsidList (*ppListSource)) != NULL);
}
BOOL ADMINAPI asc_AsidListAddEntry (LPASIDLIST *ppList, ASID idObject, LPARAM lp)
{
return AfsAdmSvr_AddToAsidList (ppList, idObject, lp);
}
BOOL ADMINAPI asc_AsidListRemoveEntry (LPASIDLIST *ppList, ASID idObject)
{
return AfsAdmSvr_RemoveFromAsidList (ppList, idObject);
}
BOOL ADMINAPI asc_AsidListRemoveEntryByIndex (LPASIDLIST *ppList, size_t iIndex)
{
return AfsAdmSvr_RemoveFromAsidListByIndex (ppList, iIndex);
}
BOOL ADMINAPI asc_AsidListSetEntryParam (LPASIDLIST *ppList, ASID idObject, LPARAM lp)
{
return AfsAdmSvr_SetAsidListParam (ppList, idObject, lp);
}
BOOL ADMINAPI asc_AsidListSetEntryParamByIndex (LPASIDLIST *ppList, size_t iIndex, LPARAM lp)
{
return AfsAdmSvr_SetAsidListParamByIndex (ppList, iIndex, lp);
}
BOOL ADMINAPI asc_AsidListTest (LPASIDLIST *ppList, ASID idObject, LPARAM *pParam)
{
return AfsAdmSvr_IsInAsidList (ppList, idObject, pParam);
}
BOOL ADMINAPI asc_AsidListFree (LPASIDLIST *ppList)
{
AfsAdmSvr_FreeAsidList (ppList);
return TRUE;
}
BOOL ADMINAPI asc_ObjPropListCreate (LPASOBJPROPLIST *ppList)
{
return ((*ppList = AfsAdmSvr_CreateObjPropList()) != NULL);
}
BOOL ADMINAPI asc_ObjPropListCopy (LPASOBJPROPLIST *ppListTarget, LPASOBJPROPLIST *ppListSource)
{
return ((*ppListTarget = AfsAdmSvr_CopyObjPropList (*ppListSource)) != NULL);
}
BOOL ADMINAPI asc_ObjPropListAddEntry (LPASOBJPROPLIST *ppList, LPASOBJPROP pProperties, LPARAM lp)
{
return AfsAdmSvr_AddToObjPropList (ppList, pProperties, lp);
}
BOOL ADMINAPI asc_ObjPropListRemoveEntry (LPASOBJPROPLIST *ppList, ASID idObject)
{
return AfsAdmSvr_RemoveFromObjPropList (ppList, idObject);
}
BOOL ADMINAPI asc_ObjPropListTest (LPASOBJPROPLIST *ppList, ASID idObject, LPASOBJPROP pProperties, LPARAM *pParam)
{
return AfsAdmSvr_IsInObjPropList (ppList, idObject, pProperties, pParam);
}
BOOL ADMINAPI asc_ObjPropListFree (LPASOBJPROPLIST *ppList)
{
AfsAdmSvr_FreeObjPropList (ppList);
return TRUE;
}
BOOL ADMINAPI asc_ActionListCreate (LPASACTIONLIST *ppList)
{
return ((*ppList = AfsAdmSvr_CreateActionList()) != NULL);
}
BOOL ADMINAPI asc_ActionListCopy (LPASACTIONLIST *ppListTarget, LPASACTIONLIST *ppListSource)
{
return ((*ppListTarget = AfsAdmSvr_CopyActionList (*ppListSource)) != NULL);
}
BOOL ADMINAPI asc_ActionListAddEntry (LPASACTIONLIST *ppList, LPASACTION pAction)
{
return AfsAdmSvr_AddToActionList (ppList, pAction);
}
BOOL ADMINAPI asc_ActionListRemoveEntry (LPASACTIONLIST *ppList, DWORD idAction)
{
return AfsAdmSvr_RemoveFromActionList (ppList, idAction);
}
BOOL ADMINAPI asc_ActionListTest (LPASACTIONLIST *ppList, DWORD idAction, LPASACTION pAction)
{
return AfsAdmSvr_IsInActionList (ppList, idAction, pAction);
}
BOOL ADMINAPI asc_ActionListFree (LPASACTIONLIST *ppList)
{
AfsAdmSvr_FreeActionList (ppList);
return TRUE;
}
/*
* ROUTINES ___________________________________________________________________
*
*/
BOOL ADMINAPI asc_AdminServerOpen (LPCTSTR pszAddress, DWORD *pidClient, ULONG *pStatus)
{
BOOL rc = TRUE;
ULONG status = 0;
if (!l.fInitializedSockets)
{
WSADATA Data;
WSAStartup (0x0101, &Data);
l.fInitializedSockets = TRUE;
}
if ((++l.cReqForAdminServer) == 1)
{
LPCTSTR pszResolvedAddress = ResolveAddress (pszAddress);
if (!BindToAdminServer (pszResolvedAddress, FALSE, pidClient, &status))
{
if (status != RPC_S_CALL_FAILED_DNE) // server rejected us?
rc = FALSE;
else if (pszResolvedAddress || !ForkNewAdminServer (&status))
rc = FALSE;
else
rc = BindToAdminServer (pszResolvedAddress, TRUE, pidClient, &status);
}
}
if (rc)
StartPingThread (*pidClient);
if (rc)
StartCallbackThread();
if (!rc && pStatus)
*pStatus = status;
return rc;
}
BOOL ADMINAPI asc_AdminServerClose (DWORD idClient, ULONG *pStatus)
{
BOOL rc = TRUE;
ULONG status = 0;
StopCallbackThread();
StopPingThread (idClient);
if (l.cReqForAdminServer && ((--l.cReqForAdminServer) == 0))
{
UnbindFromAdminServer (idClient, &status);
}
if (!rc && pStatus)
*pStatus = status;
return rc;
}
BOOL ADMINAPI asc_CredentialsCrack (DWORD idClient, PVOID hCreds, LPTSTR pszCell, LPTSTR pszUser, SYSTEMTIME *pstExpiration, ULONG *pStatus)
{
BOOL rc = FALSE;
ULONG status = 0;
RpcTryExcept
{
STRING szCell = TEXT("");
STRING szUser = TEXT("");
if ((rc = AfsAdmSvr_CrackCredentials (idClient, (DWORD)hCreds, szCell, szUser, pstExpiration, &status)) != FALSE)
{
lstrcpy (pszCell, szCell);
lstrcpy (pszUser, szUser);
}
}
RpcExcept(1)
{
rc = FALSE;
status = RPC_S_CALL_FAILED_DNE;
}
RpcEndExcept
if (!rc && pStatus)
*pStatus = status;
return rc;
}
PVOID ADMINAPI asc_CredentialsGet (DWORD idClient, LPCTSTR pszCell, ULONG *pStatus)
{
PVOID rc = NULL;
ULONG status = 0;
RpcTryExcept
{
if (pszCell)
{
STRING szCell;
lstrcpy (szCell, pszCell);
rc = (PVOID)AfsAdmSvr_GetCredentials (idClient, szCell, &status);
}
}
RpcExcept(1)
{
rc = FALSE;
status = RPC_S_CALL_FAILED_DNE;
}
RpcEndExcept
if (!rc && pStatus)
*pStatus = status;
return rc;
}
PVOID ADMINAPI asc_CredentialsSet (DWORD idClient, LPCTSTR pszCell, LPCTSTR pszUser, LPCTSTR pszPassword, ULONG *pStatus)
{
PVOID rc = NULL;
ULONG status = 0;
RpcTryExcept
{
STRING szCell;
lstrcpy (szCell, pszCell);
STRING szUser;
lstrcpy (szUser, pszUser);
STRING szPassword;
lstrcpy (szPassword, pszPassword);
// TODO: Ensure we do some encryption here, or using an
// encrypted socket, or something... can't just be pushing
// the user's unencrypted password across the wire.
rc = (PVOID)AfsAdmSvr_SetCredentials (idClient, szCell, szUser, szPassword, &status);
}
RpcExcept(1)
{
rc = FALSE;
status = RPC_S_CALL_FAILED_DNE;
}
RpcEndExcept
if (!rc && pStatus)
*pStatus = status;
return rc;
}
BOOL ADMINAPI asc_CredentialsPush (DWORD idClient, PVOID hCreds, ASID idCell, ULONG *pStatus)
{
BOOL rc = TRUE;
ULONG status = 0;
RpcTryExcept
{
rc = AfsAdmSvr_PushCredentials (idClient, (DWORD)hCreds, idCell, &status);
}
RpcExcept(1)
{
rc = FALSE;
status = RPC_S_CALL_FAILED_DNE;
}
RpcEndExcept
if (!rc && pStatus)
*pStatus = status;
return rc;
}
BOOL ADMINAPI asc_LocalCellGet (DWORD idClient, LPTSTR pszCell, ULONG *pStatus)
{
BOOL rc = TRUE;
ULONG status = 0;
RpcTryExcept
{
STRING szCell;
if ((rc = AfsAdmSvr_GetLocalCell (idClient, szCell, &status)) != FALSE)
{
lstrcpy (pszCell, szCell);
}
}
RpcExcept(1)
{
rc = FALSE;
status = RPC_S_CALL_FAILED_DNE;
}
RpcEndExcept
if (!rc && pStatus)
*pStatus = status;
return rc;
}
BOOL ADMINAPI asc_ErrorCodeTranslate (DWORD idClient, ULONG code, LANGID idLanguage, STRING pszErrorText, ULONG *pStatus)
{
BOOL rc = TRUE;
ULONG status = 0;
RpcTryExcept
{
STRING szText;
if ((rc = AfsAdmSvr_ErrorCodeTranslate (idClient, code, idLanguage, szText, &status)) != FALSE)
{
lstrcpy (pszErrorText, szText);
}
}
RpcExcept(1)
{
rc = FALSE;
status = RPC_S_CALL_FAILED_DNE;
}
RpcEndExcept
if (!rc && pStatus)
*pStatus = status;
return rc;
}
BOOL ADMINAPI asc_CellOpen (DWORD idClient, PVOID hCreds, LPCTSTR pszCell, DWORD dwScope, ASID *pidCell, ULONG *pStatus)
{
BOOL rc = TRUE;
ULONG status = 0;
RpcTryExcept
{
STRING szCell;
lstrcpy (szCell, pszCell);
if ((rc = AfsAdmSvr_OpenCell (idClient, (DWORD)hCreds, szCell, dwScope, pidCell, &status)) != FALSE)
{
if (!CreateCellCache (*pidCell))
{
(void)AfsAdmSvr_CloseCell (idClient, *pidCell, &status);
rc = FALSE;
status = ERROR_NOT_ENOUGH_MEMORY;
}
else // get rudimentary properties about the cell
{
rc = RefreshCachedProperties (idClient, *pidCell, *pidCell, GET_RUDIMENTARY_DATA, &status);
}
}
}
RpcExcept(1)
{
rc = FALSE;
status = RPC_S_CALL_FAILED_DNE;
}
RpcEndExcept
if (!rc && pStatus)
*pStatus = status;
return rc;
}
BOOL ADMINAPI asc_CellClose (DWORD idClient, ASID idCell, ULONG *pStatus)
{
BOOL rc = TRUE;
ULONG status = 0;
RpcTryExcept
{
rc = AfsAdmSvr_CloseCell (idClient, idCell, &status);
DestroyCellCache (idCell);
}
RpcExcept(1)
{
rc = FALSE;
status = RPC_S_CALL_FAILED_DNE;
}
RpcEndExcept
if (!rc && pStatus)
*pStatus = status;
return rc;
}
BOOL ADMINAPI asc_ObjectFind (DWORD idClient, ASID idSearchScope, ASOBJTYPE ObjectType, LPCTSTR pszName, ASID *pidObject, ULONG *pStatus)
{
BOOL rc = TRUE;
ULONG status = 0;
RpcTryExcept
{
STRING szName = TEXT("");
if (pszName)
lstrcpy (szName, pszName);
rc = AfsAdmSvr_FindObject (idClient, idSearchScope, ObjectType, SEARCH_ALL_OBJECTS, szName, pidObject, &status);
}
RpcExcept(1)
{
rc = FALSE;
status = RPC_S_CALL_FAILED_DNE;
}
RpcEndExcept
if (!rc && pStatus)
*pStatus = status;
return rc;
}
BOOL ADMINAPI asc_ObjectFindMultiple (DWORD idClient, ASID idSearchScope, ASOBJTYPE ObjectType, LPCTSTR pszPattern, LPAFSADMSVR_SEARCH_PARAMS pSearchParams, LPASIDLIST *ppList, ULONG *pStatus)
{
BOOL rc = TRUE;
ULONG status = 0;
RpcTryExcept
{
*ppList = NULL;
STRING szPattern = TEXT("");
if (pszPattern)
lstrcpy (szPattern, pszPattern);
AFSADMSVR_SEARCH_PARAMS SearchParams;
if (pSearchParams)
memcpy (&SearchParams, pSearchParams, sizeof(AFSADMSVR_SEARCH_PARAMS));
else
{
memset (&SearchParams, 0x00, sizeof(AFSADMSVR_SEARCH_PARAMS));
SearchParams.SearchType = SEARCH_NO_LIMITATIONS;
}
rc = AfsAdmSvr_FindObjects (idClient, idSearchScope, ObjectType, SEARCH_ALL_OBJECTS, szPattern, &SearchParams, ppList, &status);
}
RpcExcept(1)
{
rc = FALSE;
status = RPC_S_CALL_FAILED_DNE;
}
RpcEndExcept
if (!rc && pStatus)
*pStatus = status;
return rc;
}
BOOL ADMINAPI asc_ObjectPropertiesGet (DWORD idClient, AFSADMSVR_GET_LEVEL GetLevel, ASID idCell, ASID idObject, LPASOBJPROP pProperties, ULONG *pStatus)
{
BOOL rc = TRUE;
ULONG status = 0;
if (!RefreshCachedProperties (idClient, idCell, idObject, GetLevel, &status))
{
rc = FALSE;
}
else
{
LPASOBJPROP pFound;
if ((pFound = GetCachedProperties (idCell, idObject)) == NULL)
{
status = ERROR_NOT_ENOUGH_MEMORY;
rc = FALSE;
}
else
{
memcpy (pProperties, pFound, sizeof(ASOBJPROP));
}
}
if (!rc && pStatus)
*pStatus = status;
return rc;
}
BOOL ADMINAPI asc_ObjectPropertiesGetMultiple (DWORD idClient, AFSADMSVR_GET_LEVEL GetLevel, ASID idCell, LPASIDLIST pAsidList, LPASOBJPROPLIST *ppPropertiesList, ULONG *pStatus)
{
BOOL rc = TRUE;
ULONG status = 0;
if (!RefreshCachedProperties (idClient, idCell, pAsidList, GetLevel, &status))
{
rc = FALSE;
}
else
{
*ppPropertiesList = NULL;
for (size_t iAsidList = 0; iAsidList < pAsidList->cEntries; ++iAsidList)
{
LPASOBJPROP pFound;
if ((pFound = GetCachedProperties (idCell, pAsidList->aEntries[ iAsidList ].idObject)) != NULL)
{
if (!*ppPropertiesList)
asc_ObjPropListCreate(ppPropertiesList);
if (*ppPropertiesList)
AfsAdmSvr_AddToObjPropList (ppPropertiesList, pFound, pAsidList->aEntries[ iAsidList ].lParam);
}
}
}
if (!rc && *ppPropertiesList)
AfsAdmSvr_FreeObjPropList (ppPropertiesList);
if (!rc && pStatus)
*pStatus = status;
return rc;
}
BOOL ADMINAPI asc_ObjectListen (DWORD idClient, ASID idCell, ASID idObject, HWND hNotify, ULONG *pStatus)
{
if (!idObject)
{
if (*pStatus)
*pStatus = ERROR_INVALID_PARAMETER;
return FALSE;
}
if (!AddObjectNotification (hNotify, idCell, idObject))
{
if (*pStatus)
*pStatus = ERROR_NOT_ENOUGH_MEMORY;
return FALSE;
}
TestForNotifications (idClient, idCell, idObject);
return TRUE;
}
BOOL ADMINAPI asc_ObjectListenClear (DWORD idClient, HWND hNotify, ULONG *pStatus)
{
ClearObjectNotifications (hNotify);
return TRUE;
}
BOOL ADMINAPI asc_ObjectListenMultiple (DWORD idClient, ASID idCell, LPASIDLIST pAsidList, HWND hNotify, ULONG *pStatus)
{
if (!pAsidList)
{
if (*pStatus)
*pStatus = ERROR_INVALID_PARAMETER;
return FALSE;
}
for (size_t ii = 0; ii < pAsidList->cEntriesAllocated; ++ii)
{
if (!pAsidList->aEntries[ ii ].idObject)
continue;
if (!AddObjectNotification (hNotify, idCell, pAsidList->aEntries[ ii ].idObject))
{
if (*pStatus)
*pStatus = ERROR_NOT_ENOUGH_MEMORY;
return FALSE;
}
TestForNotifications (idClient, idCell, pAsidList->aEntries[ ii ].idObject);
}
return TRUE;
}
BOOL ADMINAPI asc_ObjectRefresh (DWORD idClient, ASID idCell, ASID idObject, ULONG *pStatus)
{
BOOL rc = TRUE;
ULONG status = 0;
// First have the server invalidate its cache of information; regardless
// of the name, this is actually just an Invalidate call, not a Refresh call
//
RpcTryExcept
{
rc = AfsAdmSvr_RefreshObject (idClient, idObject, &status);
}
RpcExcept(1)
{
rc = FALSE;
status = RPC_S_CALL_FAILED_DNE;
}
RpcEndExcept
// If that suceeded, see if there is anyone listening for changes
// in this object or any of its children. If so, this call
// will requery the server for the latest properties for all
// listened-for objects, which will make us post notifications if
// we get new data back.
//
if (rc)
{
TestForNotifications (idClient, idCell);
}
if (!rc && pStatus)
*pStatus = status;
return rc;
}
BOOL ADMINAPI asc_ObjectRefreshMultiple (DWORD idClient, ASID idCell, LPASIDLIST pAsidList, ULONG *pStatus)
{
BOOL rc = TRUE;
ULONG status = 0;
// First have the server invalidate its cache of information; regardless
// of the name, this is actually just an Invalidate call, not a Refresh call
//
RpcTryExcept
{
rc = AfsAdmSvr_RefreshObjects (idClient, pAsidList, &status);
}
RpcExcept(1)
{
rc = FALSE;
status = RPC_S_CALL_FAILED_DNE;
}
RpcEndExcept
// If that suceeded, see if there is anyone listening for changes
// in any of these objects or their children. If so, this call
// will requery the server for the latest properties for all
// listened-for objects, which will make us post notifications if
// we get new data back.
//
if (rc)
{
TestForNotifications (idClient, idCell);
}
if (!rc && pStatus)
*pStatus = status;
return rc;
}
BOOL ADMINAPI asc_RandomKeyGet (DWORD idClient, ASID idCell, PBYTE key, ULONG *pStatus)
{
BOOL rc = TRUE;
ULONG status = 0;
RpcTryExcept
{
memset (key, 0x00, sizeof(BYTE) * ENCRYPTIONKEYLENGTH);
rc = AfsAdmSvr_GetRandomKey (idClient, idCell, key, &status);
}
RpcExcept(1)
{
rc = FALSE;
status = RPC_S_CALL_FAILED_DNE;
}
RpcEndExcept
if (!rc && pStatus)
*pStatus = status;
return rc;
}
BOOL ADMINAPI asc_CellNameGet_Fast (DWORD idClient, ASID idCell, LPTSTR pszCell, ULONG *pStatus)
{
return asc_ObjectNameGet_Fast (idClient, idCell, idCell, pszCell, pStatus);
}
BOOL ADMINAPI asc_ObjectNameGet_Fast (DWORD idClient, ASID idCell, ASID idObject, LPTSTR pszObject, ULONG *pStatus)
{
BOOL rc = TRUE;
ULONG status = 0;
LPASOBJPROP pProperties;
if ((pProperties = GetCachedProperties (idCell, idObject)) == NULL)
{
rc = FALSE;
status = ERROR_NO_DATA;
}
else if (pProperties->verProperties == verPROP_NO_OBJECT)
{
rc = FALSE;
status = ERROR_NO_DATA;
}
else
{
lstrcpy (pszObject, pProperties->szName);
}
if (!rc && pStatus)
*pStatus = status;
return rc;
}
BOOL ADMINAPI asc_ObjectTypeGet_Fast (DWORD idClient, ASID idCell, ASID idObject, ASOBJTYPE *pObjectType, ULONG *pStatus)
{
BOOL rc = TRUE;
ULONG status = 0;
LPASOBJPROP pProperties;
if ((pProperties = GetCachedProperties (idCell, idObject)) == NULL)
{
rc = FALSE;
status = ERROR_NO_DATA;
}
else if (pProperties->verProperties == verPROP_NO_OBJECT)
{
rc = FALSE;
status = ERROR_NO_DATA;
}
else
{
*pObjectType = pProperties->Type;
}
if (!rc && pStatus)
*pStatus = status;
return rc;
}
BOOL ADMINAPI asc_ObjectPropertiesGet_Fast (DWORD idClient, ASID idCell, ASID idObject, LPASOBJPROP pProperties, ULONG *pStatus)
{
BOOL rc = TRUE;
ULONG status = 0;
LPASOBJPROP pPropFound;
if ((pPropFound = GetCachedProperties (idCell, idObject)) == NULL)
{
rc = FALSE;
status = ERROR_NO_DATA;
}
else if (pPropFound->verProperties == verPROP_NO_OBJECT)
{
rc = FALSE;
status = ERROR_NO_DATA;
}
else if (pProperties)
{
memcpy (pProperties, pPropFound, sizeof(ASOBJPROP));
}
if (!rc && pStatus)
*pStatus = status;
return rc;
}
BOOL ADMINAPI asc_ActionGet (DWORD idClient, DWORD idAction, LPASACTION pAction, ULONG *pStatus)
{
BOOL rc = TRUE;
ULONG status = 0;
RpcTryExcept
{
memset (pAction, 0x00, sizeof(ASACTION));
rc = AfsAdmSvr_GetAction (idClient, idAction, pAction, &status);
}
RpcExcept(1)
{
rc = FALSE;
status = RPC_S_CALL_FAILED_DNE;
}
RpcEndExcept
if (!rc && pStatus)
*pStatus = status;
return rc;
}
BOOL ADMINAPI asc_ActionGetMultiple (DWORD idClient, DWORD idClientSearch, ASID idCellSearch, LPASACTIONLIST *ppList, ULONG *pStatus)
{
BOOL rc = TRUE;
ULONG status = 0;
RpcTryExcept
{
*ppList = NULL;
rc = AfsAdmSvr_GetActions (idClient, idClientSearch, idCellSearch, ppList, &status);
}
RpcExcept(1)
{
rc = FALSE;
status = RPC_S_CALL_FAILED_DNE;
}
RpcEndExcept
if (!rc && pStatus)
*pStatus = status;
return rc;
}
BOOL ADMINAPI asc_ActionListen (DWORD idClient, HWND hNotify, ULONG *pStatus)
{
if (!SetActionNotification (hNotify, TRUE))
{
if (*pStatus)
*pStatus = ERROR_NOT_ENOUGH_MEMORY;
return FALSE;
}
return TRUE;
}
BOOL ADMINAPI asc_ActionListenClear (DWORD idClient, HWND hNotify, ULONG *pStatus)
{
if (!SetActionNotification (hNotify, FALSE))
{
if (*pStatus)
*pStatus = ERROR_NOT_ENOUGH_MEMORY;
return FALSE;
}
return TRUE;
}
// AfsAdmSvrCallback_Action
// ...called by the server in the context of the CallbackHost() routine;
// this routine is used to notify the client whenever an action is
// initiated or completed.
//
void AfsAdmSvrCallback_Action (LPASACTION pAction, BOOL fFinished)
{
NotifyActionListeners (pAction, fFinished);
}

View File

@ -0,0 +1,151 @@
#ifndef TAAFSADMSVRCLIENT_H
#define TAAFSADMSVRCLIENT_H
/*
* DEFINITIONS ________________________________________________________________
*
*/
#include <WINNT/TaAfsAdmSvr.h>
#ifndef ADMINAPI
#ifdef WIN32
#define ADMINAPI __cdecl
#else
#define ADMINAPI
#endif
#endif
// You can use asc_ObjectListen() to specify that you want a
// particular window to receive a message whenever there is a
// change to a given object's properties. Changes will automatically
// be detected when the server performs its periodic refresh,
// or will be detected whenever an explicit asc_ObjectRefresh()
// call is made.
//
#define WM_ASC_NOTIFY_OBJECT (WM_USER + 0x300) // lp=object ASID
// You can use asc_ActionListen() to specify that you want a
// particular window to receive a message whenever an action
// is initiated or completed on the server.
//
#define WM_ASC_NOTIFY_ACTION (WM_USER + 0x301) // wp=fEnd, lp=action ASID
/*
* DATA STRUCTURES ____________________________________________________________
*
*/
BOOL ADMINAPI asc_AsidListCreate (LPASIDLIST *ppList);
BOOL ADMINAPI asc_AsidListCopy (LPASIDLIST *ppListTarget, LPASIDLIST *ppListSource);
BOOL ADMINAPI asc_AsidListAddEntry (LPASIDLIST *ppList, ASID idObject, LPARAM lp);
BOOL ADMINAPI asc_AsidListRemoveEntry (LPASIDLIST *ppList, ASID idObject);
BOOL ADMINAPI asc_AsidListRemoveEntryByIndex (LPASIDLIST *ppList, size_t iIndex);
BOOL ADMINAPI asc_AsidListSetEntryParam (LPASIDLIST *ppList, ASID idObject, LPARAM lp);
BOOL ADMINAPI asc_AsidListSetEntryParamByIndex (LPASIDLIST *ppList, size_t iIndex, LPARAM lp);
BOOL ADMINAPI asc_AsidListTest (LPASIDLIST *ppList, ASID idObject, LPARAM *pParam = NULL);
BOOL ADMINAPI asc_AsidListFree (LPASIDLIST *ppList);
BOOL ADMINAPI asc_ObjPropListCreate (LPASOBJPROPLIST *ppList);
BOOL ADMINAPI asc_ObjPropListCopy (LPASOBJPROPLIST *ppListTarget, LPASOBJPROPLIST *ppListSource);
BOOL ADMINAPI asc_ObjPropListAddEntry (LPASOBJPROPLIST *ppList, LPASOBJPROP pProperties, LPARAM lp);
BOOL ADMINAPI asc_ObjPropListRemoveEntry (LPASOBJPROPLIST *ppList, ASID idObject);
BOOL ADMINAPI asc_ObjPropListTest (LPASOBJPROPLIST *ppList, ASID idObject, LPASOBJPROP pProperties = NULL, LPARAM *pParam = NULL);
BOOL ADMINAPI asc_ObjPropListFree (LPASOBJPROPLIST *ppList);
BOOL ADMINAPI asc_ActionListCreate (LPASACTIONLIST *ppList);
BOOL ADMINAPI asc_ActionListCopy (LPASACTIONLIST *ppListTarget, LPASACTIONLIST *ppListSource);
BOOL ADMINAPI asc_ActionListAddEntry (LPASACTIONLIST *ppList, LPASACTION pAction);
BOOL ADMINAPI asc_ActionListRemoveEntry (LPASACTIONLIST *ppList, DWORD idAction);
BOOL ADMINAPI asc_ActionListTest (LPASACTIONLIST *ppList, DWORD idAction, LPASACTION pAction = NULL);
BOOL ADMINAPI asc_ActionListFree (LPASACTIONLIST *ppList);
/*
* GENERAL PROTOTYPES _________________________________________________________
*
*/
BOOL ADMINAPI asc_AdminServerOpen (LPCTSTR pszAddress, DWORD *pidClient, ULONG *pStatus);
BOOL ADMINAPI asc_AdminServerClose (DWORD idClient, ULONG *pStatus);
BOOL ADMINAPI asc_CredentialsCrack (DWORD idClient, PVOID hCreds, LPTSTR pszCell, LPTSTR pszUser, SYSTEMTIME *pstExpiration, ULONG *pStatus);
PVOID ADMINAPI asc_CredentialsGet (DWORD idClient, LPCTSTR pszCell, ULONG *pStatus);
PVOID ADMINAPI asc_CredentialsSet (DWORD idClient, LPCTSTR pszCell, LPCTSTR pszUser, LPCTSTR pszPassword, ULONG *pStatus);
BOOL ADMINAPI asc_CredentialsPush (DWORD idClient, PVOID hCreds, ASID idCel, ULONG *pStatus);
BOOL ADMINAPI asc_LocalCellGet (DWORD idClient, LPTSTR pszCell, ULONG *pStatus);
BOOL ADMINAPI asc_ErrorCodeTranslate (DWORD idClient, ULONG code, LANGID idLanguage, STRING pszErrorText, ULONG *pStatus);
BOOL ADMINAPI asc_CellOpen (DWORD idClient, PVOID hCreds, LPCTSTR pszCell, DWORD dwScope, ASID *pidCell, ULONG *pStatus);
BOOL ADMINAPI asc_CellClose (DWORD idClient, ASID idCell, ULONG *pStatus);
BOOL ADMINAPI asc_CellChange (DWORD idClient, ASID idCell, LPAFSADMSVR_CHANGECELL_PARAMS pChange, ULONG *pStatus);
BOOL ADMINAPI asc_CellRefreshRateSet (DWORD idClient, ASID idCell, ULONG cminRefreshRate, ULONG *pStatus);
BOOL ADMINAPI asc_ObjectFind (DWORD idClient, ASID idSearchScope, ASOBJTYPE ObjectType, LPCTSTR pszName, ASID *pidObject, ULONG *pStatus);
BOOL ADMINAPI asc_ObjectFindMultiple (DWORD idClient, ASID idSearchScope, ASOBJTYPE ObjectType, LPCTSTR pszPattern, LPAFSADMSVR_SEARCH_PARAMS pSearchParams, LPASIDLIST *ppList, ULONG *pStatus);
BOOL ADMINAPI asc_ObjectPropertiesGet (DWORD idClient, AFSADMSVR_GET_LEVEL GetLevel, ASID idCell, ASID idObject, LPASOBJPROP pProperties, ULONG *pStatus);
BOOL ADMINAPI asc_ObjectPropertiesGetMultiple (DWORD idClient, AFSADMSVR_GET_LEVEL GetLevel, ASID idCell, LPASIDLIST pAsidList, LPASOBJPROPLIST *ppPropertiesList, ULONG *pStatus);
BOOL ADMINAPI asc_ObjectRefresh (DWORD idClient, ASID idCell, ASID idObject, ULONG *pStatus);
BOOL ADMINAPI asc_ObjectRefreshMultiple (DWORD idClient, ASID idCell, LPASIDLIST pAsidList, ULONG *pStatus);
BOOL ADMINAPI asc_RandomKeyGet (DWORD idClient, ASID idCell, PBYTE key, ULONG *pStatus);
BOOL ADMINAPI asc_CellNameGet_Fast (DWORD idClient, ASID idCell, LPTSTR pszCell, ULONG *pStatus = NULL);
BOOL ADMINAPI asc_ObjectNameGet_Fast (DWORD idClient, ASID idCell, ASID idObject, LPTSTR pszObjectName, ULONG *pStatus = NULL);
BOOL ADMINAPI asc_ObjectTypeGet_Fast (DWORD idClient, ASID idCell, ASID idObject, ASOBJTYPE *pObjectType, ULONG *pStatus = NULL);
BOOL ADMINAPI asc_ObjectPropertiesGet_Fast (DWORD idClient, ASID idCell, ASID idObject, LPASOBJPROP pProperties, ULONG *pStatus = NULL);
void ADMINAPI asc_Enter (void);
void ADMINAPI asc_Leave (void);
LPCRITICAL_SECTION ADMINAPI asc_GetCriticalSection (void);
/*
* NOTIFICATIONS ______________________________________________________________
*
*/
BOOL ADMINAPI asc_ObjectListen (DWORD idClient, ASID idCell, ASID idObject, HWND hNotify, ULONG *pStatus);
BOOL ADMINAPI asc_ObjectListenClear (DWORD idClient, HWND hNotify, ULONG *pStatus);
BOOL ADMINAPI asc_ObjectListenMultiple (DWORD idClient, ASID idCell, LPASIDLIST pAsidList, HWND hNotify, ULONG *pStatus);
BOOL ADMINAPI asc_ActionGet (DWORD idClient, DWORD idAction, LPASACTION pAction, ULONG *pStatus);
BOOL ADMINAPI asc_ActionGetMultiple (DWORD idClient, DWORD idClientSearch, ASID idCellSearch, LPASACTIONLIST *ppList, ULONG *pStatus);
BOOL ADMINAPI asc_ActionListen (DWORD idClient, HWND hNotify, ULONG *pStatus);
BOOL ADMINAPI asc_ActionListenClear (DWORD idClient, HWND hNotify, ULONG *pStatus);
/*
* USER-ACCOUNT PROTOTYPES ____________________________________________________
*
*/
BOOL ADMINAPI asc_UserChange (DWORD idClient, ASID idCell, ASID idUser, LPAFSADMSVR_CHANGEUSER_PARAMS pChange, ULONG *pStatus);
BOOL ADMINAPI asc_UserPasswordSet (DWORD idClient, ASID idCell, ASID idUser, int keyVersion, LPCTSTR pkeyString, PBYTE pkeyData, ULONG *pStatus);
BOOL ADMINAPI asc_UserUnlock (DWORD idClient, ASID idCell, ASID idUser, ULONG *pStatus);
BOOL ADMINAPI asc_UserCreate (DWORD idClient, ASID idCell, LPAFSADMSVR_CREATEUSER_PARAMS pCreate, ASID *pidUser, ULONG *pStatus);
BOOL ADMINAPI asc_UserDelete (DWORD idClient, ASID idCell, ASID idUser, LPAFSADMSVR_DELETEUSER_PARAMS pDelete, ULONG *pStatus);
/*
* GROUP-ACCOUNT PROTOTYPES ___________________________________________________
*
*/
BOOL ADMINAPI asc_GroupChange (DWORD idClient, ASID idCell, ASID idGroup, LPAFSADMSVR_CHANGEGROUP_PARAMS pChange, ULONG *pStatus);
BOOL ADMINAPI asc_GroupMembersGet (DWORD idClient, ASID idCell, ASID idGroup, LPASIDLIST *ppAsidList, ULONG *pStatus);
BOOL ADMINAPI asc_GroupMemberAdd (DWORD idClient, ASID idCell, ASID idGroup, ASID idMember, ULONG *pStatus);
BOOL ADMINAPI asc_GroupMemberRemove (DWORD idClient, ASID idCell, ASID idGroup, ASID idMember, ULONG *pStatus);
BOOL ADMINAPI asc_GroupRename (DWORD idClient, ASID idCell, ASID idGroup, LPCTSTR pszNewName, ULONG *pStatus);
BOOL ADMINAPI asc_GroupMembershipGet (DWORD idClient, ASID idCell, ASID idMember, LPASIDLIST *ppAsidList, ULONG *pStatus);
BOOL ADMINAPI asc_GroupOwnershipGet (DWORD idClient, ASID idCell, ASID idOwner, LPASIDLIST *ppAsidList, ULONG *pStatus);
BOOL ADMINAPI asc_GroupCreate (DWORD idClient, ASID idCell, LPAFSADMSVR_CREATEGROUP_PARAMS pCreate, ASID *pidGroup, ULONG *pStatus);
BOOL ADMINAPI asc_GroupDelete (DWORD idClient, ASID idCell, ASID idGroup, ULONG *pStatus);
#endif // TAAFSADMSVRCLIENT_H

View File

@ -0,0 +1,210 @@
extern "C" {
#include <afs/param.h>
#include <afs/stds.h>
}
#include "TaAfsAdmSvrClientInternal.h"
extern "C" {
#include <afs/afs_AdminErrors.h>
} // extern "C"
/*
* DEFINITIONS ________________________________________________________________
*
*/
#define cmsecLOCAL_BIND_TIMEOUT (15L * 1000L) // wait up to 15 seconds to bind
#define cmsecLOCAL_BIND_SLEEP (1L * 1000L) // sleep for a second between
/*
* PROTOTYPES _________________________________________________________________
*
*/
BOOL ValidateBinding (RPC_NS_HANDLE hBind, DWORD *pidClient, ULONG *pStatus);
/*
* ROUTINES ___________________________________________________________________
*
*/
BOOL ADMINAPI BindToAdminServer (LPCTSTR pszAddress, BOOL fWait, DWORD *pidClient, ULONG *pStatus)
{
RPC_STATUS status = 0;
unsigned char *pszPROTOCOL = (unsigned char *)"ncacn_ip_tcp";
unsigned char *pszENTRYNAME = (unsigned char *)AFSADMSVR_ENTRYNAME_DEFAULT;
unsigned char szEndpoint[ 32 ];
wsprintf ((LPTSTR)szEndpoint, "%lu", AFSADMSVR_ENDPOINT_DEFAULT);
for (DWORD dwTickStart = GetTickCount(); ; )
{
// First we'll enumerate the name services around here to see if
// an admin server is already running.
//
RPC_NS_HANDLE hEnum;
if ((status = RpcNsBindingImportBegin (RPC_C_NS_SYNTAX_DEFAULT, pszENTRYNAME, ITaAfsAdminSvr_v1_0_c_ifspec, NULL, &hEnum)) == 0)
{
RPC_BINDING_HANDLE hBind;
status = RpcNsBindingImportNext (hEnum, &hBind);
RpcNsBindingImportDone (&hEnum);
if (status)
RpcBindingFree (&hBind);
else if (ValidateBinding (hBind, pidClient, (ULONG*)&status))
return TRUE;
else if (status != RPC_S_CALL_FAILED_DNE) // server rejected us!
break;
}
// Failing that, we'll try to bind to the well-known endpoint that the
// admin server may have had to use. (if RpcNsBindingExport failed.)
//
unsigned char *pszStringBinding = NULL;
if ((status = RpcStringBindingCompose (NULL, pszPROTOCOL, (unsigned char *)pszAddress, szEndpoint, NULL, &pszStringBinding)) == 0)
{
RPC_BINDING_HANDLE hBind;
status = RpcBindingFromStringBinding (pszStringBinding, &hBind);
RpcStringFree (&pszStringBinding);
if (status)
RpcBindingFree (&hBind);
else if (ValidateBinding (hBind, pidClient, (ULONG*)&status))
return TRUE;
else if (status != RPC_S_CALL_FAILED_DNE) // server rejected us!
break;
}
// If we can't wait any longer, fail. Otherwise, sleep for a little bit
// and try again.
//
if ((!fWait) || (GetTickCount() - dwTickStart > cmsecLOCAL_BIND_TIMEOUT))
break;
Sleep (cmsecLOCAL_BIND_SLEEP);
}
if (pStatus)
*pStatus = (LONG)status;
return FALSE;
}
BOOL ADMINAPI UnbindFromAdminServer (DWORD idClient, ULONG *pStatus)
{
BOOL rc = TRUE;
ULONG status = 0;
RpcTryExcept
{
ULONG status;
AfsAdmSvr_Disconnect (idClient, &status);
}
RpcExcept(1)
;
RpcEndExcept
if ((status = RpcBindingFree (&hBindTaAfsAdminSvr)) != 0)
rc = FALSE;
if (!rc && pStatus)
*pStatus = (LONG)status;
return rc;
}
BOOL ADMINAPI ForkNewAdminServer (ULONG *pStatus)
{
// Before we can fork a new process, we have to find the program to run.
//
TCHAR szFile[ MAX_PATH ];
GetModuleFileName (GetModuleHandle(NULL), szFile, MAX_PATH);
LPTSTR pch;
if ((pch = (LPTSTR)lstrrchr (szFile, TEXT('\\'))) != NULL)
*(1+pch) = TEXT('\0');
lstrcat (szFile, AFSADMSVR_PROGRAM);
if (GetFileAttributes (szFile) == (DWORD)0xFFFFFFFF)
{
lstrcpy (szFile, AFSADMSVR_PROGRAM); // hope it's on the path
}
// Try to launch the program. Error codes are returns <= 32.
// Remember to add the "Timed" keyword, so it will shut itself down
// if it's idle too long, and the "Manual" keyword so it won't automatically
// start opening a cell and looking around.
//
wsprintf (&szFile[ lstrlen(szFile) ], TEXT(" %s %s"), AFSADMSVR_KEYWORD_TIMED, AFSADMSVR_KEYWORD_MANUAL);
UINT hInst;
if ((hInst = WinExec (szFile, SW_HIDE)) <= 32)
{
if (pStatus)
*pStatus = (DWORD)hInst;
return FALSE;
}
return TRUE;
}
BOOL ValidateBinding (RPC_NS_HANDLE hBind, DWORD *pidClient, ULONG *pStatus)
{
RPC_NS_HANDLE hBindOld = hBindTaAfsAdminSvr;
BOOL rc = FALSE;
ULONG status = RPC_S_CALL_FAILED_DNE;
hBindTaAfsAdminSvr = hBind;
RpcTryExcept
{
STRING szMyName;
gethostname (szMyName, cchSTRING);
rc = AfsAdmSvr_Connect (szMyName, pidClient, &status);
}
RpcExcept(1)
{
rc = FALSE;
status = RPC_S_CALL_FAILED_DNE;
}
RpcEndExcept
if (!rc)
hBindTaAfsAdminSvr = hBindOld;
if (!rc && pStatus)
*pStatus = status;
return rc;
}
LPCTSTR ADMINAPI ResolveAddress (LPCTSTR pszAddress)
{
if (!pszAddress || !*pszAddress)
return NULL;
// The caller may have specified an IP address or a server name.
// If the former, we're done; if the latter, we'll have to look up
// the server's IP address.
//
if ((*pszAddress >= TEXT('0')) && (*pszAddress <= TEXT('9')))
return pszAddress;
HOSTENT *pEntry;
if ((pEntry = gethostbyname (pszAddress)) == NULL)
return pszAddress; // we'll try it by name, but it probly won't work.
try {
static TCHAR szResolved[ 1024 ];
lstrcpy (szResolved, inet_ntoa (*(struct in_addr *)pEntry->h_addr));
return szResolved;
} catch (...) {
return pszAddress; // we'll try it by name, but it probly won't work.
}
}

View File

@ -0,0 +1,18 @@
#ifndef TAAFSADMSVRCLIENTBIND_H
#define TAAFSADMSVRCLIENTBIND_H
/*
* PROTOTYPES _________________________________________________________________
*
*/
BOOL ADMINAPI BindToAdminServer (LPCTSTR pszAddress, BOOL fWait, DWORD *pidClient, ULONG *pStatus);
BOOL ADMINAPI UnbindFromAdminServer (DWORD idClient, ULONG *pStatus);
BOOL ADMINAPI ForkNewAdminServer (ULONG *pStatus);
LPCTSTR ADMINAPI ResolveAddress (LPCTSTR pszAddress);
#endif // TAAFSADMSVRCLIENTBIND_H

View File

@ -0,0 +1,277 @@
extern "C" {
#include <afs/param.h>
#include <afs/stds.h>
}
#include "TaAfsAdmSvrClientInternal.h"
#include <WINNT/AfsAppLib.h>
/*
* VARIABLES __________________________________________________________________
*
*/
typedef struct
{
ASID idCell;
LPHASHLIST pCache;
LPHASHLISTKEY pCacheKeyAsid;
DWORD cReqCache;
} CELLCACHE, *LPCELLCACHE;
static struct
{
LPHASHLIST pCells;
LPHASHLISTKEY pCellsKeyAsid;
} l;
/*
* PROTOTYPES _________________________________________________________________
*
*/
BOOL CALLBACK CacheKeyAsid_Compare (LPHASHLISTKEY pKey, PVOID pObject, PVOID pData);
HASHVALUE CALLBACK CacheKeyAsid_HashObject (LPHASHLISTKEY pKey, PVOID pObject);
HASHVALUE CALLBACK CacheKeyAsid_HashData (LPHASHLISTKEY pKey, PVOID pData);
BOOL CALLBACK CellsKeyAsid_Compare (LPHASHLISTKEY pKey, PVOID pObject, PVOID pData);
HASHVALUE CALLBACK CellsKeyAsid_HashObject (LPHASHLISTKEY pKey, PVOID pObject);
HASHVALUE CALLBACK CellsKeyAsid_HashData (LPHASHLISTKEY pKey, PVOID pData);
/*
* ROUTINES ___________________________________________________________________
*
*/
LPCELLCACHE GetCellCache (ASID idCell)
{
if (!l.pCells)
return NULL;
return (LPCELLCACHE)(l.pCellsKeyAsid->GetFirstObject (&idCell));
}
BOOL CreateCellCache (ASID idCell)
{
asc_Enter();
if (!l.pCells)
{
l.pCells = New (HASHLIST);
l.pCells->SetCriticalSection (asc_GetCriticalSection());
l.pCellsKeyAsid = l.pCells->CreateKey (TEXT("ASID"), CellsKeyAsid_Compare, CellsKeyAsid_HashObject, CellsKeyAsid_HashData);
}
LPCELLCACHE pcc;
if ((pcc = GetCellCache (idCell)) == NULL)
{
pcc = New (CELLCACHE);
memset (pcc, 0x00, sizeof(CELLCACHE));
pcc->idCell = idCell;
pcc->pCache = New (HASHLIST);
pcc->pCache->SetCriticalSection (asc_GetCriticalSection());
pcc->pCacheKeyAsid = pcc->pCache->CreateKey (TEXT("ASID"), CacheKeyAsid_Compare, CacheKeyAsid_HashObject, CacheKeyAsid_HashData);
l.pCells->Add (pcc);
}
pcc->cReqCache ++;
asc_Leave();
return TRUE;
}
BOOL DestroyCellCache (ASID idCell)
{
asc_Enter();
LPCELLCACHE pcc;
if ((pcc = GetCellCache (idCell)) == NULL)
{
asc_Leave();
return FALSE;
}
if (!pcc->cReqCache || !(--(pcc->cReqCache)))
{
if (pcc->pCache)
{
for (LPENUM pEnum = pcc->pCache->FindFirst(); pEnum; pEnum = pEnum->FindNext())
{
LPASOBJPROP pProp = (LPASOBJPROP)( pEnum->GetObject() );
pcc->pCache->Remove (pProp);
Delete (pProp);
}
Delete (pcc->pCache);
}
l.pCells->Remove (pcc);
Delete (pcc);
}
asc_Leave();
return TRUE;
}
LPASOBJPROP GetCachedProperties (ASID idCell, ASID idObject)
{
LPASOBJPROP pCachedProperties = NULL;
asc_Enter();
LPCELLCACHE pcc;
if ((pcc = GetCellCache (idCell)) != NULL)
{
pCachedProperties = (LPASOBJPROP)(pcc->pCacheKeyAsid->GetFirstObject (&idObject));
}
asc_Leave();
return pCachedProperties;
}
void UpdateCachedProperties (ASID idCell, ASID idObject, LPASOBJPROP pProperties)
{
if (pProperties)
{
asc_Enter();
LPCELLCACHE pcc;
if ((pcc = GetCellCache (idCell)) != NULL)
{
LPASOBJPROP pCachedProperties;
if ((pCachedProperties = (LPASOBJPROP)(pcc->pCacheKeyAsid->GetFirstObject (&idObject))) == NULL)
{
pCachedProperties = New (ASOBJPROP);
memcpy (pCachedProperties, pProperties, sizeof(ASOBJPROP));
pcc->pCache->Add (pCachedProperties);
}
else // Just update?
{
memcpy (pCachedProperties, pProperties, sizeof(ASOBJPROP));
// Note: don't need to call pcc->pCache->Update(), because
// we haven't affected any indices (the old and new ASOBJPROP
// structures should have the same ASID)
}
}
NotifyObjectListeners (idCell, idObject);
asc_Leave();
}
}
BOOL RefreshCachedProperties (DWORD idClient, ASID idCell, ASID idObject, AFSADMSVR_GET_LEVEL GetLevel, ULONG *pStatus)
{
BOOL rc = TRUE;
ULONG status = 0;
RpcTryExcept
{
LPASOBJPROP pProperties = GetCachedProperties (idCell, idObject);
DWORD verProperties = (pProperties) ? (pProperties->verProperties) : verPROP_NO_OBJECT;
ASOBJPROP NewProperties;
if ((rc = AfsAdmSvr_GetObject (idClient, RETURN_IF_OUT_OF_DATE, GetLevel, idObject, verProperties, &NewProperties, &status)) != FALSE)
{
if (NewProperties.idObject == idObject)
{
UpdateCachedProperties (idCell, idObject, &NewProperties);
}
}
}
RpcExcept(1)
{
rc = FALSE;
status = RPC_S_CALL_FAILED_DNE;
}
RpcEndExcept
if (!rc && pStatus)
*pStatus = status;
return rc;
}
BOOL RefreshCachedProperties (DWORD idClient, ASID idCell, LPASIDLIST pAsidList, AFSADMSVR_GET_LEVEL GetLevel, ULONG *pStatus)
{
BOOL rc = TRUE;
ULONG status = 0;
if (pAsidList->cEntries)
{
RpcTryExcept
{
for (size_t iObject = 0; iObject < pAsidList->cEntries; ++iObject)
{
LPASOBJPROP pProperties = GetCachedProperties (idCell, pAsidList->aEntries[ iObject ].idObject);
pAsidList->aEntries[ iObject ].lParam = (pProperties) ? (pProperties->verProperties) : verPROP_NO_OBJECT;
}
LPASOBJPROPLIST pNewProperties = NULL;
if ((rc = AfsAdmSvr_GetObjects (idClient, RETURN_IF_OUT_OF_DATE, GetLevel, pAsidList, &pNewProperties, &status)) != FALSE)
{
if (pNewProperties)
{
for (size_t iObject = 0; iObject < pNewProperties->cEntries; ++iObject)
{
UpdateCachedProperties (idCell, pNewProperties->aEntries[ iObject ].ObjectProperties.idObject, &pNewProperties->aEntries[ iObject ].ObjectProperties);
}
AfsAdmSvr_FreeObjPropList (&pNewProperties);
}
}
}
RpcExcept(1)
{
rc = FALSE;
status = RPC_S_CALL_FAILED_DNE;
}
RpcEndExcept
}
if (!rc && pStatus)
*pStatus = status;
return rc;
}
/*
* HASHLIST KEYS ______________________________________________________________
*
*/
BOOL CALLBACK CacheKeyAsid_Compare (LPHASHLISTKEY pKey, PVOID pObject, PVOID pData)
{
return (((LPASOBJPROP)pObject)->idObject == *(ASID*)pData);
}
HASHVALUE CALLBACK CacheKeyAsid_HashObject (LPHASHLISTKEY pKey, PVOID pObject)
{
return CacheKeyAsid_HashData (pKey, &((LPASOBJPROP)pObject)->idObject);
}
HASHVALUE CALLBACK CacheKeyAsid_HashData (LPHASHLISTKEY pKey, PVOID pData)
{
return (HASHVALUE)*(ASID*)pData;
}
BOOL CALLBACK CellsKeyAsid_Compare (LPHASHLISTKEY pKey, PVOID pObject, PVOID pData)
{
return (((LPCELLCACHE)pObject)->idCell == *(ASID*)pData);
}
HASHVALUE CALLBACK CellsKeyAsid_HashObject (LPHASHLISTKEY pKey, PVOID pObject)
{
return CellsKeyAsid_HashData (pKey, &((LPCELLCACHE)pObject)->idCell);
}
HASHVALUE CALLBACK CellsKeyAsid_HashData (LPHASHLISTKEY pKey, PVOID pData)
{
return (HASHVALUE)*(ASID*)pData;
}

View File

@ -0,0 +1,20 @@
#ifndef TAAFSADMSVRCLIENTCACHE_H
#define TAAFSADMSVRCLIENTCACHE_H
/*
* PROTOTYPES _________________________________________________________________
*
*/
BOOL CreateCellCache (ASID idCell);
BOOL DestroyCellCache (ASID idCell);
LPASOBJPROP GetCachedProperties (ASID idCell, ASID idObject);
BOOL RefreshCachedProperties (DWORD idClient, ASID idCell, ASID idObject, AFSADMSVR_GET_LEVEL GetLevel, ULONG *pStatus);
BOOL RefreshCachedProperties (DWORD idClient, ASID idCell, LPASIDLIST pAsidList, AFSADMSVR_GET_LEVEL GetLevel, ULONG *pStatus);
#endif // TAAFSADMSVRCLIENTCACHE_H

View File

@ -0,0 +1,63 @@
extern "C" {
#include <afs/param.h>
#include <afs/stds.h>
}
#include "TaAfsAdmSvrClientInternal.h"
/*
* ROUTINES ___________________________________________________________________
*
*/
BOOL ADMINAPI asc_CellChange (DWORD idClient, ASID idCell, LPAFSADMSVR_CHANGECELL_PARAMS pChange, ULONG *pStatus)
{
BOOL rc = TRUE;
ULONG status = 0;
RpcTryExcept
{
if ((rc = AfsAdmSvr_ChangeCell (idClient, idCell, pChange, &status)) != FALSE)
{
// If we succeeded in changing this cell's properties, get the
// newest values for our cache.
//
ASOBJPROP Properties;
rc = asc_ObjectPropertiesGet (idClient, GET_ALL_DATA, idCell, idCell, &Properties, &status);
}
}
RpcExcept(1)
{
rc = FALSE;
status = RPC_S_CALL_FAILED_DNE;
}
RpcEndExcept
if (!rc && pStatus)
*pStatus = status;
return rc;
}
BOOL ADMINAPI asc_CellRefreshRateSet (DWORD idClient, ASID idCell, ULONG cminRefreshRate, ULONG *pStatus)
{
BOOL rc = TRUE;
ULONG status = 0;
RpcTryExcept
{
rc = AfsAdmSvr_SetRefreshRate (idClient, idCell, cminRefreshRate, &status);
}
RpcExcept(1)
{
rc = FALSE;
status = RPC_S_CALL_FAILED_DNE;
}
RpcEndExcept
if (!rc && pStatus)
*pStatus = status;
return rc;
}

View File

@ -0,0 +1,242 @@
extern "C" {
#include <afs/param.h>
#include <afs/stds.h>
}
#include "TaAfsAdmSvrClientInternal.h"
/*
* ROUTINES ___________________________________________________________________
*
*/
BOOL ADMINAPI asc_GroupChange (DWORD idClient, ASID idCell, ASID idGroup, LPAFSADMSVR_CHANGEGROUP_PARAMS pChange, ULONG *pStatus)
{
BOOL rc = TRUE;
ULONG status = 0;
RpcTryExcept
{
if ((rc = AfsAdmSvr_ChangeGroup (idClient, idCell, idGroup, pChange, &status)) != FALSE)
{
// If we succeeded in changing this group's properties, get the
// newest values for our cache.
//
ASOBJPROP Properties;
rc = asc_ObjectPropertiesGet (idClient, GET_ALL_DATA, idCell, idGroup, &Properties, &status);
}
}
RpcExcept(1)
{
rc = FALSE;
status = RPC_S_CALL_FAILED_DNE;
}
RpcEndExcept
if (!rc && pStatus)
*pStatus = status;
return rc;
}
BOOL ADMINAPI asc_GroupMembersGet (DWORD idClient, ASID idCell, ASID idGroup, LPASIDLIST *ppAsidList, ULONG *pStatus)
{
BOOL rc = TRUE;
ULONG status = 0;
RpcTryExcept
{
rc = AfsAdmSvr_GetGroupMembers (idClient, idCell, idGroup, ppAsidList, &status);
}
RpcExcept(1)
{
rc = FALSE;
status = RPC_S_CALL_FAILED_DNE;
}
RpcEndExcept
if (!rc && pStatus)
*pStatus = status;
return rc;
}
BOOL ADMINAPI asc_GroupMemberAdd (DWORD idClient, ASID idCell, ASID idGroup, ASID idMember, ULONG *pStatus)
{
BOOL rc = TRUE;
ULONG status = 0;
RpcTryExcept
{
rc = AfsAdmSvr_AddGroupMember (idClient, idCell, idGroup, idMember, &status);
}
RpcExcept(1)
{
rc = FALSE;
status = RPC_S_CALL_FAILED_DNE;
}
RpcEndExcept
if (!rc && pStatus)
*pStatus = status;
return rc;
}
BOOL ADMINAPI asc_GroupMemberRemove (DWORD idClient, ASID idCell, ASID idGroup, ASID idMember, ULONG *pStatus)
{
BOOL rc = TRUE;
ULONG status = 0;
RpcTryExcept
{
rc = AfsAdmSvr_RemoveGroupMember (idClient, idCell, idGroup, idMember, &status);
}
RpcExcept(1)
{
rc = FALSE;
status = RPC_S_CALL_FAILED_DNE;
}
RpcEndExcept
if (!rc && pStatus)
*pStatus = status;
return rc;
}
BOOL ADMINAPI asc_GroupRename (DWORD idClient, ASID idCell, ASID idGroup, LPCTSTR pszNewName, ULONG *pStatus)
{
BOOL rc = TRUE;
ULONG status = 0;
RpcTryExcept
{
STRING szNewName = TEXT("");
if (pszNewName)
lstrcpy (szNewName, pszNewName);
if ((rc = AfsAdmSvr_RenameGroup (idClient, idCell, idGroup, szNewName, &status)) == TRUE)
{
// If we succeeded in changing this group's name, get the
// newest group properties for our cache.
//
ASOBJPROP Properties;
rc = asc_ObjectPropertiesGet (idClient, GET_ALL_DATA, idCell, idGroup, &Properties, &status);
}
}
RpcExcept(1)
{
rc = FALSE;
status = RPC_S_CALL_FAILED_DNE;
}
RpcEndExcept
if (!rc && pStatus)
*pStatus = status;
return rc;
}
BOOL ADMINAPI asc_GroupMembershipGet (DWORD idClient, ASID idCell, ASID idMember, LPASIDLIST *ppAsidList, ULONG *pStatus)
{
BOOL rc = TRUE;
ULONG status = 0;
RpcTryExcept
{
rc = AfsAdmSvr_GetGroupMembership (idClient, idCell, idMember, ppAsidList, &status);
}
RpcExcept(1)
{
rc = FALSE;
status = RPC_S_CALL_FAILED_DNE;
}
RpcEndExcept
if (!rc && pStatus)
*pStatus = status;
return rc;
}
BOOL ADMINAPI asc_GroupOwnershipGet (DWORD idClient, ASID idCell, ASID idOwner, LPASIDLIST *ppAsidList, ULONG *pStatus)
{
BOOL rc = TRUE;
ULONG status = 0;
RpcTryExcept
{
rc = AfsAdmSvr_GetGroupOwnership (idClient, idCell, idOwner, ppAsidList, &status);
}
RpcExcept(1)
{
rc = FALSE;
status = RPC_S_CALL_FAILED_DNE;
}
RpcEndExcept
if (!rc && pStatus)
*pStatus = status;
return rc;
}
BOOL ADMINAPI asc_GroupCreate (DWORD idClient, ASID idCell, LPAFSADMSVR_CREATEGROUP_PARAMS pCreate, ASID *pidGroup, ULONG *pStatus)
{
BOOL rc = TRUE;
ULONG status = 0;
RpcTryExcept
{
if ((rc = AfsAdmSvr_CreateGroup (idClient, idCell, pCreate, pidGroup, &status)) == TRUE)
{
// If we succeeded in creating this group, get the
// initial group properties for our cache.
//
ASOBJPROP Properties;
rc = asc_ObjectPropertiesGet (idClient, GET_ALL_DATA, idCell, *pidGroup, &Properties, &status);
}
}
RpcExcept(1)
{
rc = FALSE;
status = RPC_S_CALL_FAILED_DNE;
}
RpcEndExcept
if (!rc && pStatus)
*pStatus = status;
return rc;
}
BOOL ADMINAPI asc_GroupDelete (DWORD idClient, ASID idCell, ASID idGroup, ULONG *pStatus)
{
BOOL rc = TRUE;
ULONG status = 0;
RpcTryExcept
{
if ((rc = AfsAdmSvr_DeleteGroup (idClient, idCell, idGroup, &status)) == TRUE)
{
// If we succeeded in deleting this group, clean up our cache.
// Expect this call to fail (the group's deleted, right?)
//
ASOBJPROP Properties;
ULONG dummy;
(void)asc_ObjectPropertiesGet (idClient, GET_ALL_DATA, idCell, idGroup, &Properties, &dummy);
}
}
RpcExcept(1)
{
rc = FALSE;
status = RPC_S_CALL_FAILED_DNE;
}
RpcEndExcept
if (!rc && pStatus)
*pStatus = status;
return rc;
}

View File

@ -0,0 +1,51 @@
extern "C" {
#include <afs/param.h>
#include <afs/stds.h>
}
#include "TaAfsAdmSvrClientInternal.h"
/*
* VARIABLES __________________________________________________________________
*
*/
static struct
{
LPCRITICAL_SECTION pcs;
} l;
/*
* ROUTINES ___________________________________________________________________
*
*/
void ADMINAPI asc_Enter (void)
{
if (!l.pcs)
{
l.pcs = New (CRITICAL_SECTION);
InitializeCriticalSection (l.pcs);
}
EnterCriticalSection (l.pcs);
}
void ADMINAPI asc_Leave (void)
{
LeaveCriticalSection (l.pcs);
}
LPCRITICAL_SECTION ADMINAPI asc_GetCriticalSection (void)
{
if (!l.pcs)
{
l.pcs = New (CRITICAL_SECTION);
InitializeCriticalSection (l.pcs);
}
return l.pcs;
}

View File

@ -0,0 +1,18 @@
#ifndef TAAFSADMSVRCLIENTINTERNAL_H
#define TAAFSADMSVRCLIENTINTERNAL_H
/*
* INCLUSIONS _________________________________________________________________
*
*/
#include <WINNT/TaAfsAdmSvrClient.h>
#include "TaAfsAdmSvrClientBind.h"
#include "TaAfsAdmSvrClientCache.h"
#include "TaAfsAdmSvrClientNotify.h"
#include "TaAfsAdmSvrClientPing.h"
#endif // TAAFSADMSVRCLIENTINTERNAL_H

View File

@ -0,0 +1,235 @@
extern "C" {
#include <afs/param.h>
#include <afs/stds.h>
}
#include "TaAfsAdmSvrClientInternal.h"
#include <WINNT/AfsAppLib.h>
/*
* VARIABLES __________________________________________________________________
*
*/
typedef struct
{
ASID idCell;
ASID idObject;
HWND hNotify;
} LISTENER, *LPLISTENER;
static struct
{
LPHASHLIST pListeners;
LPHASHLISTKEY pListenersKeyObject;
HWND *ahActionListeners;
size_t chActionListeners;
} l;
/*
* PROTOTYPES _________________________________________________________________
*
*/
BOOL CALLBACK ListenersKeyObject_Compare (LPHASHLISTKEY pKey, PVOID pObject, PVOID pData);
HASHVALUE CALLBACK ListenersKeyObject_HashObject (LPHASHLISTKEY pKey, PVOID pObject);
HASHVALUE CALLBACK ListenersKeyObject_HashData (LPHASHLISTKEY pKey, PVOID pData);
/*
* ROUTINES ___________________________________________________________________
*
*/
BOOL AddObjectNotification (HWND hNotify, ASID idCell, ASID idObject)
{
asc_Enter();
if (!l.pListeners)
{
l.pListeners = New (HASHLIST);
l.pListenersKeyObject = l.pListeners->CreateKey (TEXT("idObject"), ListenersKeyObject_Compare, ListenersKeyObject_HashObject, ListenersKeyObject_HashData);
}
LPLISTENER pl = New (LISTENER);
pl->idCell = idCell;
pl->idObject = idObject;
pl->hNotify = hNotify;
l.pListeners->Add (pl);
asc_Leave();
return TRUE;
}
void ClearObjectNotifications (HWND hNotify)
{
asc_Enter();
if (l.pListeners)
{
for (LPENUM pEnum = l.pListeners->FindFirst(); pEnum; pEnum = pEnum->FindNext())
{
LPLISTENER pl = (LPLISTENER)( pEnum->GetObject() );
if (pl->hNotify == hNotify)
{
l.pListeners->Remove (pl);
Delete (pl);
}
}
}
asc_Leave();
}
void TestForNotifications (DWORD idClient, ASID idCell, ASID idObject)
{
if (l.pListeners)
{
// First we'll zip through our list of listeners and
// build an ASIDLIST reflecting the objects in this cell
// for which we're listening.
//
LPASIDLIST pAsidList = NULL;
for (LPENUM pEnum = l.pListeners->FindFirst(); pEnum; pEnum = pEnum->FindNext())
{
LPLISTENER pl = (LPLISTENER)( pEnum->GetObject() );
if (pl->idCell != idCell)
continue;
if (idObject && (pl->idObject != idObject))
continue;
if (!pAsidList)
{
if (!asc_AsidListCreate (&pAsidList))
break;
}
if (!asc_AsidListAddEntry (&pAsidList, pl->idObject, 0))
break;
}
// Then we'll call one of our cache routines, which in turn will tell
// the admin server what version of the properties we have for each
// of these objects; if any have newer properties available, we'll
// get them back--and that will cause us to send out notifications to
// our listeners.
//
if (pAsidList)
{
ULONG status;
(void)RefreshCachedProperties (idClient, idCell, pAsidList, GET_ALL_DATA, &status);
}
}
}
void NotifyObjectListeners (ASID idCell, ASID idObject)
{
// If we get here, our cache of information for the specified object
// has just been updated. Check for listeners who may be interested
// in changes to this object.
//
if (l.pListeners)
{
for (LPENUM pEnum = l.pListenersKeyObject->FindFirst (&idObject); pEnum; pEnum = pEnum->FindNext())
{
LPLISTENER pl = (LPLISTENER)( pEnum->GetObject() );
if (pl->idCell != idCell)
continue;
if (!IsWindow (pl->hNotify))
{
l.pListeners->Remove (pl);
Delete (pl);
continue;
}
PostMessage (pl->hNotify, WM_ASC_NOTIFY_OBJECT, (WPARAM)0, (LPARAM)idObject);
}
}
}
/*
* HASHLIST KEYS ______________________________________________________________
*
*/
BOOL CALLBACK ListenersKeyObject_Compare (LPHASHLISTKEY pKey, PVOID pObject, PVOID pData)
{
return (((LPLISTENER)pObject)->idObject == *(ASID*)pData) ? TRUE : FALSE;
}
HASHVALUE CALLBACK ListenersKeyObject_HashObject (LPHASHLISTKEY pKey, PVOID pObject)
{
return ListenersKeyObject_HashData (pKey, &((LPLISTENER)pObject)->idObject);
}
HASHVALUE CALLBACK ListenersKeyObject_HashData (LPHASHLISTKEY pKey, PVOID pData)
{
return (HASHVALUE)*(ASID*)pData;
}
/*
* ACTION NOTIFICATIONS _______________________________________________________
*
*/
BOOL SetActionNotification (HWND hNotify, BOOL fSet)
{
BOOL rc = TRUE;
asc_Enter();
if (!fSet)
{
for (size_t ii = 0; ii < l.chActionListeners; ++ii)
{
if (l.ahActionListeners[ ii ] == hNotify)
l.ahActionListeners[ ii ] = NULL;
}
}
else // (fSet)
{
for (size_t ii = 0; ii < l.chActionListeners; ++ii)
{
if (l.ahActionListeners[ ii ] == NULL)
break;
}
if (!REALLOC (l.ahActionListeners, l.chActionListeners, 1+ii, 1))
{
rc = FALSE;
}
else
{
l.ahActionListeners[ ii ] = hNotify;
}
}
asc_Leave();
return rc;
}
void NotifyActionListeners (LPASACTION pAction, BOOL fFinished)
{
asc_Enter();
for (size_t ii = 0; ii < l.chActionListeners; ++ii)
{
if (IsWindow (l.ahActionListeners[ ii ]))
{
LPASACTION pActionPost = New (ASACTION);
memcpy (pActionPost, pAction, sizeof(ASACTION));
PostMessage (l.ahActionListeners[ ii ], WM_ASC_NOTIFY_ACTION, (WPARAM)fFinished, (LPARAM)pActionPost);
}
}
asc_Leave();
}

View File

@ -0,0 +1,20 @@
#ifndef TAAFSADMSVRCLIENTNOTIFY_H
#define TAAFSADMSVRCLIENTNOTIFY_H
/*
* PROTOTYPES _________________________________________________________________
*
*/
BOOL AddObjectNotification (HWND hNotify, ASID idCell, ASID idObject);
void ClearObjectNotifications (HWND hNotify);
void TestForNotifications (DWORD idClient, ASID idCell, ASID idObject = 0);
void NotifyObjectListeners (ASID idCell, ASID idObject);
BOOL SetActionNotification (HWND hNotify, BOOL fSet);
void NotifyActionListeners (LPASACTION pAction, BOOL fFinished);
#endif // TAAFSADMSVRCLIENTNOTIFY_H

View File

@ -0,0 +1,164 @@
extern "C" {
#include <afs/param.h>
#include <afs/stds.h>
}
#include "TaAfsAdmSvrClientInternal.h"
#include <WINNT/AfsAppLib.h>
/*
* VARIABLES __________________________________________________________________
*
*/
static struct
{
HANDLE hPingThread;
DWORD *adwClients;
size_t cdwClients;
HANDLE hCallbackThread;
size_t cReqCallback;
} l;
/*
* PROTOTYPES _________________________________________________________________
*
*/
DWORD WINAPI ClientPingThread (LPVOID lp);
DWORD WINAPI ClientCallbackThread (LPVOID lp);
/*
* ROUTINES ___________________________________________________________________
*
*/
void StartPingThread (DWORD idClient)
{
asc_Enter();
for (size_t ii = 0; ii < l.cdwClients; ++ii)
{
if (!l.adwClients[ ii ])
break;
}
if (REALLOC (l.adwClients, l.cdwClients, 1+ii, 1))
{
l.adwClients[ ii ] = idClient;
}
if (!l.hPingThread)
{
DWORD dwThreadID;
l.hPingThread = CreateThread (NULL, 0, (LPTHREAD_START_ROUTINE)ClientPingThread, (LPVOID)0, 0, &dwThreadID);
}
asc_Leave();
}
void StopPingThread (DWORD idClient)
{
asc_Enter();
for (size_t ii = 0; ii < l.cdwClients; ++ii)
{
if (l.adwClients[ ii ] == idClient)
l.adwClients[ ii ] = 0;
}
asc_Leave();
}
DWORD WINAPI ClientPingThread (LPVOID lp)
{
for (;;)
{
Sleep (csecAFSADMSVR_CLIENT_PING * 1000L); // server adds race allowance
asc_Enter();
for (size_t ii = 0; ii < l.cdwClients; ++ii)
{
DWORD idClient;
if ((idClient = l.adwClients[ ii ]) == 0)
continue;
asc_Leave();
RpcTryExcept
{
ULONG status;
if (!AfsAdmSvr_Ping (idClient, &status))
{
if (status == ERROR_INVALID_HANDLE) // we've been disconnected!
StopPingThread (idClient);
}
}
RpcExcept(1)
;
RpcEndExcept
asc_Enter();
}
asc_Leave();
}
l.hPingThread = NULL;
return 0;
}
void StartCallbackThread (void)
{
asc_Enter();
if ((++l.cReqCallback) == 1)
{
DWORD dwThreadID;
l.hCallbackThread = CreateThread (NULL, 0, (LPTHREAD_START_ROUTINE)ClientCallbackThread, (LPVOID)0, 0, &dwThreadID);
}
asc_Leave();
}
void StopCallbackThread (void)
{
asc_Enter();
if (!(l.cReqCallback) || !(--l.cReqCallback))
{
if (l.hCallbackThread)
{
TerminateThread (l.hCallbackThread, 0);
l.hCallbackThread = NULL;
}
}
asc_Leave();
}
DWORD WINAPI ClientCallbackThread (LPVOID lp)
{
// The callback thread's task is simple: it initiates a particular
// RPC, which never returns. (Well, actually, it will return if the
// server shuts down.) By leaving a thread active, the server has a
// context in which to perform callback calls.
//
RpcTryExcept
{
AfsAdmSvr_CallbackHost();
}
RpcExcept(1)
;
RpcEndExcept
l.hCallbackThread = NULL;
return 0;
}

View File

@ -0,0 +1,18 @@
#ifndef TAAFSADMSVRCLIENTPING_H
#define TAAFSADMSVRCLIENTPING_H
/*
* PROTOTYPES _________________________________________________________________
*
*/
void StartPingThread (DWORD idClient);
void StopPingThread (DWORD idClient);
void StartCallbackThread (void);
void StopCallbackThread (void);
#endif // TAAFSADMSVRCLIENTPING_H

View File

@ -0,0 +1,170 @@
extern "C" {
#include <afs/param.h>
#include <afs/stds.h>
}
#include "TaAfsAdmSvrClientInternal.h"
/*
* ROUTINES ___________________________________________________________________
*
*/
BOOL ADMINAPI asc_UserChange (DWORD idClient, ASID idCell, ASID idUser, LPAFSADMSVR_CHANGEUSER_PARAMS pChange, ULONG *pStatus)
{
BOOL rc = TRUE;
ULONG status = 0;
RpcTryExcept
{
if ((rc = AfsAdmSvr_ChangeUser (idClient, idCell, idUser, pChange, &status)) != FALSE)
{
// If we succeeded in changing this user's properties, get the
// newest values for our cache.
//
ASOBJPROP Properties;
rc = asc_ObjectPropertiesGet (idClient, GET_ALL_DATA, idCell, idUser, &Properties, &status);
}
}
RpcExcept(1)
{
rc = FALSE;
status = RPC_S_CALL_FAILED_DNE;
}
RpcEndExcept
if (!rc && pStatus)
*pStatus = status;
return rc;
}
BOOL ADMINAPI asc_UserPasswordSet (DWORD idClient, ASID idCell, ASID idUser, int keyVersion, LPCTSTR pkeyString, PBYTE pkeyData, ULONG *pStatus)
{
BOOL rc = TRUE;
ULONG status = 0;
RpcTryExcept
{
BYTE keyData[ ENCRYPTIONKEYLENGTH ];
if (pkeyData)
memcpy (keyData, pkeyData, sizeof(keyData));
else
memset (keyData, 0x00, sizeof(keyData));
STRING keyString;
if (pkeyString)
lstrcpy (keyString, pkeyString);
else
memset (keyString, 0x00, sizeof(keyString));
if ((rc = AfsAdmSvr_SetUserPassword (idClient, idCell, idUser, keyVersion, keyString, keyData, &status)) == TRUE)
{
// If we succeeded in changing this user's password, get the
// newest user properties for our cache.
//
ASOBJPROP Properties;
rc = asc_ObjectPropertiesGet (idClient, GET_ALL_DATA, idCell, idUser, &Properties, &status);
}
}
RpcExcept(1)
{
rc = FALSE;
status = RPC_S_CALL_FAILED_DNE;
}
RpcEndExcept
if (!rc && pStatus)
*pStatus = status;
return rc;
}
BOOL ADMINAPI asc_UserUnlock (DWORD idClient, ASID idCell, ASID idUser, ULONG *pStatus)
{
BOOL rc = TRUE;
ULONG status = 0;
RpcTryExcept
{
if ((rc = AfsAdmSvr_UnlockUser (idClient, idCell, idUser, &status)) == TRUE)
{
// If we succeeded in unlocking this user's account, get the
// newest user properties for our cache.
//
ASOBJPROP Properties;
rc = asc_ObjectPropertiesGet (idClient, GET_ALL_DATA, idCell, idUser, &Properties, &status);
}
}
RpcExcept(1)
{
rc = FALSE;
status = RPC_S_CALL_FAILED_DNE;
}
RpcEndExcept
if (!rc && pStatus)
*pStatus = status;
return rc;
}
BOOL ADMINAPI asc_UserCreate (DWORD idClient, ASID idCell, LPAFSADMSVR_CREATEUSER_PARAMS pCreate, ASID *pidUser, ULONG *pStatus)
{
BOOL rc = TRUE;
ULONG status = 0;
RpcTryExcept
{
if ((rc = AfsAdmSvr_CreateUser (idClient, idCell, pCreate, pidUser, &status)) == TRUE)
{
// If we succeeded in creating this user's account, get the
// initial user properties for our cache.
//
ASOBJPROP Properties;
rc = asc_ObjectPropertiesGet (idClient, GET_ALL_DATA, idCell, *pidUser, &Properties, &status);
}
}
RpcExcept(1)
{
rc = FALSE;
status = RPC_S_CALL_FAILED_DNE;
}
RpcEndExcept
if (!rc && pStatus)
*pStatus = status;
return rc;
}
BOOL ADMINAPI asc_UserDelete (DWORD idClient, ASID idCell, ASID idUser, LPAFSADMSVR_DELETEUSER_PARAMS pDelete, ULONG *pStatus)
{
BOOL rc = TRUE;
ULONG status = 0;
RpcTryExcept
{
if ((rc = AfsAdmSvr_DeleteUser (idClient, idCell, idUser, pDelete, &status)) == TRUE)
{
// If we succeeded in deleting this user's account, clean up our cache.
// Expect this call to fail (the user's deleted, right?)
//
ASOBJPROP Properties;
ULONG dummy;
(void)asc_ObjectPropertiesGet (idClient, GET_ALL_DATA, idCell, idUser, &Properties, &dummy);
}
}
RpcExcept(1)
{
rc = FALSE;
status = RPC_S_CALL_FAILED_DNE;
}
RpcEndExcept
if (!rc && pStatus)
*pStatus = status;
return rc;
}

View File

@ -0,0 +1,406 @@
extern "C" {
#include <afs/param.h>
#include <afs/stds.h>
}
#include <WINNT/TaAfsAdmSvr.h>
/*
* DEFINITIONS ________________________________________________________________
*
*/
#define cREALLOC_ASIDLIST 64
#define cREALLOC_OBJPROPLIST 32
#define cREALLOC_ACTIONLIST 8
/*
* REALLOC ____________________________________________________________________
*
* This thing, RPC_REALLOC, is a specialized version of the REALLOC() code that
* you'll find in most libraries. It's intended to deal with structures that
* look like this:
*
* typedef struct {
* DWORD dwGarbage1;
* size_t cElements; <- The interesting bit
* DWORD dwGarbage2;
* MYTYPE aElements[1]; <- <- <- The really interesting bit
* } MYSTRUCT;
*
* Remember that since the array is growable, it must be the last element
* in the structure. This thing's called RPC_REALLOC because these growable
* arrays are well-suited for transferring via rpc--just make the aElements
* line in your .IDL file look like:
*
* [size_is(cElements) length_is(cElements)] MYTYPE aElements[*];
*
* As an example of its use, say we want to fill in element 15:
*
* void FillInElement15 (MYSTRUCT *pStruct, MYTYPE *pNewData)
* {
* int iElement = 15;
* if (RPC_REALLOC (MYSTRUCT, pStruct, aElements, cElements, 1+iElement, cREALLOC_MYSTRUCT))
* {
* memcpy (&pStruct->aElements[ iElement ], pNewData, sizeof(MYTYPE));
* }
* }
*
* As always, the "cREALLOC_MYSTRUCT" can be any positive value; it specifies
* the granularity with which the the array will be over-allocated. Note that
* unlike the normal REALLOC() routine, the {aElements} and {cElements}
* parameters are presumed to be members of the specified pointer-to-structure.
* If {*pStruct} is NULL upon entry, it will be allocated and zero-filled.
*
*/
#define OFFSETOF(_type,_a) (size_t)&(((_type *)0)->_a)
#define RPC_REALLOC(_type,_str,_a,_c,_r,_ci) AfsAdmSvr_ReallocFunction ((PVOID*)&(_str), OFFSETOF(_type,_a), OFFSETOF(_type,_c), sizeof((_str)->_a[0]), (size_t)_r, (size_t)_ci, 0x00)
BOOL AfsAdmSvr_ReallocFunction (PVOID *ppStructure, size_t cbHeader, size_t iposCount, size_t cbElement, size_t cReq, size_t cInc, BYTE chFill)
{
// Use cInc to over-estimate how much space is really required; that
// way, allocating space for one element actually allocates space for
// many--so that next time we get here, we won't have to do any work.
//
if (cInc)
cReq = cInc * ( (cReq + cInc - 1) / cInc );
cReq = max (cReq, 1);
// See how much space is allocated now. If we have no structure to start
// with, obviously we have no array elements either.
//
size_t cNow = 0;
if (*ppStructure)
cNow = *(size_t *)( ((PBYTE)(*ppStructure)) + iposCount );
if (cNow < cReq)
{
// Hmmm... there wasn't enough space. Allocate a new structure.
//
size_t cbAlloc = cbHeader + cbElement * cReq;
PVOID pNewStructure;
if ((pNewStructure = Allocate (cbAlloc)) == NULL)
return FALSE;
memset (pNewStructure, 0x00, cbHeader);
memset ((PBYTE)pNewStructure + cbHeader, chFill, cbAlloc - cbHeader);
if (*ppStructure)
memcpy (pNewStructure, *ppStructure, cbHeader);
*(size_t *)( ((PBYTE)pNewStructure) + iposCount ) = cReq;
// Transfer any information from the old structure's elements
//
if (cNow)
memcpy ((PBYTE)pNewStructure + cbHeader, ((PBYTE)(*ppStructure)) + cbHeader, cNow * cbElement);
// If there was one, free the old structure
//
if (*ppStructure)
Free (*ppStructure);
*ppStructure = pNewStructure;
}
return TRUE;
}
/*
* ROUTINES ___________________________________________________________________
*
*/
// ASIDLIST - Managed type for lists of cell objects
//
LPASIDLIST AfsAdmSvr_CreateAsidList (void)
{
LPASIDLIST pList = NULL;
if (!RPC_REALLOC (ASIDLIST, pList, aEntries, cEntriesAllocated, 0, cREALLOC_ASIDLIST))
return NULL;
return pList;
}
LPASIDLIST AfsAdmSvr_CopyAsidList (LPASIDLIST pListSource)
{
LPASIDLIST pList = NULL;
if (!RPC_REALLOC (ASIDLIST, pList, aEntries, cEntriesAllocated, pListSource->cEntries, cREALLOC_ASIDLIST))
return NULL;
if (pList->cEntriesAllocated)
memcpy (pList->aEntries, pListSource->aEntries, sizeof(pList->aEntries[0]) * pList->cEntriesAllocated);
pList->cEntries = pListSource->cEntries;
return pList;
}
BOOL AfsAdmSvr_AddToAsidList (LPASIDLIST *ppList, ASID idObject, LPARAM lp)
{
if (!ppList || !*ppList)
return FALSE;
if (!RPC_REALLOC (ASIDLIST, *ppList, aEntries, cEntriesAllocated, (*ppList)->cEntries +1, cREALLOC_ASIDLIST))
return FALSE;
(*ppList)->aEntries[ (*ppList)->cEntries ].idObject = idObject;
(*ppList)->aEntries[ (*ppList)->cEntries ].lParam = lp;
(*ppList)->cEntries ++;
return TRUE;
}
BOOL AfsAdmSvr_RemoveFromAsidList (LPASIDLIST *ppList, ASID idObject)
{
if (!ppList || !(*ppList) || !(*ppList)->cEntries)
return FALSE;
BOOL fFound = FALSE;
for (ULONG iEntry = 0; iEntry < (*ppList)->cEntries; )
{
if ((*ppList)->aEntries[ iEntry ].idObject != idObject)
iEntry ++;
else if ((fFound = AfsAdmSvr_RemoveFromAsidListByIndex (ppList, iEntry)) == FALSE)
break;
}
return fFound;
}
BOOL AfsAdmSvr_RemoveFromAsidListByIndex (LPASIDLIST *ppList, size_t iIndex)
{
if (iIndex >= (*ppList)->cEntries)
return FALSE;
if (iIndex < (*ppList)->cEntries -1)
memcpy (&(*ppList)->aEntries[ iIndex ], &(*ppList)->aEntries[ (*ppList)->cEntries-1 ], sizeof((*ppList)->aEntries[0]));
(*ppList)->cEntries --;
return TRUE;
}
BOOL AfsAdmSvr_SetAsidListParam (LPASIDLIST *ppList, ASID idObject, LPARAM lp)
{
BOOL fFound = FALSE;
for (ULONG iEntry = 0; iEntry < (*ppList)->cEntries; ++iEntry)
{
if ((*ppList)->aEntries[ iEntry ].idObject == idObject)
{
(*ppList)->aEntries[ iEntry ].lParam = lp;
fFound = TRUE;
}
}
return fFound;
}
BOOL AfsAdmSvr_SetAsidListParamByIndex (LPASIDLIST *ppList, size_t iIndex, LPARAM lp)
{
if (iIndex >= (*ppList)->cEntries)
return FALSE;
(*ppList)->aEntries[ iIndex ].lParam = lp;
return TRUE;
}
BOOL AfsAdmSvr_IsInAsidList (LPASIDLIST *ppList, ASID idObject, LPARAM *pParam)
{
if (!ppList || !(*ppList) || !(*ppList)->cEntries)
return FALSE;
for (ULONG iEntry = 0; iEntry < (*ppList)->cEntries; ++iEntry)
{
if ((*ppList)->aEntries[ iEntry ].idObject == idObject)
{
if (pParam)
*pParam = (*ppList)->aEntries[ iEntry ].lParam;
return TRUE;
}
}
return FALSE;
}
void AfsAdmSvr_FreeAsidList (LPASIDLIST *ppList)
{
if (ppList && *ppList)
{
Free (*ppList);
(*ppList) = 0;
}
}
// ASOBJPROPLIST - Managed type for lists of cell objects
//
LPASOBJPROPLIST AfsAdmSvr_CreateObjPropList (void)
{
LPASOBJPROPLIST pList = NULL;
if (!RPC_REALLOC (ASOBJPROPLIST, pList, aEntries, cEntriesAllocated, 0, cREALLOC_OBJPROPLIST))
return NULL;
return pList;
}
LPASOBJPROPLIST AfsAdmSvr_CopyObjPropList (LPASOBJPROPLIST pListSource)
{
LPASOBJPROPLIST pList = NULL;
if (!RPC_REALLOC (ASOBJPROPLIST, pList, aEntries, cEntriesAllocated, pListSource->cEntries, cREALLOC_OBJPROPLIST))
return NULL;
if (pList->cEntriesAllocated)
memcpy (pList->aEntries, pListSource->aEntries, sizeof(pList->aEntries[0]) * pList->cEntriesAllocated);
pList->cEntries = pListSource->cEntries;
return pList;
}
BOOL AfsAdmSvr_AddToObjPropList (LPASOBJPROPLIST *ppList, LPASOBJPROP pProperties, LPARAM lp)
{
if (!ppList || !*ppList)
return FALSE;
if (!RPC_REALLOC (ASOBJPROPLIST, *ppList, aEntries, cEntriesAllocated, (*ppList)->cEntries +1, cREALLOC_OBJPROPLIST))
return NULL;
memcpy (&(*ppList)->aEntries[ (*ppList)->cEntries ].ObjectProperties, pProperties, sizeof(ASOBJPROP));
(*ppList)->aEntries[ (*ppList)->cEntries ].lParam = lp;
(*ppList)->cEntries ++;
return TRUE;
}
BOOL AfsAdmSvr_RemoveFromObjPropList (LPASOBJPROPLIST *ppList, ASID idObject)
{
if (!ppList || !(*ppList) || !(*ppList)->cEntries)
return FALSE;
BOOL fFound = FALSE;
for (ULONG iEntry = 0; iEntry < (*ppList)->cEntries; )
{
if ((*ppList)->aEntries[ iEntry ].ObjectProperties.idObject != idObject)
iEntry ++;
else
{
fFound = TRUE;
if (iEntry < (*ppList)->cEntries -1)
memcpy (&(*ppList)->aEntries[ iEntry ], &(*ppList)->aEntries[ (*ppList)->cEntries-1 ], sizeof((*ppList)->aEntries[0]));
(*ppList)->cEntries --;
}
}
return fFound;
}
BOOL AfsAdmSvr_IsInObjPropList (LPASOBJPROPLIST *ppList, ASID idObject, LPASOBJPROP pProperties, LPARAM *pParam)
{
if (!ppList || !(*ppList) || !(*ppList)->cEntries)
return FALSE;
for (ULONG iEntry = 0; iEntry < (*ppList)->cEntries; ++iEntry)
{
if ((*ppList)->aEntries[ iEntry ].ObjectProperties.idObject == idObject)
{
if (pProperties)
memcpy (pProperties, &(*ppList)->aEntries[ iEntry ].ObjectProperties, sizeof(ASOBJPROP));
if (pParam)
*pParam = (*ppList)->aEntries[ iEntry ].lParam;
return TRUE;
}
}
return FALSE;
}
void AfsAdmSvr_FreeObjPropList (LPASOBJPROPLIST *ppList)
{
if (ppList && *ppList)
{
Free (*ppList);
(*ppList) = 0;
}
}
// ASACTIONLIST - Managed type for lists of cell objects
//
LPASACTIONLIST AfsAdmSvr_CreateActionList (void)
{
LPASACTIONLIST pList = NULL;
if (!RPC_REALLOC (ASACTIONLIST, pList, aEntries, cEntriesAllocated, 0, cREALLOC_ACTIONLIST))
return NULL;
return pList;
}
LPASACTIONLIST AfsAdmSvr_CopyActionList (LPASACTIONLIST pListSource)
{
LPASACTIONLIST pList = NULL;
if (!RPC_REALLOC (ASACTIONLIST, pList, aEntries, cEntriesAllocated, pListSource->cEntries, cREALLOC_ACTIONLIST))
return NULL;
if (pList->cEntriesAllocated)
memcpy (pList->aEntries, pListSource->aEntries, sizeof(pList->aEntries[0]) * pList->cEntriesAllocated);
pList->cEntries = pListSource->cEntries;
return pList;
}
BOOL AfsAdmSvr_AddToActionList (LPASACTIONLIST *ppList, LPASACTION pAction)
{
if (!ppList || !*ppList)
return FALSE;
if (!RPC_REALLOC (ASACTIONLIST, *ppList, aEntries, cEntriesAllocated, (*ppList)->cEntries +1, cREALLOC_OBJPROPLIST))
return NULL;
memcpy (&(*ppList)->aEntries[ (*ppList)->cEntries ].Action, pAction, sizeof(ASACTION));
(*ppList)->cEntries ++;
return TRUE;
}
BOOL AfsAdmSvr_RemoveFromActionList (LPASACTIONLIST *ppList, DWORD idAction)
{
if (!ppList || !(*ppList) || !(*ppList)->cEntries)
return FALSE;
BOOL fFound = FALSE;
for (ULONG iEntry = 0; iEntry < (*ppList)->cEntries; )
{
if ((*ppList)->aEntries[ iEntry ].Action.idAction != idAction)
iEntry ++;
else
{
fFound = TRUE;
if (iEntry < (*ppList)->cEntries -1)
memcpy (&(*ppList)->aEntries[ iEntry ], &(*ppList)->aEntries[ (*ppList)->cEntries-1 ], sizeof((*ppList)->aEntries[0]));
(*ppList)->cEntries --;
}
}
return fFound;
}
BOOL AfsAdmSvr_IsInActionList (LPASACTIONLIST *ppList, DWORD idAction, LPASACTION pAction)
{
if (!ppList || !(*ppList) || !(*ppList)->cEntries)
return FALSE;
for (ULONG iEntry = 0; iEntry < (*ppList)->cEntries; ++iEntry)
{
if ((*ppList)->aEntries[ iEntry ].Action.idAction == idAction)
{
if (pAction)
memcpy (pAction, &(*ppList)->aEntries[ iEntry ].Action, sizeof(ASACTION));
return TRUE;
}
}
return FALSE;
}
void AfsAdmSvr_FreeActionList (LPASACTIONLIST *ppList)
{
if (ppList && *ppList)
{
Free (*ppList);
(*ppList) = 0;
}
}

View File

@ -0,0 +1,41 @@
#ifndef TAAFSADMSVRCOMMON_H
#define TAAFSADMSVRCOMMON_H
/*
* PROTOTYPES _________________________________________________________________
*
*/
// ASIDLIST - Managed type for lists of cell objects
//
LPASIDLIST AfsAdmSvr_CreateAsidList (void);
LPASIDLIST AfsAdmSvr_CopyAsidList (LPASIDLIST pListSource);
BOOL AfsAdmSvr_AddToAsidList (LPASIDLIST *ppList, ASID idObject, LPARAM lp);
BOOL AfsAdmSvr_RemoveFromAsidList (LPASIDLIST *ppList, ASID idObject);
BOOL AfsAdmSvr_RemoveFromAsidListByIndex (LPASIDLIST *ppList, size_t iIndex);
BOOL AfsAdmSvr_SetAsidListParam (LPASIDLIST *ppList, ASID idObject, LPARAM lp);
BOOL AfsAdmSvr_SetAsidListParamByIndex (LPASIDLIST *ppList, size_t iIndex, LPARAM lp);
BOOL AfsAdmSvr_IsInAsidList (LPASIDLIST *ppList, ASID idObject, LPARAM *pParam = NULL);
void AfsAdmSvr_FreeAsidList (LPASIDLIST *ppList);
// ASOBJPROPLIST - Managed type for lists of cell objects
//
LPASOBJPROPLIST AfsAdmSvr_CreateObjPropList (void);
LPASOBJPROPLIST AfsAdmSvr_CopyObjPropList (LPASOBJPROPLIST pListSource);
BOOL AfsAdmSvr_AddToObjPropList (LPASOBJPROPLIST *ppList, LPASOBJPROP pProperties, LPARAM lp);
BOOL AfsAdmSvr_RemoveFromObjPropList (LPASOBJPROPLIST *ppList, ASID idObject);
BOOL AfsAdmSvr_IsInObjPropList (LPASOBJPROPLIST *ppList, ASID idObject, LPASOBJPROP pProperties = NULL, LPARAM *pParam = NULL);
void AfsAdmSvr_FreeObjPropList (LPASOBJPROPLIST *ppList);
// ASACTIONLIST - Managed type for lists of cell objects
//
LPASACTIONLIST AfsAdmSvr_CreateActionList (void);
LPASACTIONLIST AfsAdmSvr_CopyActionList (LPASACTIONLIST pListSource);
BOOL AfsAdmSvr_AddToActionList (LPASACTIONLIST *pLispt, LPASACTION pAction);
BOOL AfsAdmSvr_RemoveFromActionList (LPASACTIONLIST *ppList, DWORD idAction);
BOOL AfsAdmSvr_IsInActionList (LPASACTIONLIST *ppList, DWORD idAction, LPASACTION pAction = NULL);
void AfsAdmSvr_FreeActionList (LPASACTIONLIST *ppList);
#endif // TAAFSADMSVRCOMMON_H

View File

@ -0,0 +1,77 @@
extern "C" {
#include <afs/param.h>
#include <afs/stds.h>
}
#include "TaAfsAdmSvrInternal.h"
/*
* VARIABLES __________________________________________________________________
*
*/
static DWORD PrintDetailLevel = dlDEFAULT;
/*
* ROUTINES ___________________________________________________________________
*
*/
void cdecl vPrint (DWORD level, LPTSTR pszLine, va_list arg)
{
static LPCRITICAL_SECTION pcs = NULL;
if (!pcs)
{
pcs = New (CRITICAL_SECTION);
InitializeCriticalSection (pcs);
}
EnterCriticalSection (pcs);
if ((!level) || (PrintDetailLevel & level))
{
TCHAR szOut[ 1024 ];
wvsprintf (szOut, pszLine, arg);
printf ("AdmSvr: ");
if (!level)
printf (" * ");
if (level & dlINDENT1)
printf (" ");
if (level & dlINDENT2)
printf (" ");
printf ("%s\n", szOut);
}
LeaveCriticalSection (pcs);
}
void cdecl Print (LPTSTR pszLine, ...)
{
va_list arg;
va_start (arg, pszLine);
vPrint (dlSTANDARD, pszLine, arg);
}
void cdecl Print (DWORD level, LPTSTR pszLine, ...)
{
va_list arg;
va_start (arg, pszLine);
vPrint (level, pszLine, arg);
}
DWORD GetPrintDetailLevel (void)
{
return PrintDetailLevel;
}
void SetPrintDetailLevel (DWORD level)
{
PrintDetailLevel = level;
}

View File

@ -0,0 +1,51 @@
#ifndef TAAFSADMSVRDEBUG_H
#define TAAFSADMSVRDEBUG_H
/*
* INCLUSIONS _________________________________________________________________
*
*/
#include <WINNT/TaAfsAdmSvr.h>
/*
* DETAIL LEVELS ______________________________________________________________
*
*/
#define dlSTANDARD 0x00000001
#define dlWARNING 0x00000002
#define dlERROR 0x00000004
#define dlCONNECTION 0x00000008
#define dlOPERATION 0x00000010
#define dlDETAIL 0x00000020
#define dlDETAIL2 0x00000040
#define dlALL 0x00FFFFFF
#define dlINDENT1 0x01000000
#define dlINDENT2 0x02000000
#define dlINDENT3 0x03000000
#define dlRESERVED 0xFF000000
#ifdef DEBUG
#define dlDEFAULT (dlSTANDARD | dlERROR | dlWARNING | dlCONNECTION | dlOPERATION | dlDETAIL)
#else
#define dlDEFAULT (dlSTANDARD | dlERROR | dlCONNECTION)
#endif
/*
* PROTOTYPES _________________________________________________________________
*
*/
extern void cdecl Print (DWORD dwLevel, LPTSTR pszLine, ...);
extern void cdecl Print (LPTSTR pszLine, ...);
extern DWORD GetPrintDetailLevel (DWORD dwLevel);
extern void SetPrintDetailLevel (DWORD dwLevel);
#endif // TAAFSADMSVRDEBUG_H

View File

@ -0,0 +1,742 @@
extern "C" {
#include <afs/param.h>
#include <afs/stds.h>
}
#include "TaAfsAdmSvrInternal.h"
extern "C" {
#include <afs/afs_AdminErrors.h>
} // extern "C"
/*
* VARIABLES __________________________________________________________________
*
*/
#define cminREQ_CLIENT_PING (csecAFSADMSVR_CLIENT_PING * 2L / 60L)
#define cREALLOC_CLIENTS 1
#define cREALLOC_OPERATIONS 16
#define cminAUTO_SHUTDOWN 2 // stop if idle for more than 2min
#define cminAUTO_SHUTDOWN_SLEEP 1 // test for stop every minute
typedef struct
{
TCHAR szName[ cchSTRING ];
SOCKADDR_IN ipAddress;
DWORD timeLastPing;
} CLIENTINFO, *LPCLIENTINFO;
typedef struct
{
BOOL fInUse;
DWORD idClient;
LPASACTION pAction;
DWORD dwTickStart;
} OPERATION, *LPOPERATION;
static struct
{
BOOL fOperational;
LPCRITICAL_SECTION pcsAfsAdmSvr;
LPCLIENTINFO *aClients;
size_t cClients;
size_t cClientsAllocated;
LPNOTIFYCALLBACK pNotify;
BOOL fAutoShutdown;
HANDLE hThreadShutdown;
DWORD timeLastIdleStart;
OPERATION *aOperations;
size_t cOperations;
size_t cOperationsAllocated;
DWORD idActionLast;
DWORD dwScopeMin;
} l;
/*
* PROTOTYPES _________________________________________________________________
*
*/
void AfsAdmSvr_TestShutdown (void);
DWORD WINAPI AfsAdmSvr_AutoShutdownThread (LPVOID lp);
/*
* SYNCHRONIZATION ____________________________________________________________
*
*/
void AfsAdmSvr_Enter (void)
{
if (!l.pcsAfsAdmSvr)
{
l.pcsAfsAdmSvr = New (CRITICAL_SECTION);
InitializeCriticalSection (l.pcsAfsAdmSvr);
}
EnterCriticalSection (l.pcsAfsAdmSvr);
}
void AfsAdmSvr_Leave (void)
{
LeaveCriticalSection (l.pcsAfsAdmSvr);
}
/*
* CLIENT INFORMATION _________________________________________________________
*
*/
BOOL AfsAdmSvr_fIsValidClient (DWORD idClient)
{
BOOL rc = FALSE;
AfsAdmSvr_Enter();
for (size_t iClient = 0; !rc && iClient < l.cClientsAllocated; ++iClient)
{
if (idClient == (DWORD)(l.aClients[ iClient ]))
{
if (l.aClients[ iClient ]->timeLastPing + cminREQ_CLIENT_PING > AfsAdmSvr_GetCurrentTime())
rc = TRUE;
}
}
AfsAdmSvr_Leave();
return rc;
}
BOOL AfsAdmSvr_AttachClient (LPCTSTR pszName, DWORD *pidClient, ULONG *pStatus)
{
AfsAdmSvr_Enter();
for (size_t iClient = 0; iClient < l.cClientsAllocated; ++iClient)
{
if (!l.aClients[ iClient ])
break;
}
if (!REALLOC (l.aClients, l.cClientsAllocated, 1+iClient, cREALLOC_CLIENTS))
{
*pidClient = 0;
return FALSE;
}
if ((l.aClients[ iClient ] = New (CLIENTINFO)) == NULL)
{
*pidClient = 0;
return FALSE;
}
memset (l.aClients[ iClient ], 0x00, sizeof(CLIENTINFO));
lstrcpy (l.aClients[ iClient ]->szName, pszName);
l.aClients[ iClient ]->timeLastPing = AfsAdmSvr_GetCurrentTime();
l.cClients ++;
if (!AfsAdmSvr_ResolveName (&l.aClients[ iClient ]->ipAddress, l.aClients[ iClient ]->szName))
memset (&l.aClients[ iClient ]->ipAddress, 0x00, sizeof(SOCKADDR_IN));
*pidClient = (DWORD)(l.aClients[ iClient ]);
AfsAdmSvr_Leave();
return TRUE;
}
void AfsAdmSvr_DetachClient (DWORD idClient)
{
AfsAdmSvr_Enter();
for (size_t iClient = 0; iClient < l.cClientsAllocated; ++iClient)
{
if (idClient == (DWORD)(l.aClients[ iClient ]))
break;
}
if (iClient < l.cClientsAllocated)
{
Delete (l.aClients[ iClient ]);
l.aClients[ iClient ] = NULL;
l.cClients --;
}
AfsAdmSvr_TestShutdown();
AfsAdmSvr_Leave();
}
LPCTSTR AfsAdmSvr_GetClientName (DWORD idClient)
{
static TCHAR szName[ cchSTRING ];
LPCTSTR pszName = NULL;
AfsAdmSvr_Enter();
for (size_t iClient = 0; !pszName && iClient < l.cClientsAllocated; ++iClient)
{
if (idClient == (DWORD)(l.aClients[ iClient ]))
{
lstrcpy (szName, l.aClients[ iClient ]->szName);
pszName = szName;
}
}
AfsAdmSvr_Leave();
return pszName;
}
LPSOCKADDR_IN AfsAdmSvr_GetClientAddress (DWORD idClient)
{
static SOCKADDR_IN ipAddress;
LPSOCKADDR_IN pAddress = NULL;
AfsAdmSvr_Enter();
for (size_t iClient = 0; !pAddress && iClient < l.cClientsAllocated; ++iClient)
{
if (idClient == (DWORD)(l.aClients[ iClient ]))
{
memcpy (&ipAddress, &l.aClients[ iClient ]->ipAddress, sizeof(SOCKADDR_IN));
pAddress = &ipAddress;
}
}
AfsAdmSvr_Leave();
return pAddress;
}
void AfsAdmSvr_PingClient (DWORD idClient)
{
AfsAdmSvr_Enter();
for (size_t iClient = 0; iClient < l.cClientsAllocated; ++iClient)
{
if (idClient == (DWORD)(l.aClients[ iClient ]))
{
l.aClients[ iClient ]->timeLastPing = AfsAdmSvr_GetCurrentTime();
}
}
AfsAdmSvr_Leave();
}
DWORD AfsAdmSvr_GetCurrentTime (void) // returns counter in ~minute increments
{
static WORD wMonthish = 0; // One "Monthish" is 49.7 days
static WORD wTickLast = 0;
DWORD dwTick = GetTickCount();
WORD wTickNow = HIWORD(dwTick);
if (wTickNow < wTickLast) // wrapped over a Monthish?
++wMonthish;
wTickLast = wTickNow;
return MAKELONG(wTickNow,wMonthish);
}
/*
* STARTUP/SHUTDOWN ___________________________________________________________
*
*/
void AfsAdmSvr_Startup (void)
{
l.pNotify = New2 (NOTIFYCALLBACK,(AfsAdmSvr_NotifyCallback, 0));
l.fOperational = FALSE;
ULONG status;
if (AfsClass_Initialize (&status))
l.fOperational = TRUE;
else
{
Print (dlERROR, TEXT("Could not initialize AfsClass (fatal error 0x%08lX)"), status);
Print (dlERROR, TEXT("Remaining active to tell potential clients about the problem"));
}
if (!l.hThreadShutdown)
{
DWORD dwThreadID;
l.hThreadShutdown = CreateThread (NULL, 0, (LPTHREAD_START_ROUTINE)AfsAdmSvr_AutoShutdownThread, (LPVOID)0, 0, &dwThreadID);
}
}
void AfsAdmSvr_Shutdown (void)
{
Delete (l.pNotify);
l.pNotify = NULL;
l.fOperational = FALSE;
}
/*
* GENERAL ____________________________________________________________________
*
*/
BOOL FALSE_ (ULONG status, ULONG *pStatus, size_t iOp)
{
if (pStatus)
*pStatus = status;
if (iOp != (size_t)-2)
AfsAdmSvr_EndOperation (iOp);
return FALSE;
}
BOOL Leave_FALSE_ (ULONG status, ULONG *pStatus, size_t iOp)
{
AfsAdmSvr_Leave();
if (pStatus)
*pStatus = status;
if (iOp != (size_t)-2)
AfsAdmSvr_EndOperation (iOp);
return FALSE;
}
BOOL TRUE_ (ULONG *pStatus, size_t iOp)
{
if (pStatus)
*pStatus = 0;
if (iOp != (size_t)-2)
AfsAdmSvr_EndOperation (iOp);
return TRUE;
}
BOOL Leave_TRUE_ (ULONG *pStatus, size_t iOp)
{
AfsAdmSvr_Leave();
if (pStatus)
*pStatus = 0;
if (iOp != (size_t)-2)
AfsAdmSvr_EndOperation (iOp);
return TRUE;
}
IDENTTYPE GetAsidType (ASID idObject)
{
IDENTTYPE iType;
try {
iType = ((LPIDENT)idObject)->GetType();
} catch(...) {
iType = itUNUSED;
}
return iType;
}
BOOL AfsAdmSvr_ResolveName (LPSOCKADDR_IN pAddress, LPTSTR pszName)
{
if ((pszName[0] >= TEXT('0')) && (pszName[0] <= TEXT('9')))
{
int ipAddress;
if ((ipAddress = inet_addr (pszName)) == INADDR_NONE)
return FALSE;
memset (pAddress, 0x00, sizeof(SOCKADDR_IN));
pAddress->sin_family = AF_INET;
pAddress->sin_addr.s_addr = ipAddress;
HOSTENT *pEntry;
if ((pEntry = gethostbyaddr ((char*)&ipAddress, sizeof(ipAddress), AF_INET)) != NULL)
lstrcpy (pszName, pEntry->h_name);
}
else // (!isdigit(szServer[0]))
{
HOSTENT *pEntry;
if ((pEntry = gethostbyname (pszName)) == NULL)
return FALSE;
memset (pAddress, 0x00, sizeof(SOCKADDR_IN));
pAddress->sin_family = AF_INET;
pAddress->sin_addr.s_addr = *(int *)pEntry->h_addr;
lstrcpy (pszName, pEntry->h_name);
}
return TRUE;
}
/*
* AUTO-SHUTDOWN ______________________________________________________________
*
*/
DWORD WINAPI AfsAdmSvr_AutoShutdownThread (LPVOID lp)
{
for (;;)
{
AfsAdmSvr_Enter();
BOOL fShutdown = l.fAutoShutdown;
// If there are any clients connected, forcably disconnect any
// that haven't pinged us for too long
//
for (size_t iClient = 0; iClient < l.cClientsAllocated; ++iClient)
{
if (!l.aClients[ iClient ])
continue;
if (l.aClients[ iClient ]->timeLastPing + cminREQ_CLIENT_PING <= AfsAdmSvr_GetCurrentTime())
{
Print (dlCONNECTION, "Client 0x%08lX idle for too long; detaching", l.aClients[ iClient ]);
AfsAdmSvr_DetachClient ((DWORD)l.aClients[ iClient ]);
}
}
// If any operations are in progress, we can't shutdown.
//
if (l.cOperations)
fShutdown = FALSE;
// If any clients are still connected, we can't shutdown.
//
if (l.cClients)
fShutdown = FALSE;
// If we haven't been idle long enough, we can't shutdown
//
if (!l.timeLastIdleStart)
fShutdown = FALSE;
else if (l.timeLastIdleStart + cminAUTO_SHUTDOWN > AfsAdmSvr_GetCurrentTime())
fShutdown = FALSE;
// That's it; can we stop now?
//
if (fShutdown)
{
Print ("Idle for too long; shutting down.");
RpcMgmtStopServerListening (NULL);
AfsAdmSvr_StopCallbackManagers();
}
AfsAdmSvr_Leave();
if (fShutdown)
break;
Sleep (cminAUTO_SHUTDOWN_SLEEP * 60L * 1000L);
}
return 0;
}
void AfsAdmSvr_EnableAutoShutdown (BOOL fEnable)
{
AfsAdmSvr_Enter();
l.fAutoShutdown = fEnable;
if (fEnable)
Print (dlDETAIL, TEXT("Auto-shutdown enabled, trigger = %lu minutes idle time"), cminAUTO_SHUTDOWN);
else
Print (dlDETAIL, TEXT("Auto-shutdown on idle disabled"));
AfsAdmSvr_Leave();
}
void AfsAdmSvr_TestShutdown (void)
{
if (!l.cOperations && !l.cClients)
{
l.timeLastIdleStart = AfsAdmSvr_GetCurrentTime();
}
}
size_t AfsAdmSvr_BeginOperation (DWORD idClient, LPASACTION pAction)
{
AfsAdmSvr_Enter();
++l.cOperations;
for (size_t iOp = 0; iOp < l.cOperationsAllocated; ++iOp)
{
if (!l.aOperations[ iOp ].fInUse)
break;
}
if (!REALLOC (l.aOperations, l.cOperationsAllocated, 1+iOp, cREALLOC_OPERATIONS))
{
AfsAdmSvr_Leave();
return (size_t)(-1);
}
l.aOperations[ iOp ].idClient = idClient;
l.aOperations[ iOp ].pAction = NULL;
l.aOperations[ iOp ].fInUse = TRUE;
if (pAction)
{
l.aOperations[ iOp ].pAction = New (ASACTION);
memcpy (l.aOperations[ iOp ].pAction, pAction, sizeof(ASACTION));
l.aOperations[ iOp ].pAction->idAction = ++l.idActionLast;
l.aOperations[ iOp ].pAction->idClient = idClient;
l.aOperations[ iOp ].pAction->csecActive = 0;
TCHAR szDesc[256];
switch (l.aOperations[ iOp ].pAction->Action)
{
case ACTION_REFRESH:
wsprintf (szDesc, TEXT("Refresh (scope=0x%08lX)"), l.aOperations[ iOp ].pAction->u.Refresh.idScope);
break;
case ACTION_SCOUT:
wsprintf (szDesc, TEXT("Scout (scope=0x%08lX)"), l.aOperations[ iOp ].pAction->u.Refresh.idScope);
break;
case ACTION_USER_CHANGE:
wsprintf (szDesc, TEXT("ChangeUser (user=0x%08lX)"), l.aOperations[ iOp ].pAction->u.User_Change.idUser);
break;
case ACTION_USER_PW_CHANGE:
wsprintf (szDesc, TEXT("SetUserPassword (user=0x%08lX)"), l.aOperations[ iOp ].pAction->u.User_Pw_Change.idUser);
break;
case ACTION_USER_UNLOCK:
wsprintf (szDesc, TEXT("UnlockUser (user=0x%08lX)"), l.aOperations[ iOp ].pAction->u.User_Unlock.idUser);
break;
case ACTION_USER_CREATE:
wsprintf (szDesc, TEXT("CreateUser (user=%s)"), l.aOperations[ iOp ].pAction->u.User_Create.szUser);
break;
case ACTION_USER_DELETE:
wsprintf (szDesc, TEXT("CreateUser (user=0x%08lX)"), l.aOperations[ iOp ].pAction->u.User_Delete.idUser);
break;
case ACTION_GROUP_CHANGE:
wsprintf (szDesc, TEXT("ChangeGroup (group=0x%08lX)"), l.aOperations[ iOp ].pAction->u.Group_Change.idGroup);
break;
case ACTION_GROUP_MEMBER_ADD:
wsprintf (szDesc, TEXT("AddGroupMember (group=0x%08lX, user=0x%08lX)"), l.aOperations[ iOp ].pAction->u.Group_Member_Add.idGroup, l.aOperations[ iOp ].pAction->u.Group_Member_Add.idUser);
break;
case ACTION_GROUP_MEMBER_REMOVE:
wsprintf (szDesc, TEXT("RemoveGroupMember (group=0x%08lX, user=0x%08lX)"), l.aOperations[ iOp ].pAction->u.Group_Member_Remove.idGroup, l.aOperations[ iOp ].pAction->u.Group_Member_Remove.idUser);
break;
case ACTION_GROUP_RENAME:
wsprintf (szDesc, TEXT("RenameGroup (group=0x%08lX, new name=%s)"), l.aOperations[ iOp ].pAction->u.Group_Rename.idGroup, l.aOperations[ iOp ].pAction->u.Group_Rename.szNewName);
break;
case ACTION_GROUP_DELETE:
wsprintf (szDesc, TEXT("CreateGroup (group=0x%08lX)"), l.aOperations[ iOp ].pAction->u.Group_Delete.idGroup);
break;
case ACTION_CELL_CHANGE:
wsprintf (szDesc, TEXT("ChangeCell (cell=0x%08lX)"), l.aOperations[ iOp ].pAction->idCell);
break;
default:
wsprintf (szDesc, TEXT("Unknown Action (#%lu)"), l.aOperations[ iOp ].pAction->Action);
break;
}
Print (dlOPERATION, TEXT("Starting action 0x%08lX: %s"), l.aOperations[ iOp ].pAction->idAction, szDesc);
AfsAdmSvr_PostCallback (cbtACTION, FALSE, l.aOperations[ iOp ].pAction);
}
l.aOperations[ iOp ].dwTickStart = GetTickCount();
AfsAdmSvr_Leave();
return iOp;
}
void AfsAdmSvr_EndOperation (size_t iOp)
{
AfsAdmSvr_Enter();
if ((iOp != (size_t)-1) && (iOp < l.cOperationsAllocated) && (l.aOperations[ iOp ].fInUse))
{
if (l.aOperations[ iOp ].pAction)
{
Print (dlOPERATION, TEXT("Ending action 0x%08lX"), l.aOperations[ iOp ].pAction->idAction);
AfsAdmSvr_PostCallback (cbtACTION, TRUE, l.aOperations[ iOp ].pAction);
Delete (l.aOperations[ iOp ].pAction);
}
memset (&l.aOperations[ iOp ], 0x00, sizeof(l.aOperations[ iOp ]));
l.cOperations --;
}
AfsAdmSvr_TestShutdown();
AfsAdmSvr_Leave();
}
BOOL AfsAdmSvr_GetOperation (DWORD idAction, LPASACTION pAction)
{
AfsAdmSvr_Enter();
for (size_t iOp = 0; iOp < l.cOperationsAllocated; ++iOp)
{
if (!l.aOperations[ iOp ].fInUse)
continue;
if (!l.aOperations[ iOp ].pAction)
continue;
if (l.aOperations[ iOp ].pAction->idAction != idAction)
continue;
memcpy (pAction, l.aOperations[ iOp ].pAction, sizeof(ASACTION));
pAction->csecActive = (GetTickCount() - l.aOperations[ iOp ].dwTickStart) / 1000;
AfsAdmSvr_Leave();
return TRUE;
}
AfsAdmSvr_Leave();
return FALSE;
}
LPASACTIONLIST AfsAdmSvr_GetOperations (DWORD idClientSearch, ASID idCellSearch)
{
LPASACTIONLIST pList = AfsAdmSvr_CreateActionList();
AfsAdmSvr_Enter();
for (size_t iOp = 0; iOp < l.cOperationsAllocated; ++iOp)
{
if (!l.aOperations[ iOp ].fInUse)
continue;
if (!l.aOperations[ iOp ].pAction)
continue;
if (idClientSearch && (idClientSearch != l.aOperations[ iOp ].pAction->idClient))
continue;
if (idCellSearch && (idCellSearch != l.aOperations[ iOp ].pAction->idCell))
continue;
ASACTION Action;
memcpy (&Action, l.aOperations[ iOp ].pAction, sizeof(ASACTION));
Action.csecActive = (GetTickCount() - l.aOperations[ iOp ].dwTickStart) / 1000;
if (!AfsAdmSvr_AddToActionList (&pList, &Action))
{
AfsAdmSvr_FreeActionList (&pList);
break;
}
}
AfsAdmSvr_Leave();
return pList;
}
void AfsAdmSvr_Action_StartRefresh (ASID idScope)
{
switch (GetAsidType (idScope))
{
case itCELL:
AfsAdmSvr_MarkRefreshThread (idScope);
// fall through
case itSERVER:
ASACTION Action;
memset (&Action, 0x00, sizeof(Action));
Action.Action = ACTION_REFRESH;
Action.idCell = (ASID)( ((LPIDENT)idScope)->GetCell() );
Action.u.Refresh.idScope = idScope;
(void)AfsAdmSvr_BeginOperation (0, &Action);
break;
default:
// Don't bother listing status-refreshes as ongoing operations
// for any granularity smaller than the server; they'll occur
// really frequently, and finish really quickly.
break;
}
}
void AfsAdmSvr_Action_StopRefresh (ASID idScope)
{
AfsAdmSvr_Enter();
for (size_t iOp = 0; iOp < l.cOperationsAllocated; ++iOp)
{
if (!l.aOperations[ iOp ].fInUse)
continue;
if (!l.aOperations[ iOp ].pAction)
continue;
if (l.aOperations[ iOp ].pAction->Action != ACTION_REFRESH)
continue;
if (l.aOperations[ iOp ].pAction->u.Refresh.idScope != idScope)
continue;
AfsAdmSvr_EndOperation (iOp);
break;
}
if (GetAsidType (idScope) == itCELL)
{
AfsAdmSvr_MarkRefreshThread (idScope);
}
AfsAdmSvr_Leave();
}
DWORD WINAPI AfsAdmSvr_AutoOpen_ThreadProc (PVOID lp)
{
DWORD dwScope = (DWORD)lp;
ULONG status;
if (!l.fOperational)
return 0;
// First we'll have to find out which cell to open
//
TCHAR szCell[ cchNAME ];
if (!CELL::GetDefaultCell (szCell, &status))
{
Print (dlERROR, TEXT("CELL::GetDefaultCell failed; error 0x%08lX"), status);
}
else
{
// Then try to actually open the cell
//
Print (dlSTANDARD, TEXT("Auto-opening cell %s; scope=%s"), szCell, (dwScope == (AFSADMSVR_SCOPE_VOLUMES | AFSADMSVR_SCOPE_USERS)) ? TEXT("full") : (dwScope == AFSADMSVR_SCOPE_VOLUMES) ? TEXT("volumes") : TEXT("users"));
LPIDENT lpiCell;
if ((lpiCell = CELL::OpenCell ((LPTSTR)szCell, &status)) == NULL)
{
Print (dlERROR, TEXT("Auto-open of cell %s failed; error 0x%08lX"), szCell, status);
}
else
{
LPCELL lpCell;
if ((lpCell = lpiCell->OpenCell (&status)) == NULL)
{
Print (dlERROR, TEXT("Auto-open: OpenCell failed; error 0x%08lX"), status);
}
else
{
AfsAdmSvr_AddToMinScope (dwScope);
if (!lpCell->RefreshAll (&status))
Print (dlERROR, TEXT("Auto-open: RefreshCell failed; error 0x%08lX"), status);
else
Print (dlSTANDARD, TEXT("Auto-open of cell %s successful"), szCell);
lpCell->Close();
// We intentionally do not call CELL::CloseCell() here--as would
// ordinarily be necessary to balance our CELL::OpenCell() call
// above--because we never want to close our cache for this cell.
// The point of calling AutoOpen() up front is to keep an admin
// server alive and ready for use on a particular cell--calling
// CELL::CloseCell() here negates that purpose.
}
}
}
return 0;
}
void AfsAdmSvr_AddToMinScope (DWORD dwScope)
{
l.dwScopeMin |= dwScope;
AfsClass_SpecifyRefreshDomain (l.dwScopeMin);
}
void AfsAdmSvr_SetMinScope (DWORD dwScope)
{
l.dwScopeMin = dwScope;
}
DWORD AfsAdmSvr_GetMinScope (void)
{
return l.dwScopeMin;
}

View File

@ -0,0 +1,56 @@
#ifndef TAAFSADMSVRGENERAL_H
#define TAAFSADMSVRGENERAL_H
/*
* INCLUSIONS _________________________________________________________________
*
*/
#include <WINNT/TaAfsAdmSvr.h>
/*
* PROTOTYPES _________________________________________________________________
*
*/
void AfsAdmSvr_Enter (void);
void AfsAdmSvr_Leave (void);
void AfsAdmSvr_Startup (void);
void AfsAdmSvr_Shutdown (void);
void AfsAdmSvr_EnableAutoShutdown (BOOL fEnable);
size_t AfsAdmSvr_BeginOperation (DWORD idClient, LPASACTION pAction = NULL);
void AfsAdmSvr_EndOperation (size_t iOp);
BOOL AfsAdmSvr_GetOperation (DWORD idAction, LPASACTION pAction);
LPASACTIONLIST AfsAdmSvr_GetOperations (DWORD idClientSearch = 0, ASID idCellSearch = 0);
void AfsAdmSvr_Action_StartRefresh (ASID idScope);
void AfsAdmSvr_Action_StopRefresh (ASID idScope);
BOOL AfsAdmSvr_fIsValidClient (DWORD idClient);
BOOL AfsAdmSvr_AttachClient (LPCTSTR pszName, DWORD *pidClient, ULONG *pStatus);
void AfsAdmSvr_DetachClient (DWORD idClient);
LPCTSTR AfsAdmSvr_GetClientName (DWORD idClient);
LPSOCKADDR_IN AfsAdmSvr_GetClientAddress (DWORD idClient);
void AfsAdmSvr_PingClient (DWORD idClient);
BOOL FALSE_ (ULONG status, ULONG *pStatus, size_t iOp = (size_t)-2);
BOOL Leave_FALSE_ (ULONG status, ULONG *pStatus, size_t iOp = (size_t)-2);
BOOL TRUE_ (ULONG *pStatus, size_t iOp = (size_t)-2);
BOOL Leave_TRUE_ (ULONG *pStatus, size_t iOp = (size_t)-2);
IDENTTYPE GetAsidType (ASID idObject);
BOOL AfsAdmSvr_ResolveName (LPSOCKADDR_IN pAddress, LPTSTR pszName);
DWORD WINAPI AfsAdmSvr_AutoOpen_ThreadProc (PVOID lp);
void AfsAdmSvr_AddToMinScope (DWORD dwScope);
void AfsAdmSvr_SetMinScope (DWORD dwScope);
DWORD AfsAdmSvr_GetMinScope (void);
void AfsAdmSvr_CallbackManager (void);
DWORD AfsAdmSvr_GetCurrentTime (void);
#endif // TAAFSADMSVRGENERAL_H

View File

@ -0,0 +1,450 @@
extern "C" {
#include <afs/param.h>
#include <afs/stds.h>
}
#include "TaAfsAdmSvrInternal.h"
/*
* ROUTINES ___________________________________________________________________
*
*/
// AfsAdmSvr_ChangeGroup
// ...changes a group account's properties.
//
int AfsAdmSvr_ChangeGroup (DWORD idClient, ASID idCell, ASID idGroup, LPAFSADMSVR_CHANGEGROUP_PARAMS pChange, ULONG *pStatus)
{
ASACTION Action;
Action.Action = ACTION_GROUP_CHANGE;
Action.idClient = idClient;
Action.idCell = idCell;
Action.u.Group_Change.idGroup = idGroup;
size_t iOp = AfsAdmSvr_BeginOperation (idClient, &Action);
Print (dlDETAIL, TEXT("Client 0x%08lX: ChangeGroup (idGroup=0x%08lX)"), idClient, idGroup);
if (!AfsAdmSvr_fIsValidClient (idClient))
return FALSE_(ERROR_INVALID_PARAMETER,pStatus,iOp);
// Find this group's current properties
//
LPASOBJPROP pCurrentProperties;
if ((pCurrentProperties = AfsAdmSvr_GetCurrentProperties (idGroup, pStatus)) == NULL)
{
Print (dlERROR, TEXT("Client 0x%08lX: ChangeGroup failed; no properties"), idClient);
AfsAdmSvr_EndOperation (iOp);
return FALSE;
}
// Build an AFSCLASS-style GROUPPROPERTIES structure that reflects the
// new properties for the user; mark the structure's dwMask bit to indicate
// what we're changing.
//
GROUPPROPERTIES NewProperties;
memset (&NewProperties, 0x00, sizeof(NewProperties));
if (!pChange->szOwner[0])
lstrcpy (NewProperties.szOwner, pCurrentProperties->u.GroupProperties.szOwner);
else
{
lstrcpy (NewProperties.szOwner, pChange->szOwner);
if (lstrcmpi (NewProperties.szOwner, pCurrentProperties->u.GroupProperties.szOwner))
NewProperties.dwMask |= MASK_GROUPPROP_szOwner;
}
if ((NewProperties.aaListStatus = pChange->aaListStatus) != pCurrentProperties->u.GroupProperties.aaListStatus)
NewProperties.dwMask |= MASK_GROUPPROP_aaListStatus;
if ((NewProperties.aaListGroupsOwned = pChange->aaListGroupsOwned) != pCurrentProperties->u.GroupProperties.aaListGroupsOwned)
NewProperties.dwMask |= MASK_GROUPPROP_aaListGroupsOwned;
if ((NewProperties.aaListMembers = pChange->aaListMembers) != pCurrentProperties->u.GroupProperties.aaListMembers)
NewProperties.dwMask |= MASK_GROUPPROP_aaListMembers;
if ((NewProperties.aaAddMember = pChange->aaAddMember) != pCurrentProperties->u.GroupProperties.aaAddMember)
NewProperties.dwMask |= MASK_GROUPPROP_aaAddMember;
if ((NewProperties.aaDeleteMember = pChange->aaDeleteMember) != pCurrentProperties->u.GroupProperties.aaDeleteMember)
NewProperties.dwMask |= MASK_GROUPPROP_aaDeleteMember;
// If we've decided to change anything, call AfsClass to actually do it
//
if (NewProperties.dwMask == 0)
{
Print (dlDETAIL, TEXT("Client 0x%08lX: ChangeGroup succeeded (nothing to do)"), idClient);
}
else
{
ULONG status;
if (!AfsClass_SetGroupProperties ((LPIDENT)idGroup, &NewProperties, &status))
{
Print (dlERROR, TEXT("Client 0x%08lX: ChangeGroup failed; error 0x%08lX"), idClient, status);
return FALSE_(status,pStatus,iOp);
}
Print (dlDETAIL, TEXT("Client 0x%08lX: ChangeGroup succeeded"), idClient);
}
AfsAdmSvr_EndOperation (iOp);
return TRUE;
}
// AfsAdmSvr_GetGroupMembers
// ...retrieves the list of users which belong to a group
//
int AfsAdmSvr_GetGroupMembers (DWORD idClient, ASID idCell, ASID idGroup, LPASIDLIST *ppAsidList, ULONG *pStatus)
{
size_t iOp = AfsAdmSvr_BeginOperation (idClient);
Print (dlDETAIL, TEXT("Client 0x%08lX: GetGroupMembers (idGroup=0x%08lX)"), idClient, idGroup);
if (!AfsAdmSvr_fIsValidClient (idClient))
return FALSE_(ERROR_INVALID_PARAMETER,pStatus,iOp);
// Use AfsClass to get the list of group members
//
if (GetAsidType (idGroup) != itGROUP)
return FALSE_(ERROR_INVALID_PARAMETER,pStatus,iOp);
ULONG status;
LPPTSGROUP lpGroup;
if ((lpGroup = ((LPIDENT)idGroup)->OpenGroup (&status)) == NULL)
return FALSE_(status,pStatus,iOp);
LPTSTR pmszUsers = NULL;
lpGroup->GetMembers (&pmszUsers);
lpGroup->Close();
// Then translate those user names into an ASID list
//
if ((*ppAsidList = AfsAdmSvr_CreateAsidList()) == NULL)
{
if (pmszUsers)
FreeString (pmszUsers);
return FALSE_(ERROR_NOT_ENOUGH_MEMORY,pStatus,iOp);
}
if (pmszUsers)
{
for (LPTSTR psz = pmszUsers; psz && *psz; psz += 1+lstrlen(psz))
{
LPIDENT lpi;
if ((lpi = IDENT::FindGroup ((LPIDENT)idCell, psz)) == NULL)
{
TCHAR szName[ cchNAME ];
TCHAR szInstance[ cchNAME ];
USER::SplitUserName (psz, szName, szInstance);
if ((lpi = IDENT::FindUser ((LPIDENT)idCell, szName, szInstance)) == NULL)
{
continue;
}
}
AfsAdmSvr_AddToAsidList (ppAsidList, (ASID)lpi, 0);
}
FreeString (pmszUsers);
}
Print (dlDETAIL, TEXT("Client 0x%08lX: GetGroupMembers succeeded"), idClient);
AfsAdmSvr_EndOperation (iOp);
return TRUE;
}
// AfsAdmSvr_GetGroupMembership
// ...retrieves the list of groups to which a user or group belongs
//
int AfsAdmSvr_GetGroupMembership (DWORD idClient, ASID idCell, ASID idMember, LPASIDLIST *ppAsidList, ULONG *pStatus)
{
size_t iOp = AfsAdmSvr_BeginOperation (idClient);
Print (dlDETAIL, TEXT("Client 0x%08lX: GetGroupMembership (idMember=0x%08lX)"), idClient, idMember);
if (!AfsAdmSvr_fIsValidClient (idClient))
return FALSE_(ERROR_INVALID_PARAMETER,pStatus,iOp);
// Use AfsClass to get the appropriate list of groups
//
ULONG status;
LPTSTR pmszGroups = NULL;
if (GetAsidType (idMember) == itUSER)
{
LPUSER lpUser;
if ((lpUser = ((LPIDENT)idMember)->OpenUser (&status)) == NULL)
return FALSE_(status,pStatus,iOp);
lpUser->GetMemberOf (&pmszGroups);
lpUser->Close();
}
else if (GetAsidType (idMember) == itGROUP)
{
LPPTSGROUP lpGroup;
if ((lpGroup = ((LPIDENT)idMember)->OpenGroup (&status)) == NULL)
return FALSE_(status,pStatus,iOp);
lpGroup->GetMemberOf (&pmszGroups);
lpGroup->Close();
}
else // bogus type
{
return FALSE_(ERROR_INVALID_PARAMETER,pStatus,iOp);
}
// Then translate those group names into an ASID list
//
if ((*ppAsidList = AfsAdmSvr_CreateAsidList()) == NULL)
{
if (pmszGroups)
FreeString (pmszGroups);
return FALSE_(ERROR_NOT_ENOUGH_MEMORY,pStatus,iOp);
}
if (pmszGroups)
{
for (LPTSTR psz = pmszGroups; psz && *psz; psz += 1+lstrlen(psz))
{
LPIDENT lpi;
if ((lpi = IDENT::FindGroup ((LPIDENT)idCell, psz)) == NULL)
continue;
AfsAdmSvr_AddToAsidList (ppAsidList, (ASID)lpi, 0);
}
FreeString (pmszGroups);
}
Print (dlDETAIL, TEXT("Client 0x%08lX: GetGroupMembership succeeded"), idClient);
AfsAdmSvr_EndOperation (iOp);
return TRUE;
}
// AfsAdmSvr_GetGroupOwnership
// ...retrieves the list of groups which a user owns
//
int AfsAdmSvr_GetGroupOwnership (DWORD idClient, ASID idCell, ASID idOwner, LPASIDLIST *ppAsidList, ULONG *pStatus)
{
size_t iOp = AfsAdmSvr_BeginOperation (idClient);
Print (dlDETAIL, TEXT("Client 0x%08lX: GetGroupOwnership (idOwner=0x%08lX)"), idClient, idOwner);
if (!AfsAdmSvr_fIsValidClient (idClient))
return FALSE_(ERROR_INVALID_PARAMETER,pStatus,iOp);
// Use AfsClass to get the appropriate list of groups
//
ULONG status;
LPTSTR pmszGroups = NULL;
if (GetAsidType (idOwner) == itUSER)
{
LPUSER lpUser;
if ((lpUser = ((LPIDENT)idOwner)->OpenUser (&status)) == NULL)
return FALSE_(status,pStatus,iOp);
lpUser->GetOwnerOf (&pmszGroups);
lpUser->Close();
}
else if (GetAsidType (idOwner) == itGROUP)
{
LPPTSGROUP lpGroup;
if ((lpGroup = ((LPIDENT)idOwner)->OpenGroup (&status)) == NULL)
return FALSE_(status,pStatus,iOp);
lpGroup->GetOwnerOf (&pmszGroups);
lpGroup->Close();
}
else // bogus type
{
return FALSE_(ERROR_INVALID_PARAMETER,pStatus,iOp);
}
// Then translate those group names into an ASID list
//
if ((*ppAsidList = AfsAdmSvr_CreateAsidList()) == NULL)
{
if (pmszGroups)
FreeString (pmszGroups);
return FALSE_(ERROR_NOT_ENOUGH_MEMORY,pStatus,iOp);
}
if (pmszGroups)
{
for (LPTSTR psz = pmszGroups; psz && *psz; psz += 1+lstrlen(psz))
{
LPIDENT lpi;
if ((lpi = IDENT::FindGroup ((LPIDENT)idCell, psz)) == NULL)
continue;
AfsAdmSvr_AddToAsidList (ppAsidList, (ASID)lpi, 0);
}
FreeString (pmszGroups);
}
Print (dlDETAIL, TEXT("Client 0x%08lX: GetGroupOwnership succeeded"), idClient);
AfsAdmSvr_EndOperation (iOp);
return TRUE;
}
// AfsAdmSvr_AddGroupMember
// ...adds a member to the specified group
//
int AfsAdmSvr_AddGroupMember (DWORD idClient, ASID idCell, ASID idGroup, ASID idMember, ULONG *pStatus)
{
ASACTION Action;
Action.Action = ACTION_GROUP_MEMBER_ADD;
Action.idClient = idClient;
Action.idCell = idCell;
Action.u.Group_Member_Add.idGroup = idGroup;
Action.u.Group_Member_Add.idUser = idMember;
size_t iOp = AfsAdmSvr_BeginOperation (idClient, &Action);
Print (dlDETAIL, TEXT("Client 0x%08lX: AddGroupMember (idGroup=0x%08lX, idUser=0x%08lX)"), idClient, idGroup, idMember);
if (!AfsAdmSvr_fIsValidClient (idClient))
return FALSE_(ERROR_INVALID_PARAMETER,pStatus,iOp);
// Modify the group as requested
//
ULONG status;
if (!AfsClass_AddUserToGroup ((LPIDENT)idGroup, (LPIDENT)idMember, &status))
return FALSE_(status,pStatus,iOp);
Print (dlDETAIL, TEXT("Client 0x%08lX: AddGroupMember succeeded"), idClient);
AfsAdmSvr_EndOperation (iOp);
return TRUE;
}
// AfsAdmSvr_RemoveGroupMember
// ...removes a member from the specified group
//
int AfsAdmSvr_RemoveGroupMember (DWORD idClient, ASID idCell, ASID idGroup, ASID idMember, ULONG *pStatus)
{
ASACTION Action;
Action.Action = ACTION_GROUP_MEMBER_REMOVE;
Action.idClient = idClient;
Action.idCell = idCell;
Action.u.Group_Member_Remove.idGroup = idGroup;
Action.u.Group_Member_Remove.idUser = idMember;
size_t iOp = AfsAdmSvr_BeginOperation (idClient, &Action);
Print (dlDETAIL, TEXT("Client 0x%08lX: RemoveGroupMember (idGroup=0x%08lX, idUser=0x%08lX)"), idClient, idGroup, idMember);
if (!AfsAdmSvr_fIsValidClient (idClient))
return FALSE_(ERROR_INVALID_PARAMETER,pStatus,iOp);
// Modify the group as requested
//
ULONG status;
if (!AfsClass_RemoveUserFromGroup ((LPIDENT)idGroup, (LPIDENT)idMember, &status))
return FALSE_(status,pStatus,iOp);
Print (dlDETAIL, TEXT("Client 0x%08lX: RemoveGroupMember succeeded"), idClient);
AfsAdmSvr_EndOperation (iOp);
return TRUE;
}
// AfsAdmSvr_RenameGroup
// ...changes a group's name
//
int AfsAdmSvr_RenameGroup (DWORD idClient, ASID idCell, ASID idGroup, STRING szNewGroupName, ULONG *pStatus)
{
ASACTION Action;
Action.Action = ACTION_GROUP_RENAME;
Action.idClient = idClient;
Action.idCell = idCell;
Action.u.Group_Rename.idGroup = idGroup;
lstrcpy (Action.u.Group_Rename.szNewName, szNewGroupName);
size_t iOp = AfsAdmSvr_BeginOperation (idClient, &Action);
Print (dlDETAIL, TEXT("Client 0x%08lX: RenameGroup (idGroup=0x%08lX, szNewName=%s)"), idClient, idGroup, szNewGroupName);
if (!AfsAdmSvr_fIsValidClient (idClient))
return FALSE_(ERROR_INVALID_PARAMETER,pStatus,iOp);
// Modify the group as requested
//
ULONG status;
if (!AfsClass_RenameGroup ((LPIDENT)idGroup, szNewGroupName, &status))
return FALSE_(status,pStatus,iOp);
Print (dlDETAIL, TEXT("Client 0x%08lX: RenameGroup succeeded"), idClient);
AfsAdmSvr_EndOperation (iOp);
return TRUE;
}
// AfsAdmSvr_CreateGroup
// ...creates a new PTS group
//
int AfsAdmSvr_CreateGroup (DWORD idClient, ASID idCell, LPAFSADMSVR_CREATEGROUP_PARAMS pCreate, ASID *pidGroup, ULONG *pStatus)
{
ASACTION Action;
Action.Action = ACTION_GROUP_CREATE;
Action.idClient = idClient;
Action.idCell = idCell;
lstrcpy (Action.u.Group_Create.szGroup, pCreate->szName);
size_t iOp = AfsAdmSvr_BeginOperation (idClient, &Action);
Print (dlDETAIL, TEXT("Client 0x%08lX: CreateGroup (szGroup=%s)"), idClient, pCreate->szName);
if (!AfsAdmSvr_fIsValidClient (idClient))
return FALSE_(ERROR_INVALID_PARAMETER,pStatus,iOp);
// Find the owner (if we can)
//
LPIDENT lpiOwner;
if ((lpiOwner = IDENT::FindUser ((LPIDENT)idCell, pCreate->szOwner)) == NULL)
lpiOwner = IDENT::FindGroup ((LPIDENT)idCell, pCreate->szOwner);
// Create the group account
//
ULONG status;
LPIDENT lpiGroup;
if ((lpiGroup = AfsClass_CreateGroup ((LPIDENT)idCell, pCreate->szName, lpiOwner, pCreate->idGroup, &status)) == NULL)
{
Print (dlERROR, TEXT("Client 0x%08lX: CreateGroup failed; error 0x%08lX"), idClient, status);
return FALSE_(status,pStatus,iOp);
}
if (pidGroup)
*pidGroup = (ASID)lpiGroup;
// Creating a group account may change the max group ID
AfsAdmSvr_TestProperties (idCell);
Print (dlDETAIL, TEXT("Client 0x%08lX: CreateGroup succeeded"), idClient);
AfsAdmSvr_EndOperation (iOp);
return TRUE;
}
// AfsAdmSvr_DeleteGroup
// ...deletes a PTS group
//
int AfsAdmSvr_DeleteGroup (DWORD idClient, ASID idCell, ASID idGroup, ULONG *pStatus)
{
ASACTION Action;
Action.Action = ACTION_GROUP_DELETE;
Action.idClient = idClient;
Action.idCell = idCell;
Action.u.Group_Delete.idGroup = idGroup;
size_t iOp = AfsAdmSvr_BeginOperation (idClient, &Action);
Print (dlDETAIL, TEXT("Client 0x%08lX: DeleteGroup (idGroup=0x%08lX)"), idClient, idGroup);
if (!AfsAdmSvr_fIsValidClient (idClient))
return FALSE_(ERROR_INVALID_PARAMETER,pStatus,iOp);
// Delete the group
//
ULONG status;
if (!AfsClass_DeleteGroup ((LPIDENT)idGroup, &status))
{
Print (dlERROR, TEXT("Client 0x%08lX: DeleteGroup failed; error 0x%08lX"), idClient, status);
return FALSE_(status,pStatus,iOp);
}
Print (dlDETAIL, TEXT("Client 0x%08lX: DeleteGroup succeeded"), idClient);
AfsAdmSvr_EndOperation (iOp);
return TRUE;
}

View File

@ -0,0 +1,33 @@
#ifndef TAAFSADMSVRINTERNAL_H
#define TAAFSADMSVRINTERNAL_H
/*
* INCLUSIONS _________________________________________________________________
*
*/
#include <rpc.h>
#include <rpcndr.h>
#include <WINNT/AfsClass.h>
#include <WINNT/TaAfsAdmSvr.h>
#include "TaAfsAdmSvrDebug.h"
#include "TaAfsAdmSvrSearch.h"
#include "TaAfsAdmSvrProperties.h"
#include "TaAfsAdmSvrGeneral.h"
#include "TaAfsAdmSvrCallback.h"
extern "C" {
#include <afs/afs_Admin.h>
#include <afs/afs_kasAdmin.h>
#include <afs/afs_ptsAdmin.h>
#include <afs/afs_vosAdmin.h>
#include <afs/afs_bosAdmin.h>
#include <afs/afs_clientAdmin.h>
#include <afs/afs_utilAdmin.h>
} // extern "C"
#endif // TAAFSADMSVRINTERNAL_H

View File

@ -0,0 +1,198 @@
extern "C" {
#include <afs/param.h>
#include <afs/stds.h>
}
#include "TaAfsAdmSvrInternal.h"
/*
* DEFINITIONS ________________________________________________________________
*
*/
extern void AfsAdmSvr_Startup (void);
extern void AfsAdmSvr_Shutdown (void);
/*
* ROUTINES ___________________________________________________________________
*
*/
#ifdef DEBUG
LPARAM CALLBACK AfsAdmSvr_Debug_ThreadProc (PVOID lp)
{
ShowMemoryManager();
MSG msg;
while (GetMessage (&msg, 0, 0, 0))
{
if (!IsMemoryManagerMessage (&msg))
{
TranslateMessage (&msg);
DispatchMessage (&msg);
}
}
return 0;
}
#endif
int cdecl main (int argc, char **argv)
{
BOOL fSuccess = FALSE;
Print (TEXT("Initializing..."));
WSADATA Data;
WSAStartup (0x0101, &Data);
// Parse the command-line
//
DWORD dwAutoScope = AFSADMSVR_SCOPE_VOLUMES | AFSADMSVR_SCOPE_USERS;
for (--argc,++argv; argc; --argc,++argv)
{
if (!lstrcmpi (*argv, AFSADMSVR_KEYWORD_TIMED))
AfsAdmSvr_EnableAutoShutdown (TRUE);
else if (!lstrcmpi (*argv, AFSADMSVR_KEYWORD_MANUAL))
dwAutoScope = 0;
else if (!lstrcmpi (*argv, AFSADMSVR_KEYWORD_SCOPE_USERS))
dwAutoScope &= ~AFSADMSVR_SCOPE_VOLUMES;
else if (!lstrcmpi (*argv, AFSADMSVR_KEYWORD_SCOPE_VOLUMES))
dwAutoScope &= ~AFSADMSVR_SCOPE_USERS;
#ifdef DEBUG
else if (!lstrcmpi (*argv, AFSADMSVR_KEYWORD_DEBUG))
CreateThread (NULL, 0, (LPTHREAD_START_ROUTINE)AfsAdmSvr_Debug_ThreadProc, 0, 0, 0);
#endif
}
// Prepare to listen for RPCs
//
unsigned char *pszPROTOCOL = (unsigned char *)"ncacn_ip_tcp";
unsigned char *pszENTRYNAME = (unsigned char *)AFSADMSVR_ENTRYNAME_DEFAULT;
unsigned char *pszANNOTATION = (unsigned char *)"Transarc AFS Administrative Server";
unsigned char szEndpoint[ 32 ];
wsprintf ((LPTSTR)szEndpoint, "%lu", AFSADMSVR_ENDPOINT_DEFAULT);
int cMAX_CALLS = 50;
// Clean up any broken interface registration
//
RpcServerUnregisterIf (ITaAfsAdminSvr_v1_0_s_ifspec, 0, FALSE);
RpcNsBindingUnexport (RPC_C_NS_SYNTAX_DEFAULT, pszENTRYNAME, ITaAfsAdminSvr_v1_0_s_ifspec, NULL);
// Register our interface
//
RPC_STATUS status;
if ((status = RpcServerUseProtseq (pszPROTOCOL, cMAX_CALLS, NULL)) != 0)
{
Print (dlERROR, TEXT("RpcServerUseProtseq failed; error 0x%08lX"), status);
}
else if ((status = RpcServerRegisterIf (ITaAfsAdminSvr_v1_0_s_ifspec, 0, 0)) != 0)
{
Print (dlERROR, TEXT("RpcServerRegisterIf failed; error 0x%08lX"), status);
}
else
{
// Always try to register on port 1025; that's the easiest thing for
// some clients to find. We'll only fail if we (a) can't use 1025, and
// (b) can't export our bindings.
//
BOOL fGotPort = FALSE;
if (RpcServerUseProtseqEp (pszPROTOCOL, cMAX_CALLS, szEndpoint, NULL) == 0)
fGotPort = TRUE;
else
Print (dlWARNING, TEXT("RpcServerUseProtseqEp failed (benign); error 0x%08lX"), status);
RPC_BINDING_VECTOR *pBindingVector;
if ((status = RpcServerInqBindings (&pBindingVector)) != 0)
{
Print (dlERROR, TEXT("RpcServerRegisterIf failed; error 0x%08lX"), status);
}
else if ((status = RpcEpRegister (ITaAfsAdminSvr_v1_0_s_ifspec, pBindingVector, NULL, pszANNOTATION)) != 0)
{
Print (dlERROR, TEXT("RpcEpRegister failed; error 0x%08lX"), status);
}
else
{
BOOL fExportedBinding = FALSE;
if ((status = RpcNsBindingExport (RPC_C_NS_SYNTAX_DEFAULT, pszENTRYNAME, ITaAfsAdminSvr_v1_0_s_ifspec, pBindingVector, NULL)) == 0)
fExportedBinding = TRUE;
else
Print (dlWARNING, TEXT("RpcNsBindingExport failed (benign); error 0x%08lX"), status);
if (!fExportedBinding && !fGotPort)
{
Print (dlERROR, TEXT("RpcNsBindingExport failed; error 0x%08lX"), status);
Print (dlERROR, TEXT("Could not bind to port %s or export bindings; terminating"), szEndpoint);
}
else
{
AfsAdmSvr_Startup();
Print (TEXT("Ready.\n"));
// If not asked to open cells manually, fork a thread to start opening
// the default local cell
//
if (dwAutoScope)
{
DWORD dwThreadID;
CreateThread (NULL, 0, (LPTHREAD_START_ROUTINE)AfsAdmSvr_AutoOpen_ThreadProc, (PVOID)dwAutoScope, 0, &dwThreadID);
}
// Listen for requests until someone calls StopListen
//
if ((status = RpcServerListen (1, cMAX_CALLS, FALSE)) != 0)
{
Print (dlERROR, TEXT("RpcServerListen failed; error 0x%08lX"), status);
}
else
{
fSuccess = TRUE;
}
AfsAdmSvr_Shutdown();
}
if (fExportedBinding)
{
if ((status = RpcNsBindingUnexport (RPC_C_NS_SYNTAX_DEFAULT, pszENTRYNAME, ITaAfsAdminSvr_v1_0_s_ifspec, NULL)) != 0)
{
Print (dlWARNING, TEXT("RpcNsBindingExport failed; error 0x%08lX"), status);
}
}
if ((status = RpcEpUnregister (ITaAfsAdminSvr_v1_0_s_ifspec, pBindingVector, NULL)) != 0)
{
Print (dlWARNING, TEXT("RpcEpUnregister failed; error 0x%08lX"), status);
}
}
}
Print (TEXT("Shutting down...\n"));
if ((status = RpcServerUnregisterIf (0, 0, FALSE)) != 0)
{
Print (dlWARNING, TEXT("RpcServerUnregisterIf failed; error 0x%08lX"), status);
exit (-1);
}
return (fSuccess) ? (0) : (-1);
}
void __RPC_FAR * __RPC_USER MIDL_user_allocate (size_t cbAllocate)
{
return (void __RPC_FAR *)Allocate (cbAllocate);
}
void __RPC_USER MIDL_user_free (void __RPC_FAR *pData)
{
Free (pData);
}

View File

@ -0,0 +1,685 @@
extern "C" {
#include <afs/param.h>
#include <afs/stds.h>
}
#include "TaAfsAdmSvrInternal.h"
/*
* VARIABLES __________________________________________________________________
*
*/
typedef struct
{
ASID idCell;
DWORD timeLastRefresh;
DWORD cminRefreshRate;
HANDLE hThread;
} REFRESHTHREAD, *LPREFRESHTHREAD;
static struct
{
REFRESHTHREAD *aRefreshThreads;
size_t cRefreshThreads;
CRITICAL_SECTION *pcsRefreshThreads;
} l;
/*
* AUTO-REFRESH _______________________________________________________________
*
*/
DWORD WINAPI AfsAdmSvr_AutoRefreshThread (PVOID lp)
{
ASID idCell = (ASID)lp;
for (;;)
{
EnterCriticalSection (l.pcsRefreshThreads);
BOOL fFound = FALSE;
DWORD cminRefreshRate;
DWORD timeLastRefresh;
for (size_t iThread = 0; (!fFound) && (iThread < l.cRefreshThreads); ++iThread)
{
LPREFRESHTHREAD pThread = &l.aRefreshThreads[ iThread ];
if (pThread->idCell == idCell)
{
fFound = TRUE;
cminRefreshRate = pThread->cminRefreshRate;
timeLastRefresh = pThread->timeLastRefresh;
}
}
LeaveCriticalSection (l.pcsRefreshThreads);
if (!fFound)
break;
DWORD timeNextRefresh = timeLastRefresh + cminRefreshRate;
if ((cminRefreshRate) && ((!timeLastRefresh) || (AfsAdmSvr_GetCurrentTime() >= timeNextRefresh)))
{
Print (dlDETAIL, TEXT("Auto-refresh: %lu minutes elapsed; refreshing cell 0x%08lX"), cminRefreshRate, idCell);
LPCELL lpCell;
if ((lpCell = ((LPIDENT)idCell)->OpenCell()) != NULL)
{
lpCell->Invalidate();
ULONG status;
if (!lpCell->RefreshAll (&status))
Print (dlERROR, TEXT("Auto-refresh: RefreshCell failed; error 0x%08lX"), status);
else
Print (dlSTANDARD, TEXT("Auto-refresh of cell 0x%08lX successful"), idCell);
lpCell->Close();
}
}
Sleep (60L * 1000L); // sleep for one minute
}
return 0;
}
void AfsAdmSvr_PrepCellRefresh (void)
{
if (!l.pcsRefreshThreads)
{
l.pcsRefreshThreads = New (CRITICAL_SECTION);
InitializeCriticalSection (l.pcsRefreshThreads);
}
}
void AfsAdmSvr_SetCellRefreshRate (ASID idCell, ULONG cminRefreshRate)
{
AfsAdmSvr_PrepCellRefresh();
EnterCriticalSection (l.pcsRefreshThreads);
for (size_t iThread = 0; iThread < l.cRefreshThreads; ++iThread)
{
LPREFRESHTHREAD pThread = &l.aRefreshThreads[ iThread ];
if (pThread->idCell == idCell)
{
pThread->cminRefreshRate = cminRefreshRate;
break;
}
}
if (iThread == l.cRefreshThreads)
{
for (size_t iThread = 0; iThread < l.cRefreshThreads; ++iThread)
{
LPREFRESHTHREAD pThread = &l.aRefreshThreads[ iThread ];
if (pThread->idCell == 0)
break;
}
if (REALLOC (l.aRefreshThreads, l.cRefreshThreads, 1+iThread, 1))
{
DWORD idThread;
LPREFRESHTHREAD pThread = &l.aRefreshThreads[ iThread ];
pThread->idCell = idCell;
pThread->timeLastRefresh = AfsAdmSvr_GetCurrentTime();
pThread->cminRefreshRate = cminRefreshRate;
pThread->hThread = CreateThread (NULL, 0, (LPTHREAD_START_ROUTINE)AfsAdmSvr_AutoRefreshThread, (LPVOID)idCell, 0, &idThread);
}
}
LeaveCriticalSection (l.pcsRefreshThreads);
}
void AfsAdmSvr_StopCellRefreshThread (ASID idCell)
{
AfsAdmSvr_PrepCellRefresh();
EnterCriticalSection (l.pcsRefreshThreads);
for (size_t iThread = 0; iThread < l.cRefreshThreads; ++iThread)
{
LPREFRESHTHREAD pThread = &l.aRefreshThreads[ iThread ];
if (pThread->idCell == idCell)
pThread->idCell = 0;
}
LeaveCriticalSection (l.pcsRefreshThreads);
}
void AfsAdmSvr_MarkRefreshThread (ASID idCell)
{
AfsAdmSvr_PrepCellRefresh();
EnterCriticalSection (l.pcsRefreshThreads);
for (size_t iThread = 0; iThread < l.cRefreshThreads; ++iThread)
{
LPREFRESHTHREAD pThread = &l.aRefreshThreads[ iThread ];
if (pThread->idCell == idCell)
pThread->timeLastRefresh = AfsAdmSvr_GetCurrentTime();
}
LeaveCriticalSection (l.pcsRefreshThreads);
}
/*
* OBJECT PROPERTIES __________________________________________________________
*
*/
void AfsAdmSvr_ObtainRudimentaryProperties (LPASOBJPROP pProperties)
{
LPIDENT lpi = (LPIDENT)(pProperties->idObject);
switch (GetAsidType (pProperties->idObject))
{
case itCELL:
pProperties->Type = TYPE_CELL;
lpi->GetCellName (pProperties->szName);
break;
case itSERVER:
pProperties->Type = TYPE_SERVER;
pProperties->idParentCell = (ASID)( lpi->GetCell() );
lpi->GetServerName (pProperties->szName);
break;
case itSERVICE:
pProperties->Type = TYPE_SERVICE;
pProperties->idParentCell = (ASID)( lpi->GetCell() );
pProperties->idParentServer = (ASID)( lpi->GetServer() );
lpi->GetServiceName (pProperties->szName);
break;
case itAGGREGATE:
pProperties->Type = TYPE_PARTITION;
pProperties->idParentCell = (ASID)( lpi->GetCell() );
pProperties->idParentServer = (ASID)( lpi->GetServer() );
lpi->GetAggregateName (pProperties->szName);
break;
case itFILESET:
pProperties->Type = TYPE_VOLUME;
pProperties->idParentCell = (ASID)( lpi->GetCell() );
pProperties->idParentServer = (ASID)( lpi->GetServer() );
pProperties->idParentPartition = (ASID)( lpi->GetAggregate() );
lpi->GetFilesetName (pProperties->szName);
break;
case itUSER:
pProperties->Type = TYPE_USER;
pProperties->idParentCell = (ASID)( lpi->GetCell() );
lpi->GetUserName (pProperties->szName);
break;
case itGROUP:
pProperties->Type = TYPE_GROUP;
pProperties->idParentCell = (ASID)( lpi->GetCell() );
lpi->GetGroupName (pProperties->szName);
break;
default:
pProperties->verProperties = verPROP_NO_OBJECT;
return;
}
if (pProperties->verProperties == verPROP_NO_OBJECT)
pProperties->verProperties = verPROP_RUDIMENTARY;
}
BOOL AfsAdmSvr_ObtainFullProperties (LPASOBJPROP pProperties, ULONG *pStatus)
{
BOOL rc = TRUE;
ULONG status = 0;
AfsAdmSvr_ObtainRudimentaryProperties (pProperties);
if (pProperties->verProperties != verPROP_NO_OBJECT)
{
LPIDENT lpi = (LPIDENT)(pProperties->idObject);
switch (GetAsidType (pProperties->idObject))
{
case itCELL:
PTSPROPERTIES PtsProperties;
if ((rc = AfsClass_GetPtsProperties (lpi, &PtsProperties, &status)) == TRUE)
{
pProperties->u.CellProperties.idUserMax = (DWORD)PtsProperties.idUserMax;
pProperties->u.CellProperties.idGroupMax = (DWORD)PtsProperties.idGroupMax;
}
break;
case itSERVER:
LPSERVER lpServer;
if ((lpServer = lpi->OpenServer (&status)) == NULL)
rc = FALSE;
else
{
SERVERSTATUS ss;
if (!lpServer->GetStatus (&ss, TRUE, &status))
rc = FALSE;
else
{
pProperties->u.ServerProperties.nAddresses = 0;
for (size_t ii = 0; ii < ss.nAddresses; ++ii)
{
if (!ss.aAddresses[ii].sin_addr.s_addr)
continue;
if (pProperties->u.ServerProperties.nAddresses < ASOBJPROP_SERVER_MAXADDRESS)
{
pProperties->u.ServerProperties.aAddresses[ pProperties->u.ServerProperties.nAddresses ] = ntohl(ss.aAddresses[ii].sin_addr.s_addr);
pProperties->u.ServerProperties.nAddresses ++;
}
}
}
lpServer->Close();
}
break;
case itSERVICE:
LPSERVICE lpService;
if ((lpService = lpi->OpenService (&status)) == NULL)
rc = FALSE;
else
{
SERVICESTATUS ss;
if (!lpService->GetStatus (&ss, TRUE, &status))
rc = FALSE;
else
{
pProperties->u.ServiceProperties.ServiceType = ss.type;
pProperties->u.ServiceProperties.ServiceState = ss.state;
lstrcpy (pProperties->u.ServiceProperties.szAuxStatus, ss.szAuxStatus);
lstrcpy (pProperties->u.ServiceProperties.szParams, ss.szParams);
lstrcpy (pProperties->u.ServiceProperties.szNotifier, ss.szNotifier);
memcpy (&pProperties->u.ServiceProperties.timeLastStart, &ss.timeLastStart, sizeof(SYSTEMTIME));
memcpy (&pProperties->u.ServiceProperties.timeLastStop, &ss.timeLastStop, sizeof(SYSTEMTIME));
memcpy (&pProperties->u.ServiceProperties.timeLastFail, &ss.timeLastFail, sizeof(SYSTEMTIME));
pProperties->u.ServiceProperties.nStarts = ss.nStarts;
pProperties->u.ServiceProperties.dwErrLast = ss.dwErrLast;
pProperties->u.ServiceProperties.dwSigLast = ss.dwSigLast;
}
lpService->Close();
}
break;
case itAGGREGATE:
LPAGGREGATE lpAggregate;
if ((lpAggregate = lpi->OpenAggregate(&status)) == NULL)
rc = FALSE;
else
{
AGGREGATESTATUS as;
if (!lpAggregate->GetStatus (&as, TRUE, &status))
rc = FALSE;
else
{
pProperties->u.PartitionProperties.dwID = as.dwID;
pProperties->u.PartitionProperties.ckStorageTotal = as.ckStorageTotal;
pProperties->u.PartitionProperties.ckStorageFree = as.ckStorageFree;
pProperties->u.PartitionProperties.ckStorageAllocated = as.ckStorageAllocated;
}
lpAggregate->Close();
}
break;
case itFILESET:
LPFILESET lpFileset;
if ((lpFileset = lpi->OpenFileset(&status)) == NULL)
rc = FALSE;
else
{
FILESETSTATUS fs;
if (!lpFileset->GetStatus (&fs, TRUE, &status))
rc = FALSE;
else
{
pProperties->u.VolumeProperties.id = fs.id;
pProperties->u.VolumeProperties.idReadWrite = fs.idReadWrite;
pProperties->u.VolumeProperties.idReplica = fs.idReplica;
pProperties->u.VolumeProperties.idClone = fs.idClone;
memcpy (&pProperties->u.VolumeProperties.timeCreation, &fs.timeCreation, sizeof(SYSTEMTIME));
memcpy (&pProperties->u.VolumeProperties.timeLastUpdate, &fs.timeLastUpdate, sizeof(SYSTEMTIME));
memcpy (&pProperties->u.VolumeProperties.timeLastAccess, &fs.timeLastAccess, sizeof(SYSTEMTIME));
memcpy (&pProperties->u.VolumeProperties.timeLastBackup, &fs.timeLastBackup, sizeof(SYSTEMTIME));
memcpy (&pProperties->u.VolumeProperties.timeCopyCreation, &fs.timeCopyCreation, sizeof(SYSTEMTIME));
pProperties->u.VolumeProperties.nFiles = fs.nFiles;
pProperties->u.VolumeProperties.ckQuota = fs.ckQuota;
pProperties->u.VolumeProperties.ckUsed = fs.ckUsed;
pProperties->u.VolumeProperties.FilesetType = fs.Type;
pProperties->u.VolumeProperties.FilesetState = fs.State;
}
lpFileset->Close();
}
break;
case itUSER:
LPUSER lpUser;
if ((lpUser = lpi->OpenUser (&status)) == NULL)
rc = FALSE;
else
{
USERSTATUS us;
if (!lpUser->GetStatus (&us, TRUE, &status))
rc = FALSE;
else
{
lpUser->GetName (NULL, pProperties->u.UserProperties.szInstance);
if ((pProperties->u.UserProperties.fHaveKasInfo = us.fHaveKasInfo) == TRUE)
{
pProperties->u.UserProperties.KASINFO.fIsAdmin = us.KASINFO.fIsAdmin;
pProperties->u.UserProperties.KASINFO.fCanGetTickets = us.KASINFO.fCanGetTickets;
pProperties->u.UserProperties.KASINFO.fEncrypt = us.KASINFO.fEncrypt;
pProperties->u.UserProperties.KASINFO.fCanChangePassword = us.KASINFO.fCanChangePassword;
pProperties->u.UserProperties.KASINFO.fCanReusePasswords = us.KASINFO.fCanReusePasswords;
memcpy (&pProperties->u.UserProperties.KASINFO.timeExpires, &us.KASINFO.timeExpires, sizeof(SYSTEMTIME));
memcpy (&pProperties->u.UserProperties.KASINFO.timeLastPwChange, &us.KASINFO.timeLastPwChange, sizeof(SYSTEMTIME));
memcpy (&pProperties->u.UserProperties.KASINFO.timeLastMod, &us.KASINFO.timeLastMod, sizeof(SYSTEMTIME));
pProperties->u.UserProperties.KASINFO.szUserLastMod[0] = TEXT('\0');
pProperties->u.UserProperties.KASINFO.csecTicketLifetime = us.KASINFO.csecTicketLifetime;
pProperties->u.UserProperties.KASINFO.keyVersion = us.KASINFO.keyVersion;
memcpy (&pProperties->u.UserProperties.KASINFO.keyData, us.KASINFO.key.key, ENCRYPTIONKEYLENGTH);
pProperties->u.UserProperties.KASINFO.dwKeyChecksum = us.KASINFO.dwKeyChecksum;
pProperties->u.UserProperties.KASINFO.cdayPwExpire = us.KASINFO.cdayPwExpire;
pProperties->u.UserProperties.KASINFO.cFailLogin = us.KASINFO.cFailLogin;
pProperties->u.UserProperties.KASINFO.csecFailLoginLock = us.KASINFO.csecFailLoginLock;
if (us.KASINFO.lpiLastMod)
us.KASINFO.lpiLastMod->GetUserName (pProperties->u.UserProperties.KASINFO.szUserLastMod);
}
if ((pProperties->u.UserProperties.fHavePtsInfo = us.fHavePtsInfo) == TRUE)
{
pProperties->u.UserProperties.PTSINFO.cgroupCreationQuota = us.PTSINFO.cgroupCreationQuota;
pProperties->u.UserProperties.PTSINFO.cgroupMember = us.PTSINFO.cgroupMember;
pProperties->u.UserProperties.PTSINFO.uidName = us.PTSINFO.uidName;
pProperties->u.UserProperties.PTSINFO.uidOwner = us.PTSINFO.uidOwner;
pProperties->u.UserProperties.PTSINFO.uidCreator = us.PTSINFO.uidCreator;
lstrcpy (pProperties->u.UserProperties.PTSINFO.szOwner, us.PTSINFO.szOwner);
lstrcpy (pProperties->u.UserProperties.PTSINFO.szCreator, us.PTSINFO.szCreator);
pProperties->u.UserProperties.PTSINFO.aaListStatus = us.PTSINFO.aaListStatus;
pProperties->u.UserProperties.PTSINFO.aaGroupsOwned = us.PTSINFO.aaGroupsOwned;
pProperties->u.UserProperties.PTSINFO.aaMembership = us.PTSINFO.aaMembership;
}
}
lpUser->Close();
}
break;
case itGROUP:
lpi->GetGroupName (pProperties->szName);
LPPTSGROUP lpGroup;
if ((lpGroup = lpi->OpenGroup (&status)) == NULL)
rc = FALSE;
else
{
PTSGROUPSTATUS gs;
if (!lpGroup->GetStatus (&gs, TRUE, &status))
rc = FALSE;
else
{
pProperties->u.GroupProperties.nMembers = gs.nMembers;
pProperties->u.GroupProperties.uidName = gs.uidName;
pProperties->u.GroupProperties.uidOwner = gs.uidOwner;
pProperties->u.GroupProperties.uidCreator = gs.uidCreator;
pProperties->u.GroupProperties.aaListStatus = gs.aaListStatus;
pProperties->u.GroupProperties.aaListGroupsOwned = gs.aaListGroupsOwned;
pProperties->u.GroupProperties.aaListMembers = gs.aaListMembers;
pProperties->u.GroupProperties.aaAddMember = gs.aaAddMember;
pProperties->u.GroupProperties.aaDeleteMember = gs.aaDeleteMember;
lstrcpy (pProperties->u.GroupProperties.szOwner, gs.szOwner);
lstrcpy (pProperties->u.GroupProperties.szCreator, gs.szCreator);
}
lpGroup->Close();
}
break;
}
}
if (rc && (pProperties->verProperties < verPROP_FIRST_SCAN))
pProperties->verProperties = verPROP_FIRST_SCAN;
if (!rc)
pProperties->verProperties = verPROP_NO_OBJECT;
if (!rc && pStatus)
*pStatus = status;
return rc;
}
BOOL AfsAdmSvr_PropertiesDiffer (LPASOBJPROP pProp1, LPASOBJPROP pProp2)
{
if (pProp1->idObject != pProp2->idObject)
return TRUE;
if (pProp1->Type != pProp2->Type)
return TRUE;
if (pProp1->idParentCell != pProp2->idParentCell)
return TRUE;
if (pProp1->idParentServer != pProp2->idParentServer)
return TRUE;
if (pProp1->idParentPartition != pProp2->idParentPartition)
return TRUE;
if (lstrcmp (pProp1->szName, pProp2->szName))
return TRUE;
if (memcmp (&pProp1->u, &pProp2->u, sizeof(pProp1->u)))
return TRUE;
return FALSE;
}
void AfsAdmSvr_TestProperties (ASID idObject)
{
LPASOBJPROP pProperties;
if ((pProperties = (LPASOBJPROP)((LPIDENT)idObject)->GetUserParam()) == NULL)
return;
if (pProperties->verProperties >= verPROP_FIRST_SCAN)
{
ASOBJPROP NewProperties;
memcpy (&NewProperties, pProperties, sizeof(ASOBJPROP));
memset (&NewProperties.u, 0x00, sizeof(NewProperties.u));
if (AfsAdmSvr_ObtainFullProperties (&NewProperties))
{
if (AfsAdmSvr_PropertiesDiffer (&NewProperties, pProperties))
{
LPIDENT lpi = (LPIDENT)(pProperties->idObject);
LPASOBJPROP pStoredProp;
if ((pStoredProp = (LPASOBJPROP)(lpi->GetUserParam())) != NULL)
{
pStoredProp->idParentCell = NewProperties.idParentCell;
pStoredProp->idParentServer = NewProperties.idParentServer;
pStoredProp->idParentPartition = NewProperties.idParentPartition;
lstrcpy (pStoredProp->szName, NewProperties.szName);
memcpy (&pStoredProp->u, &NewProperties.u, sizeof(NewProperties.u));
pStoredProp->verProperties ++;
}
}
}
}
}
BOOL CALLBACK AfsAdmSvr_NotifyCallback (NOTIFYEVENT evt, PNOTIFYPARAMS pParams)
{
switch (evt)
{
case evtCreate:
LPIDENT lpiCreate;
if ((lpiCreate = pParams->lpi1) != NULL)
{
if ((lpiCreate->GetUserParam()) == NULL)
{
LPASOBJPROP pProperties = New (ASOBJPROP);
memset (pProperties, 0x00, sizeof(ASOBJPROP));
pProperties->idObject = (ASID)lpiCreate;
AfsAdmSvr_ObtainRudimentaryProperties (pProperties);
lpiCreate->SetUserParam(pProperties);
}
AfsAdmSvr_TestProperties ((ASID)lpiCreate);
}
break;
case evtDestroy:
if (GetAsidType ((ASID)pParams->lpi1) == itCELL)
AfsAdmSvr_StopCellRefreshThread ((ASID)(pParams->lpi1));
break;
case evtRefreshAllBegin:
AfsAdmSvr_Action_StartRefresh ((ASID)(pParams->lpi1));
break;
case evtRefreshAllEnd:
AfsAdmSvr_Action_StopRefresh ((ASID)(pParams->lpi1));
break;
case evtRefreshStatusEnd:
AfsAdmSvr_TestProperties ((ASID)(pParams->lpi1));
break;
}
return TRUE;
}
LPASOBJPROP AfsAdmSvr_GetCurrentProperties (ASID idObject, ULONG *pStatus)
{
switch (GetAsidType (idObject))
{
case itCELL:
LPCELL lpCell;
if ((lpCell = ((LPIDENT)idObject)->OpenCell (pStatus)) == NULL)
return NULL;
lpCell->Close();
break;
case itSERVER:
LPSERVER lpServer;
if ((lpServer = ((LPIDENT)idObject)->OpenServer (pStatus)) == NULL)
return NULL;
lpServer->Close();
break;
case itSERVICE:
LPSERVICE lpService;
if ((lpService = ((LPIDENT)idObject)->OpenService (pStatus)) == NULL)
return NULL;
lpService->Close();
break;
case itAGGREGATE:
LPAGGREGATE lpAggregate;
if ((lpAggregate = ((LPIDENT)idObject)->OpenAggregate (pStatus)) == NULL)
return NULL;
lpAggregate->Close();
break;
case itFILESET:
LPFILESET lpFileset;
if ((lpFileset = ((LPIDENT)idObject)->OpenFileset (pStatus)) == NULL)
return NULL;
lpFileset->Close();
break;
case itUSER:
LPUSER lpUser;
if ((lpUser = ((LPIDENT)idObject)->OpenUser (pStatus)) == NULL)
return NULL;
lpUser->Close();
break;
case itGROUP:
LPPTSGROUP lpGroup;
if ((lpGroup = ((LPIDENT)idObject)->OpenGroup (pStatus)) == NULL)
return NULL;
lpGroup->Close();
break;
default:
return (LPASOBJPROP)FALSE_(ERROR_INVALID_PARAMETER,pStatus);
}
LPASOBJPROP pCurrentProperties;
if ((pCurrentProperties = (LPASOBJPROP)((LPIDENT)idObject)->GetUserParam()) == NULL)
{
return (LPASOBJPROP)FALSE_(ERROR_NOT_ENOUGH_MEMORY,pStatus);
}
return pCurrentProperties;
}
BOOL AfsAdmSvr_InvalidateObjectProperties (ASID idObject, ULONG *pStatus)
{
switch (GetAsidType (idObject))
{
case itCELL:
LPCELL lpCell;
if ((lpCell = ((LPIDENT)idObject)->OpenCell (pStatus)) == NULL)
return FALSE;
lpCell->Invalidate();
lpCell->Close();
break;
case itSERVER:
LPSERVER lpServer;
if ((lpServer = ((LPIDENT)idObject)->OpenServer (pStatus)) == NULL)
return FALSE;
lpServer->Invalidate();
lpServer->Close();
break;
case itSERVICE:
LPSERVICE lpService;
if ((lpService = ((LPIDENT)idObject)->OpenService (pStatus)) == NULL)
return FALSE;
lpService->Invalidate();
lpService->Close();
break;
case itAGGREGATE:
LPAGGREGATE lpAggregate;
if ((lpAggregate = ((LPIDENT)idObject)->OpenAggregate (pStatus)) == NULL)
return FALSE;
lpAggregate->Invalidate();
lpAggregate->Close();
break;
case itFILESET:
LPFILESET lpFileset;
if ((lpFileset = ((LPIDENT)idObject)->OpenFileset (pStatus)) == NULL)
return FALSE;
lpFileset->Invalidate();
lpFileset->Close();
break;
case itUSER:
LPUSER lpUser;
if ((lpUser = ((LPIDENT)idObject)->OpenUser (pStatus)) == NULL)
return FALSE;
lpUser->Invalidate();
lpUser->Close();
break;
case itGROUP:
LPPTSGROUP lpGroup;
if ((lpGroup = ((LPIDENT)idObject)->OpenGroup (pStatus)) == NULL)
return FALSE;
lpGroup->Invalidate();
lpGroup->Close();
break;
default:
return FALSE_(ERROR_INVALID_PARAMETER,pStatus);
}
return TRUE;
}

View File

@ -0,0 +1,32 @@
#ifndef TAAFSADMSVRPROPERTIES_H
#define TAAFSADMSVRPROPERTIES_H
/*
* INCLUSIONS _________________________________________________________________
*
*/
#include <WINNT/TaAfsAdmSvr.h>
/*
* PROTOTYPES _________________________________________________________________
*
*/
BOOL CALLBACK AfsAdmSvr_NotifyCallback (NOTIFYEVENT evt, PNOTIFYPARAMS pParams);
void AfsAdmSvr_ObtainRudimentaryProperties (LPASOBJPROP pProperties);
BOOL AfsAdmSvr_ObtainFullProperties (LPASOBJPROP pProperties, ULONG *pStatus = NULL);
LPASOBJPROP AfsAdmSvr_GetCurrentProperties (ASID idObject, ULONG *pStatus = NULL);
BOOL AfsAdmSvr_InvalidateObjectProperties (ASID idObject, ULONG *pStatus = NULL);
void AfsAdmSvr_TestProperties (ASID idObject);
void AfsAdmSvr_SetCellRefreshRate (ASID idCell, ULONG cminRefreshRate);
void AfsAdmSvr_StopCellRefreshThread (ASID idCell);
void AfsAdmSvr_MarkRefreshThread (ASID idCell);
#endif // TAAFSADMSVRPROPERTIES_H

View File

@ -0,0 +1,919 @@
extern "C" {
#include <afs/param.h>
#include <afs/stds.h>
}
#include "TaAfsAdmSvrInternal.h"
#define c100ns1SECOND ((LONGLONG)10000000)
/*
* ROUTINES ___________________________________________________________________
*
*/
BOOL IsValidTime (LPSYSTEMTIME pst)
{
return (pst->wYear > 1970) ? TRUE : FALSE;
}
BOOL AfsAdmSvr_Search_Compare (LPTSTR pszName, LPTSTR pszPattern)
{
// An empty pattern matches everyone
//
if (!pszPattern || !*pszPattern)
return TRUE;
// Cache the expression so we only have to compile it when it changes.
// We also add a little convenience measure: you can prepend "!" to any
// regexp to negate the entire sense of the regexp--for instance, "!ri"
// matches every word which doesn't have "ri" in it.
//
static LPREGEXP pLastExpr = NULL;
static TCHAR szLastExpression[ 1024 ] = TEXT("");
static BOOL fLastInclusive = TRUE;
if (lstrcmp (pszPattern, szLastExpression))
{
if (pLastExpr)
Delete (pLastExpr);
lstrcpy (szLastExpression, pszPattern);
if ((fLastInclusive = (*pszPattern != TEXT('!'))) == FALSE)
++pszPattern;
pLastExpr = New2 (REGEXP,(pszPattern));
}
if (!pLastExpr) // this shouldn't happen, but be safe anyway
return TRUE;
return ((pLastExpr->Matches (pszName)) == fLastInclusive);
}
BOOL AfsAdmSvr_Search_Compare (LPIDENT lpi, LPTSTR pszPattern)
{
if (lpi->GetRefCount() == 0)
return FALSE;
TCHAR szName[ cchSTRING ];
switch (lpi->GetType())
{
case itCELL:
lpi->GetCellName (szName);
break;
case itSERVER:
lpi->GetLongServerName (szName);
break;
case itSERVICE:
lpi->GetServiceName (szName);
break;
case itAGGREGATE:
lpi->GetAggregateName (szName);
break;
case itFILESET:
lpi->GetFilesetName (szName);
break;
case itUSER:
lpi->GetUserName (szName);
break;
case itGROUP:
lpi->GetGroupName (szName);
break;
default:
return FALSE;
}
return AfsAdmSvr_Search_Compare (szName, pszPattern);
}
BOOL AfsAdmSvr_SearchRefresh (ASID idSearchScope, ASOBJTYPE ObjectType, AFSADMSVR_SEARCH_REFRESH SearchRefresh, ULONG *pStatus)
{
BOOL rc = TRUE;
ULONG status = 0;
if (SearchRefresh == SEARCH_ALL_OBJECTS)
{
if (GetAsidType (idSearchScope) == itCELL)
{
LPCELL lpCell;
if ((lpCell = ((LPIDENT)idSearchScope)->OpenCell (&status)) == NULL)
rc = FALSE;
else
{
lpCell->RefreshAll();
lpCell->Close();
}
}
else // (GetAsidType (idSearchScope) != itCELL)
{
LPSERVER lpServer;
if ((lpServer = ((LPIDENT)idSearchScope)->OpenServer (&status)) == NULL)
rc = FALSE;
else
{
// What do we need to refresh on this server?
switch (ObjectType)
{
case TYPE_SERVICE:
lpServer->RefreshStatus();
lpServer->RefreshServices();
break;
case TYPE_PARTITION:
case TYPE_VOLUME:
lpServer->RefreshStatus();
lpServer->RefreshAggregates();
break;
default:
lpServer->RefreshAll();
break;
}
lpServer->Close();
}
}
}
if (!rc && pStatus)
*pStatus = status;
return rc;
}
BOOL AfsAdmSvr_Search_AllInCell (LPASIDLIST *ppList, ASID idCell, LPTSTR pszPattern, ULONG *pStatus)
{
BOOL rc = TRUE;
ULONG status = 0;
HENUM hEnum;
for (LPIDENT lpiFind = IDENT::FindFirst (&hEnum); lpiFind; lpiFind = IDENT::FindNext (&hEnum))
{
if (lpiFind->GetCell() != (LPIDENT)idCell)
continue;
if (!AfsAdmSvr_Search_Compare (lpiFind, pszPattern))
continue;
AfsAdmSvr_AddToAsidList (ppList, (ASID)lpiFind, 0);
}
IDENT::FindClose (&hEnum);
if (!rc && pStatus)
*pStatus = status;
return rc;
}
BOOL AfsAdmSvr_Search_ServersInCell (LPASIDLIST *ppList, ASID idCell, LPTSTR pszPattern, ULONG *pStatus)
{
BOOL rc = TRUE;
ULONG status = 0;
LPCELL lpCell;
if ((lpCell = ((LPIDENT)idCell)->OpenCell (&status)) == NULL)
rc = FALSE;
else
{
HENUM hEnum;
for (LPSERVER lpServer = lpCell->ServerFindFirst (&hEnum, TRUE, &status); lpServer; lpServer = lpCell->ServerFindNext (&hEnum))
{
LPIDENT lpiFind = lpServer->GetIdentifier();
if (AfsAdmSvr_Search_Compare (lpiFind, pszPattern))
AfsAdmSvr_AddToAsidList (ppList, (ASID)lpiFind, 0);
lpServer->Close();
}
lpCell->ServerFindClose (&hEnum);
if (status && (status != ADMITERATORDONE))
rc = FALSE;
lpCell->Close();
}
if (!rc && pStatus)
*pStatus = status;
return rc;
}
BOOL AfsAdmSvr_Search_ServicesInCell (LPASIDLIST *ppList, ASID idCell, LPTSTR pszPattern, ULONG *pStatus)
{
BOOL rc = TRUE;
ULONG status = 0;
HENUM hEnum;
for (LPIDENT lpiFind = IDENT::FindFirst (&hEnum); lpiFind; lpiFind = IDENT::FindNext (&hEnum))
{
if (lpiFind->GetType() != itSERVICE)
continue;
if (lpiFind->GetCell() != (LPIDENT)idCell)
continue;
if (!AfsAdmSvr_Search_Compare (lpiFind, pszPattern))
continue;
AfsAdmSvr_AddToAsidList (ppList, (ASID)lpiFind, 0);
}
IDENT::FindClose (&hEnum);
if (!rc && pStatus)
*pStatus = status;
return rc;
}
BOOL AfsAdmSvr_Search_PartitionsInCell (LPASIDLIST *ppList, ASID idCell, LPTSTR pszPattern, ULONG *pStatus)
{
BOOL rc = TRUE;
ULONG status = 0;
HENUM hEnum;
for (LPIDENT lpiFind = IDENT::FindFirst (&hEnum); lpiFind; lpiFind = IDENT::FindNext (&hEnum))
{
if (lpiFind->GetType() != itAGGREGATE)
continue;
if (lpiFind->GetCell() != (LPIDENT)idCell)
continue;
if (!AfsAdmSvr_Search_Compare (lpiFind, pszPattern))
continue;
AfsAdmSvr_AddToAsidList (ppList, (ASID)lpiFind, 0);
}
IDENT::FindClose (&hEnum);
if (!rc && pStatus)
*pStatus = status;
return rc;
}
BOOL AfsAdmSvr_Search_VolumesInCell (LPASIDLIST *ppList, ASID idCell, LPTSTR pszPattern, ULONG *pStatus)
{
BOOL rc = TRUE;
ULONG status = 0;
HENUM hEnum;
for (LPIDENT lpiFind = IDENT::FindFirst (&hEnum); lpiFind; lpiFind = IDENT::FindNext (&hEnum))
{
if (lpiFind->GetType() != itFILESET)
continue;
if (lpiFind->GetCell() != (LPIDENT)idCell)
continue;
if (!AfsAdmSvr_Search_Compare (lpiFind, pszPattern))
continue;
AfsAdmSvr_AddToAsidList (ppList, (ASID)lpiFind, 0);
}
IDENT::FindClose (&hEnum);
if (!rc && pStatus)
*pStatus = status;
return rc;
}
BOOL AfsAdmSvr_Search_UsersInCell (LPASIDLIST *ppList, ASID idCell, LPTSTR pszPattern, ULONG *pStatus)
{
BOOL rc = TRUE;
ULONG status = 0;
LPCELL lpCell;
if ((lpCell = ((LPIDENT)idCell)->OpenCell (&status)) == NULL)
rc = FALSE;
else
{
HENUM hEnum;
for (LPUSER lpUser = lpCell->UserFindFirst (&hEnum, TRUE, &status); lpUser; lpUser = lpCell->UserFindNext (&hEnum))
{
LPIDENT lpiFind = lpUser->GetIdentifier();
if (AfsAdmSvr_Search_Compare (lpiFind, pszPattern))
AfsAdmSvr_AddToAsidList (ppList, (ASID)lpiFind, 0);
lpUser->Close();
}
lpCell->UserFindClose (&hEnum);
if (status && (status != ADMITERATORDONE))
rc = FALSE;
lpCell->Close();
}
if (!rc && pStatus)
*pStatus = status;
return rc;
}
BOOL AfsAdmSvr_Search_GroupsInCell (LPASIDLIST *ppList, ASID idCell, LPTSTR pszPattern, ULONG *pStatus)
{
BOOL rc = TRUE;
ULONG status = 0;
LPCELL lpCell;
if ((lpCell = ((LPIDENT)idCell)->OpenCell (&status)) == NULL)
rc = FALSE;
else
{
HENUM hEnum;
for (LPPTSGROUP lpGroup = lpCell->GroupFindFirst (&hEnum, TRUE, &status); lpGroup; lpGroup = lpCell->GroupFindNext (&hEnum))
{
LPIDENT lpiFind = lpGroup->GetIdentifier();
if (AfsAdmSvr_Search_Compare (lpiFind, pszPattern))
AfsAdmSvr_AddToAsidList (ppList, (ASID)lpiFind, 0);
lpGroup->Close();
}
lpCell->GroupFindClose (&hEnum);
if (status && (status != ADMITERATORDONE))
rc = FALSE;
lpCell->Close();
}
if (!rc && pStatus)
*pStatus = status;
return rc;
}
BOOL AfsAdmSvr_Search_AllInServer (LPASIDLIST *ppList, ASID idServer, LPTSTR pszPattern, ULONG *pStatus)
{
BOOL rc = TRUE;
ULONG status = 0;
LPSERVER lpServer;
if ((lpServer = ((LPIDENT)idServer)->OpenServer (&status)) == NULL)
rc = FALSE;
else
{
HENUM hEnum;
for (LPAGGREGATE lpAggregate = lpServer->AggregateFindFirst (&hEnum, TRUE, &status); lpAggregate; lpAggregate = lpServer->AggregateFindNext (&hEnum))
{
LPIDENT lpiFind = lpAggregate->GetIdentifier();
if (AfsAdmSvr_Search_Compare (lpiFind, pszPattern))
AfsAdmSvr_AddToAsidList (ppList, (ASID)lpiFind, 0);
lpAggregate->Close();
}
lpServer->AggregateFindClose (&hEnum);
if (status && (status != ADMITERATORDONE))
rc = FALSE;
else
{
for (LPSERVICE lpService = lpServer->ServiceFindFirst (&hEnum, TRUE, &status); lpService; lpService = lpServer->ServiceFindNext (&hEnum))
{
LPIDENT lpiFind = lpService->GetIdentifier();
if (AfsAdmSvr_Search_Compare (lpiFind, pszPattern))
AfsAdmSvr_AddToAsidList (ppList, (ASID)lpiFind, 0);
lpService->Close();
}
lpServer->ServiceFindClose (&hEnum);
if (status && (status != ADMITERATORDONE))
rc = FALSE;
}
lpServer->Close();
}
if (!rc && pStatus)
*pStatus = status;
return rc;
}
BOOL AfsAdmSvr_Search_ServicesInServer (LPASIDLIST *ppList, ASID idServer, LPTSTR pszPattern, ULONG *pStatus)
{
BOOL rc = TRUE;
ULONG status = 0;
LPSERVER lpServer;
if ((lpServer = ((LPIDENT)idServer)->OpenServer (&status)) == NULL)
rc = FALSE;
else
{
HENUM hEnum;
for (LPSERVICE lpService = lpServer->ServiceFindFirst (&hEnum, TRUE, &status); lpService; lpService = lpServer->ServiceFindNext (&hEnum))
{
LPIDENT lpiFind = lpService->GetIdentifier();
if (AfsAdmSvr_Search_Compare (lpiFind, pszPattern))
AfsAdmSvr_AddToAsidList (ppList, (ASID)lpiFind, 0);
lpService->Close();
}
lpServer->ServiceFindClose (&hEnum);
if (status && (status != ADMITERATORDONE))
rc = FALSE;
lpServer->Close();
}
if (!rc && pStatus)
*pStatus = status;
return rc;
}
BOOL AfsAdmSvr_Search_PartitionsInServer (LPASIDLIST *ppList, ASID idServer, LPTSTR pszPattern, ULONG *pStatus)
{
BOOL rc = TRUE;
ULONG status = 0;
LPSERVER lpServer;
if ((lpServer = ((LPIDENT)idServer)->OpenServer (&status)) == NULL)
rc = FALSE;
else
{
HENUM hEnum;
for (LPAGGREGATE lpAggregate = lpServer->AggregateFindFirst (&hEnum, TRUE, &status); lpAggregate; lpAggregate = lpServer->AggregateFindNext (&hEnum))
{
LPIDENT lpiFind = lpAggregate->GetIdentifier();
if (AfsAdmSvr_Search_Compare (lpiFind, pszPattern))
AfsAdmSvr_AddToAsidList (ppList, (ASID)lpiFind, 0);
lpAggregate->Close();
}
lpServer->AggregateFindClose (&hEnum);
if (status && (status != ADMITERATORDONE))
rc = FALSE;
lpServer->Close();
}
if (!rc && pStatus)
*pStatus = status;
return rc;
}
BOOL AfsAdmSvr_Search_VolumesInServer (LPASIDLIST *ppList, ASID idServer, LPTSTR pszPattern, ULONG *pStatus)
{
BOOL rc = TRUE;
ULONG status = 0;
HENUM hEnum;
for (LPIDENT lpiFind = IDENT::FindFirst (&hEnum); lpiFind; lpiFind = IDENT::FindNext (&hEnum))
{
if (lpiFind->GetType() != itFILESET)
continue;
if (lpiFind->GetServer() != (LPIDENT)idServer)
continue;
if (!AfsAdmSvr_Search_Compare (lpiFind, pszPattern))
continue;
AfsAdmSvr_AddToAsidList (ppList, (ASID)lpiFind, 0);
}
IDENT::FindClose (&hEnum);
if (!rc && pStatus)
*pStatus = status;
return rc;
}
BOOL AfsAdmSvr_Search_VolumesInPartition (LPASIDLIST *ppList, ASID idPartition, LPTSTR pszPattern, ULONG *pStatus)
{
BOOL rc = TRUE;
ULONG status = 0;
LPAGGREGATE lpAggregate;
if ((lpAggregate = ((LPIDENT)idPartition)->OpenAggregate (&status)) == NULL)
rc = FALSE;
else
{
HENUM hEnum;
for (LPFILESET lpFileset = lpAggregate->FilesetFindFirst (&hEnum, TRUE, &status); lpFileset; lpFileset = lpAggregate->FilesetFindNext (&hEnum))
{
LPIDENT lpiFind = lpFileset->GetIdentifier();
if (AfsAdmSvr_Search_Compare (lpiFind, pszPattern))
AfsAdmSvr_AddToAsidList (ppList, (ASID)lpiFind, 0);
lpFileset->Close();
}
lpAggregate->FilesetFindClose (&hEnum);
if (status && (status != ADMITERATORDONE))
rc = FALSE;
lpAggregate->Close();
}
if (!rc && pStatus)
*pStatus = status;
return rc;
}
BOOL AfsAdmSvr_Search_ServerInCell (ASID *pidObject, ASID idCell, LPTSTR pszName, ULONG *pStatus)
{
BOOL rc = TRUE;
ULONG status = 0;
LPCELL lpCell;
if ((lpCell = ((LPIDENT)idCell)->OpenCell (&status)) == NULL)
rc = FALSE;
else
{
LPSERVER lpServer;
if ((lpServer = lpCell->OpenServer (pszName, &status)) == NULL)
rc = FALSE;
else
{
*pidObject = (ASID)(lpServer->GetIdentifier());
lpServer->Close();
}
lpCell->Close();
}
if (!rc && pStatus)
*pStatus = status;
return rc;
}
BOOL AfsAdmSvr_Search_ServiceInCell (ASID *pidObject, ASID idCell, LPTSTR pszName, ULONG *pStatus)
{
BOOL rc = FALSE;
ULONG status = ERROR_INVALID_PARAMETER;
HENUM hEnum;
for (LPIDENT lpiFind = IDENT::FindFirst (&hEnum); lpiFind; lpiFind = IDENT::FindNext (&hEnum))
{
if (lpiFind->GetType() != itSERVICE)
continue;
if (lpiFind->GetCell() != (LPIDENT)idCell)
continue;
if (lpiFind->GetRefCount() == 0)
return FALSE;
TCHAR szService[ cchNAME ];
lpiFind->GetServiceName (szService);
if (!lstrcmpi (pszName, szService))
{
*pidObject = (ASID)lpiFind;
rc = TRUE;
break;
}
}
IDENT::FindClose (&hEnum);
if (!rc && pStatus)
*pStatus = status;
return rc;
}
BOOL AfsAdmSvr_Search_PartitionInCell (ASID *pidObject, ASID idCell, LPTSTR pszName, ULONG *pStatus)
{
BOOL rc = FALSE;
ULONG status = ERROR_INVALID_PARAMETER;
HENUM hEnum;
for (LPIDENT lpiFind = IDENT::FindFirst (&hEnum); lpiFind; lpiFind = IDENT::FindNext (&hEnum))
{
if (lpiFind->GetType() != itAGGREGATE)
continue;
if (lpiFind->GetCell() != (LPIDENT)idCell)
continue;
if (lpiFind->GetRefCount() == 0)
return FALSE;
TCHAR szAggregate[ cchNAME ];
lpiFind->GetAggregateName (szAggregate);
if (!lstrcmpi (pszName, szAggregate))
{
*pidObject = (ASID)lpiFind;
rc = TRUE;
break;
}
}
IDENT::FindClose (&hEnum);
if (!rc && pStatus)
*pStatus = status;
return rc;
}
BOOL AfsAdmSvr_Search_VolumeInCell (ASID *pidObject, ASID idCell, LPTSTR pszName, ULONG *pStatus)
{
BOOL rc = FALSE;
ULONG status = ERROR_INVALID_PARAMETER;
HENUM hEnum;
for (LPIDENT lpiFind = IDENT::FindFirst (&hEnum); lpiFind; lpiFind = IDENT::FindNext (&hEnum))
{
if (lpiFind->GetType() != itFILESET)
continue;
if (lpiFind->GetCell() != (LPIDENT)idCell)
continue;
if (lpiFind->GetRefCount() == 0)
return FALSE;
TCHAR szFileset[ cchNAME ];
lpiFind->GetFilesetName (szFileset);
if (!lstrcmpi (szFileset, pszName))
{
*pidObject = (ASID)lpiFind;
rc = TRUE;
break;
}
}
IDENT::FindClose (&hEnum);
if (!rc && pStatus)
*pStatus = status;
return rc;
}
BOOL AfsAdmSvr_Search_UserInCell (ASID *pidObject, ASID idCell, LPTSTR pszName, ULONG *pStatus)
{
BOOL rc = TRUE;
ULONG status = 0;
LPCELL lpCell;
if ((lpCell = ((LPIDENT)idCell)->OpenCell (&status)) == NULL)
rc = FALSE;
else
{
LPUSER lpUser;
if ((lpUser = lpCell->OpenUser (pszName, NULL, &status)) == NULL)
rc = FALSE;
else
{
*pidObject = (ASID)(lpUser->GetIdentifier());
lpUser->Close();
}
lpCell->Close();
}
if (!rc && pStatus)
*pStatus = status;
return rc;
}
BOOL AfsAdmSvr_Search_GroupInCell (ASID *pidObject, ASID idCell, LPTSTR pszName, ULONG *pStatus)
{
BOOL rc = TRUE;
ULONG status = 0;
LPCELL lpCell;
if ((lpCell = ((LPIDENT)idCell)->OpenCell (&status)) == NULL)
rc = FALSE;
else
{
LPPTSGROUP lpGroup;
if ((lpGroup = lpCell->OpenGroup (pszName, &status)) == NULL)
rc = FALSE;
else
{
*pidObject = (ASID)(lpGroup->GetIdentifier());
lpGroup->Close();
}
lpCell->Close();
}
if (!rc && pStatus)
*pStatus = status;
return rc;
}
BOOL AfsAdmSvr_Search_ServiceInServer (ASID *pidObject, ASID idServer, LPTSTR pszName, ULONG *pStatus)
{
BOOL rc = TRUE;
ULONG status = 0;
LPSERVER lpServer;
if ((lpServer = ((LPIDENT)idServer)->OpenServer (&status)) == NULL)
rc = FALSE;
else
{
LPSERVICE lpService;
if ((lpService = lpServer->OpenService (pszName, &status)) == NULL)
rc = FALSE;
else
{
*pidObject = (ASID)(lpService->GetIdentifier());
lpService->Close();
}
lpServer->Close();
}
if (!rc && pStatus)
*pStatus = status;
return rc;
}
BOOL AfsAdmSvr_Search_PartitionInServer (ASID *pidObject, ASID idServer, LPTSTR pszName, ULONG *pStatus)
{
BOOL rc = TRUE;
ULONG status = 0;
LPSERVER lpServer;
if ((lpServer = ((LPIDENT)idServer)->OpenServer (&status)) == NULL)
rc = FALSE;
else
{
LPAGGREGATE lpAggregate;
if ((lpAggregate = lpServer->OpenAggregate (pszName, &status)) == NULL)
rc = FALSE;
else
{
*pidObject = (ASID)(lpAggregate->GetIdentifier());
lpAggregate->Close();
}
lpServer->Close();
}
if (!rc && pStatus)
*pStatus = status;
return rc;
}
BOOL AfsAdmSvr_Search_VolumeInServer (ASID *pidObject, ASID idServer, LPTSTR pszName, ULONG *pStatus)
{
BOOL rc = FALSE;
ULONG status = ERROR_INVALID_PARAMETER;
HENUM hEnum;
for (LPIDENT lpiFind = IDENT::FindFirst (&hEnum); lpiFind; lpiFind = IDENT::FindNext (&hEnum))
{
if (lpiFind->GetType() != itFILESET)
continue;
if (lpiFind->GetServer() != (LPIDENT)idServer)
continue;
if (lpiFind->GetRefCount() == 0)
return FALSE;
TCHAR szFileset[ cchNAME ];
lpiFind->GetFilesetName (szFileset);
if (!lstrcmpi (pszName, szFileset))
{
*pidObject = (ASID)lpiFind;
rc = TRUE;
break;
}
}
IDENT::FindClose (&hEnum);
if (!rc && pStatus)
*pStatus = status;
return rc;
}
BOOL AfsAdmSvr_Search_VolumeInPartition (ASID *pidObject, ASID idPartition, LPTSTR pszName, ULONG *pStatus)
{
BOOL rc = TRUE;
ULONG status = 0;
LPAGGREGATE lpAggregate;
if ((lpAggregate = ((LPIDENT)idPartition)->OpenAggregate (&status)) == NULL)
rc = FALSE;
else
{
LPFILESET lpFileset;
if ((lpFileset = lpAggregate->OpenFileset (pszName, &status)) == NULL)
rc = FALSE;
else
{
*pidObject = (ASID)(lpFileset->GetIdentifier());
lpFileset->Close();
}
lpAggregate->Close();
}
if (!rc && pStatus)
*pStatus = status;
return rc;
}
BOOL AfsAdmSvr_Search_OneUser (ASID *pidObject, ASID idScope, LPTSTR pszName, ULONG *pStatus)
{
BOOL rc = TRUE;
ULONG status = 0;
LPCELL lpCell;
if ((lpCell = ((LPIDENT)idScope)->OpenCell (&status)) == NULL)
rc = FALSE;
else
{
LPUSER lpUser;
if ((lpUser = lpCell->OpenUser (pszName, TEXT(""), &status)) == NULL)
rc = FALSE;
else
{
*pidObject = (ASID)(lpUser->GetIdentifier());
lpUser->Close();
}
lpCell->Close();
}
if (!rc && pStatus)
*pStatus = status;
return rc;
}
BOOL AfsAdmSvr_Search_OneGroup (ASID *pidObject, ASID idScope, LPTSTR pszName, ULONG *pStatus)
{
BOOL rc = TRUE;
ULONG status = 0;
LPCELL lpCell;
if ((lpCell = ((LPIDENT)idScope)->OpenCell (&status)) == NULL)
rc = FALSE;
else
{
LPPTSGROUP lpGroup;
if ((lpGroup = lpCell->OpenGroup (pszName, &status)) == NULL)
rc = FALSE;
else
{
*pidObject = (ASID)(lpGroup->GetIdentifier());
lpGroup->Close();
}
lpCell->Close();
}
if (!rc && pStatus)
*pStatus = status;
return rc;
}
void AfsAdmSvr_Search_Advanced (LPASIDLIST *ppList, LPAFSADMSVR_SEARCH_PARAMS pSearchParams)
{
ULONG status;
if (ppList && (*ppList) && pSearchParams && (pSearchParams->SearchType != SEARCH_NO_LIMITATIONS))
{
for (size_t iEntry = 0; iEntry < (*ppList)->cEntries; )
{
BOOL fDelete = TRUE;
// Try to grab the properties for this object. If we succeed,
// we can determine if the object matches the necessary criteria
// to indicate we should keep it in the list.
//
ASID idObject = (*ppList)->aEntries[ iEntry ].idObject;
LPASOBJPROP pProperties;
if ((pProperties = AfsAdmSvr_GetCurrentProperties (idObject, &status)) != NULL)
{
if ( (pProperties->verProperties >= verPROP_FIRST_SCAN) ||
(AfsAdmSvr_ObtainFullProperties (pProperties, &status)) )
{
// We managed to get the full properties for this object.
// Now check its properties against our search criteria--
// only if it has exactly the necessary criteria will we
// clear {fDelete}.
//
switch (pSearchParams->SearchType)
{
case SEARCH_EXPIRES_BEFORE:
if ((pProperties->Type == TYPE_USER) && (pProperties->u.UserProperties.fHaveKasInfo))
{
if (IsValidTime (&pProperties->u.UserProperties.KASINFO.timeExpires))
{
FILETIME ftExpires;
SystemTimeToFileTime (&pProperties->u.UserProperties.KASINFO.timeExpires, &ftExpires);
FILETIME ftThreshhold;
SystemTimeToFileTime (&pSearchParams->SearchTime, &ftThreshhold);
if (CompareFileTime (&ftExpires, &ftThreshhold) <= 0)
fDelete = FALSE;
}
}
break;
case SEARCH_PASSWORD_EXPIRES_BEFORE:
if ((pProperties->Type == TYPE_USER) && (pProperties->u.UserProperties.fHaveKasInfo))
{
if (pProperties->u.UserProperties.KASINFO.cdayPwExpire)
{
FILETIME ftPwExpires;
SystemTimeToFileTime (&pProperties->u.UserProperties.KASINFO.timeLastPwChange, &ftPwExpires);
// A FILETIME is a count-of-100ns-intervals since 1601.
// We need to increase the {ftPwExpires} time by the
// number of days in KASINFO.cdayPwExpires, so we'll
// be adding a big number to our FILETIME structure.
//
LARGE_INTEGER ldw;
ldw.HighPart = ftPwExpires.dwHighDateTime;
ldw.LowPart = ftPwExpires.dwLowDateTime;
ldw.QuadPart += c100ns1SECOND * (LONGLONG)csec1DAY * (LONGLONG)pProperties->u.UserProperties.KASINFO.cdayPwExpire;
ftPwExpires.dwHighDateTime = (DWORD)ldw.HighPart;
ftPwExpires.dwLowDateTime = (DWORD)ldw.LowPart;
FILETIME ftThreshhold;
SystemTimeToFileTime (&pSearchParams->SearchTime, &ftThreshhold);
if (CompareFileTime (&ftPwExpires, &ftThreshhold) <= 0)
fDelete = FALSE;
}
}
break;
}
}
}
// Okay, we've made our choice--remove it, or not.
//
if (fDelete)
AfsAdmSvr_RemoveFromAsidListByIndex (ppList, iEntry);
else
++iEntry;
}
}
}

View File

@ -0,0 +1,49 @@
#ifndef TAAFSADMSVRSEARCH_H
#define TAAFSADMSVRSEARCH_H
/*
* INCLUSIONS _________________________________________________________________
*
*/
#include <WINNT/TaAfsAdmSvr.h>
/*
* PROTOTYPES _________________________________________________________________
*
*/
BOOL AfsAdmSvr_SearchRefresh (ASID idSearchScope, ASOBJTYPE ObjectType, AFSADMSVR_SEARCH_REFRESH SearchRefresh, ULONG *pStatus);
BOOL AfsAdmSvr_Search_AllInCell (LPASIDLIST *ppList, ASID idCell, LPTSTR pszPattern, ULONG *pStatus = NULL);
BOOL AfsAdmSvr_Search_ServersInCell (LPASIDLIST *ppList, ASID idCell, LPTSTR pszPattern, ULONG *pStatus = NULL);
BOOL AfsAdmSvr_Search_ServicesInCell (LPASIDLIST *ppList, ASID idCell, LPTSTR pszPattern, ULONG *pStatus = NULL);
BOOL AfsAdmSvr_Search_PartitionsInCell (LPASIDLIST *ppList, ASID idCell, LPTSTR pszPattern, ULONG *pStatus = NULL);
BOOL AfsAdmSvr_Search_VolumesInCell (LPASIDLIST *ppList, ASID idCell, LPTSTR pszPattern, ULONG *pStatus = NULL);
BOOL AfsAdmSvr_Search_UsersInCell (LPASIDLIST *ppList, ASID idCell, LPTSTR pszPattern, ULONG *pStatus = NULL);
BOOL AfsAdmSvr_Search_GroupsInCell (LPASIDLIST *ppList, ASID idCell, LPTSTR pszPattern, ULONG *pStatus = NULL);
BOOL AfsAdmSvr_Search_AllInServer (LPASIDLIST *ppList, ASID idServer, LPTSTR pszPattern, ULONG *pStatus = NULL);
BOOL AfsAdmSvr_Search_ServicesInServer (LPASIDLIST *ppList, ASID idServer, LPTSTR pszPattern, ULONG *pStatus = NULL);
BOOL AfsAdmSvr_Search_PartitionsInServer (LPASIDLIST *ppList, ASID idServer, LPTSTR pszPattern, ULONG *pStatus = NULL);
BOOL AfsAdmSvr_Search_VolumesInServer (LPASIDLIST *ppList, ASID idServer, LPTSTR pszPattern, ULONG *pStatus = NULL);
BOOL AfsAdmSvr_Search_VolumesInPartition (LPASIDLIST *ppList, ASID idPartition, LPTSTR pszPattern, ULONG *pStatus = NULL);
BOOL AfsAdmSvr_Search_ServerInCell (ASID *pidObject, ASID idCell, LPTSTR pszName, ULONG *pStatus = NULL);
BOOL AfsAdmSvr_Search_ServiceInCell (ASID *pidObject, ASID idCell, LPTSTR pszName, ULONG *pStatus = NULL);
BOOL AfsAdmSvr_Search_PartitionInCell (ASID *pidObject, ASID idCell, LPTSTR pszName, ULONG *pStatus = NULL);
BOOL AfsAdmSvr_Search_VolumeInCell (ASID *pidObject, ASID idCell, LPTSTR pszName, ULONG *pStatus = NULL);
BOOL AfsAdmSvr_Search_UserInCell (ASID *pidObject, ASID idCell, LPTSTR pszName, ULONG *pStatus = NULL);
BOOL AfsAdmSvr_Search_GroupInCell (ASID *pidObject, ASID idCell, LPTSTR pszName, ULONG *pStatus = NULL);
BOOL AfsAdmSvr_Search_ServiceInServer (ASID *pidObject, ASID idServer, LPTSTR pszName, ULONG *pStatus = NULL);
BOOL AfsAdmSvr_Search_PartitionInServer (ASID *pidObject, ASID idServer, LPTSTR pszName, ULONG *pStatus = NULL);
BOOL AfsAdmSvr_Search_VolumeInServer (ASID *pidObject, ASID idServer, LPTSTR pszName, ULONG *pStatus = NULL);
BOOL AfsAdmSvr_Search_VolumeInPartition (ASID *pidObject, ASID idPartition, LPTSTR pszName, ULONG *pStatus = NULL);
BOOL AfsAdmSvr_Search_OneUser (ASID *pidObject, ASID idScope, LPTSTR pszName, ULONG *pStatus = NULL);
BOOL AfsAdmSvr_Search_OneGroup (ASID *pidObject, ASID idScope, LPTSTR pszName, ULONG *pStatus = NULL);
void AfsAdmSvr_Search_Advanced (LPASIDLIST *ppList, LPAFSADMSVR_SEARCH_PARAMS pSearchParams);
#endif // TAAFSADMSVRSEARCH_H

View File

@ -0,0 +1,243 @@
extern "C" {
#include <afs/param.h>
#include <afs/stds.h>
}
#include "TaAfsAdmSvrInternal.h"
/*
* ROUTINES ___________________________________________________________________
*
*/
// AfsAdmSvr_ChangeUser
// ...changes a user account's properties.
//
int AfsAdmSvr_ChangeUser (DWORD idClient, ASID idCell, ASID idUser, LPAFSADMSVR_CHANGEUSER_PARAMS pChange, ULONG *pStatus)
{
ASACTION Action;
Action.Action = ACTION_USER_CHANGE;
Action.idClient = idClient;
Action.idCell = idCell;
Action.u.User_Change.idUser = idUser;
size_t iOp = AfsAdmSvr_BeginOperation (idClient, &Action);
Print (dlDETAIL, TEXT("Client 0x%08lX: ChangeUser (idUser=0x%08lX)"), idClient, idUser);
if (!AfsAdmSvr_fIsValidClient (idClient))
return FALSE_(ERROR_INVALID_PARAMETER,pStatus,iOp);
// Find this user's current properties
//
LPASOBJPROP pCurrentProperties;
if ((pCurrentProperties = AfsAdmSvr_GetCurrentProperties (idUser, pStatus)) == NULL)
{
Print (dlERROR, TEXT("Client 0x%08lX: ChangeUser failed; no properties"), idClient);
AfsAdmSvr_EndOperation (iOp);
return FALSE;
}
// Build an AFSCLASS-style USERPROPERTIES structure that reflects the
// new properties for the user; mark the structure's dwMask bit to indicate
// what we're changing.
//
USERPROPERTIES NewProperties;
memset (&NewProperties, 0x00, sizeof(NewProperties));
if ((NewProperties.fAdmin = pChange->fIsAdmin) != pCurrentProperties->u.UserProperties.KASINFO.fIsAdmin)
NewProperties.dwMask |= MASK_USERPROP_fAdmin;
if ((NewProperties.fGrantTickets = pChange->fCanGetTickets) != pCurrentProperties->u.UserProperties.KASINFO.fCanGetTickets)
NewProperties.dwMask |= MASK_USERPROP_fGrantTickets;
if ((NewProperties.fCanEncrypt = pChange->fEncrypt) != pCurrentProperties->u.UserProperties.KASINFO.fEncrypt)
NewProperties.dwMask |= MASK_USERPROP_fCanEncrypt;
if ((NewProperties.fCanChangePassword = pChange->fCanChangePassword) != pCurrentProperties->u.UserProperties.KASINFO.fCanChangePassword)
NewProperties.dwMask |= MASK_USERPROP_fCanChangePassword;
if ((NewProperties.fCanReusePasswords = pChange->fCanReusePasswords) != pCurrentProperties->u.UserProperties.KASINFO.fCanReusePasswords)
NewProperties.dwMask |= MASK_USERPROP_fCanReusePasswords;
if ((NewProperties.cdayPwExpires = pChange->cdayPwExpire) != pCurrentProperties->u.UserProperties.KASINFO.cdayPwExpire)
NewProperties.dwMask |= MASK_USERPROP_cdayPwExpires;
if ((NewProperties.csecTicketLifetime = pChange->csecTicketLifetime) != pCurrentProperties->u.UserProperties.KASINFO.csecTicketLifetime)
NewProperties.dwMask |= MASK_USERPROP_csecTicketLifetime;
if ((NewProperties.nFailureAttempts = pChange->cFailLogin) != pCurrentProperties->u.UserProperties.KASINFO.cFailLogin)
NewProperties.dwMask |= MASK_USERPROP_nFailureAttempts;
if ((NewProperties.csecFailedLoginLockTime = pChange->csecFailLoginLock) != pCurrentProperties->u.UserProperties.KASINFO.csecFailLoginLock)
NewProperties.dwMask |= MASK_USERPROP_csecFailedLoginLockTime;
if ((NewProperties.cGroupCreationQuota = pChange->cgroupCreationQuota) != pCurrentProperties->u.UserProperties.PTSINFO.cgroupCreationQuota)
NewProperties.dwMask |= MASK_USERPROP_cGroupCreationQuota;
if ((NewProperties.aaListStatus = pChange->aaListStatus) != pCurrentProperties->u.UserProperties.PTSINFO.aaListStatus)
NewProperties.dwMask |= MASK_USERPROP_aaListStatus;
if ((NewProperties.aaGroupsOwned = pChange->aaGroupsOwned) != pCurrentProperties->u.UserProperties.PTSINFO.aaGroupsOwned)
NewProperties.dwMask |= MASK_USERPROP_aaGroupsOwned;
if ((NewProperties.aaMembership = pChange->aaMembership) != pCurrentProperties->u.UserProperties.PTSINFO.aaMembership)
NewProperties.dwMask |= MASK_USERPROP_aaMembership;
memcpy (&NewProperties.timeAccountExpires, &pChange->timeExpires, sizeof(SYSTEMTIME));
if (memcmp (&NewProperties.timeAccountExpires, &pCurrentProperties->u.UserProperties.KASINFO.timeExpires, sizeof(SYSTEMTIME)))
NewProperties.dwMask |= MASK_USERPROP_timeAccountExpires;
// If we've decided to change anything, call AfsClass to actually do it
//
if (NewProperties.dwMask == 0)
{
Print (dlDETAIL, TEXT("Client 0x%08lX: ChangeUser succeeded (nothing to do)"), idClient);
}
else
{
ULONG status;
if (!AfsClass_SetUserProperties ((LPIDENT)idUser, &NewProperties, &status))
{
Print (dlERROR, TEXT("Client 0x%08lX: ChangeUser failed; error 0x%08lX"), idClient, status);
return FALSE_(status,pStatus,iOp);
}
Print (dlDETAIL, TEXT("Client 0x%08lX: ChangeUser succeeded"), idClient);
}
AfsAdmSvr_EndOperation (iOp);
return TRUE;
}
// AfsAdmSvr_SetUserPassword
// ...changes the password for the specified user account. Pass a non-empty
// string in {keyString} to encrypt the specified string; otherwise,
// pass a valid encryption key in {keyData}.
//
int AfsAdmSvr_SetUserPassword (DWORD idClient, ASID idCell, ASID idUser, int keyVersion, STRING keyString, BYTE keyData[ ENCRYPTIONKEYLENGTH ], ULONG *pStatus)
{
BOOL rc = TRUE;
ULONG status = 0;
ASACTION Action;
Action.Action = ACTION_USER_PW_CHANGE;
Action.idClient = idClient;
Action.idCell = idCell;
Action.u.User_Pw_Change.idUser = idUser;
size_t iOp = AfsAdmSvr_BeginOperation (idClient, &Action);
Print (dlDETAIL, TEXT("Client 0x%08lX: SetUserPassword (idUser=0x%08lX)"), idClient, idUser);
if (!AfsAdmSvr_fIsValidClient (idClient))
return FALSE_(ERROR_INVALID_PARAMETER,pStatus,iOp);
// Change the user's password
//
if (keyString && keyString[0])
{
rc = AfsClass_SetUserPassword ((LPIDENT)idUser, keyVersion, keyString, &status);
}
else // (!keyString || !keyString[0])
{
rc = AfsClass_SetUserPassword ((LPIDENT)idUser, keyVersion, (LPENCRYPTIONKEY)keyData, &status);
}
if (!rc)
return FALSE_(status,pStatus,iOp);
Print (dlDETAIL, TEXT("Client 0x%08lX: SetUserPassword succeeded"), idClient);
AfsAdmSvr_EndOperation (iOp);
return TRUE;
}
// AfsAdmSvr_UnlockUser
// ...unlocks a user's account
//
int AfsAdmSvr_UnlockUser (DWORD idClient, ASID idCell, ASID idUser, ULONG *pStatus)
{
ASACTION Action;
Action.Action = ACTION_USER_UNLOCK;
Action.idClient = idClient;
Action.idCell = idCell;
Action.u.User_Unlock.idUser = idUser;
size_t iOp = AfsAdmSvr_BeginOperation (idClient, &Action);
Print (dlDETAIL, TEXT("Client 0x%08lX: UnlockUser (idUser=0x%08lX)"), idClient, idUser);
if (!AfsAdmSvr_fIsValidClient (idClient))
return FALSE_(ERROR_INVALID_PARAMETER,pStatus,iOp);
// Unlock the user's account
//
ULONG status;
if (!AfsClass_UnlockUser ((LPIDENT)idUser, &status))
return FALSE_(status,pStatus,iOp);
Print (dlDETAIL, TEXT("Client 0x%08lX: UnlockUser succeeded"), idClient);
AfsAdmSvr_EndOperation (iOp);
return TRUE;
}
// AfsAdmSvr_CreateUser
// ...creates a new user account
//
int AfsAdmSvr_CreateUser (DWORD idClient, ASID idCell, LPAFSADMSVR_CREATEUSER_PARAMS pCreate, ASID *pidUser, ULONG *pStatus)
{
ASACTION Action;
Action.Action = ACTION_USER_CREATE;
Action.idClient = idClient;
Action.idCell = idCell;
lstrcpy (Action.u.User_Create.szUser, pCreate->szName);
lstrcpy (Action.u.User_Create.szInstance, pCreate->szInstance);
size_t iOp = AfsAdmSvr_BeginOperation (idClient, &Action);
Print (dlDETAIL, TEXT("Client 0x%08lX: CreateUser (szUser=%s)"), idClient, pCreate->szName);
if (!AfsAdmSvr_fIsValidClient (idClient))
return FALSE_(ERROR_INVALID_PARAMETER,pStatus,iOp);
// Create the user account
//
ULONG status;
LPIDENT lpiUser;
if ((lpiUser = AfsClass_CreateUser ((LPIDENT)idCell, pCreate->szName, pCreate->szInstance, pCreate->szPassword, pCreate->idUser, pCreate->fCreateKAS, pCreate->fCreatePTS, &status)) == NULL)
{
Print (dlERROR, TEXT("Client 0x%08lX: CreateUser failed; error 0x%08lX"), idClient, status);
return FALSE_(status,pStatus,iOp);
}
if (pidUser)
*pidUser = (ASID)lpiUser;
// Creating a user account may change the max user ID
AfsAdmSvr_TestProperties (idCell);
Print (dlDETAIL, TEXT("Client 0x%08lX: CreateUser succeeded"), idClient);
AfsAdmSvr_EndOperation (iOp);
return TRUE;
}
// AfsAdmSvr_DeleteUser
// ...deletes a user's account
//
int AfsAdmSvr_DeleteUser (DWORD idClient, ASID idCell, ASID idUser, LPAFSADMSVR_DELETEUSER_PARAMS pDelete, ULONG *pStatus)
{
ASACTION Action;
Action.Action = ACTION_USER_DELETE;
Action.idClient = idClient;
Action.idCell = idCell;
Action.u.User_Delete.idUser = idUser;
size_t iOp = AfsAdmSvr_BeginOperation (idClient, &Action);
Print (dlDETAIL, TEXT("Client 0x%08lX: DeleteUser (idUser=0x%08lX)"), idClient, idUser);
if (!AfsAdmSvr_fIsValidClient (idClient))
return FALSE_(ERROR_INVALID_PARAMETER,pStatus,iOp);
// Delete the user's accounts
//
ULONG status;
if (!AfsClass_DeleteUser ((LPIDENT)idUser, pDelete->fDeleteKAS, pDelete->fDeletePTS, &status))
{
Print (dlERROR, TEXT("Client 0x%08lX: DeleteUser failed; error 0x%08lX"), idClient, status);
return FALSE_(status,pStatus,iOp);
}
Print (dlDETAIL, TEXT("Client 0x%08lX: DeleteUser succeeded"), idClient);
AfsAdmSvr_EndOperation (iOp);
return TRUE;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

@ -0,0 +1,82 @@
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include <windows.h>
#ifndef APSTUDIO_INVOKED
#define AFS_VERINFO_FILE_DESCRIPTION "AFS Administration Server"
#include "AFS_component_version_number.h"
#include "..\..\config\NTVersioninfo.rc"
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_MAIN ICON DISCARDABLE "afsadmsvr.ico"
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"#include <windows.h>\r\n"
"#ifndef APSTUDIO_INVOKED\r\n"
"#define AFS_VERINFO_FILE_DESCRIPTION ""AFS Administration Server DLL""\r\n"
"#include ""AFS_component_version_number.h""\r\n"
"#include ""..\..\config\NTVersioninfo.rc""\r\n"
"#endif // APSTUDIO_INVOKED\r\n"
"\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View File

@ -0,0 +1,17 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by afsadmsvr.rc
//
#define IDI_MAIN 102
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NO_MFC 1
#define _APS_NEXT_RESOURCE_VALUE 103
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

View File

@ -0,0 +1,137 @@
# Copyright (C) 1998 Transarc Corporation. All rights reserved.
############################################################################
# make compiler warnings fatal
AFSDEV_AUXCDEFINES = $(AFSDEV_AUXCDEFINES) -WX
# indicate that the functions in this library should be exported
AFSDEV_AUXCDEFINES = $(AFSDEV_AUXCDEFINES) -DEXPORT_AFSAPPLIB -DEXPORTED=_declspec(dllexport)
# include the primary makefile
!INCLUDE ..\..\config\NTMakefile.$(SYS_NAME)
!INCLUDE ..\..\config\NTMakefile.version
############################################################################
INCFILEDIR = $(DESTDIR)\include\WINNT
ILIBDIR = $(DESTDIR)\lib\afs
INCFILES = \
$(INCFILEDIR)\afsapplib.h \
$(INCFILEDIR)\al_admsvr.h \
$(INCFILEDIR)\al_dynlink.h \
$(INCFILEDIR)\al_messages.h \
$(INCFILEDIR)\al_progress.h \
$(INCFILEDIR)\al_resource.h \
$(INCFILEDIR)\al_wizard.h \
$(INCFILEDIR)\checklist.h \
$(INCFILEDIR)\ctl_date.h \
$(INCFILEDIR)\ctl_elapsed.h \
$(INCFILEDIR)\ctl_sockaddr.h \
$(INCFILEDIR)\ctl_spinner.h \
$(INCFILEDIR)\ctl_time.h \
$(INCFILEDIR)\dialog.h \
$(INCFILEDIR)\fastlist.h \
$(INCFILEDIR)\hashlist.h \
$(INCFILEDIR)\regexp.h \
$(INCFILEDIR)\resize.h \
$(INCFILEDIR)\settings.h \
$(INCFILEDIR)\subclass.h
DLLOBJS = \
afsapplib_stub.res \
afsapplib.obj \
al_admsvr.obj \
al_browse.obj \
al_browseset.obj \
al_cover.obj \
al_creds.obj \
al_dynlink.obj \
al_error.obj \
al_help.obj \
al_misc.obj \
al_progress.obj \
al_pump.obj \
al_task.obj \
al_wizard.obj \
checklist.obj \
ctl_date.obj \
ctl_elapsed.obj \
ctl_sockaddr.obj \
ctl_spinner.obj \
ctl_time.obj \
dialog.obj \
fastlist.obj \
hashlist.obj \
regexp.obj \
resize.obj \
settings.obj \
subclass.obj
VCLIBS =\
comctl32.lib \
rpcrt4.lib \
rpcns4.lib \
DLLLIBS = \
$(DESTDIR)\lib\afs\TaAfsAdmSvrClient.lib \
$(DESTDIR)\lib\afs\TaLocale.lib
DLLFILE = $(DESTDIR)\root.server\usr\afs\bin\TaAfsAppLib.dll
# Since AfsAppLib links with TaAfsAdmSvrClient.lib--and both need stuff
# like the HashList code--we'll get lots of unnecessary 4049 warnings from
# the linker. Disable that complaint.
LOCALLINKFLAGS = -IGNORE:4049
# AfsAppLib needs to use an explicit .DEF file to get its entry points public
LOCALLINKFLAGS = $(LOCALLINKFLAGS) /DEF:TaAfsAppLib.def
# Also, AfsAppLib has a specific DLL entry-point which should be used
LOCALLINKFLAGS = $(LOCALLINKFLAGS) -entry:DllEntryPoint
############################################################################
install :
@echo TaAfsAppLib.DLL is built automatically when building AfsAdmSvr
@echo (the two are related--AfsAppLib uses the AfsAdmSvr client library,
@echo and the AfsAdmSvr server executable uses the AfsAppLib DLL--
@echo and they must therefore be built in a specific order).
@echo.
@echo You do not need to build in the AfsAppLib directory explicitly.
@echo.
headers : $(INCFILES)
lang ::
$(CD) lang
for /f %l in ('dir /B ??_??') do @$(NTLANG) %l $(MAKECMD) /nologo /f NTMakefile install
$(CD) ..
primary : headers $(DLLFILE) lang
$(DLLFILE) : $(DLLOBJS) $(DLLLIBS)
$(DLLGUILINK) $(LOCALLINKFLAGS) $(VCLIBS)
$(DLLPREP)
$(COPY) $*.lib $(ILIBDIR)
$(DEL) $*.lib $*.exp
clean::
############################################################################
#
# Dependencies
#
AfsAppLib_stub.res : AfsAppLib_stub.rc AFS_component_version_number.h

View File

@ -0,0 +1,99 @@
LIBRARY TAAFSAPPLIB
DESCRIPTION 'Transarc Application Base DLL'
EXPORTS
DllEntryPoint
?TaLocaleReallocFunction@@YAHPAPAXIPAIII@Z
?TaLocale_EnumModule@@YAHIPAPAUHINSTANCE__@@PAG@Z
?TaLocale_GetDialogResource@@YAPBUDLGTEMPLATE@@HPAPAUHINSTANCE__@@@Z
?TaLocale_GetLanguage@@YAGXZ
?TaLocale_LoadCorrespondingModule@@YAPAUHINSTANCE__@@PAU1@G@Z
?TaLocale_GetLanguageOverride@@YAGXZ
?TaLocale_RemoveLanguageOverride@@YAXXZ
?TaLocale_SetLanguageOverride@@YAXG@Z
?TaLocale_LoadImage@@YAPAXHIHHI@Z
?TaLocale_LoadMenu@@YAPAUHMENU__@@H@Z
?TaLocale_LoadIcon@@YAPAUHICON__@@H@Z
?TaLocale_LoadAccelerators@@YAPAUHACCEL__@@H@Z
?TaLocale_GetResource@@YAPBXPBD0GPAPAUHINSTANCE__@@@Z
?TaLocale_GetResourceEx@@YAPBXPBD0GPAPAUHINSTANCE__@@H@Z
?TaLocale_GetStringResource@@YAPBUSTRINGTEMPLATE@@HPAPAUHINSTANCE__@@@Z
?TaLocale_Initialize@@YAXXZ
?TaLocale_SetLanguage@@YAXG@Z
?TaLocale_SpecifyModule@@YAXPAUHINSTANCE__@@G@Z
?Message@@YAHIHHPBDZZ
?Message@@YAHIHPBD0ZZ
?Message@@YAHIPBD00ZZ
?Message@@YAHIPBDH0ZZ
?Message_ThreadProc@@YGKPAX@Z
?ModalDialog@@YAHHPAUHWND__@@P6GH0IIJ@Z@Z
?ModalDialogParam@@YAHHPAUHWND__@@P6GH0IIJ@ZJ@Z
?ModelessDialog@@YAPAUHWND__@@HPAU1@P6GH0IIJ@Z@Z
?ModelessDialogParam@@YAPAUHWND__@@HPAU1@P6GH0IIJ@ZJ@Z
?vMessage@@YAHIHHPBDPAD@Z
?vMessage@@YAHIHPBD0PAD@Z
?vMessage@@YAHIJJPBDPAD@Z
?vMessage@@YAHIPBD00PAD@Z
?vMessage@@YAHIPBDH0PAD@Z
?AnsiToString@@YAPADPBD@Z
?AnsiToUnicode@@YAPAGPBD@Z
?ChangeExtension@@YAXPADPBD1H@Z
?CloneAnsi@@YAPADPAD@Z
?CloneMultiString@@YAPADPBD@Z
?CloneString@@YAPADPAD@Z
?CloneUnicode@@YAPADPAG@Z
?CopyAnsiToString@@YAXPADPBDI@Z
?CopyAnsiToUnicode@@YAXPAGPBDI@Z
?CopyBaseFileName@@YAXPADPBD@Z
?CopyStringToAnsi@@YAXPADPBDI@Z
?CopyStringToUnicode@@YAXPAGPBDI@Z
?CopyUnicodeToAnsi@@YAXPADPBGI@Z
?CopyUnicodeToString@@YAXPADPBGI@Z
?FindBaseFileName@@YAPBDPBD@Z
?FindExtension@@YAPBDPBD@Z
?FixFormatString@@YAPADPAD@Z
?FormatBytes@@YAXPAD0N@Z
?FormatDouble@@YAXPAD0N@Z
?FormatElapsed@@YAHPAD0PAU_SYSTEMTIME@@@Z
?FormatError@@YAHPAD0K@Z
?FormatLargeInt@@YAXPAD0PAT_LARGE_INTEGER@@@Z
?FormatMultiString@@YAXPAPADHHPBDZZ
?FormatMultiString@@YAXPAPADHPBD1ZZ
?FormatSockAddr@@YAXPAD0PAUsockaddr_in@@@Z
?FormatString@@YAPADHPBDZZ
?FormatString@@YAPADPBD0ZZ
?FormatTime@@YAHPAD0PAU_SYSTEMTIME@@HH@Z
?FreeString@@YAXPBX0@Z
?GetString@@YAXPADHH@Z
?GetStringLength@@YAIH@Z
?SearchMultiString@@YAHPBD0H@Z
?SetErrorTranslationFunction@@YAXP6GHPADKG@Z@Z
?StringToAnsi@@YAPADPBD@Z
?StringToUnicode@@YAPAGPBD@Z
?TranslateError@@YAHPADK@Z
?TranslateErrorFunc@@YAHPADKG@Z
?UnicodeToAnsi@@YAPADPBG@Z
?UnicodeToString@@YAPADPBG@Z
?lsplitpath@@YAXPBDPAD111@Z
?lstrchr@@YAPBDPBDD@Z
?lstrncmpi@@YAHPBD0I@Z
?lstrncpy@@YAXPADPBDI@Z
?lstrrchr@@YAPBDPBDD@Z
?lstrupr@@YAXPAD@Z
?lstrzcpy@@YAXPADPBDI@Z
?vFormatMultiString@@YAXPAPADHHPBDPAD@Z
?vFormatMultiString@@YAXPAPADHJPBDPAD@Z
?vFormatMultiString@@YAXPAPADHPBD1PAD@Z
?vFormatString@@YAPADHPBDPAD@Z
?vFormatString@@YAPADJPBDPAD@Z
?vFormatString@@YAPADPBD0PAD@Z
ShowMemoryManager
WhileMemoryManagerShowing
IsMemoryManagerMessage
MemMgr_AllocateMemory
MemMgr_FreeMemory
MemMgr_TrackNew
MemMgr_TrackDelete

View File

@ -0,0 +1,91 @@
extern "C" {
#include <afs/param.h>
#include <afs/stds.h>
}
#include <WINNT/afsapplib.h>
/*
* VARIABLES __________________________________________________________________
*
*/
static HWND g_hMain = NULL;
static TCHAR g_szAppName[ cchNAME ] = TEXT("");
/*
* PROTOTYPES _________________________________________________________________
*
*/
extern void OnCoverWindow (WPARAM wp, LPARAM lp);
extern void OnExpiredCredentials (WPARAM wp, LPARAM lp);
extern void OnCreateErrorDialog (WPARAM wp, LPARAM lp);
BOOL CALLBACK AfsAppLib_MainHook (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp);
/*
* ROUTINES ___________________________________________________________________
*
*/
void AfsAppLib_SetAppName (LPTSTR pszName)
{
lstrcpy (g_szAppName, pszName);
}
void AfsAppLib_GetAppName (LPTSTR pszName)
{
lstrcpy (pszName, g_szAppName);
}
void AfsAppLib_SetMainWindow (HWND hMain)
{
if (g_hMain != NULL)
Subclass_RemoveHook (g_hMain, AfsAppLib_MainHook);
if ((g_hMain = hMain) != NULL)
Subclass_AddHook (g_hMain, AfsAppLib_MainHook);
}
HWND AfsAppLib_GetMainWindow (void)
{
return g_hMain;
}
BOOL CALLBACK AfsAppLib_MainHook (HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
{
PVOID oldProc = Subclass_FindNextHook (hWnd, AfsAppLib_MainHook);
switch (msg)
{
case WM_COVER_WINDOW:
OnCoverWindow (wp, lp);
break;
case WM_EXPIRED_CREDENTIALS:
OnExpiredCredentials (wp, lp);
break;
case WM_CREATE_ERROR_DIALOG:
OnCreateErrorDialog (wp, lp);
break;
case WM_DESTROY:
AfsAppLib_SetMainWindow (NULL);
break;
}
if (oldProc)
return CallWindowProc ((WNDPROC)oldProc, hWnd, msg, wp, lp);
else
return DefWindowProc (hWnd, msg, wp, lp);
}

View File

@ -0,0 +1,746 @@
#ifndef AFSAPPLIB_H
#define AFSAPPLIB_H
/*
* The AFS Application Library is a collection of handy support code
* for UI-level applications written for Windows NT and Windows 95.
*
* The various components of the library provide common dialogs,
* error code translation, task threading, error dialogs, additional
* Windows dialog controls, and many other functions.
*
* The goal of this library is to shorten application development time
* by providing pre-packaged functions, while ensuring a common user
* interface for Transarc applications.
*
*/
/*
* DEFINITIONS ________________________________________________________________
*
*/
#ifdef EXPORTED
#undef EXPORTED
#endif
#ifdef EXPORT_AFSAPPLIB
#define EXPORTED __declspec(dllexport)
#else
#define EXPORTED __declspec(dllimport)
#endif
#ifndef APP_HINST
# define APP_HINST AfsAppLib_GetAppInstance()
#endif
#ifndef APPLIB_HINST
# define APPLIB_HINST AfsAppLib_GetInstance()
#endif
#ifndef THIS_HINST
# ifdef EXPORT
# define THIS_HINST APPLIB_HINST
# else
# define THIS_HINST APP_HINST
# endif
#endif
#ifndef cchNAME
#define cchNAME 256
#endif
#ifdef DBG
#ifndef DEBUG
#define DEBUG
#endif
#ifdef NDEBUG
#undef NDEBUG
#endif
#endif
#include <windows.h>
#include <windowsx.h>
/*
* INCLUSIONS _________________________________________________________________
*
*/
// This library relies on the TaLocale suite to provide
// access to localized resources.
//
#include <WINNT/TaLocale.h>
// This library provides support for performing all operations
// through a remote administration server. If you want to use
// these capabilities AND you want to use the asc_* routines
// from TaAfsAdmSvrClient.lib directly, you must include
// <TaAfsAdmSvrClient.h> before including this header.
//
#ifdef TAAFSADMSVRCLIENT_H
#ifndef TAAFSADMSVRINTERNAL_H
#ifndef TAAFSADMSVRCLIENTINTERNAL_H
#include <WINNT/al_admsvr.h>
#endif // TAAFSADMSVRCLIENTINTERNAL_H
#endif // TAAFSADMSVRINTERNAL_H
#endif // TAAFSADMSVRCLIENT_H
// A few general-purpose AfsAppLib headers
//
#include <WINNT/al_resource.h>
#include <WINNT/al_messages.h>
// In addition to the prototypes you'll find in this header file,
// the following source files provide many useful features--
// take a few moments and examine their headers individually to
// see what they can do for your application.
//
// Each header is associated with one source file, and each pair
// can easily (well, hopefully easily) be copied off to other
// applications.
//
#include <WINNT/hashlist.h> // general-purpose list management code
#include <WINNT/resize.h> // window resizing functions
#include <WINNT/subclass.h> // window subclass code
#include <WINNT/dialog.h> // general window control routines
#include <WINNT/ctl_spinner.h> // enhanced version of MSCTLS_UPDOWN
#include <WINNT/ctl_elapsed.h> // elapsed-time entry window control
#include <WINNT/ctl_time.h> // absolute-time entry window control
#include <WINNT/ctl_date.h> // absolute-date entry window control
#include <WINNT/ctl_sockaddr.h> // IP address entry window control
#include <WINNT/settings.h> // version-controlled settings
#include <WINNT/checklist.h> // checked-item listbox control
#include <WINNT/fastlist.h> // fast treeview/listview replacement
#include <WINNT/al_wizard.h> // easy wizard generation code
#include <WINNT/al_progress.h> // easy threaded progress-dialog code
#include <WINNT/regexp.h> // regular-expression pattern matching
/*
* GENERAL ____________________________________________________________________
*
*/
// AfsAppLib_SetAppName
// ...records the display name of your application, so AfsAppLib
// can add it to dialog boxes' titles.
//
EXPORTED void AfsAppLib_SetAppName (LPTSTR pszName);
EXPORTED void AfsAppLib_GetAppName (LPTSTR pszName);
// AfsAppLib_SetMainWindow
// ...specifies which window represents your application; the library
// subclasses this window and uses it to ensure some tasks are
// performed by the UI thread.
//
EXPORTED void AfsAppLib_SetMainWindow (HWND hMain);
EXPORTED HWND AfsAppLib_GetMainWindow (void);
/*
* REMOTE ADMINISTRATION ______________________________________________________
*
*/
// AfsAppLib_OpenAdminServer
// AfsAppLib_CloseAdminServer
// ...enables the caller of the AfsAppLib library to indicate
// that AFS administrative functions should be performed by
// out-farming the actual operations onto an administrative
// server process, possibly running on another machine.
// By calling the OpenAdminServer() routine specifying a
// machine name or IP address, the AfsAppLib library will attempt
// to connect to an already-running administrative server on
// that machine; if successful, all further administrative
// tasks (until CloseAdminServer() is called) will be performed
// on that remote server. Similarly, by calling OpenAdminServer()
// but passing NULL as the address, the AfsAppLib library will
// use a separate administrative process running on the local
// computer, forking a new administrative server process if
// none is currently running now.
//
EXPORTED BOOL AfsAppLib_OpenAdminServer (LPTSTR pszAddress = NULL, ULONG *pStatus = NULL);
EXPORTED void AfsAppLib_CloseAdminServer (void);
// AfsAppLib_GetAdminServerClientID
// ...every process which interacts with a remote administration
// server is assigned a client ID by that server, which the
// client process passes on each RPC to identify itself to the
// server. If AfsAppLib_OpenAdminServer() has previously been
// called, the AfsAppLib_GetAdminServerClientID() routine can
// be used to obtain the client id which the administrative
// server has assigned to this process.
//
EXPORTED DWORD AfsAppLib_GetAdminServerClientID (void);
/*
* CELLLIST ___________________________________________________________________
*
*/
// AfsAppLib_GetCellList
// ...obtains a list of cells:
// - if a registry path is supplied, that path is enumerated
// and the names of the keys below it returned as a cell list
// - if a registry path is not supplied, the list of cells
// contacted by the AFS client is returned.
// - if another cell list is supplied, that list is copied.
// The local cell will be in element 0. The AfsAppLib_FreeCellList
// routine should be called when the CELLLIST structure is no
// longer needed.
//
typedef struct // CELLLIST
{
LPTSTR *aCells;
size_t nCells;
HKEY hkBase;
TCHAR szRegPath[ MAX_PATH ];
} CELLLIST, *LPCELLLIST;
EXPORTED LPCELLLIST AfsAppLib_GetCellList (HKEY hkBase = NULL, LPTSTR pszRegPath = NULL);
EXPORTED LPCELLLIST AfsAppLib_GetCellList (LPCELLLIST lpcl);
EXPORTED void AfsAppLib_AddToCellList (LPCELLLIST lpcl, LPTSTR pszCell);
EXPORTED void AfsAppLib_FreeCellList (LPCELLLIST lpcl);
/*
* BROWSE _____________________________________________________________________
*
*/
// AfsAppLib_ShowBrowseDialog
// ...creates a modal dialog that lets the user select an AFS
// user or group
//
typedef enum
{
btLOCAL_USER,
btLOCAL_GROUP,
btANY_USER,
btANY_GROUP
} BROWSETYPE;
typedef struct
{
HWND hParent; // [in] Parent window for browse dialog
TCHAR szCell[ cchNAME ]; // [inout] Cell name
TCHAR szNamed[ cchNAME ]; // [inout] Selected principal
BROWSETYPE bt; // [in] type of prinicipals to show
int idsTitle; // [in] string ID for dialog title
int idsPrompt; // [in] string ID for Edit prompt
int idsNone; // [in] string ID for checkbox (or 0)
LPCELLLIST lpcl; // [in] from AfsAppLib_GetCellList()
PVOID hCreds; // [in] credentials for enumeration
} BROWSEDLG_PARAMS, *LPBROWSEDLG_PARAMS;
EXPORTED BOOL AfsAppLib_ShowBrowseDialog (LPBROWSEDLG_PARAMS lpp);
// AfsAppLib_ShowBrowseFilesetDialog
// ...creates a modal dialog that lets the user select a fileset
//
typedef struct
{
HWND hParent; // [in] parent window for browse dialog
TCHAR szCell[ cchNAME ]; // [inout] cell name
TCHAR szFileset[ cchNAME ]; // [inout] selected fileset
int idsTitle; // [in] string ID for title (or 0)
int idsPrompt; // [in] string ID for prompt (or 0)
LPCELLLIST lpcl; // [in] NULL to disable cell selection
PVOID pInternal;
} BROWSESETDLG_PARAMS, *LPBROWSESETDLG_PARAMS;
EXPORTED BOOL AfsAppLib_ShowBrowseFilesetDialog (LPBROWSESETDLG_PARAMS lpp);
/*
* COVER ______________________________________________________________________
*
*/
// AfsAppLib_CoverClient
// AfsAppLib_CoverWindow
// ...hides the specified window (or just its client area), showing
// instead a simple etched rectangle filled with the descriptive
// text that you supply. An optional button can be shown in the
// lower-right corner; when pressed, the parent of the covered
// window receives a WM_COMMAND/IDC_COVERBUTTON message.
//
EXPORTED void AfsAppLib_CoverClient (HWND hWnd, LPTSTR pszDesc, LPTSTR pszButton = NULL);
EXPORTED void AfsAppLib_CoverWindow (HWND hWnd, LPTSTR pszDesc, LPTSTR pszButton = NULL);
// AfsAppLib_Uncover
// ...removes a cover (if any) from the specified window, re-showing
// the controls previously hidden underneath the cover.
//
EXPORTED void AfsAppLib_Uncover (HWND hWnd);
/*
* CREDENTIALS ________________________________________________________________
*
*/
// AfsAppLib_CrackCredentials
// ...obtains information about the specified credentials cookie.
// returns TRUE if the data could be successfully parsed.
//
EXPORTED BOOL AfsAppLib_CrackCredentials (PVOID hCreds, LPTSTR pszCell = NULL, LPTSTR pszUser = NULL, LPSYSTEMTIME pst = NULL, ULONG *pStatus = NULL);
// AfsAppLib_GetCredentials
// ...returns nonzero if the calling process has AFS credentials within
// the specified cell. Specify NULL as the cell ID to query
// credentials within the local cell. The return code is actually
// a token handle which can be supplied to the AFS administrative
// functions.
//
EXPORTED PVOID AfsAppLib_GetCredentials (LPCTSTR pszCell = NULL, ULONG *pStatus = NULL);
// AfsAppLib_SetCredentials
// ...obtains new credentials for the calling process; performs no UI.
// If successful, returns a nonzero token handle which can be
// supplied to the AFS administrative functions.
//
EXPORTED PVOID AfsAppLib_SetCredentials (LPCTSTR pszCell, LPCTSTR pszUser, LPCTSTR pszPassword, ULONG *pStatus = NULL);
// AfsAppLib_IsUserAdmin
// ...queries the KAS database for a particular cell to determine
// whether the specified identity has administrative privileges.
// The hCreds passed in should be for an admin, or for the user
// being queried.
//
EXPORTED BOOL AfsAppLib_IsUserAdmin (PVOID hCreds, LPTSTR pszUser);
// AfsAppLib_ShowOpenCellDialog
// ...presents a dialog which allows the user to select a cell,
// and optionally obtain new AFS credentials within that cell.
// the caller may optionally specify an alternate dialog template;
// if not, a default template will be used. the caller may also
// optionally supply a DLGPROC, which will be called to handle all
// dialog messages--if this hook returns FALSE, the default handler
// will be called; if it returns TRUE, no further processing for
// that message is performed.
//
typedef struct
{
int idd; // [in] dialog template (or 0)
DLGPROC hookproc; // [in] dialog procedure (or NULL)
HWND hParent; // [in] parent window (or NULL)
int idsDesc; // [in] string ID for description
BOOL *pfShowWarningEver; // [in] "don't ask again" checkbox
} BADCREDSDLG_PARAMS, *LPBADCREDSDLG_PARAMS;
typedef struct
{
int idd; // [in] dialog template (or 0)
DLGPROC hookproc; // [in] dialog procedure (or NULL)
HWND hParent; // [in] parent window (or NULL)
int idsDesc; // [in] string ID for dialog text
LPCELLLIST lpcl; // [in] from AfsAppLib_GetCellList()
BADCREDSDLG_PARAMS bcdp; // [in] params for bad creds dialog
TCHAR szCell[ cchNAME ]; // [out] selected cell
PVOID hCreds; // [out] credentials in cell
} OPENCELLDLG_PARAMS, *LPOPENCELLDLG_PARAMS;
EXPORTED BOOL AfsAppLib_ShowOpenCellDialog (LPOPENCELLDLG_PARAMS lpp);
// AfsAppLib_ShowCredentialsDialog
// ...presents a dialog which displays the current AFS credentials
// and allows the user to obtain new credentials. An alternate
// dialog template and hook procedure can be specified.
//
typedef struct
{
int idd; // [in] dialog template (or 0)
DLGPROC hookproc; // [in] dialog procedure (or NULL)
HWND hParent; // [in] parent window (or NULL)
TCHAR szCell[ MAX_PATH ]; // [in out] current cell
BOOL fIgnoreBadCreds; // [in] TRUE to skip bad creds dialog
BADCREDSDLG_PARAMS bcdp; // [in] params for bad creds dialog
TCHAR szIdentity[ cchNAME ]; // [out] current DCE identity in szCell
TCHAR szPassword[ cchNAME ]; // [out] password entered (or "")
PVOID hCreds; // [in out] credentials in cell
} CREDENTIALSDLG_PARAMS, *LPCREDENTIALSDLG_PARAMS;
EXPORTED BOOL AfsAppLib_ShowCredentialsDialog (LPCREDENTIALSDLG_PARAMS lpp);
// AfsAppLib_CheckCredentials
// ...tests the current credentials to see if they represent
// a user with administrative access within the target cell.
//
typedef struct
{
PVOID hCreds; // [in] credentials to query
BOOL fShowWarning; // [in] TRUE to present warning dialog
BADCREDSDLG_PARAMS bcdp; // [in] params for bad creds dialog
} CHECKCREDS_PARAMS, *LPCHECKCREDS_PARAMS;
EXPORTED BOOL AfsAppLib_CheckCredentials (LPCHECKCREDS_PARAMS lpp);
// AfsAppLib_CheckForExpiredCredentials
// ...tests the user's credentials in the specified cell to see if
// they have expired; if so, calls AfsAppLib_CheckCredentials to
// display a warning dialog--if the user accepts the warning
// dialog, calls AfsAppLib_ShowCredentialsDialog. All that UI
// is modeless; this routine returns immediately.
//
EXPORTED void AfsAppLib_CheckForExpiredCredentials (LPCREDENTIALSDLG_PARAMS lpp);
/*
* TASKING ____________________________________________________________________
*
*/
typedef struct
{
int idTask; // task ID requested
HWND hReply; // window to which to reply
PVOID lpUser; // parameter supplied by user
BOOL rc; // TRUE if successful
ULONG status; // if (rc == FALSE), error code
PVOID pReturn; // allocated storage for return data
} TASKPACKET, *LPTASKPACKET;
// AfsAppLib_InitTaskQueue
// ...allows use of StartTask to perform background tasks.
// call this routine only once per application, and only
// if you want to use StartTask().
//
typedef struct
{
LPTASKPACKET (*fnCreateTaskPacket)(int idTask, HWND hReply, PVOID lpUser);
void (*fnPerformTask)(LPTASKPACKET ptp);
void (*fnFreeTaskPacket)(LPTASKPACKET ptp);
int nThreadsMax;
} TASKQUEUE_PARAMS, *LPTASKQUEUE_PARAMS;
EXPORTED void AfsAppLib_InitTaskQueue (LPTASKQUEUE_PARAMS lpp);
// StartTask
// ...pushes a request onto the task queue created by a previous
// call to AfsAppLib_InitTaskQueue. A background thread will
// be allocated to popping off the request and performing it,
// optionally posting a WM_ENDTASK message to the specified
// window upon completion.
//
EXPORTED void StartTask (int idTask, HWND hReply = 0, PVOID lpUser = 0);
/*
* ERROR DIALOGS ______________________________________________________________
*
*/
// ErrorDialog
// ...creates a modeless error dialog containing the specified
// error text. if a non-zero status code is specified, the
// error dialog will also translate that error code and
// display its description. These routines create a modeless
// dialog, and can be called by any thread.
//
EXPORTED void cdecl ErrorDialog (DWORD dwStatus, LPTSTR pszError, LPTSTR pszFmt = NULL, ...);
EXPORTED void cdecl ErrorDialog (DWORD dwStatus, int idsError, LPTSTR pszFmt = NULL, ...);
// FatalErrorDialog
// ...identical to ErrorDialog, except that PostQuitMessage()
// is performed after the error dialog is dismissed.
//
EXPORTED void cdecl FatalErrorDialog (DWORD dwStatus, LPTSTR pszError, LPTSTR pszFmt = NULL, ...);
EXPORTED void cdecl FatalErrorDialog (DWORD dwStatus, int idsError, LPTSTR pszFmt = NULL, ...);
// ImmediateErrorDialog
// ...identical to ErrorDialog, except that the error dialog
// is modal.
//
EXPORTED void cdecl ImmediateErrorDialog (DWORD dwStatus, LPTSTR pszError, LPTSTR pszFmt = NULL, ...);
EXPORTED void cdecl ImmediateErrorDialog (DWORD dwStatus, int idsError, LPTSTR pszFmt = NULL, ...);
/*
* MODELESS DIALOGS ___________________________________________________________
*
* Modeless dialogs aren't treated as dialogs unless you call IsDialogMessage()
* for them in your pump--that is, tab won't work, nor will RETURN or ESC do
* what you expect, nor will hotkeys. The routines below allow you to specify
* that a given window should be treated as a modeless dialog--by calling one
* routine in your main pump, you can ensure all such modeless dialogs will
* have IsDialogMessage called for them:
*
* MSG msg;
* while (GetMessage (&msg, NULL, 0, 0))
* {
* -> if (AfsAppLib_IsModelessDialogMessage (&msg))
* -> continue;
*
* TranslateMessage (&msg);
* DispatchMessage (&msg);
* }
*
* An equivalent technique is:
*
* AfsAppLib_MainPump();
*
* ...the MainPump() routine does exactly what the first example did.
*
*/
// AfsAppLib_IsModelessDialogMessage
// ...called from your applications pump, this routine
// calls IsDialogMessage() for each window which
// has been registered by AfsAppLib_RegisterModelessDialog.
//
EXPORTED BOOL AfsAppLib_IsModelessDialogMessage (MSG *lpm);
// AfsAppLib_RegisterModelessDialog
// ...ensures that AfsAppLib_IsModelessDialogMessage will
// call IsDialogMessage() for the specified window
//
EXPORTED void AfsAppLib_RegisterModelessDialog (HWND hDlg);
// AfsAppLib_SetPumpRoutine
// ...can be used to specify a routine which will be called for
// your application to process every message--if not done,
// AfsAppLib_MainPump and ModalDialog will instead simply
// call TranslateMessage/DispatchMessage.
//
EXPORTED void AfsAppLib_SetPumpRoutine (void (*fnPump)(MSG *lpm));
// AfsAppLib_MainPump
// ...Calls GetMessage() until the WM_QUIT message is received;
// for each message, calls AfsAppLib_IsModelessDialogMessage
// followed by the pump routine which was specified by
// AfsAppLib_SetPumpRoutine.
//
EXPORTED void AfsAppLib_MainPump (void);
/*
* WINDOW DATA ________________________________________________________________
*
* Ever been frustrated by Get/SetWindowLong's inability to dynamically
* grow the space associated with a window? Worse, how do you know
* that GetWindowLong(hWnd,3) isn't already used by some other routine?
*
* The routines below solve both problems: by specifying indices by a
* descriptive name rather than an integer index, collisions are eliminated.
* And as new fields are specified, they're dynamically added--the data-space
* associated with a window grows indefinitely as needed.
*
* Note that GetWindowData will return 0 unless SetWindowData
* has been used to explicitly change that field for that window.
*
*/
// GetWindowData
// SetWindowData
// ...Alternatives to GetWindowLong and SetWindowLong; these
// routines use descriptive field indices rather than
// the integer indices used by the Get/SetWindowLong routines,
// and can grow windows' data-space as necessary.
//
EXPORTED DWORD GetWindowData (HWND hWnd, LPTSTR pszField);
EXPORTED DWORD SetWindowData (HWND hWnd, LPTSTR pszField, DWORD dwNewData);
/*
* IMAGE LISTS ________________________________________________________________
*
*/
// AfsAppLib_CreateImageList
// ...creates an initial IMAGELIST, containing several
// AFS-specific icons (which are included in this library's
// resources). fLarge indicates whether the imagelist should
// be composed of 32x32 or 16x16 icons; the highest visible
// color depth image will automatically be selected for each icon.
//
#define imageSERVER 0
#define imageSERVER_ALERT 1
#define imageSERVER_UNMON 2
#define imageSERVICE 3
#define imageSERVICE_ALERT 4
#define imageSERVICE_STOPPED 5
#define imageAGGREGATE 6
#define imageAGGREGATE_ALERT 7
#define imageFILESET 8
#define imageFILESET_ALERT 9
#define imageFILESET_LOCKED 10
#define imageBOSSERVICE 11
#define imageCELL 12
#define imageSERVERKEY 13
#define imageUSER 14
#define imageGROUP 15
#define imageNEXT 16 // next ID given by AfsAppLib_AddToImageList()
EXPORTED HIMAGELIST AfsAppLib_CreateImageList (BOOL fLarge);
// AfsAppLib_AddToImageList
// ...easy wrapper for adding additional icons to an image list.
//
EXPORTED void AfsAppLib_AddToImageList (HIMAGELIST hil, int idi, BOOL fLarge);
/*
* HELP _______________________________________________________________________
*
* These routines make implementing context-sensitive help fairly easy.
* To use them, your application should contain the following code at startup
* for each dialog in your application:
*
* static DWORD IDH_MAIN_HELP_CTX[] = {
* IDC_BUTTON, IDH_BUTTON_HELP_ID,
* IDC_EDIT, IDH_EDIT_HELP_ID,
* 0, 0
* };
*
* AfsAppLib_RegisterHelp (IDD_MAIN, IDH_MAIN_HELP_CTX, IDH_MAIN_HELP_OVIEW);
*
* You'll also have to call one other routine, at least once:
*
* AfsAppLib_RegisterHelpFile (TEXT("myapp.hlp"));
*
* Within IDD_MAIN's dialog proc, call the following:
*
* BOOL CALLBACK IddMain_DlgProc (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp)
* {
* if (AfsAppLib_HandleHelp (IDD_MAIN, hDlg, msg, wp, lp))
* return TRUE;
* ...
* }
*
* That's it--context help will work for the dialog, and if you've attached
* a "Help" button (which should be IDHELP==9), it will conjure an overall
* help topic.
*
*/
// AfsAppLib_RegisterHelpFile
// ...specifies the help file that the library should use to display
// help topics.
//
EXPORTED void AfsAppLib_RegisterHelpFile (LPTSTR pszFilename);
// AfsAppLib_RegisterHelp
// ...adds another dialog to the library's list of CSH-enabled
// dialogs. Dialogs are referenced by their resource ID--that's
// what the "idd" thing is.
//
EXPORTED void AfsAppLib_RegisterHelp (int idd, DWORD *adwContext, int idhOverview);
// AfsAppLib_HandleHelp
// ...handles CSH messages and IDHELP button presses; returns TRUE
// if the given message has been handled and needs no further
// processing.
//
EXPORTED BOOL AfsAppLib_HandleHelp (int idd, HWND hDlg, UINT msg, WPARAM wp, LPARAM lp);
/*
* GENERAL ____________________________________________________________________
*
*/
// AfsApplib_CreateFont
// ...loads a string resource and uses its content to create a
// font. The string resource should be of the form:
// "TypeFace,Size,Flags"--
// where:
// TypeFace is "MS Sans Serif", "Times New Roman", or other font
// Size is the point-size of the font (no decimals!)
// Flags is combination of B, I, U (bold, italicized, underlined)
//
// Some examples, then:
// IDS_BIG_FONT "Times New Roman,20,BU"
// IDS_LITTLE_FONT "Arial,8,I"
// IDS_NORMAL_FONT "MS Sans Serif,10"
//
// The returned font handle should be destroyed with DeleteObject()
// when no longer needed.
//
EXPORTED HFONT AfsAppLib_CreateFont (int idsFont);
// AfsAppLib_GetInstance
// ...returns the handle representing this library, for use in
// loading resources.
//
EXPORTED HINSTANCE AfsAppLib_GetInstance (void);
// AfsAppLib_GetAppInstance
// ...returns the handle representing the application which
// loaded this library. If a .DLL loaded this library,
// you may need to call AfsAppLib_SetAppInstance().
//
EXPORTED HINSTANCE AfsAppLib_GetAppInstance (void);
EXPORTED void AfsAppLib_SetAppInstance (HINSTANCE hInst);
// AfsAppLib_AnimateIcon
// ...used to animate the 8-frame spinning Transarc logo.
// specify NULL for piFrameLast to stop the spinning,
// otherwise, provide a pointer to an int that will be used
// to track the current frame.
//
EXPORTED void AfsAppLib_AnimateIcon (HWND hIcon, int *piFrameLast = NULL);
// AfsAppLib_StartAnimation
// AfsAppLib_StopAnimation
// ...an alternate technique for calling AfsAppLib_AnimateIcon;
// using these routines causes a timer to be created which will
// animate the Transarc logo within the specified window.
//
EXPORTED void AfsAppLib_StartAnimation (HWND hIcon, int fps = 8);
EXPORTED void AfsAppLib_StopAnimation (HWND hIcon);
// AfsAppLib_IsTimeInFuture
// ...returns TRUE if the specified time (GMT) is in the
// future; handy for checking credentials' expiration dates.
//
EXPORTED BOOL AfsAppLib_IsTimeInFuture (LPSYSTEMTIME pstTest);
// AfsAppLib_UnixTimeToSystemTime
// ...translate a unix time DWORD into a SYSTEMTIME structure
//
EXPORTED void AfsAppLib_UnixTimeToSystemTime (LPSYSTEMTIME pst, ULONG ut, BOOL fElapsed = FALSE);
// AfsAppLib_TranslateError
// ...obtains descriptive text for the given status code.
// This routine is just a wrapper around TaLocale's
// FormatError(); either routine produces identical output.
// Both routines call back into a hook installed by the
// AfsAppLib library to provide AFS-specific error translation..
// If successful, the resulting string will appear as:
// "Unable to create an RPC binding to host. (0x0E008001)"
// If unsuccessful, the resulting string will appear as:
// "0x0E008001"
//
EXPORTED BOOL AfsAppLib_TranslateError (LPTSTR pszText, ULONG status, LANGID idLanguage = 0);
// AfsAppLib_GetLocalCell
// ...returns the local cell into which this machine is configured.
//
EXPORTED BOOL AfsAppLib_GetLocalCell (LPTSTR pszCell, ULONG *pStatus = NULL);
// REALLOC
// ...general-purpose array reallocator:
// int *aInts = NULL;
// size_t cInts = 0;
// if (!REALLOC (aInts, cInts, 128, 16)) { ... }
// the code above ensures that there will be 128 ints available
// as iInts[0]..aInts[127]; the 16 indicates the minimum allocation
// granularity (i.e., asking for 129 ints will actually get you
// 144 of them). Reallocation only increases array size, and is
// only performed when necessary; newly-allocated space is zero-
// initialized, and old data is always retained across reallocation.
// Use GlobalFree((HGLOBAL)aInts) to free the array when done.
// Use it a few times, and you'll be hooked: amazingly useful.
//
#ifndef REALLOC
#define REALLOC(_a,_c,_r,_i) AfsAppLib_ReallocFunction ((LPVOID*)&_a,sizeof(*_a),&_c,_r,_i)
EXPORTED BOOL AfsAppLib_ReallocFunction (LPVOID *ppTarget, size_t cbElement, size_t *pcTarget, size_t cReq, size_t cInc);
#endif
#endif

View File

@ -0,0 +1,5 @@
#ifndef APSTUDIO_INVOKED
#define AFS_VERINFO_FILE_DESCRIPTION "AFS Application Base DLL"
#include "AFS_component_version_number.h"
#include "..\..\config\NTVersioninfo.rc"
#endif // APSTUDIO_INVOKED

View File

@ -0,0 +1,427 @@
extern "C" {
#include <afs/param.h>
#include <afs/stds.h>
}
#include <WINNT/TaAfsAdmSvrClient.h>
#include <WINNT/AfsAppLib.h>
/*
* VARIABLES __________________________________________________________________
*
*/
static struct
{
BOOL fUseAdminServer;
DWORD idAdminServerClient;
} l;
/*
* PROTOTYPES _________________________________________________________________
*
*/
/*
* ROUTINES ___________________________________________________________________
*
*/
BOOL AfsAppLib_OpenAdminServer (LPTSTR pszAddress, ULONG *pStatus)
{
AfsAppLib_CloseAdminServer();
ULONG status;
if (!asc_AdminServerOpen (pszAddress, &l.idAdminServerClient, &status))
{
if (pStatus)
*pStatus = status;
return FALSE;
}
l.fUseAdminServer = TRUE;
return TRUE;
}
void AfsAppLib_CloseAdminServer (void)
{
if (l.fUseAdminServer)
{
ULONG status;
asc_AdminServerClose (l.idAdminServerClient, &status);
l.idAdminServerClient = 0;
l.fUseAdminServer = FALSE;
}
}
DWORD AfsAppLib_GetAdminServerClientID (void)
{
return (l.fUseAdminServer) ? l.idAdminServerClient : 0;
}
/*
* WRAPPERS ___________________________________________________________________
*
* This really ugly hack allows other processes to call the asc_* routines
* in the context of the AfsAppLib library.
*
*/
EXPORTED BOOL ADMINAPI AfsAppLib_asc_AsidListCreate (LPASIDLIST *ppList)
{
return asc_AsidListCreate (ppList);
}
EXPORTED BOOL ADMINAPI AfsAppLib_asc_AsidListCopy (LPASIDLIST *ppListTarget, LPASIDLIST *ppListSource)
{
return asc_AsidListCopy (ppListTarget, ppListSource);
}
EXPORTED BOOL ADMINAPI AfsAppLib_asc_AsidListAddEntry (LPASIDLIST *ppList, ASID idObject, LPARAM lp)
{
return asc_AsidListAddEntry (ppList, idObject, lp);
}
EXPORTED BOOL ADMINAPI AfsAppLib_asc_AsidListRemoveEntry (LPASIDLIST *ppList, ASID idObject)
{
return asc_AsidListRemoveEntry (ppList, idObject);
}
EXPORTED BOOL ADMINAPI AfsAppLib_asc_AsidListRemoveEntryByIndex (LPASIDLIST *ppList, size_t iIndex)
{
return asc_AsidListRemoveEntryByIndex (ppList, iIndex);
}
EXPORTED BOOL ADMINAPI AfsAppLib_asc_AsidListSetEntryParam (LPASIDLIST *ppList, ASID idObject, LPARAM lp)
{
return asc_AsidListSetEntryParam (ppList, idObject, lp);
}
EXPORTED BOOL ADMINAPI AfsAppLib_asc_AsidListSetEntryParamByIndex (LPASIDLIST *ppList, size_t iIndex, LPARAM lp)
{
return asc_AsidListSetEntryParamByIndex (ppList, iIndex, lp);
}
EXPORTED BOOL ADMINAPI AfsAppLib_asc_AsidListTest (LPASIDLIST *ppList, ASID idObject, LPARAM *pParam)
{
return asc_AsidListTest (ppList, idObject, pParam);
}
EXPORTED BOOL ADMINAPI AfsAppLib_asc_AsidListFree (LPASIDLIST *ppList)
{
return asc_AsidListFree (ppList);
}
EXPORTED BOOL ADMINAPI AfsAppLib_asc_ObjPropListCreate (LPASOBJPROPLIST *ppList)
{
return asc_ObjPropListCreate (ppList);
}
EXPORTED BOOL ADMINAPI AfsAppLib_asc_ObjPropListCopy (LPASOBJPROPLIST *ppListTarget, LPASOBJPROPLIST *ppListSource)
{
return asc_ObjPropListCopy (ppListTarget, ppListSource);
}
EXPORTED BOOL ADMINAPI AfsAppLib_asc_ObjPropListAddEntry (LPASOBJPROPLIST *ppList, LPASOBJPROP pProperties, LPARAM lp)
{
return asc_ObjPropListAddEntry (ppList, pProperties, lp);
}
EXPORTED BOOL ADMINAPI AfsAppLib_asc_ObjPropListRemoveEntry (LPASOBJPROPLIST *ppList, ASID idObject)
{
return asc_ObjPropListRemoveEntry (ppList, idObject);
}
EXPORTED BOOL ADMINAPI AfsAppLib_asc_ObjPropListTest (LPASOBJPROPLIST *ppList, ASID idObject, LPASOBJPROP pProperties, LPARAM *pParam)
{
return asc_ObjPropListTest (ppList, idObject, pProperties, pParam);
}
EXPORTED BOOL ADMINAPI AfsAppLib_asc_ObjPropListFree (LPASOBJPROPLIST *ppList)
{
return asc_ObjPropListFree (ppList);
}
EXPORTED BOOL ADMINAPI AfsAppLib_asc_ActionListCreate (LPASACTIONLIST *ppList)
{
return asc_ActionListCreate (ppList);
}
EXPORTED BOOL ADMINAPI AfsAppLib_asc_ActionListCopy (LPASACTIONLIST *ppListTarget, LPASACTIONLIST *ppListSource)
{
return asc_ActionListCopy (ppListTarget, ppListSource);
}
EXPORTED BOOL ADMINAPI AfsAppLib_asc_ActionListAddEntry (LPASACTIONLIST *ppList, LPASACTION pAction)
{
return asc_ActionListAddEntry (ppList, pAction);
}
EXPORTED BOOL ADMINAPI AfsAppLib_asc_ActionListRemoveEntry (LPASACTIONLIST *ppList, DWORD idAction)
{
return asc_ActionListRemoveEntry (ppList, idAction);
}
EXPORTED BOOL ADMINAPI AfsAppLib_asc_ActionListTest (LPASACTIONLIST *ppList, DWORD idAction, LPASACTION pAction)
{
return asc_ActionListTest (ppList, idAction, pAction);
}
EXPORTED BOOL ADMINAPI AfsAppLib_asc_ActionListFree (LPASACTIONLIST *ppList)
{
return asc_ActionListFree (ppList);
}
EXPORTED BOOL ADMINAPI AfsAppLib_asc_AdminServerOpen (LPCTSTR pszAddress, DWORD *pidClient, ULONG *pStatus)
{
return asc_AdminServerOpen (pszAddress, pidClient, pStatus);
}
EXPORTED BOOL ADMINAPI AfsAppLib_asc_AdminServerClose (DWORD idClient, ULONG *pStatus)
{
return asc_AdminServerClose (idClient, pStatus);
}
EXPORTED BOOL ADMINAPI AfsAppLib_asc_CredentialsCrack (DWORD idClient, PVOID hCreds, LPTSTR pszCell, LPTSTR pszUser, SYSTEMTIME *pstExpiration, ULONG *pStatus)
{
return asc_CredentialsCrack (idClient, hCreds, pszCell, pszUser, pstExpiration, pStatus);
}
EXPORTED PVOID ADMINAPI AfsAppLib_asc_CredentialsGet (DWORD idClient, LPCTSTR pszCell, ULONG *pStatus)
{
return asc_CredentialsGet (idClient, pszCell, pStatus);
}
EXPORTED PVOID ADMINAPI AfsAppLib_asc_CredentialsSet (DWORD idClient, LPCTSTR pszCell, LPCTSTR pszUser, LPCTSTR pszPassword, ULONG *pStatus)
{
return asc_CredentialsSet (idClient, pszCell, pszUser, pszPassword, pStatus);
}
EXPORTED BOOL ADMINAPI AfsAppLib_asc_CredentialsPush (DWORD idClient, PVOID hCreds, ASID idCell, ULONG *pStatus)
{
return asc_CredentialsPush (idClient, hCreds, idCell, pStatus);
}
EXPORTED BOOL ADMINAPI AfsAppLib_asc_LocalCellGet (DWORD idClient, LPTSTR pszCell, ULONG *pStatus)
{
return asc_LocalCellGet (idClient, pszCell, pStatus);
}
EXPORTED BOOL ADMINAPI AfsAppLib_asc_ErrorCodeTranslate (DWORD idClient, ULONG code, LANGID idLanguage, STRING pszErrorText, ULONG *pStatus)
{
return asc_ErrorCodeTranslate (idClient, code, idLanguage, pszErrorText, pStatus);
}
EXPORTED BOOL ADMINAPI AfsAppLib_asc_ActionGet (DWORD idClient, DWORD idAction, LPASACTION pAction, ULONG *pStatus)
{
return asc_ActionGet (idClient, idAction, pAction, pStatus);
}
EXPORTED BOOL ADMINAPI AfsAppLib_asc_ActionGetMultiple (DWORD idClient, DWORD idClientSearch, ASID idCellSearch, LPASACTIONLIST *ppList, ULONG *pStatus)
{
return asc_ActionGetMultiple (idClient, idClientSearch, idCellSearch, ppList, pStatus);
}
EXPORTED BOOL ADMINAPI AfsAppLib_asc_ActionListen (DWORD idClient, HWND hNotify, ULONG *pStatus)
{
return asc_ActionListen (idClient, hNotify, pStatus);
}
EXPORTED BOOL ADMINAPI AfsAppLib_asc_ActionListenClear (DWORD idClient, HWND hNotify, ULONG *pStatus)
{
return asc_ActionListenClear (idClient, hNotify, pStatus);
}
EXPORTED BOOL ADMINAPI AfsAppLib_asc_CellOpen (DWORD idClient, PVOID hCreds, LPCTSTR pszCell, DWORD dwScope, ASID *pidCell, ULONG *pStatus)
{
return asc_CellOpen (idClient, hCreds, pszCell, dwScope, pidCell, pStatus);
}
EXPORTED BOOL ADMINAPI AfsAppLib_asc_CellClose (DWORD idClient, ASID idCell, ULONG *pStatus)
{
return asc_CellClose (idClient, idCell, pStatus);
}
EXPORTED BOOL ADMINAPI AfsAppLib_asc_CellChange (DWORD idClient, ASID idCell, LPAFSADMSVR_CHANGECELL_PARAMS pChange, ULONG *pStatus)
{
return asc_CellChange (idClient, idCell, pChange, pStatus);
}
EXPORTED BOOL ADMINAPI AfsAppLib_asc_CellRefreshRateSet (DWORD idClient, ASID idCell, LONG cminRefreshRate, ULONG *pStatus)
{
return asc_CellRefreshRateSet (idClient, idCell, cminRefreshRate, pStatus);
}
EXPORTED BOOL ADMINAPI AfsAppLib_asc_ObjectFind (DWORD idClient, ASID idSearchScope, ASOBJTYPE ObjectType, LPCTSTR pszName, ASID *pidObject, ULONG *pStatus)
{
return asc_ObjectFind (idClient, idSearchScope, ObjectType, pszName, pidObject, pStatus);
}
EXPORTED BOOL ADMINAPI AfsAppLib_asc_ObjectFindMultiple (DWORD idClient, ASID idSearchScope, ASOBJTYPE ObjectType, LPCTSTR pszPattern, LPAFSADMSVR_SEARCH_PARAMS pSearchParams, LPASIDLIST *ppList, ULONG *pStatus)
{
return asc_ObjectFindMultiple (idClient, idSearchScope, ObjectType, pszPattern, pSearchParams, ppList, pStatus);
}
EXPORTED BOOL ADMINAPI AfsAppLib_asc_ObjectPropertiesGet (DWORD idClient, AFSADMSVR_GET_LEVEL GetLevel, ASID idCell, ASID idObject, LPASOBJPROP pProperties, ULONG *pStatus)
{
return asc_ObjectPropertiesGet (idClient, GetLevel, idCell, idObject, pProperties, pStatus);
}
EXPORTED BOOL ADMINAPI AfsAppLib_asc_ObjectPropertiesGetMultiple (DWORD idClient, AFSADMSVR_GET_LEVEL GetLevel, ASID idCell, LPASIDLIST pAsidList, LPASOBJPROPLIST *ppPropertiesList, ULONG *pStatus)
{
return asc_ObjectPropertiesGetMultiple (idClient, GetLevel, idCell, pAsidList, ppPropertiesList, pStatus);
}
EXPORTED BOOL ADMINAPI AfsAppLib_asc_ObjectListen (DWORD idClient, ASID idCell, ASID idObject, HWND hNotify, ULONG *pStatus)
{
return asc_ObjectListen (idClient, idCell, idObject, hNotify, pStatus);
}
EXPORTED BOOL ADMINAPI AfsAppLib_asc_ObjectListenClear (DWORD idClient, HWND hNotify, ULONG *pStatus)
{
return asc_ObjectListenClear (idClient, hNotify, pStatus);
}
EXPORTED BOOL ADMINAPI AfsAppLib_asc_ObjectListenMultiple (DWORD idClient, ASID idCell, LPASIDLIST pAsidList, HWND hNotify, ULONG *pStatus)
{
return asc_ObjectListenMultiple (idClient, idCell, pAsidList, hNotify, pStatus);
}
EXPORTED BOOL ADMINAPI AfsAppLib_asc_ObjectRefresh (DWORD idClient, ASID idCell, ASID idObject, ULONG *pStatus)
{
return asc_ObjectRefresh (idClient, idCell, idObject, pStatus);
}
EXPORTED BOOL ADMINAPI AfsAppLib_asc_ObjectRefreshMultiple (DWORD idClient, ASID idCell, LPASIDLIST pAsidList, ULONG *pStatus)
{
return asc_ObjectRefreshMultiple (idClient, idCell, pAsidList, pStatus);
}
EXPORTED BOOL ADMINAPI AfsAppLib_asc_RandomKeyGet (DWORD idClient, ASID idCell, PBYTE pkey, ULONG *pStatus)
{
return asc_RandomKeyGet (idClient, idCell, pkey, pStatus);
}
EXPORTED BOOL ADMINAPI AfsAppLib_asc_CellNameGet_Fast (DWORD idClient, ASID idCell, LPTSTR pszCell, ULONG *pStatus)
{
return asc_CellNameGet_Fast (idClient, idCell, pszCell, pStatus);
}
EXPORTED BOOL ADMINAPI AfsAppLib_asc_ObjectNameGet_Fast (DWORD idClient, ASID idCell, ASID idObject, LPTSTR pszObject, ULONG *pStatus)
{
return asc_ObjectNameGet_Fast (idClient, idCell, idObject, pszObject, pStatus);
}
EXPORTED BOOL ADMINAPI AfsAppLib_asc_ObjectTypeGet_Fast (DWORD idClient, ASID idCell, ASID idObject, ASOBJTYPE *pObjectType, ULONG *pStatus)
{
return asc_ObjectTypeGet_Fast (idClient, idCell, idObject, pObjectType, pStatus);
}
EXPORTED BOOL ADMINAPI AfsAppLib_asc_ObjectPropertiesGet_Fast (DWORD idClient, ASID idCell, ASID idObject, LPASOBJPROP pProperties, ULONG *pStatus)
{
return asc_ObjectPropertiesGet_Fast (idClient, idCell, idObject, pProperties, pStatus);
}
EXPORTED void ADMINAPI AfsAppLib_asc_Enter (void)
{
asc_Enter();
}
EXPORTED void ADMINAPI AfsAppLib_asc_Leave (void)
{
asc_Leave();
}
EXPORTED LPCRITICAL_SECTION ADMINAPI AfsAppLib_asc_GetCriticalSection (void)
{
return asc_GetCriticalSection();
}
EXPORTED BOOL ADMINAPI AfsAppLib_asc_UserChange (DWORD idClient, ASID idCell, ASID idUser, LPAFSADMSVR_CHANGEUSER_PARAMS pChange, ULONG *pStatus)
{
return asc_UserChange (idClient, idCell, idUser, pChange, pStatus);
}
EXPORTED BOOL ADMINAPI AfsAppLib_asc_UserPasswordSet (DWORD idClient, ASID idCell, ASID idUser, int keyVersion, LPCTSTR pkeyString, PBYTE pkeyData, ULONG *pStatus)
{
return asc_UserPasswordSet (idClient, idCell, idUser, keyVersion, pkeyString, pkeyData, pStatus);
}
EXPORTED BOOL ADMINAPI AfsAppLib_asc_UserUnlock (DWORD idClient, ASID idCell, ASID idUser, ULONG *pStatus)
{
return asc_UserUnlock (idClient, idCell, idUser, pStatus);
}
EXPORTED BOOL ADMINAPI AfsAppLib_asc_UserCreate (DWORD idClient, ASID idCell, LPAFSADMSVR_CREATEUSER_PARAMS pCreate, ASID *pidUser, ULONG *pStatus)
{
return asc_UserCreate (idClient, idCell, pCreate, pidUser, pStatus);
}
EXPORTED BOOL ADMINAPI AfsAppLib_asc_UserDelete (DWORD idClient, ASID idCell, ASID idUser, LPAFSADMSVR_DELETEUSER_PARAMS pDelete, ULONG *pStatus)
{
return asc_UserDelete (idClient, idCell, idUser, pDelete, pStatus);
}
EXPORTED BOOL ADMINAPI AfsAppLib_asc_GroupChange (DWORD idClient, ASID idCell, ASID idGroup, LPAFSADMSVR_CHANGEGROUP_PARAMS pChange, ULONG *pStatus)
{
return asc_GroupChange (idClient, idCell, idGroup, pChange, pStatus);
}
EXPORTED BOOL ADMINAPI AfsAppLib_asc_GroupMembersGet (DWORD idClient, ASID idCell, ASID idGroup, LPASIDLIST *ppAsidList, ULONG *pStatus)
{
return asc_GroupMembersGet (idClient, idCell, idGroup, ppAsidList, pStatus);
}
EXPORTED BOOL ADMINAPI AfsAppLib_asc_GroupMemberAdd (DWORD idClient, ASID idCell, ASID idGroup, ASID idMember, ULONG *pStatus)
{
return asc_GroupMemberAdd (idClient, idCell, idGroup, idMember, pStatus);
}
EXPORTED BOOL ADMINAPI AfsAppLib_asc_GroupMemberRemove (DWORD idClient, ASID idCell, ASID idGroup, ASID idMember, ULONG *pStatus)
{
return asc_GroupMemberRemove (idClient, idCell, idGroup, idMember, pStatus);
}
EXPORTED BOOL ADMINAPI AfsAppLib_asc_GroupRename (DWORD idClient, ASID idCell, ASID idGroup, LPCTSTR pszNewName, ULONG *pStatus)
{
return asc_GroupRename (idClient, idCell, idGroup, pszNewName, pStatus);
}
EXPORTED BOOL ADMINAPI AfsAppLib_asc_GroupOwnershipGet (DWORD idClient, ASID idCell, ASID idMember, LPASIDLIST *ppAsidList, ULONG *pStatus)
{
return asc_GroupOwnershipGet (idClient, idCell, idMember, ppAsidList, pStatus);
}
EXPORTED BOOL ADMINAPI AfsAppLib_asc_GroupMembershipGet (DWORD idClient, ASID idCell, ASID idOwner, LPASIDLIST *ppAsidList, ULONG *pStatus)
{
return asc_GroupMembershipGet (idClient, idCell, idOwner, ppAsidList, pStatus);
}
EXPORTED BOOL ADMINAPI AfsAppLib_asc_GroupCreate (DWORD idClient, ASID idCell, LPAFSADMSVR_CREATEGROUP_PARAMS pCreate, ASID *pidGroup, ULONG *pStatus)
{
return asc_GroupCreate (idClient, idCell, pCreate, pidGroup, pStatus);
}
EXPORTED BOOL ADMINAPI AfsAppLib_asc_GroupDelete (DWORD idClient, ASID idCell, ASID idGroup, ULONG *pStatus)
{
return asc_GroupDelete (idClient, idCell, idGroup, pStatus);
}

View File

@ -0,0 +1,204 @@
#ifndef AL_ADMSVR_H
#define AL_ADMSVR_H
/*
* ADMIN SERVER INTERFACE _____________________________________________________
*
* The AfsAppLib .DLL links with the admin server client library,
* TaAfsAdmSvrClient.lib. Moreover, when you call AfsAppLib_OpenAdminServer(),
* it's AfsAppLib's instance of that .LIB which gets initialized and used
* by AfsAppLib.
*
* Ah, but the problem is: if you want your app to access the asc_* functions
* as well (aside from just indirectly using them by calling AfsAppLib_*
* functions), you'll have to magically access the .LIB inside of AfsAppLib--
* if you just link your app with the .LIB, you'll find your copy of the .LIB
* never is initialized.
*
* So for those of you who want to use the asc_* routines directly AND want
* to the AfsAppLib library, including this header file remaps all asc_*
* routines to ensure they'll call within al_admsvr.cpp.
*
* First, note that AfsAppLib exposes its own wrappers for its .LIB:
*
*/
EXPORTED BOOL ADMINAPI AfsAppLib_asc_AsidListCreate (LPASIDLIST *ppList);
EXPORTED BOOL ADMINAPI AfsAppLib_asc_AsidListCopy (LPASIDLIST *ppListTarget, LPASIDLIST *ppListSource);
EXPORTED BOOL ADMINAPI AfsAppLib_asc_AsidListAddEntry (LPASIDLIST *ppList, ASID idObject, LPARAM lp);
EXPORTED BOOL ADMINAPI AfsAppLib_asc_AsidListRemoveEntry (LPASIDLIST *ppList, ASID idObject);
EXPORTED BOOL ADMINAPI AfsAppLib_asc_AsidListRemoveEntryByIndex (LPASIDLIST *ppList, size_t iIndex);
EXPORTED BOOL ADMINAPI AfsAppLib_asc_AsidListSetEntryParam (LPASIDLIST *ppList, ASID idObject, LPARAM lp);
EXPORTED BOOL ADMINAPI AfsAppLib_asc_AsidListSetEntryParamByIndex (LPASIDLIST *ppList, size_t iIndex, LPARAM lp);
EXPORTED BOOL ADMINAPI AfsAppLib_asc_AsidListTest (LPASIDLIST *ppList, ASID idObject, LPARAM *pParam = NULL);
EXPORTED BOOL ADMINAPI AfsAppLib_asc_AsidListFree (LPASIDLIST *ppList);
EXPORTED BOOL ADMINAPI AfsAppLib_asc_ObjPropListCreate (LPASOBJPROPLIST *ppList);
EXPORTED BOOL ADMINAPI AfsAppLib_asc_ObjPropListCopy (LPASOBJPROPLIST *ppListTarget, LPASOBJPROPLIST *ppListSource);
EXPORTED BOOL ADMINAPI AfsAppLib_asc_ObjPropListAddEntry (LPASOBJPROPLIST *ppList, LPASOBJPROP pProperties, LPARAM lp);
EXPORTED BOOL ADMINAPI AfsAppLib_asc_ObjPropListRemoveEntry (LPASOBJPROPLIST *ppList, ASID idObject);
EXPORTED BOOL ADMINAPI AfsAppLib_asc_ObjPropListTest (LPASOBJPROPLIST *ppList, ASID idObject, LPASOBJPROP pProperties = NULL, LPARAM *pParam = NULL);
EXPORTED BOOL ADMINAPI AfsAppLib_asc_ObjPropListFree (LPASOBJPROPLIST *ppList);
EXPORTED BOOL ADMINAPI AfsAppLib_asc_ActionListCreate (LPASACTIONLIST *ppList);
EXPORTED BOOL ADMINAPI AfsAppLib_asc_ActionListCopy (LPASACTIONLIST *ppListTarget, LPASACTIONLIST *ppListSource);
EXPORTED BOOL ADMINAPI AfsAppLib_asc_ActionListAddEntry (LPASACTIONLIST *ppList, LPASACTION pAction);
EXPORTED BOOL ADMINAPI AfsAppLib_asc_ActionListRemoveEntry (LPASACTIONLIST *ppList, DWORD idAction);
EXPORTED BOOL ADMINAPI AfsAppLib_asc_ActionListTest (LPASACTIONLIST *ppList, DWORD idAction, LPASACTION pAction = NULL);
EXPORTED BOOL ADMINAPI AfsAppLib_asc_ActionListFree (LPASACTIONLIST *ppList);
EXPORTED BOOL ADMINAPI AfsAppLib_asc_AdminServerOpen (LPCTSTR pszAddress, DWORD *pidClient, ULONG *pStatus);
EXPORTED BOOL ADMINAPI AfsAppLib_asc_AdminServerClose (DWORD idClient, ULONG *pStatus);
EXPORTED BOOL ADMINAPI AfsAppLib_asc_CredentialsCrack (DWORD idClient, PVOID hCreds, LPTSTR pszCell, LPTSTR pszUser, SYSTEMTIME *pstExpiration, ULONG *pStatus);
EXPORTED PVOID ADMINAPI AfsAppLib_asc_CredentialsGet (DWORD idClient, LPCTSTR pszCell, ULONG *pStatus);
EXPORTED PVOID ADMINAPI AfsAppLib_asc_CredentialsSet (DWORD idClient, LPCTSTR pszCell, LPCTSTR pszUser, LPCTSTR pszPassword, ULONG *pStatus);
EXPORTED BOOL ADMINAPI AfsAppLib_asc_CredentialsPush (DWORD idClient, PVOID hCreds, ASID idCell, ULONG *pStatus);
EXPORTED BOOL ADMINAPI AfsAppLib_asc_LocalCellGet (DWORD idClient, LPTSTR pszCell, ULONG *pStatus);
EXPORTED BOOL ADMINAPI AfsAppLib_asc_ErrorCodeTranslate (DWORD idClient, ULONG code, LANGID idLanguage, STRING pszErrorText, ULONG *pStatus);
EXPORTED BOOL ADMINAPI AfsAppLib_asc_ActionGet (DWORD idClient, DWORD idAction, LPASACTION pAction, ULONG *pStatus);
EXPORTED BOOL ADMINAPI AfsAppLib_asc_ActionGetMultiple (DWORD idClient, DWORD idClientSearch, ASID idCellSearch, LPASACTIONLIST *ppList, ULONG *pStatus);
EXPORTED BOOL ADMINAPI AfsAppLib_asc_ActionListen (DWORD idClient, HWND hNotify, ULONG *pStatus);
EXPORTED BOOL ADMINAPI AfsAppLib_asc_ActionListenClear (DWORD idClient, HWND hNotify, ULONG *pStatus);
EXPORTED BOOL ADMINAPI AfsAppLib_asc_CellOpen (DWORD idClient, PVOID hCreds, LPCTSTR pszCell, DWORD dwScope, ASID *pidCell, ULONG *pStatus);
EXPORTED BOOL ADMINAPI AfsAppLib_asc_CellClose (DWORD idClient, ASID idCell, ULONG *pStatus);
EXPORTED BOOL ADMINAPI AfsAppLib_asc_CellChange (DWORD idClient, ASID idCell, LPAFSADMSVR_CHANGECELL_PARAMS pChange, ULONG *pStatus);
EXPORTED BOOL ADMINAPI AfsAppLib_asc_CellRefreshRateSet (DWORD idClient, ASID idCell, LONG cminRefreshRate, ULONG *pStatus);
EXPORTED BOOL ADMINAPI AfsAppLib_asc_ObjectFind (DWORD idClient, ASID idSearchScope, ASOBJTYPE ObjectType, LPCTSTR pszName, ASID *pidObject, ULONG *pStatus);
EXPORTED BOOL ADMINAPI AfsAppLib_asc_ObjectFindMultiple (DWORD idClient, ASID idSearchScope, ASOBJTYPE ObjectType, LPCTSTR pszPattern, LPAFSADMSVR_SEARCH_PARAMS pSearchParams, LPASIDLIST *ppList, ULONG *pStatus);
EXPORTED BOOL ADMINAPI AfsAppLib_asc_ObjectPropertiesGet (DWORD idClient, AFSADMSVR_GET_LEVEL GetLevel, ASID idCell, ASID idObject, LPASOBJPROP pProperties, ULONG *pStatus);
EXPORTED BOOL ADMINAPI AfsAppLib_asc_ObjectPropertiesGetMultiple (DWORD idClient, AFSADMSVR_GET_LEVEL GetLevel, ASID idCell, LPASIDLIST pAsidList, LPASOBJPROPLIST *ppPropertiesList, ULONG *pStatus);
EXPORTED BOOL ADMINAPI AfsAppLib_asc_ObjectListen (DWORD idClient, ASID idCell, ASID idObject, HWND hNotify, ULONG *pStatus);
EXPORTED BOOL ADMINAPI AfsAppLib_asc_ObjectListenClear (DWORD idClient, HWND hNotify, ULONG *pStatus);
EXPORTED BOOL ADMINAPI AfsAppLib_asc_ObjectListenMultiple (DWORD idClient, ASID idCell, LPASIDLIST pAsidList, HWND hNotify, ULONG *pStatus);
EXPORTED BOOL ADMINAPI AfsAppLib_asc_ObjectRefresh (DWORD idClient, ASID idCell, ASID idObject, ULONG *pStatus);
EXPORTED BOOL ADMINAPI AfsAppLib_asc_ObjectRefreshMultiple (DWORD idClient, ASID idCell, LPASIDLIST pAsidList, ULONG *pStatus);
EXPORTED BOOL ADMINAPI AfsAppLib_asc_RandomKeyGet (DWORD idClient, ASID idCell, PBYTE pkey, ULONG *pStatus);
EXPORTED BOOL ADMINAPI AfsAppLib_asc_CellNameGet_Fast (DWORD idClient, ASID idCell, LPTSTR pszCell, ULONG *pStatus = NULL);
EXPORTED BOOL ADMINAPI AfsAppLib_asc_ObjectNameGet_Fast (DWORD idClient, ASID idCell, ASID idObject, LPTSTR pszObject, ULONG *pStatus = NULL);
EXPORTED BOOL ADMINAPI AfsAppLib_asc_ObjectTypeGet_Fast (DWORD idClient, ASID idCell, ASID idObject, ASOBJTYPE *pObjectType, ULONG *pStatus = NULL);
EXPORTED BOOL ADMINAPI AfsAppLib_asc_ObjectPropertiesGet_Fast (DWORD idClient, ASID idCell, ASID idObject, LPASOBJPROP pProperties, ULONG *pStatus = NULL);
EXPORTED void ADMINAPI AfsAppLib_asc_Enter (void);
EXPORTED void ADMINAPI AfsAppLib_asc_Leave (void);
EXPORTED LPCRITICAL_SECTION ADMINAPI AfsAppLib_asc_GetCriticalSection (void);
EXPORTED BOOL ADMINAPI AfsAppLib_asc_UserChange (DWORD idClient, ASID idCell, ASID idUser, LPAFSADMSVR_CHANGEUSER_PARAMS pChange, ULONG *pStatus);
EXPORTED BOOL ADMINAPI AfsAppLib_asc_UserPasswordSet (DWORD idClient, ASID idCell, ASID idUser, int keyVersion, LPCTSTR pkeyString, PBYTE pkeyData, ULONG *pStatus);
EXPORTED BOOL ADMINAPI AfsAppLib_asc_UserUnlock (DWORD idClient, ASID idCell, ASID idUser, ULONG *pStatus);
EXPORTED BOOL ADMINAPI AfsAppLib_asc_UserCreate (DWORD idClient, ASID idCell, LPAFSADMSVR_CREATEUSER_PARAMS pCreate, ASID *pidUser, ULONG *pStatus);
EXPORTED BOOL ADMINAPI AfsAppLib_asc_UserDelete (DWORD idClient, ASID idCell, ASID idUser, LPAFSADMSVR_DELETEUSER_PARAMS pDelete, ULONG *pStatus);
EXPORTED BOOL ADMINAPI AfsAppLib_asc_GroupChange (DWORD idClient, ASID idCell, ASID idGroup, LPAFSADMSVR_CHANGEGROUP_PARAMS pChange, ULONG *pStatus);
EXPORTED BOOL ADMINAPI AfsAppLib_asc_GroupMembersGet (DWORD idClient, ASID idCell, ASID idGroup, LPASIDLIST *ppAsidList, ULONG *pStatus);
EXPORTED BOOL ADMINAPI AfsAppLib_asc_GroupMemberAdd (DWORD idClient, ASID idCell, ASID idGroup, ASID idMember, ULONG *pStatus);
EXPORTED BOOL ADMINAPI AfsAppLib_asc_GroupMemberRemove (DWORD idClient, ASID idCell, ASID idGroup, ASID idMember, ULONG *pStatus);
EXPORTED BOOL ADMINAPI AfsAppLib_asc_GroupRename (DWORD idClient, ASID idCell, ASID idGroup, LPCTSTR pszNewName, ULONG *pStatus);
EXPORTED BOOL ADMINAPI AfsAppLib_asc_GroupMembershipGet (DWORD idClient, ASID idCell, ASID idMember, LPASIDLIST *ppAsidList, ULONG *pStatus);
EXPORTED BOOL ADMINAPI AfsAppLib_asc_GroupOwnershipGet (DWORD idClient, ASID idCell, ASID idOwner, LPASIDLIST *ppAsidList, ULONG *pStatus);
EXPORTED BOOL ADMINAPI AfsAppLib_asc_GroupCreate (DWORD idClient, ASID idCell, LPAFSADMSVR_CREATEGROUP_PARAMS pCreate, ASID *pidGroup, ULONG *pStatus);
EXPORTED BOOL ADMINAPI AfsAppLib_asc_GroupDelete (DWORD idClient, ASID idCell, ASID idGroup, ULONG *pStatus);
/*
* Then, note that AfsAppLib remaps all the asc_* routines to call their
* AfsAppLib_ equivalents:
*
*/
#ifndef EXPORT_AFSAPPLIB
#define asc_AsidListCreate AfsAppLib_asc_AsidListCreate
#define asc_AsidListCopy AfsAppLib_asc_AsidListCopy
#define asc_AsidListAddEntry AfsAppLib_asc_AsidListAddEntry
#define asc_AsidListRemoveEntry AfsAppLib_asc_AsidListRemoveEntry
#define asc_AsidListRemoveEntryByIndex AfsAppLib_asc_AsidListRemoveEntryByIndex
#define asc_AsidListSetEntryParam AfsAppLib_asc_AsidListSetEntryParam
#define asc_AsidListSetEntryParamByIndex AfsAppLib_asc_AsidListSetEntryParamByIndex
#define asc_AsidListTest AfsAppLib_asc_AsidListTest
#define asc_AsidListFree AfsAppLib_asc_AsidListFree
#define asc_ObjPropListCreate AfsAppLib_asc_ObjPropListCreate
#define asc_ObjPropListCopy AfsAppLib_asc_ObjPropListCopy
#define asc_ObjPropListAddEntry AfsAppLib_asc_ObjPropListAddEntry
#define asc_ObjPropListRemoveEntry AfsAppLib_asc_ObjPropListRemoveEntry
#define asc_ObjPropListTest AfsAppLib_asc_ObjPropListTest
#define asc_ObjPropListFree AfsAppLib_asc_ObjPropListFree
#define asc_ActionListCreate AfsAppLib_asc_ActionListCreate
#define asc_ActionListCopy AfsAppLib_asc_ActionListCopy
#define asc_ActionListAddEntry AfsAppLib_asc_ActionListAddEntry
#define asc_ActionListRemoveEntry AfsAppLib_asc_ActionListRemoveEntry
#define asc_ActionListTest AfsAppLib_asc_ActionListTest
#define asc_ActionListFree AfsAppLib_asc_ActionListFree
#define asc_AdminServerOpen AfsAppLib_asc_AdminServerOpen
#define asc_AdminServerClose AfsAppLib_asc_AdminServerClose
#define asc_CredentialsGet AfsAppLib_asc_CredentialsGet
#define asc_CredentialsSet AfsAppLib_asc_CredentialsSet
#define asc_CredentialsPush AfsAppLib_asc_CredentialsPush
#define asc_LocalCellGet AfsAppLib_asc_LocalCellGet
#define asc_ErrorCodeTranslate AfsAppLib_asc_ErrorCodeTranslate
#define asc_ActionGet AfsAppLib_asc_ActionGet
#define asc_ActionGetMultiple AfsAppLib_asc_ActionGetMultiple
#define asc_ActionListen AfsAppLib_asc_ActionListen
#define asc_ActionListenClear AfsAppLib_asc_ActionListenClear
#define asc_CellOpen AfsAppLib_asc_CellOpen
#define asc_CellClose AfsAppLib_asc_CellClose
#define asc_CellChange AfsAppLib_asc_CellChange
#define asc_CellRefreshRateSet AfsAppLib_asc_CellRefreshRateSet
#define asc_ObjectFind AfsAppLib_asc_ObjectFind
#define asc_ObjectFindMultiple AfsAppLib_asc_ObjectFindMultiple
#define asc_ObjectPropertiesGet AfsAppLib_asc_ObjectPropertiesGet
#define asc_ObjectPropertiesGetMultiple AfsAppLib_asc_ObjectPropertiesGetMultiple
#define asc_ObjectListen AfsAppLib_asc_ObjectListen
#define asc_ObjectListenClear AfsAppLib_asc_ObjectListenClear
#define asc_ObjectListenMultiple AfsAppLib_asc_ObjectListenMultiple
#define asc_ObjectRefresh AfsAppLib_asc_ObjectRefresh
#define asc_ObjectRefreshMultiple AfsAppLib_asc_ObjectRefreshMultiple
#define asc_RandomKeyGet AfsAppLib_asc_RandomKeyGet
#define asc_CellNameGet_Fast AfsAppLib_asc_CellNameGet_Fast
#define asc_ObjectNameGet_Fast AfsAppLib_asc_ObjectNameGet_Fast
#define asc_ObjectTypeGet_Fast AfsAppLib_asc_ObjectTypeGet_Fast
#define asc_ObjectPropertiesGet_Fast AfsAppLib_asc_ObjectPropertiesGet_Fast
#define asc_Enter AfsAppLib_asc_Enter
#define asc_Leave AfsAppLib_asc_Leave
#define asc_GetCriticalSection AfsAppLib_asc_GetCriticalSection
#define asc_UserChange AfsAppLib_asc_UserChange
#define asc_UserPasswordSet AfsAppLib_asc_UserPasswordSet
#define asc_UserUnlock AfsAppLib_asc_UserUnlock
#define asc_UserCreate AfsAppLib_asc_UserCreate
#define asc_UserDelete AfsAppLib_asc_UserDelete
#define asc_GroupChange AfsAppLib_asc_GroupChange
#define asc_GroupMembersGet AfsAppLib_asc_GroupMembersGet
#define asc_GroupMemberAdd AfsAppLib_asc_GroupMemberAdd
#define asc_GroupMemberRemove AfsAppLib_asc_GroupMemberRemove
#define asc_GroupRename AfsAppLib_asc_GroupRename
#define asc_GroupOwnershipGet AfsAppLib_asc_GroupOwnershipGet
#define asc_GroupMembershipGet AfsAppLib_asc_GroupMembershipGet
#define asc_GroupCreate AfsAppLib_asc_GroupCreate
#define asc_GroupDelete AfsAppLib_asc_GroupDelete
#endif // EXPORT_AFSAPPLIB
#endif // AL_ADMSVR_H

View File

@ -0,0 +1,705 @@
extern "C" {
#include <afs/param.h>
#include <afs/stds.h>
}
#include <WINNT/afsapplib.h>
#include "al_dynlink.h"
#include <WINNT/TaAfsAdmSvrClient.h>
/*
* DEFINITIONS ________________________________________________________________
*
*/
#define cxICON 19 // size of an ACL entry icon
#define cyICON 16 // size of an ACL entry icon
#define clrTRANSPARENT RGB(0,255,0) // background color on ACL entry icons
/*
* BROWSE DIALOG ______________________________________________________________
*
*/
typedef struct BROWSEDIALOGPARAMS {
TCHAR szCell[ cchRESOURCE ];
TCHAR szNamed[ cchRESOURCE ];
BOOL fThisCellOnly;
HIMAGELIST hImages;
BROWSETYPE bt; // for what entry type do we browse?
HWND hDlg;
HANDLE hThread;
BOOL fCanStopThreadEasily;
BOOL fShouldStopThread;
BOOL fThreadActive;
TCHAR szThreadCell[ cchRESOURCE ];
int idsTitle;
int idsPrompt;
int idsNone;
LPCELLLIST lpcl;
PVOID hCreds;
} BROWSEDIALOGPARAMS, *LPBROWSEDIALOGPARAMS;
BOOL CALLBACK DlgProc_Browse (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp);
void DlgProc_Browse_OnInitDialog (HWND hDlg, BROWSEDIALOGPARAMS *pbdp);
void DlgProc_Browse_OnNone (HWND hDlg, BROWSEDIALOGPARAMS *pbdp);
void DlgProc_Browse_SelectedEntry (HWND hDlg, BROWSEDIALOGPARAMS *pbdp);
void DlgProc_Browse_UpdateCellText (BROWSEDIALOGPARAMS *pbdp, LPTSTR pszCell);
BOOL DlgProc_Browse_StartSearch (BROWSEDIALOGPARAMS *pbdp, BOOL fCloseDlgIfFail);
void DlgProc_Browse_StopSearch (BROWSEDIALOGPARAMS *pbdp);
DWORD _stdcall DlgProc_Browse_ThreadProc (LPARAM lp);
void EnumeratePrincipalsRemotely (LPBROWSEDIALOGPARAMS pbdp, DWORD idClient);
void EnumeratePrincipalsLocally (LPBROWSEDIALOGPARAMS pbdp);
/*
*** ShowBrowseDialog
*
* This function presents a dialog which allows the user to select a user
* or group from a list.
*
*/
BOOL AfsAppLib_ShowBrowseDialog (LPBROWSEDLG_PARAMS lpp)
{
BROWSEDIALOGPARAMS *pbdp;
BOOL rc = FALSE;
if ((pbdp = New (BROWSEDIALOGPARAMS)) != NULL)
{
memset (pbdp, 0x00, sizeof(BROWSEDIALOGPARAMS));
lstrcpy (pbdp->szNamed, lpp->szNamed);
lstrcpy (pbdp->szCell, lpp->szCell);
pbdp->lpcl = lpp->lpcl;
pbdp->bt = lpp->bt;
pbdp->idsTitle = lpp->idsTitle;
pbdp->idsPrompt = lpp->idsPrompt;
pbdp->idsNone = lpp->idsNone;
pbdp->hCreds = lpp->hCreds;
switch (pbdp->bt)
{
case btLOCAL_USER:
case btLOCAL_GROUP:
pbdp->fThisCellOnly = TRUE;
break;
case btANY_USER:
case btANY_GROUP:
pbdp->fThisCellOnly = FALSE;
break;
}
if (ModalDialogParam (IDD_APPLIB_BROWSE, lpp->hParent, (DLGPROC)DlgProc_Browse, (LPARAM)pbdp) == IDOK)
{
lstrcpy (lpp->szCell, pbdp->szCell);
lstrcpy (lpp->szNamed, pbdp->szNamed);
rc = TRUE;
}
Delete (pbdp);
}
return rc;
}
/*
*** DlgProc_Browse
*
* This is the dialog proc for the Browse Cell dialog.
*
*/
#define WM_FOUNDNAME (WM_USER +100)
#define WM_THREADSTART (WM_USER +101)
#define WM_THREADDONE (WM_USER +102)
BOOL CALLBACK DlgProc_Browse (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp)
{
BROWSEDIALOGPARAMS *pbdp;
if (AfsAppLib_HandleHelp (IDD_APPLIB_BROWSE, hDlg, msg, wp, lp))
{
return FALSE;
}
if (msg == WM_INITDIALOG)
{
SetWindowLong (hDlg, DWL_USER, lp);
}
if ((pbdp = (BROWSEDIALOGPARAMS *)GetWindowLong (hDlg, DWL_USER)) != NULL)
{
switch (msg)
{
case WM_INITDIALOG:
DlgProc_Browse_OnInitDialog (hDlg, pbdp);
break;
case WM_NOTIFY:
switch (((LPNMHDR)lp)->code)
{
case LVN_ITEMCHANGED:
if ( ((LPNM_LISTVIEW)lp)->uNewState & LVIS_SELECTED )
{
DlgProc_Browse_SelectedEntry (hDlg, pbdp);
}
break;
case NM_DBLCLK:
PostMessage (hDlg, WM_COMMAND, MAKELONG(IDC_BROWSE_SELECT,BN_CLICKED), (LPARAM)GetDlgItem(hDlg,IDC_BROWSE_SELECT));
break;
}
break;
case WM_DESTROY:
DlgProc_Browse_StopSearch (pbdp);
if (pbdp->hImages != NULL)
{
ListView_SetImageList (GetDlgItem (hDlg, IDC_BROWSE_LIST), 0, 0);
ImageList_Destroy (pbdp->hImages);
}
break;
case WM_FOUNDNAME:
{
LPTSTR pszName = (LPTSTR)lp;
if (pszName != NULL)
{
HWND hList = GetDlgItem (hDlg, IDC_BROWSE_LIST);
LV_AddItem (hList, 1, INDEX_SORT, 0, 0, pszName);
FreeString (pszName);
}
break;
}
case WM_THREADSTART:
{
TCHAR szText[ cchRESOURCE ];
GetString (szText, IDS_BROWSE_WAITING);
SetDlgItemText (pbdp->hDlg, IDC_BROWSE_STATUS, szText);
break;
}
case WM_THREADDONE:
{
SetDlgItemText (pbdp->hDlg, IDC_BROWSE_STATUS, TEXT(""));
break;
}
case WM_COMMAND:
switch (LOWORD(wp))
{
case IDCANCEL:
EndDialog (hDlg, LOWORD(wp));
break;
case IDC_BROWSE_SELECT:
if ( (GetDlgItem (pbdp->hDlg, IDC_BROWSE_NONE) != NULL) &&
(IsDlgButtonChecked (pbdp->hDlg, IDC_BROWSE_NONE)) )
{
pbdp->szCell[0] = TEXT('\0');
pbdp->szNamed[0] = TEXT('\0');
}
else
{
GetDlgItemText (hDlg, IDC_BROWSE_CELL, pbdp->szCell, cchNAME);
GetDlgItemText (hDlg, IDC_BROWSE_NAMED, pbdp->szNamed, cchRESOURCE);
}
EndDialog (hDlg, IDOK);
break;
case IDC_BROWSE_CELL:
if (HIWORD(wp) == CBN_SELCHANGE)
{
GetDlgItemText (hDlg, IDC_BROWSE_CELL, pbdp->szCell, cchNAME);
DlgProc_Browse_StartSearch (pbdp, FALSE);
}
break;
case IDC_BROWSE_RESTART:
GetDlgItemText (hDlg, IDC_BROWSE_CELL, pbdp->szCell, cchNAME);
DlgProc_Browse_StartSearch (pbdp, FALSE);
PostMessage (hDlg, WM_NEXTDLGCTL, (WPARAM)GetDlgItem (hDlg, IDC_BROWSE_NAMED), (LPARAM)TRUE);
break;
case IDC_BROWSE_NAMED:
if (HIWORD(wp) == EN_UPDATE) // has the user hit Enter here?
{
TCHAR szTest[ cchRESOURCE ];
GetDlgItemText (hDlg, IDC_BROWSE_NAMED, szTest, cchRESOURCE);
if ( (lstrlen (szTest) > 0) &&
(szTest[ lstrlen(szTest)-1 ] == TEXT('\n')) )
{
szTest[ lstrlen(szTest)-1 ] = TEXT('\0');
if ( (lstrlen (szTest) > 0) &&
(szTest[ lstrlen(szTest)-1 ] == TEXT('\r')) )
{
szTest[ lstrlen(szTest)-1 ] = TEXT('\0');
}
SetDlgItemText (hDlg, IDC_BROWSE_NAMED, szTest);
PostMessage (hDlg, WM_COMMAND, MAKELONG(IDC_BROWSE_SELECT,BN_CLICKED), (LPARAM)GetDlgItem(hDlg,IDC_BROWSE_SELECT));
}
}
break;
case IDC_BROWSE_NONE:
DlgProc_Browse_OnNone (hDlg, pbdp);
break;
}
break;
}
}
return FALSE;
}
/*
*** DlgProc_Browse_OnInitDialog
*
* The WM_INITDIALOG handler for the Browse dialog. This routine fills
* in the dialog with any starting parameters, and kicks off a new
* searching thread for the given cell.
*
*/
void DlgProc_Browse_OnInitDialog (HWND hDlg, BROWSEDIALOGPARAMS *pbdp)
{
TCHAR szText[ cchRESOURCE ];
LPTSTR psz;
pbdp->hDlg = hDlg;
// We'll need an imagelist, if we want icons in the listview.
// This looks difficult but it's not--tis just a matter of selecting
// an appropriate bitmap.
//
if ((pbdp->hImages = ImageList_Create (cxICON, cyICON, ILC_COLOR4 | ILC_MASK, 1, 1)) != 0)
{
HBITMAP bmp;
if (pbdp->bt == btLOCAL_USER)
{
bmp = LoadBitmap (APPLIB_HINST, MAKEINTRESOURCE( IDB_LOCAL_USER ));
}
else if (pbdp->bt == btANY_USER)
{
bmp = LoadBitmap (APPLIB_HINST, MAKEINTRESOURCE( IDB_FOREIGN_USER ));
}
else if (pbdp->bt == btLOCAL_GROUP)
{
bmp = LoadBitmap (APPLIB_HINST, MAKEINTRESOURCE( IDB_LOCAL_GROUP ));
}
else if (pbdp->bt == btANY_GROUP)
{
bmp = LoadBitmap (APPLIB_HINST, MAKEINTRESOURCE( IDB_FOREIGN_GROUP ));
}
if (bmp != NULL)
{
ImageList_AddMasked (pbdp->hImages, bmp, clrTRANSPARENT);
DeleteObject (bmp);
}
ListView_SetImageList (GetDlgItem (hDlg, IDC_BROWSE_LIST), pbdp->hImages, LVSIL_SMALL);
}
// There's a default pushbutton on this dialog, so that hitting
// RETURN when you're in the Cell combobox will restart the search
// (a default pushbutton always gets called when RETURN is hit,
// unless your control traps it). But the user doesn't want to *see*
// that thing, so move it way off the dialog's client area.
//
RECT r;
GetWindowRect (GetDlgItem (hDlg, IDC_BROWSE_RESTART), &r);
SetWindowPos (GetDlgItem (hDlg, IDC_BROWSE_RESTART), NULL,
0 - (r.right-r.left), 0 - (r.bottom-r.top), 0, 0,
SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
// Fill in the choices underneath IDC_BROWSE_CELL. Can the
// user enter a new cell name?
//
if (pbdp->fThisCellOnly)
{
EnableWindow (GetDlgItem (hDlg, IDC_BROWSE_CELL), FALSE);
}
else
{
CB_StartChange (GetDlgItem (hDlg, IDC_BROWSE_CELL));
if (!pbdp->lpcl)
{
TCHAR szDefCell[ cchNAME ];
if (AfsAppLib_GetLocalCell (szDefCell) && *szDefCell)
{
CB_AddItem (GetDlgItem (hDlg, IDC_BROWSE_CELL), szDefCell, 1);
}
}
else for (size_t ii = 0; ii < pbdp->lpcl->nCells; ++ii)
{
CB_AddItem (GetDlgItem (hDlg, IDC_BROWSE_CELL), pbdp->lpcl->aCells[ii], 1+ii);
}
CB_EndChange (GetDlgItem (hDlg, IDC_BROWSE_CELL), 1);
}
// Select various texts to display in the dialog
//
psz = FormatString (TEXT("%1"), TEXT("%m"), pbdp->idsTitle);
SetWindowText (hDlg, psz);
FreeString (psz);
GetString (szText, pbdp->idsPrompt);
SetDlgItemText (hDlg, IDC_BROWSE_TYPE, szText);
// If the caller wants us to display a "[X] No Group" checkbox, do so
// by creating a checkbox right underneath the IDC_BROWSE_NAMED edit
// control--note that we'll have to hide IDC_BROWSE_STATUS if that's
// the case.
//
if (pbdp->idsNone != 0)
{
ShowWindow (GetDlgItem (pbdp->hDlg, IDC_BROWSE_STATUS), FALSE);
RECT rr;
GetRectInParent (GetDlgItem (pbdp->hDlg, IDC_BROWSE_NAMED), &rr);
LONG cy;
cy = rr.bottom -rr.top;
rr.top += cy +3;
rr.bottom = rr.top +cy;
GetString (szText, pbdp->idsNone);
CreateWindow ("Button", szText, WS_CHILD | BS_AUTOCHECKBOX,
rr.left, rr.top, rr.right-rr.left, rr.bottom-rr.top,
pbdp->hDlg, (HMENU)IDC_BROWSE_NONE, APPLIB_HINST, 0);
HFONT hf = (HFONT)GetStockObject (DEFAULT_GUI_FONT);
SendMessage (GetDlgItem (pbdp->hDlg, IDC_BROWSE_NONE), WM_SETFONT, (WPARAM)hf, FALSE);
ShowWindow (GetDlgItem (pbdp->hDlg, IDC_BROWSE_NONE), TRUE);
if (pbdp->szNamed[0] == TEXT('\0'))
CheckDlgButton (pbdp->hDlg, IDC_BROWSE_NONE, TRUE);
else
CheckDlgButton (pbdp->hDlg, IDC_BROWSE_NONE, FALSE);
DlgProc_Browse_OnNone (pbdp->hDlg, pbdp);
}
SetDlgItemText (hDlg, IDC_BROWSE_CELL, pbdp->szCell);
SetDlgItemText (hDlg, IDC_BROWSE_NAMED, pbdp->szNamed);
// Start looking for users/groups
//
DlgProc_Browse_StartSearch (pbdp, TRUE);
}
/*
*** DlgProc_Browse_OnNone
*
* This routine is called whenever the user checks or unchecks the
* "[X] None" checkbox (which we may not even be displaying)
*
*/
void DlgProc_Browse_OnNone (HWND hDlg, BROWSEDIALOGPARAMS *pbdp)
{
if (GetDlgItem (pbdp->hDlg, IDC_BROWSE_NONE) != NULL)
{
BOOL fNone = IsDlgButtonChecked (pbdp->hDlg, IDC_BROWSE_NONE);
EnableWindow (GetDlgItem (hDlg, IDC_BROWSE_CELL), !fNone && !pbdp->fThisCellOnly);
EnableWindow (GetDlgItem (hDlg, IDC_BROWSE_NAMED), !fNone);
EnableWindow (GetDlgItem (hDlg, IDC_BROWSE_LIST), !fNone);
DlgProc_Browse_SelectedEntry (hDlg, pbdp);
}
}
/*
*** DlgProc_Browse_SelectedEntry
*
* This routine is called whenever the user selects a new entry within
* the Browse dialog's listview
*
*/
void DlgProc_Browse_SelectedEntry (HWND hDlg, BROWSEDIALOGPARAMS *pbdp)
{
if ( (GetDlgItem (pbdp->hDlg, IDC_BROWSE_NONE) != NULL) &&
(IsDlgButtonChecked (pbdp->hDlg, IDC_BROWSE_NONE)) )
{
pbdp->szNamed[0] = TEXT('\0');
}
else
{
HWND hList = GetDlgItem (hDlg, IDC_BROWSE_LIST);
short idxSelected = LV_GetSelected (hList);
if (idxSelected == -1)
pbdp->szNamed[0] = TEXT('\0');
else
LV_GetItemText (hList, idxSelected, 0, pbdp->szNamed);
SetDlgItemText (hDlg, IDC_BROWSE_NAMED, pbdp->szNamed);
}
}
/*
*** DlgProc_Browse_UpdateCellText
*
* This routine places the given cell name in the browse dialog.
*
*/
void DlgProc_Browse_UpdateCellText (BROWSEDIALOGPARAMS *pbdp, LPTSTR pszCell)
{
SetDlgItemText (pbdp->hDlg, IDC_BROWSE_CELL, pbdp->szCell);
}
/*
*** DlgProc_Browse_StartSearch
*
* This routine initiates a thread which enumerates all users/groups within
* the given cell, posting messages to describe what it finds to the Browse
* dialog's DLGPROC.
*
*/
BOOL DlgProc_Browse_StartSearch (BROWSEDIALOGPARAMS *pbdp, BOOL fCloseDlgIfFail)
{
DWORD dwThreadID;
// Can't start a new search until the old search terminates.
//
DlgProc_Browse_StopSearch (pbdp);
// Then make sure that we have a valid cell to query--if not, it may
// be grounds to terminate the entire browse dialog.
//
lstrcpy (pbdp->szThreadCell, pbdp->szCell);
if (!pbdp->szCell[0])
{
AfsAppLib_GetLocalCell (pbdp->szCell);
lstrcpy (pbdp->szThreadCell, pbdp->szCell);
DlgProc_Browse_UpdateCellText (pbdp, pbdp->szThreadCell);
}
if (!pbdp->szCell[0])
{
if (fCloseDlgIfFail)
EndDialog (pbdp->hDlg, IDCANCEL);
MessageBeep (MB_ICONHAND);
Message (MB_ICONHAND, IDS_BROWSE_BADCELL_TITLE, IDS_BROWSE_BADCELL_DESC);
if (!fCloseDlgIfFail)
PostMessage (pbdp->hDlg, WM_NEXTDLGCTL, (WPARAM)GetDlgItem (pbdp->hDlg, IDC_BROWSE_CELL), (LPARAM)TRUE);
return FALSE;
}
// Great--we can do the search. Start a thread to do so.
//
pbdp->fCanStopThreadEasily = FALSE;
pbdp->fShouldStopThread = FALSE;
pbdp->fThreadActive = FALSE;
ListView_DeleteAllItems (GetDlgItem (pbdp->hDlg, IDC_BROWSE_LIST));
pbdp->hThread = CreateThread (NULL, 0,
(LPTHREAD_START_ROUTINE)DlgProc_Browse_ThreadProc,
pbdp, 0, &dwThreadID);
return (pbdp->hThread == 0) ? FALSE : TRUE;
}
/*
*** DlgProc_Browse_StopSearch
*
* This routine signals the search thread to stop, and will not return
* until it does.
*
*/
void DlgProc_Browse_StopSearch (BROWSEDIALOGPARAMS *pbdp)
{
if (pbdp->fThreadActive)
{
if (pbdp->fCanStopThreadEasily)
{
pbdp->fShouldStopThread = TRUE;
WaitForSingleObject (pbdp->hThread, INFINITE);
}
else
{
TerminateThread (pbdp->hThread, 0);
pbdp->fThreadActive = FALSE;
}
}
SetDlgItemText (pbdp->hDlg, IDC_BROWSE_STATUS, TEXT(""));
}
/*
*** DlgProc_Browse_ThreadProc
*
* The worker thread for the Browse dialog; this routine enumerates all
* users or groups on the given cell, posting a WM_FOUNDNAME message to
* the Browse dialog after every successful find. Note that LPARAM on
* such messages points to a string which should be freed with FreeString()
* when no longer needed.
*
*/
DWORD _stdcall DlgProc_Browse_ThreadProc (LPARAM lp)
{
BROWSEDIALOGPARAMS *pbdp;
if ((pbdp = (BROWSEDIALOGPARAMS *)lp) != NULL)
{
pbdp->fThreadActive = TRUE;
PostMessage (pbdp->hDlg, WM_THREADSTART, 0, 0);
DWORD idClient;
if ((idClient = AfsAppLib_GetAdminServerClientID()) != 0)
{
EnumeratePrincipalsRemotely (pbdp, idClient);
}
else
{
if (OpenClientLibrary())
{
if (OpenKasLibrary())
{
EnumeratePrincipalsLocally (pbdp);
CloseKasLibrary();
}
CloseClientLibrary();
}
}
pbdp->fThreadActive = FALSE;
PostMessage (pbdp->hDlg, WM_THREADDONE, 0, 0);
}
return 0;
}
void EnumeratePrincipalsLocally (LPBROWSEDIALOGPARAMS pbdp)
{
ULONG status;
char szCellA[ MAX_PATH ];
CopyStringToAnsi (szCellA, pbdp->szCell);
PVOID hCell;
if (afsclient_CellOpen (szCellA, pbdp->hCreds, &hCell, (afs_status_p)&status))
{
// Enumerate the principals recognized by KAS.
//
PVOID hEnum;
if (kas_PrincipalGetBegin (hCell, NULL, &hEnum, (afs_status_p)&status))
{
pbdp->fCanStopThreadEasily = TRUE;
while (!pbdp->fShouldStopThread)
{
kas_identity_t who;
if (!kas_PrincipalGetNext (hEnum, &who, (afs_status_p)&status))
break;
LPTSTR pszName;
if ((pszName = CloneAnsi ((LPSTR)who.principal)) == NULL)
break;
PostMessage (pbdp->hDlg, WM_FOUNDNAME, 0, (LPARAM)pszName);
// pszName freed by DlgProc_Browse when it receives the message
}
kas_PrincipalGetDone (hEnum, (afs_status_p)&status);
}
afsclient_CellClose (hCell, (afs_status_p)&status);
}
}
void EnumeratePrincipalsRemotely (LPBROWSEDIALOGPARAMS pbdp, DWORD idClient)
{
ULONG status;
// Open the relevant cell
//
ASID idCell;
if (asc_CellOpen (idClient, pbdp->hCreds, pbdp->szThreadCell, AFSADMSVR_SCOPE_USERS, &idCell, &status))
{
// Obtain a list of ASIDs from the admin server, each representing
// a principal which we want to show.
//
LPASIDLIST pAsidList;
if (asc_ObjectFindMultiple (idClient, idCell, TYPE_USER, NULL, NULL, &pAsidList, &status))
{
if (pAsidList)
{
// Obtain rudimentary properties (e.g., their names) for these ASIDs
//
LPASOBJPROPLIST pPropList;
if (asc_ObjectPropertiesGetMultiple (idClient, GET_RUDIMENTARY_DATA, idCell, pAsidList, &pPropList, &status))
{
if (pPropList)
{
// Use the information in {pPropList} to populate the display
//
for (size_t iEntry = 0; iEntry < pPropList->cEntries; ++iEntry)
{
LPTSTR pszName;
if ((pszName = CloneString (pPropList->aEntries[ iEntry ].ObjectProperties.szName)) != NULL)
{
PostMessage (pbdp->hDlg, WM_FOUNDNAME, 0, (LPARAM)pszName);
// pszName freed by DlgProc_Browse when it receives the message
}
}
asc_ObjPropListFree (&pPropList);
}
}
asc_AsidListFree (&pAsidList);
}
}
asc_CellClose (idClient, idCell, &status);
}
}

View File

@ -0,0 +1,341 @@
extern "C" {
#include <afs/param.h>
#include <afs/stds.h>
}
#include <WINNT/afsapplib.h>
#define WM_FOUNDNAME (WM_USER +100)
#define WM_THREADSTART (WM_USER +101)
#define WM_THREADDONE (WM_USER +102)
/*
* VARIABLES __________________________________________________________________
*
*/
/*
* PROTOTYPES _________________________________________________________________
*
*/
BOOL CALLBACK BrowseSet_DlgProc (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp);
void BrowseSet_OnInitDialog (HWND hDlg, LPBROWSESETDLG_PARAMS pszFilename);
void BrowseSet_OnDestroy (HWND hDlg);
void BrowseSet_OnAddString (HWND hDlg, LPTSTR pszString);
void BrowseSet_OnSelectedEntry (HWND hDlg);
void BrowseSet_StartSearch (HWND hDlg, LPBROWSESETDLG_PARAMS lpp);
void BrowseSet_OnSearchStart (HWND hDlg);
void BrowseSet_OnSearchDone (HWND hDlg);
void BrowseSet_EmptyList (HWND hDlg);
DWORD WINAPI BrowseSet_Init_ThreadProc (LPARAM lp);
/*
* ROUTINES ___________________________________________________________________
*
*/
BOOL AfsAppLib_ShowBrowseFilesetDialog (LPBROWSESETDLG_PARAMS lpp)
{
return (ModalDialogParam (IDD_APPLIB_BROWSE_FILESET, lpp->hParent, (DLGPROC)BrowseSet_DlgProc, (LPARAM)lpp) == IDOK) ? TRUE : FALSE;
}
BOOL CALLBACK BrowseSet_DlgProc (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp)
{
if (AfsAppLib_HandleHelp (IDD_APPLIB_BROWSE_FILESET, hDlg, msg, wp, lp))
return TRUE;
if (msg == WM_INITDIALOG)
SetWindowLong (hDlg, DWL_USER, lp);
LPBROWSESETDLG_PARAMS lpp;
if ((lpp = (LPBROWSESETDLG_PARAMS)GetWindowLong (hDlg, DWL_USER)) != NULL)
{
switch (msg)
{
case WM_INITDIALOG:
lpp->pInternal = (PVOID)hDlg;
BrowseSet_OnInitDialog (hDlg, lpp);
break;
case WM_DESTROY:
BrowseSet_OnDestroy (hDlg);
lpp->pInternal = NULL;
break;
case WM_THREADSTART:
BrowseSet_OnSearchStart (hDlg);
break;
case WM_THREADDONE:
BrowseSet_OnSearchDone (hDlg);
break;
case WM_FOUNDNAME:
BrowseSet_OnAddString (hDlg, (LPTSTR)wp);
break;
case WM_COMMAND:
switch (LOWORD(wp))
{
case IDOK:
GetDlgItemText (hDlg, IDC_BROWSE_NAMED, lpp->szFileset, cchNAME);
case IDCANCEL:
EndDialog (hDlg, LOWORD(wp));
break;
case IDC_BROWSE_CELL:
if (HIWORD(wp) == CBN_SELCHANGE)
{
GetDlgItemText (hDlg, IDC_BROWSE_CELL, lpp->szCell, cchNAME);
BrowseSet_StartSearch (hDlg, lpp);
}
break;
case IDC_BROWSE_NAMED:
if (HIWORD(wp) == EN_UPDATE) // has the user hit Enter here?
{
TCHAR szTest[ cchRESOURCE ];
GetDlgItemText (hDlg, IDC_BROWSE_NAMED, szTest, cchRESOURCE);
if ( (lstrlen (szTest) > 0) && (szTest[ lstrlen(szTest)-1 ] == TEXT('\n')) )
{
szTest[ lstrlen(szTest)-1 ] = TEXT('\0');
if ( (lstrlen (szTest) > 0) && (szTest[ lstrlen(szTest)-1 ] == TEXT('\r')) )
szTest[ lstrlen(szTest)-1 ] = TEXT('\0');
SetDlgItemText (hDlg, IDC_BROWSE_NAMED, szTest);
PostMessage (hDlg, WM_COMMAND, MAKELONG(IDOK,BN_CLICKED), (LPARAM)GetDlgItem(hDlg,IDOK));
}
}
break;
case IDC_BROWSE_RESTART:
GetDlgItemText (hDlg, IDC_BROWSE_CELL, lpp->szCell, cchNAME);
BrowseSet_StartSearch (hDlg, lpp);
PostMessage (hDlg, WM_NEXTDLGCTL, (WPARAM)GetDlgItem (hDlg, IDC_BROWSE_NAMED), (LPARAM)TRUE);
break;
}
break;
case WM_NOTIFY:
switch (((LPNMHDR)lp)->code)
{
case LVN_ITEMCHANGED:
if ( ((LPNM_LISTVIEW)lp)->uNewState & LVIS_SELECTED )
BrowseSet_OnSelectedEntry (hDlg);
break;
case NM_DBLCLK:
PostMessage (hDlg, WM_COMMAND, MAKELONG(IDOK,BN_CLICKED), (LPARAM)GetDlgItem(hDlg,IDOK));
break;
}
break;
}
}
return FALSE;
}
void BrowseSet_OnInitDialog (HWND hDlg, LPBROWSESETDLG_PARAMS lpp)
{
if (lpp->idsTitle)
{
TCHAR szText[ cchRESOURCE ];
GetString (szText, lpp->idsTitle);
SetWindowText (hDlg, szText);
}
if (lpp->idsPrompt)
{
TCHAR szText[ cchRESOURCE ];
GetString (szText, lpp->idsPrompt);
SetDlgItemText (hDlg, IDC_BROWSE_TYPE, szText);
}
ListView_SetImageList (GetDlgItem (hDlg, IDC_BROWSE_LIST), AfsAppLib_CreateImageList(FALSE), LVSIL_SMALL);
SetDlgItemText (hDlg, IDC_BROWSE_NAMED, lpp->szFileset);
if (!lpp->lpcl)
{
EnableWindow (GetDlgItem (hDlg, IDC_BROWSE_CELL), FALSE);
}
else
{
CB_StartChange (GetDlgItem (hDlg, IDC_BROWSE_CELL));
for (size_t ii = 0; ii < lpp->lpcl->nCells; ++ii)
CB_AddItem (GetDlgItem (hDlg, IDC_BROWSE_CELL), lpp->lpcl->aCells[ii], 1+ii);
CB_EndChange (GetDlgItem (hDlg, IDC_BROWSE_CELL), 1);
}
if (lpp->szCell[0] != TEXT('\0'))
{
SetDlgItemText (hDlg, IDC_BROWSE_CELL, lpp->szCell);
}
BrowseSet_StartSearch (hDlg, lpp);
// There's a default pushbutton on this dialog, so that hitting
// RETURN when you're in the Cell combobox will restart the search
// (a default pushbutton always gets called when RETURN is hit,
// unless your control traps it). But the user doesn't want to *see*
// that thing, so move it way off the dialog's client area.
//
RECT r;
GetWindowRect (GetDlgItem (hDlg, IDC_BROWSE_RESTART), &r);
SetWindowPos (GetDlgItem (hDlg, IDC_BROWSE_RESTART), NULL,
0 - (r.right-r.left), 0 - (r.bottom-r.top), 0, 0,
SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
}
void BrowseSet_OnDestroy (HWND hDlg)
{
BrowseSet_EmptyList (hDlg);
}
void BrowseSet_OnSelectedEntry (HWND hDlg)
{
HWND hList = GetDlgItem (hDlg, IDC_BROWSE_LIST);
LPTSTR pszString = (LPTSTR)LV_GetSelectedData (hList);
if (pszString != NULL)
{
SetDlgItemText (hDlg, IDC_BROWSE_NAMED, pszString);
}
}
void BrowseSet_StartSearch (HWND hDlg, LPBROWSESETDLG_PARAMS lpp)
{
BrowseSet_EmptyList (hDlg);
LPBROWSESETDLG_PARAMS lppNew = New (BROWSESETDLG_PARAMS);
memcpy (lppNew, lpp, sizeof(BROWSESETDLG_PARAMS));
DWORD dwThreadID;
HANDLE hThread;
if ((hThread = CreateThread (NULL, 0, (LPTHREAD_START_ROUTINE)BrowseSet_Init_ThreadProc, (PVOID)lppNew, 0, &dwThreadID)) == INVALID_HANDLE_VALUE)
{
EnableWindow (GetDlgItem (hDlg, IDC_BROWSE_LIST), FALSE);
Delete (lppNew);
}
}
void BrowseSet_OnSearchStart (HWND hDlg)
{
TCHAR szWait[ cchRESOURCE ];
GetString (szWait, IDS_BROWSE_WAITING);
SetDlgItemText (hDlg, IDC_BROWSE_STATUS, szWait);
}
void BrowseSet_OnSearchDone (HWND hDlg)
{
SetDlgItemText (hDlg, IDC_BROWSE_STATUS, TEXT(""));
EnableWindow (GetDlgItem (hDlg, IDC_BROWSE_LIST), TRUE);
}
void BrowseSet_OnAddString (HWND hDlg, LPTSTR pszString)
{
HWND hList = GetDlgItem (hDlg, IDC_BROWSE_LIST);
LV_AddItem (hList, 1, INDEX_SORT, (LPARAM)pszString, imageFILESET, pszString);
// string freed when list destroyed
}
void BrowseSet_EmptyList (HWND hDlg)
{
HWND hList = GetDlgItem (hDlg, IDC_BROWSE_LIST);
int iiMax = ListView_GetItemCount (hList);
for (int ii = 0; ii < iiMax; ++ii)
{
LV_ITEM lvi;
memset (&lvi, 0x00, sizeof(LV_ITEM));
lvi.mask = LVIF_PARAM;
lvi.iItem = ii;
if (ListView_GetItem (hList, &lvi))
{
LPTSTR psz;
if ((psz = (LPTSTR)lvi.lParam) != NULL)
{
lvi.mask = LVIF_PARAM;
lvi.iItem = ii;
lvi.lParam = 0;
ListView_SetItem (hList, &lvi);
FreeString (psz);
}
}
}
}
DWORD WINAPI BrowseSet_Init_ThreadProc (LPARAM lp)
{
LPBROWSESETDLG_PARAMS lpp = (LPBROWSESETDLG_PARAMS)lp;
char szCellA[ cchNAME ];
CopyStringToAnsi (szCellA, lpp->szCell);
if (IsWindow ((HWND)(lpp->pInternal)))
PostMessage ((HWND)(lpp->pInternal), WM_THREADSTART, 0, 0);
// Fill in hList with the names of all filesets in the cell.
//
ULONG status = 0;
#if 0
// TODO
if (OpenFTS (&status))
{
PVOID hCell;
if ((status = FtsOpenCell (szCellA, &hCell)) == 0)
{
fldb_short_ft_info_t *fti;
if ((status = FtsAllocateShortFtInfoBuffer (&fti)) == 0)
{
PVOID cookie = 0;
ULONG nEntries;
while ( (FtsListFilesetsFromFldb (hCell, fti, &nEntries, &cookie) == 0) && (nEntries > 0) )
{
if (!IsWindow ((HWND)(lpp->pInternal)))
break;
for (ULONG ii = 0; ii < nEntries; ++ii)
{
#define DECODE_SHINFO_TYPE_FLAGS(_fl) ((_fl) >> 12)
if (DECODE_SHINFO_TYPE_FLAGS(fti[ ii ].flags) & FTS_FT_SHINFO_TYPE_RW)
{
LPTSTR pszFileset;
if ((pszFileset = CloneString (fti[ii].name)) != NULL)
{
PostMessage ((HWND)(lpp->pInternal), WM_FOUNDNAME, (WPARAM)pszFileset, 0);
// string memory is freed by recipient of message
}
}
}
}
FtsFreeShortFtInfoBuffer (fti);
}
FtsCloseCell (hCell);
}
CloseFTS();
}
#endif
if (IsWindow ((HWND)(lpp->pInternal)))
PostMessage ((HWND)(lpp->pInternal), WM_THREADDONE, status, 0);
Delete (lpp);
return 0;
}

View File

@ -0,0 +1,276 @@
extern "C" {
#include <afs/param.h>
#include <afs/stds.h>
}
#include <WINNT/afsapplib.h>
/*
* RESIZING WINDOWS ___________________________________________________________
*
*/
rwWindowData awdCover[] = {
{ IDC_COVER_BORDER, raSizeX | raSizeY },
{ IDC_COVER_DESC, raSizeX | raSizeY | raRepaint },
{ IDC_COVER_BUTTON, raMoveX | raMoveY | raRepaint },
{ idENDLIST, 0 }
};
#define WS_EX_HIDDENBYCOVER 0x10000000L
/*
* DEFINITIONS ________________________________________________________________
*
*/
#define dwCOVER_SIGNATURE 0xC0E0C0E0 // SetWindowLong(hDlgCover,DWL_USER,#)
typedef struct // COVERPARAMS
{
BOOL fClient;
HWND hWnd;
LPTSTR pszDesc;
LPTSTR pszButton;
} COVERPARAMS, *LPCOVERPARAMS;
/*
* PROTOTYPES _________________________________________________________________
*
*/
void OnCoverWindow (WPARAM wp, LPARAM lp);
BOOL CALLBACK Cover_DialogProc (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp);
/*
* ROUTINES ___________________________________________________________________
*
*/
void AfsAppLib_CoverClient (HWND hWnd, LPTSTR pszDesc, LPTSTR pszButton)
{
AfsAppLib_Uncover (hWnd);
LPCOVERPARAMS lpcp = New (COVERPARAMS);
lpcp->fClient = TRUE;
lpcp->hWnd = hWnd;
lpcp->pszDesc = CloneString (pszDesc);
lpcp->pszButton = CloneString (pszButton);
if (!AfsAppLib_GetMainWindow())
OnCoverWindow (0, (LPARAM)lpcp);
else
PostMessage (AfsAppLib_GetMainWindow(), WM_COVER_WINDOW, 0, (LPARAM)lpcp);
}
void AfsAppLib_CoverWindow (HWND hWnd, LPTSTR pszDesc, LPTSTR pszButton)
{
AfsAppLib_Uncover (hWnd);
LPCOVERPARAMS lpcp = New (COVERPARAMS);
lpcp->fClient = FALSE;
lpcp->hWnd = hWnd;
lpcp->pszDesc = CloneString (pszDesc);
lpcp->pszButton = CloneString (pszButton);
if (!AfsAppLib_GetMainWindow())
OnCoverWindow (0, (LPARAM)lpcp);
else
PostMessage (AfsAppLib_GetMainWindow(), WM_COVER_WINDOW, 0, (LPARAM)lpcp);
}
void AfsAppLib_Uncover (HWND hDlg)
{
if (!AfsAppLib_GetMainWindow())
OnCoverWindow ((WPARAM)hDlg, 0);
else
PostMessage (AfsAppLib_GetMainWindow(), WM_COVER_WINDOW, (WPARAM)hDlg, 0);
}
void OnCoverWindow (WPARAM wp, LPARAM lp)
{
LPCOVERPARAMS lpcp;
if ((lpcp = (LPCOVERPARAMS)lp) == NULL)
{
HWND hDlg = (HWND)wp;
if (!IsWindowVisible (hDlg)) // did we create it as a sibling?
{
ShowWindow (hDlg, TRUE);
EnableWindow (hDlg, TRUE);
hDlg = GetParent(hDlg);
}
for (HWND hChild = GetWindow (hDlg, GW_CHILD);
hChild != NULL;
hChild = GetWindow (hChild, GW_HWNDNEXT))
{
TCHAR szClassName[ cchRESOURCE ];
if (GetClassName (hChild, szClassName, cchRESOURCE))
{
if (!lstrcmp (szClassName, TEXT("#32770"))) // WC_DIALOG
{
if (GetWindowLong (hChild, DWL_USER) == dwCOVER_SIGNATURE)
{
DestroyWindow (hChild);
break;
}
}
}
}
}
else
{
HWND hCover = ModelessDialogParam (IDD_APPLIB_COVER,
(lpcp->fClient) ? lpcp->hWnd : GetParent(lpcp->hWnd),
(DLGPROC)Cover_DialogProc,
(LPARAM)lp);
ShowWindow (hCover, TRUE);
SetWindowLong (hCover, DWL_USER, dwCOVER_SIGNATURE);
FreeString (lpcp->pszDesc);
FreeString (lpcp->pszButton);
Delete (lpcp);
}
}
BOOL CALLBACK Cover_DialogProc (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp)
{
switch (msg)
{
case WM_INITDIALOG:
LPCOVERPARAMS lpcp;
lpcp = (LPCOVERPARAMS)lp;
SetDlgItemText (hDlg, IDC_COVER_DESC, (lpcp && lpcp->pszDesc) ? lpcp->pszDesc : TEXT(""));
if (lpcp && lpcp->pszButton)
{
SetDlgItemText (hDlg, IDC_COVER_BUTTON, lpcp->pszButton);
}
else
{
DestroyWindow (GetDlgItem (hDlg, IDC_COVER_BUTTON));
}
RECT rCover;
if (lpcp->fClient)
{
// If we're covering a window's client area, we've been created
// as a child of that window. Hide its other children, and we'll
// be done.
//
GetClientRect (lpcp->hWnd, &rCover);
for (HWND hChild = GetWindow (lpcp->hWnd, GW_CHILD);
hChild != NULL;
hChild = GetWindow (hChild, GW_HWNDNEXT))
{
if (hChild == hDlg)
continue;
if (IsWindowVisible (hChild))
{
LONG dwStyleEx = GetWindowLong (hChild, GWL_EXSTYLE);
SetWindowLong (hChild, GWL_EXSTYLE, dwStyleEx | WS_EX_HIDDENBYCOVER);
ShowWindow (hChild, FALSE);
}
}
}
else
{
// If we're covering a window's complete area, we've been created
// as a sibling of that window. Hide that window.
//
GetRectInParent (lpcp->hWnd, &rCover);
ShowWindow (lpcp->hWnd, FALSE);
EnableWindow (lpcp->hWnd, FALSE);
}
if (lpcp && lpcp->pszButton)
{
RECT rDesc; // give the button's space to the Description window
RECT rButton;
GetRectInParent (GetDlgItem (hDlg, IDC_COVER_DESC), &rDesc);
GetRectInParent (GetDlgItem (hDlg, IDC_COVER_BUTTON), &rButton);
// If the window is higher than it is wide, put the description
// above the button. Otherwise, put it to the right of the button.
//
if (cyRECT(rCover) > cxRECT(rCover))
{
// shrink description vertically
SetWindowPos (GetDlgItem (hDlg, IDC_COVER_DESC), NULL,
0, 0,
cxRECT(rDesc),
cyRECT(rDesc) - rDesc.bottom + rButton.top -5,
SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOMOVE);
}
else
{
// shrink description horizontally
SetWindowPos (GetDlgItem (hDlg, IDC_COVER_DESC), NULL,
0, 0,
cxRECT(rDesc) - rDesc.right + rButton.left -5,
cyRECT(rDesc),
SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOMOVE);
}
}
ResizeWindow (hDlg, awdCover, rwaMoveToHere, &rCover);
break;
case WM_DESTROY:
// Show all of our parent's other children, in preparation for
// our going away.
//
HWND hChild;
for (hChild = GetWindow (GetParent (hDlg), GW_CHILD);
hChild != NULL;
hChild = GetWindow (hChild, GW_HWNDNEXT))
{
if (hChild == hDlg)
continue;
LONG dwStyleEx = GetWindowLong (hChild, GWL_EXSTYLE);
if (dwStyleEx & WS_EX_HIDDENBYCOVER)
{
SetWindowLong (hChild, GWL_EXSTYLE, dwStyleEx & (~WS_EX_HIDDENBYCOVER));
ShowWindow (hChild, TRUE);
}
}
break;
case WM_SIZE:
// if (lp==0), we're minimizing--don't call ResizeWindow().
//
if (lp != 0)
ResizeWindow (hDlg, awdCover, rwaFixupGuts);
break;
case WM_COMMAND:
switch (LOWORD(wp))
{
case IDC_COVER_BUTTON:
PostMessage (GetParent(hDlg), WM_COMMAND, wp, lp);
break;
}
break;
}
return FALSE;
}

View File

@ -0,0 +1,964 @@
extern "C" {
#include <afs/param.h>
#include <afs/stds.h>
}
#include <WINNT/afsapplib.h>
#include "al_dynlink.h"
#include <WINNT/TaAfsAdmSvrClient.h>
/*
* DEFINITIONS ________________________________________________________________
*
*/
/*
* VARIABLES __________________________________________________________________
*
*/
/*
* PROTOTYPES _________________________________________________________________
*
*/
void OnExpiredCredentials (WPARAM wp, LPARAM lp);
BOOL CALLBACK OpenCell_DlgProc (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp);
void OpenCell_OnInitDialog (HWND hDlg, LPOPENCELLDLG_PARAMS lpp);
BOOL OpenCell_OnOK (HWND hDlg, LPOPENCELLDLG_PARAMS lpp);
void OpenCell_OnCell (HWND hDlg);
void OpenCell_Enable (HWND hDlg, BOOL fEnable);
void OpenCell_OnGotCreds (HWND hDlg, LPARAM lp);
BOOL CALLBACK NewCreds_DlgProc (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp);
void NewCreds_OnInitDialog (HWND hDlg, LPCREDENTIALSDLG_PARAMS lpp);
BOOL NewCreds_OnOK (HWND hDlg, LPCREDENTIALSDLG_PARAMS lpp);
void NewCreds_OnLogin (HWND hDlg);
void NewCreds_Enable (HWND hDlg, BOOL fEnable);
void NewCreds_GetOutParams (HWND hDlg, LPCREDENTIALSDLG_PARAMS lpp);
BOOL CALLBACK BadCreds_DlgProc (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp);
/*
* ROUTINES ___________________________________________________________________
*
*/
BOOL AfsAppLib_CrackCredentials (PVOID hCreds, LPTSTR pszCell, LPTSTR pszUser, LPSYSTEMTIME pst, ULONG *pStatus)
{
BOOL rc = FALSE;
ULONG status = 0;
DWORD idClient;
if ((idClient = AfsAppLib_GetAdminServerClientID()) != 0)
{
rc = asc_CredentialsCrack (idClient, hCreds, pszCell, pszUser, pst, &status);
}
else if (OpenClientLibrary())
{
char szUserA[ cchRESOURCE ], szUser2A[ cchRESOURCE ];
char szCellA[ cchRESOURCE ];
unsigned long dateExpire;
int fHasKasToken;
if (afsclient_TokenQuery (hCreds, &dateExpire, szUserA, szUser2A, szCellA, &fHasKasToken, (afs_status_p)&status))
{
rc = TRUE;
CopyAnsiToString (pszUser, szUserA);
CopyAnsiToString (pszCell, szCellA);
AfsAppLib_UnixTimeToSystemTime (pst, dateExpire);
}
CloseClientLibrary();
}
if (!hCreds && pStatus)
*pStatus = status;
return rc;
}
PVOID AfsAppLib_GetCredentials (LPCTSTR pszCell, ULONG *pStatus)
{
PVOID hCreds = NULL;
ULONG status = 0;
DWORD idClient;
if ((idClient = AfsAppLib_GetAdminServerClientID()) != 0)
{
hCreds = asc_CredentialsGet (idClient, pszCell, &status);
}
else if (OpenClientLibrary())
{
LPSTR pszCellA = StringToAnsi (pszCell);
afsclient_TokenGetExisting (pszCellA, &hCreds, (afs_status_p)&status);
FreeString (pszCellA, pszCell);
CloseClientLibrary();
}
if (!hCreds && pStatus)
*pStatus = status;
return hCreds;
}
PVOID AfsAppLib_SetCredentials (LPCTSTR pszCell, LPCTSTR pszUser, LPCTSTR pszPassword, ULONG *pStatus)
{
PVOID hCreds = NULL;
ULONG status = 0;
DWORD idClient;
if ((idClient = AfsAppLib_GetAdminServerClientID()) != 0)
{
hCreds = asc_CredentialsSet (idClient, pszCell, pszUser, pszPassword, &status);
}
else if (OpenClientLibrary())
{
char szCellA[ cchRESOURCE ];
char szUserA[ cchRESOURCE ];
char szPasswordA[ cchRESOURCE ];
CopyStringToAnsi (szCellA, pszCell);
CopyStringToAnsi (szUserA, pszUser);
CopyStringToAnsi (szPasswordA, pszPassword);
afsclient_TokenGetNew (szCellA, szUserA, szPasswordA, &hCreds, (afs_status_p)&status);
CloseClientLibrary();
}
if (hCreds)
{
PostMessage (AfsAppLib_GetMainWindow(), WM_REFRESHED_CREDENTIALS, 0, (LPARAM)hCreds);
}
if (!hCreds && pStatus)
*pStatus = status;
return hCreds;
}
/*
* OPEN CELL DIALOG ___________________________________________________________
*
*/
BOOL AfsAppLib_ShowOpenCellDialog (LPOPENCELLDLG_PARAMS lpp)
{
HINSTANCE hInst = APP_HINST;
if (lpp->idd == 0)
{
hInst = APPLIB_HINST;
lpp->idd = IDD_APPLIB_OPENCELL;
}
if (lpp->hCreds == 0)
{
if (lpp->szCell[0])
lpp->hCreds = AfsAppLib_GetCredentials (lpp->szCell);
else
lpp->hCreds = AfsAppLib_GetCredentials (NULL);
}
int rc = ModalDialogParam (lpp->idd, lpp->hParent, (DLGPROC)OpenCell_DlgProc, (LPARAM)lpp);
return (rc == IDOK) ? TRUE : FALSE;
}
BOOL CALLBACK OpenCell_DlgProc (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp)
{
LPOPENCELLDLG_PARAMS lpp;
if (msg == WM_INITDIALOG)
SetWindowLong (hDlg, DWL_USER, lp);
if ((lpp = (LPOPENCELLDLG_PARAMS)GetWindowLong (hDlg, DWL_USER)) != NULL)
{
if (lpp->hookproc)
{
if (CallWindowProc ((WNDPROC)lpp->hookproc, hDlg, msg, wp, lp))
return TRUE;
}
}
if (lpp != NULL)
{
if (AfsAppLib_HandleHelp (lpp->idd, hDlg, msg, wp, lp))
return TRUE;
}
switch (msg)
{
case WM_INITDIALOG:
OpenCell_OnInitDialog (hDlg, lpp);
break;
case WM_COMMAND:
switch (LOWORD(wp))
{
case IDCANCEL:
EndDialog (hDlg, IDCANCEL);
return TRUE;
case IDOK:
if (OpenCell_OnOK (hDlg, lpp))
EndDialog (hDlg, IDOK);
return TRUE;
case IDC_OPENCELL_CELL:
switch (HIWORD(wp))
{
case CBN_SELCHANGE:
TCHAR szCell[ cchNAME ];
SendDlgItemMessage (hDlg, IDC_OPENCELL_CELL, CB_GETLBTEXT, CB_GetSelected(GetDlgItem (hDlg, IDC_OPENCELL_CELL)), (LPARAM)szCell);
SetDlgItemText (hDlg, IDC_OPENCELL_CELL, szCell);
OpenCell_OnCell (hDlg);
break;
case CBN_EDITCHANGE:
OpenCell_OnCell (hDlg);
break;
}
break;
}
break;
case WM_REFRESHED_CREDENTIALS:
OpenCell_OnGotCreds (hDlg, lp);
break;
}
return FALSE;
}
void OpenCell_OnInitDialog (HWND hDlg, LPOPENCELLDLG_PARAMS lpp)
{
// Fix the title of the dialog (unless the caller has supplied a
// custom dialog template)
//
if (lpp && (lpp->idd == IDD_APPLIB_OPENCELL))
{
TCHAR szApplication[ cchNAME ];
AfsAppLib_GetAppName (szApplication);
if (szApplication[0] != TEXT('\0'))
{
TCHAR szTitle[ cchRESOURCE ];
GetWindowText (hDlg, szTitle, cchRESOURCE);
lstrcat (szTitle, TEXT(" - "));
lstrcat (szTitle, szApplication);
SetWindowText (hDlg, szTitle);
}
}
// Fill in the 'Cell:' combobox; we'll list the default cell, and any
// cell which the user has specified before.
//
CB_StartChange (GetDlgItem (hDlg, IDC_OPENCELL_CELL), TRUE);
if (!lpp->lpcl)
{
TCHAR szDefCell[ cchNAME ];
if (AfsAppLib_GetLocalCell (szDefCell) && *szDefCell)
{
CB_AddItem (GetDlgItem (hDlg, IDC_OPENCELL_CELL), szDefCell, 1);
}
}
else for (size_t ii = 0; ii < lpp->lpcl->nCells; ++ii)
{
CB_AddItem (GetDlgItem (hDlg, IDC_OPENCELL_CELL), lpp->lpcl->aCells[ii], 1+ii);
}
CB_EndChange (GetDlgItem (hDlg, IDC_OPENCELL_CELL), 1);
// Set up the "Credentials" box; if the user needs credentials to edit
// this default cell, jump the cursor to the appropriate field
//
SetDlgItemText (hDlg, IDC_OPENCELL_ID, TEXT("admin"));
OpenCell_OnCell (hDlg);
}
BOOL OpenCell_OnOK (HWND hDlg, LPOPENCELLDLG_PARAMS lpp)
{
BOOL rc = FALSE;
OpenCell_Enable (hDlg, FALSE);
StartHourGlass ();
// Remember what cell the user chose to edit
//
GetDlgItemText (hDlg, IDC_OPENCELL_CELL, lpp->szCell, cchNAME);
// Try to obtain the credentials specified by the user.
//
TCHAR szCell[ cchNAME ];
GetDlgItemText (hDlg, IDC_OPENCELL_CELL, szCell, cchNAME);
TCHAR szUser[ cchRESOURCE ];
GetDlgItemText (hDlg, IDC_OPENCELL_ID, szUser, cchNAME);
TCHAR szPassword[ cchRESOURCE ];
GetDlgItemText (hDlg, IDC_OPENCELL_PASSWORD, szPassword, cchNAME);
ULONG status;
if ((lpp->hCreds = AfsAppLib_SetCredentials (lpp->szCell, szUser, szPassword, &status)) == NULL)
{
ErrorDialog (status, IDS_ERROR_BAD_CREDENTIALS);
}
else
{
// See if those credentials are sufficient
//
CHECKCREDS_PARAMS pp;
memset (&pp, 0x00, sizeof(pp));
memcpy (&pp.bcdp, &lpp->bcdp, sizeof(BADCREDSDLG_PARAMS));
pp.bcdp.hParent = hDlg;
pp.hCreds = lpp->hCreds;
pp.fShowWarning = TRUE;
if ((rc = AfsAppLib_CheckCredentials (&pp)) == FALSE)
{
SetDlgItemText (hDlg, IDC_OPENCELL_ID, TEXT("admin"));
PostMessage (hDlg, WM_NEXTDLGCTL, (WPARAM)GetDlgItem(hDlg,IDC_OPENCELL_PASSWORD), TRUE);
}
}
if (!rc)
OpenCell_Enable (hDlg, TRUE);
StopHourGlass ();
return rc;
}
typedef struct
{
HWND hDlg;
TCHAR szCell[ cchNAME ];
TCHAR szUser[ cchNAME ];
SYSTEMTIME stExpire;
BOOL fGotCreds;
BOOL fValidCreds;
} OPENCELL_ONCELL_PARAMS, *LPOPENCELL_ONCELL_PARAMS;
DWORD WINAPI OpenCell_OnCell_ThreadProc (PVOID lp)
{
LPOPENCELL_ONCELL_PARAMS lpp;
if ((lpp = (LPOPENCELL_ONCELL_PARAMS)lp) != NULL)
{
PVOID hCreds = AfsAppLib_GetCredentials (lpp->szCell);
lpp->fGotCreds = AfsAppLib_CrackCredentials (hCreds, lpp->szCell, lpp->szUser, &lpp->stExpire);
lpp->fValidCreds = FALSE;
if (lpp->fGotCreds && AfsAppLib_IsTimeInFuture (&lpp->stExpire))
{
CHECKCREDS_PARAMS pp;
memset (&pp, 0x00, sizeof(pp));
pp.hCreds = hCreds;
lpp->fValidCreds = AfsAppLib_CheckCredentials(&pp);
}
// Post our results; we'll return the same packet we got.
//
if (IsWindow (lpp->hDlg))
PostMessage (lpp->hDlg, WM_REFRESHED_CREDENTIALS, 0, (LPARAM)lpp);
else
Delete (lpp);
}
return 0;
}
void OpenCell_OnCell (HWND hDlg)
{
// Fire up a background thread to query our current credentials in the
// selected cell.
//
LPOPENCELL_ONCELL_PARAMS lpp = New (OPENCELL_ONCELL_PARAMS);
memset (lpp, 0x00, sizeof(lpp));
GetDlgItemText (hDlg, IDC_OPENCELL_CELL, lpp->szCell, cchNAME);
lpp->hDlg = hDlg;
DWORD dwThreadID;
CreateThread (NULL, 0, (LPTHREAD_START_ROUTINE)OpenCell_OnCell_ThreadProc, lpp, 0, &dwThreadID);
}
void OpenCell_OnGotCreds (HWND hDlg, LPARAM lp)
{
LPOPENCELL_ONCELL_PARAMS lpp;
if ((lpp = (LPOPENCELL_ONCELL_PARAMS)lp) != NULL)
{
// Don't do anything to the dialog if the user has chosen a different
// cell than that for which we just queried credentials.
//
TCHAR szCell[ cchNAME ];
GetDlgItemText (hDlg, IDC_OPENCELL_CELL, szCell, cchNAME);
if (!lstrcmpi (szCell, lpp->szCell))
{
TCHAR szPrevCreds[ cchRESOURCE ];
GetDlgItemText (hDlg, IDC_OPENCELL_OLDCREDS, szPrevCreds, cchRESOURCE);
if (!lpp->fGotCreds)
{
LPTSTR psz = FormatString (IDS_CREDS_NONE, TEXT("%s"), lpp->szCell);
SetDlgItemText (hDlg, IDC_OPENCELL_OLDCREDS, psz);
FreeString (psz);
}
else if (!AfsAppLib_IsTimeInFuture (&lpp->stExpire))
{
LPTSTR pszCreds = FormatString (IDS_CREDS_EXPIRED, TEXT("%s%s%t"), lpp->szCell, lpp->szUser, &lpp->stExpire);
SetDlgItemText (hDlg, IDC_OPENCELL_OLDCREDS, pszCreds);
FreeString (pszCreds);
}
else
{
LPTSTR pszCreds = FormatString (IDS_CREDS_VALID, TEXT("%s%s%t"), lpp->szCell, lpp->szUser, &lpp->stExpire);
SetDlgItemText (hDlg, IDC_OPENCELL_OLDCREDS, pszCreds);
FreeString (pszCreds);
}
SetDlgItemText (hDlg, IDC_OPENCELL_ID, (lpp->fGotCreds) ? lpp->szUser : TEXT("admin"));
if (!lpp->fValidCreds && !szPrevCreds[0])
PostMessage (hDlg, WM_NEXTDLGCTL, (WPARAM)GetDlgItem(hDlg,IDC_OPENCELL_PASSWORD), TRUE);
}
Delete (lpp);
}
}
void OpenCell_Enable (HWND hDlg, BOOL fEnable)
{
EnableWindow (GetDlgItem (hDlg, IDOK), fEnable);
EnableWindow (GetDlgItem (hDlg, IDCANCEL), fEnable);
EnableWindow (GetDlgItem (hDlg, IDHELP), fEnable);
EnableWindow (GetDlgItem (hDlg, IDC_OPENCELL_CELL), fEnable);
EnableWindow (GetDlgItem (hDlg, IDC_OPENCELL_ID), fEnable);
EnableWindow (GetDlgItem (hDlg, IDC_OPENCELL_PASSWORD), fEnable);
}
/*
* NEW CREDENTIALS DIALOG _____________________________________________________
*
*/
BOOL AfsAppLib_ShowCredentialsDialog (LPCREDENTIALSDLG_PARAMS lpp)
{
HINSTANCE hInst = APP_HINST;
if (lpp->idd == 0)
{
hInst = APPLIB_HINST;
lpp->idd = IDD_APPLIB_CREDENTIALS;
}
if (lpp->hCreds == 0)
{
if (lpp->szCell[0])
lpp->hCreds = AfsAppLib_GetCredentials (lpp->szCell);
else
lpp->hCreds = AfsAppLib_GetCredentials (NULL);
}
int rc = ModalDialogParam (lpp->idd, lpp->hParent, (DLGPROC)NewCreds_DlgProc, (LPARAM)lpp);
return (rc == IDOK) ? TRUE : FALSE;
}
BOOL CALLBACK NewCreds_DlgProc (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp)
{
LPCREDENTIALSDLG_PARAMS lpp;
if (msg == WM_INITDIALOG)
SetWindowLong (hDlg, DWL_USER, lp);
if ((lpp = (LPCREDENTIALSDLG_PARAMS)GetWindowLong (hDlg, DWL_USER)) != NULL)
{
if (lpp->hookproc)
{
if (CallWindowProc ((WNDPROC)lpp->hookproc, hDlg, msg, wp, lp))
return TRUE;
}
}
if (lpp != NULL)
{
if (AfsAppLib_HandleHelp (lpp->idd, hDlg, msg, wp, lp))
return TRUE;
}
switch (msg)
{
case WM_INITDIALOG:
NewCreds_OnInitDialog (hDlg, lpp);
break;
case WM_COMMAND:
switch (LOWORD(wp))
{
case IDCANCEL:
EndDialog (hDlg, IDCANCEL);
return TRUE;
case IDOK:
if (NewCreds_OnOK (hDlg, lpp))
EndDialog (hDlg, IDOK);
return TRUE;
case IDC_CREDS_LOGIN:
NewCreds_OnLogin (hDlg);
break;
}
break;
}
return FALSE;
}
void NewCreds_OnInitDialog (HWND hDlg, LPCREDENTIALSDLG_PARAMS lpp)
{
// Fix the title of the dialog (unless the caller has supplied a
// custom dialog template)
//
if (lpp && (lpp->idd == IDD_APPLIB_CREDENTIALS))
{
TCHAR szApplication[ cchNAME ];
AfsAppLib_GetAppName (szApplication);
if (szApplication[0] != TEXT('\0'))
{
TCHAR szTitle[ cchRESOURCE ];
GetWindowText (hDlg, szTitle, cchRESOURCE);
lstrcat (szTitle, TEXT(" - "));
lstrcat (szTitle, szApplication);
SetWindowText (hDlg, szTitle);
}
}
// Set up the "Credentials" boxes
//
TCHAR szUser[ cchRESOURCE ];
SYSTEMTIME st;
BOOL fValidCreds = TRUE;
BOOL fShowCreds = TRUE;
CHECKCREDS_PARAMS pp;
memset (&pp, 0x00, sizeof(pp));
pp.hCreds = lpp->hCreds;
pp.fShowWarning = FALSE;
memcpy (&pp.bcdp, &lpp->bcdp, sizeof(BADCREDSDLG_PARAMS));
pp.bcdp.hParent = hDlg;
if (!AfsAppLib_CrackCredentials (lpp->hCreds, lpp->szCell, szUser, &st))
{
fValidCreds = FALSE;
fShowCreds = FALSE;
}
if (!AfsAppLib_IsTimeInFuture (&st))
{
fValidCreds = FALSE;
fShowCreds = FALSE;
}
if (!AfsAppLib_CheckCredentials (&pp))
{
fValidCreds = FALSE;
}
CheckDlgButton (hDlg, IDC_CREDS_LOGIN, !fValidCreds);
if (!fValidCreds)
PostMessage (hDlg, WM_NEXTDLGCTL, (WPARAM)GetDlgItem(hDlg,IDC_CREDS_PASSWORD), TRUE);
SetDlgItemText (hDlg, IDC_CREDS_CELL, lpp->szCell);
if (fShowCreds)
{
SetDlgItemText (hDlg, IDC_CREDS_CURRENTID, szUser);
LPTSTR pszDate = FormatString (TEXT("%1"), TEXT("%t"), &st);
SetDlgItemText (hDlg, IDC_CREDS_EXPDATE, pszDate);
FreeString (pszDate);
}
SetDlgItemText (hDlg, IDC_CREDS_ID, TEXT("admin"));
NewCreds_OnLogin (hDlg);
}
BOOL NewCreds_OnOK (HWND hDlg, LPCREDENTIALSDLG_PARAMS lpp)
{
NewCreds_GetOutParams (hDlg, lpp);
if (!IsDlgButtonChecked (hDlg, IDC_CREDS_LOGIN))
return TRUE;
BOOL rc = FALSE;
StartHourGlass ();
NewCreds_Enable (hDlg, FALSE);
// Try to obtain the credentials specified by the user.
//
TCHAR szUser[ cchRESOURCE ];
GetDlgItemText (hDlg, IDC_CREDS_ID, szUser, cchNAME);
TCHAR szPassword[ cchRESOURCE ];
GetDlgItemText (hDlg, IDC_CREDS_PASSWORD, szPassword, cchNAME);
ULONG status;
if ((lpp->hCreds = AfsAppLib_SetCredentials (lpp->szCell, szUser, szPassword, &status)) == NULL)
{
ErrorDialog (status, IDS_ERROR_BAD_CREDENTIALS);
}
else
{
// See if those credentials are sufficient
//
CHECKCREDS_PARAMS pp;
memset (&pp, 0x00, sizeof(pp));
memcpy (&pp.bcdp, &lpp->bcdp, sizeof(BADCREDSDLG_PARAMS));
pp.bcdp.hParent = hDlg;
pp.hCreds = lpp->hCreds;
pp.fShowWarning = TRUE;
if ((rc = AfsAppLib_CheckCredentials (&pp)) == FALSE)
{
SetDlgItemText (hDlg, IDC_CREDS_ID, TEXT("admin"));
PostMessage (hDlg, WM_NEXTDLGCTL, (WPARAM)GetDlgItem(hDlg,IDC_CREDS_PASSWORD), TRUE);
}
}
if (!rc)
NewCreds_Enable (hDlg, TRUE);
StopHourGlass ();
return rc;
}
void NewCreds_OnLogin (HWND hDlg)
{
BOOL fEnable = IsDlgButtonChecked (hDlg, IDC_CREDS_LOGIN);
EnableWindow (GetDlgItem (hDlg, IDC_CREDS_ID), fEnable);
EnableWindow (GetDlgItem (hDlg, IDC_CREDS_PASSWORD), fEnable);
}
void NewCreds_Enable (HWND hDlg, BOOL fEnable)
{
EnableWindow (GetDlgItem (hDlg, IDOK), fEnable);
EnableWindow (GetDlgItem (hDlg, IDCANCEL), fEnable);
EnableWindow (GetDlgItem (hDlg, IDHELP), fEnable);
EnableWindow (GetDlgItem (hDlg, IDC_CREDS_LOGIN), fEnable);
if (fEnable)
NewCreds_OnLogin (hDlg);
else
{
EnableWindow (GetDlgItem (hDlg, IDC_CREDS_ID), fEnable);
EnableWindow (GetDlgItem (hDlg, IDC_CREDS_PASSWORD), fEnable);
}
}
void NewCreds_GetOutParams (HWND hDlg, LPCREDENTIALSDLG_PARAMS lpp)
{
if (!IsDlgButtonChecked (hDlg, IDC_CREDS_LOGIN))
{
lpp->szIdentity[0] = TEXT('\0');
lpp->szPassword[0] = TEXT('\0');
}
else
{
GetDlgItemText (hDlg, IDC_CREDS_ID, lpp->szIdentity, cchNAME);
GetDlgItemText (hDlg, IDC_CREDS_PASSWORD, lpp->szPassword, cchNAME);
}
}
/*
* TEST CREDENTIALS ___________________________________________________________
*
*/
typedef struct
{
BADCREDSDLG_PARAMS bcdp;
LPTSTR pszFullText;
PVOID hCreds;
} REALBADCREDSDLG_PARAMS, *LPREALBADCREDSDLG_PARAMS;
BOOL AfsAppLib_CheckCredentials (LPCHECKCREDS_PARAMS lpp)
{
BOOL fCredsOK = TRUE;
int idsWarning = IDS_BADCREDS_DESC_GENERAL;
TCHAR szCell[ cchNAME ];
TCHAR szUser[ cchNAME ];
SYSTEMTIME stExpire;
if (!AfsAppLib_CrackCredentials (lpp->hCreds, szCell, szUser, &stExpire))
{
fCredsOK = FALSE;
}
else if (!AfsAppLib_IsUserAdmin (lpp->hCreds, szUser))
{
fCredsOK = FALSE;
idsWarning = IDS_BADCREDS_DESC_BADCHOICE;
}
else if (!AfsAppLib_IsTimeInFuture (&stExpire))
{
fCredsOK = FALSE;
idsWarning = IDS_BADCREDS_DESC_EXPIRED;
}
if (!fCredsOK && lpp->fShowWarning)
{
if (lpp->bcdp.pfShowWarningEver && !(*lpp->bcdp.pfShowWarningEver))
{
fCredsOK = TRUE; // user says always ignore bad credentials.
}
else
{
if (!szCell[0])
AfsAppLib_GetLocalCell (szCell);
int idsDesc = (lpp->bcdp.idsDesc) ? lpp->bcdp.idsDesc : IDS_BADCREDS_DESC2;
LPTSTR pszDesc = FormatString (idsDesc, TEXT("%s"), szCell);
LPTSTR pszFullText = FormatString (idsWarning, TEXT("%s%s%m"), szCell, pszDesc, IDS_BADCREDS_DESC3);
FreeString (pszDesc);
REALBADCREDSDLG_PARAMS pp;
memset (&pp, 0x00, sizeof(pp));
pp.pszFullText = pszFullText;
memcpy (&pp.bcdp, &lpp->bcdp, sizeof(BADCREDSDLG_PARAMS));
HINSTANCE hInst = APP_HINST;
if (pp.bcdp.idd == 0)
{
hInst = APPLIB_HINST;
pp.bcdp.idd = IDD_APPLIB_BADCREDS;
}
int rc = ModalDialogParam (pp.bcdp.idd, pp.bcdp.hParent, (DLGPROC)BadCreds_DlgProc, (LPARAM)&pp);
if (rc == IDCANCEL)
{
fCredsOK = TRUE; // user says ignore bad credentials this time.
}
FreeString (pszFullText);
}
}
return fCredsOK;
}
BOOL CALLBACK BadCreds_DlgProc (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp)
{
LPREALBADCREDSDLG_PARAMS lpp;
if (msg == WM_INITDIALOG)
SetWindowLong (hDlg, DWL_USER, lp);
if ((lpp = (LPREALBADCREDSDLG_PARAMS)GetWindowLong (hDlg, DWL_USER)) != NULL)
{
if (lpp->bcdp.hookproc)
{
if (CallWindowProc ((WNDPROC)lpp->bcdp.hookproc, hDlg, msg, wp, lp))
return TRUE;
}
if (AfsAppLib_HandleHelp (lpp->bcdp.idd, hDlg, msg, wp, lp))
return TRUE;
}
switch (msg)
{
case WM_INITDIALOG:
TCHAR szApplication[ cchNAME ];
AfsAppLib_GetAppName (szApplication);
if (szApplication[0] != TEXT('\0'))
{
TCHAR szTitle[ cchRESOURCE ];
GetWindowText (hDlg, szTitle, cchRESOURCE);
lstrcat (szTitle, TEXT(" - "));
lstrcat (szTitle, szApplication);
SetWindowText (hDlg, szTitle);
}
if (!lpp || !lpp->bcdp.pfShowWarningEver)
DestroyWindow (GetWindow (hDlg, IDC_BADCREDS_SHUTUP));
SetDlgItemText (hDlg, IDC_BADCREDS_DESC, lpp->pszFullText);
break;
case WM_COMMAND:
switch (LOWORD(wp))
{
case IDOK:
case IDCANCEL:
if (lpp && lpp->bcdp.pfShowWarningEver)
*lpp->bcdp.pfShowWarningEver = !IsDlgButtonChecked (hDlg, IDC_BADCREDS_SHUTUP);
EndDialog (hDlg, LOWORD(wp));
break;
}
break;
}
return FALSE;
}
/*
* EXPIRED CREDENTIALS ________________________________________________________
*
*/
void AfsAppLib_CheckForExpiredCredentials (LPCREDENTIALSDLG_PARAMS lpp)
{
static PVOID hCredsPrevious = NULL;
static BOOL fHadGoodCredentials;
TCHAR szCell[ cchNAME ];
TCHAR szUser[ cchNAME ];
SYSTEMTIME stExpire;
BOOL fHaveCredentials;
fHaveCredentials = AfsAppLib_CrackCredentials (lpp->hCreds, szCell, szUser, &stExpire);
if (hCredsPrevious && (hCredsPrevious != lpp->hCreds))
{
if (!fHaveCredentials)
fHadGoodCredentials = FALSE;
else if (!AfsAppLib_IsTimeInFuture (&stExpire))
fHadGoodCredentials = FALSE;
else
fHadGoodCredentials = TRUE;
hCredsPrevious = lpp->hCreds;
}
else if (fHaveCredentials && AfsAppLib_IsTimeInFuture (&stExpire))
{
fHadGoodCredentials = TRUE;
}
else if (fHadGoodCredentials) // used to have good credentials, but now don't
{
fHadGoodCredentials = FALSE;
LPCREDENTIALSDLG_PARAMS lppCopy = New (CREDENTIALSDLG_PARAMS);
memcpy (lppCopy, lpp, sizeof(CREDENTIALSDLG_PARAMS));
if (!AfsAppLib_GetMainWindow())
OnExpiredCredentials ((WPARAM)(!AfsAppLib_IsTimeInFuture(&stExpire)), (LPARAM)lppCopy);
else
PostMessage (AfsAppLib_GetMainWindow(), WM_EXPIRED_CREDENTIALS, (WPARAM)(!AfsAppLib_IsTimeInFuture(&stExpire)), (LPARAM)lppCopy);
}
}
void OnExpiredCredentials (WPARAM wp, LPARAM lp)
{
BOOL fExpired = (BOOL)wp;
LPCREDENTIALSDLG_PARAMS lpp = (LPCREDENTIALSDLG_PARAMS)lp;
if (lpp && lpp->bcdp.pfShowWarningEver && *(lpp->bcdp.pfShowWarningEver))
{
int idsWarning = (wp) ? IDS_BADCREDS_DESC_EXPIRED : IDS_BADCREDS_DESC_DESTROYED;
int idsDesc = (lpp->bcdp.idsDesc) ? lpp->bcdp.idsDesc : IDS_BADCREDS_DESC2;
LPTSTR pszDesc = FormatString (idsDesc, TEXT("%s"), lpp->szCell);
LPTSTR pszFullText = FormatString (idsWarning, TEXT("%s%s%m"), lpp->szCell, pszDesc, IDS_BADCREDS_DESC3);
FreeString (pszDesc);
REALBADCREDSDLG_PARAMS pp;
memset (&pp, 0x00, sizeof(pp));
pp.pszFullText = pszFullText;
memcpy (&pp.bcdp, &lpp->bcdp, sizeof(BADCREDSDLG_PARAMS));
if (ModalDialogParam (IDD_APPLIB_BADCREDS, NULL, (DLGPROC)BadCreds_DlgProc, (LPARAM)&pp) != IDCANCEL)
{
AfsAppLib_ShowCredentialsDialog (lpp);
}
FreeString (pszFullText);
}
if (lpp)
{
Delete (lpp);
}
}
BOOL AfsAppLib_IsUserAdmin (PVOID hCreds, LPTSTR pszUser)
{
BOOL rc = FALSE;
afs_status_t status;
DWORD idClient;
if ((idClient = AfsAppLib_GetAdminServerClientID()) != 0)
{
TCHAR szCell[ cchRESOURCE ];
TCHAR szUser[ cchRESOURCE ];
SYSTEMTIME stExpire;
if (asc_CredentialsCrack (idClient, hCreds, szCell, szUser, &stExpire, (ULONG*)&status))
{
ASID idCell;
if (asc_CellOpen (idClient, hCreds, szCell, AFSADMSVR_SCOPE_USERS, &idCell, (ULONG*)&status))
{
ASID idUser;
if (asc_ObjectFind (idClient, idCell, TYPE_USER, pszUser, &idUser, (ULONG*)&status))
{
ASOBJPROP Info;
if (asc_ObjectPropertiesGet (idClient, GET_ALL_DATA, idCell, idUser, &Info, (ULONG*)&status))
{
if (Info.u.UserProperties.fHaveKasInfo)
{
rc = Info.u.UserProperties.KASINFO.fIsAdmin;
}
}
}
asc_CellClose (idClient, idCell, (ULONG*)&status);
}
}
}
else if (OpenClientLibrary())
{
if (OpenKasLibrary())
{
char szUserA[ cchRESOURCE ], szUser2A[ cchRESOURCE ];
char szCellA[ cchRESOURCE ];
unsigned long dateExpire;
int fHasKasToken;
if (afsclient_TokenQuery (hCreds, &dateExpire, szUserA, szUser2A, szCellA, &fHasKasToken, (afs_status_p)&status))
{
PVOID hCell;
if (afsclient_CellOpen (szCellA, hCreds, &hCell, &status))
{
kas_identity_t Identity;
memset (&Identity, 0x00, sizeof(Identity));
CopyStringToAnsi (Identity.principal, pszUser);
kas_principalEntry_t Entry;
if (kas_PrincipalGet (hCell, NULL, &Identity, &Entry, &status))
{
if (Entry.adminSetting == ADMIN)
rc = TRUE;
}
afsclient_CellClose (hCell, (afs_status_p)&status);
}
}
CloseKasLibrary();
}
CloseClientLibrary();
}
return rc;
}

View File

@ -0,0 +1,185 @@
extern "C" {
#include <afs/param.h>
#include <afs/stds.h>
}
#include <WINNT/afsapplib.h>
#include "al_dynlink.h"
/*
* LIBRARIES __________________________________________________________________
*
*/
#define cszLIBRARY_UTIL TEXT("AfsAdminUtil.dll")
#define cszLIBRARY_KAS TEXT("AfsKasAdmin.dll")
#define cszLIBRARY_CLIENT TEXT("AfsClientAdmin.dll")
/*
* ADMIN ______________________________________________________________________
*
*/
static size_t g_cReqUtilLibrary = 0;
static HINSTANCE g_hiUtilLibrary = NULL;
util_AdminErrorCodeTranslate_t util_AdminErrorCodeTranslateP = NULL;
BOOL OpenUtilLibrary (ULONG *pStatus)
{
BOOL rc = FALSE;
ULONG status = ERROR_DLL_NOT_FOUND;
if ((++g_cReqUtilLibrary) == 1)
{
if ( ((g_hiUtilLibrary = LoadLibrary (cszLIBRARY_UTIL)) == NULL) ||
((util_AdminErrorCodeTranslateP = (util_AdminErrorCodeTranslate_t)GetProcAddress (g_hiUtilLibrary, "util_AdminErrorCodeTranslate")) == NULL) )
{
status = GetLastError();
CloseUtilLibrary();
}
}
if (g_hiUtilLibrary)
{
rc = TRUE;
}
if (pStatus)
*pStatus = status;
return rc;
}
void CloseUtilLibrary (void)
{
if ((--g_cReqUtilLibrary) == 0)
{
if (g_hiUtilLibrary)
FreeLibrary (g_hiUtilLibrary);
g_hiUtilLibrary = NULL;
}
}
/*
* KAS ________________________________________________________________________
*
*/
static size_t g_cReqKasLibrary = 0;
static HINSTANCE g_hiKasLibrary = NULL;
kas_PrincipalGetBegin_t kas_PrincipalGetBeginP = NULL;
kas_PrincipalGetNext_t kas_PrincipalGetNextP = NULL;
kas_PrincipalGetDone_t kas_PrincipalGetDoneP = NULL;
kas_PrincipalGet_t kas_PrincipalGetP = NULL;
BOOL OpenKasLibrary (ULONG *pStatus)
{
BOOL rc = FALSE;
ULONG status = ERROR_DLL_NOT_FOUND;
if ((++g_cReqKasLibrary) == 1)
{
if ( ((g_hiKasLibrary = LoadLibrary (cszLIBRARY_KAS)) == NULL) ||
((kas_PrincipalGetBeginP = (kas_PrincipalGetBegin_t)GetProcAddress (g_hiKasLibrary, "kas_PrincipalGetBegin")) == NULL) ||
((kas_PrincipalGetNextP = (kas_PrincipalGetNext_t)GetProcAddress (g_hiKasLibrary, "kas_PrincipalGetNext")) == NULL) ||
((kas_PrincipalGetDoneP = (kas_PrincipalGetDone_t)GetProcAddress (g_hiKasLibrary, "kas_PrincipalGetDone")) == NULL) ||
((kas_PrincipalGetP = (kas_PrincipalGet_t)GetProcAddress (g_hiKasLibrary, "kas_PrincipalGet")) == NULL) )
{
status = GetLastError();
CloseKasLibrary();
}
}
if (g_hiKasLibrary)
{
rc = TRUE;
}
if (pStatus)
*pStatus = status;
return rc;
}
void CloseKasLibrary (void)
{
if ((--g_cReqKasLibrary) == 0)
{
if (g_hiKasLibrary)
FreeLibrary (g_hiKasLibrary);
g_hiKasLibrary = NULL;
}
}
/*
* CLIENT _____________________________________________________________________
*
*/
static size_t g_cReqClientLibrary = 0;
static HINSTANCE g_hiClientLibrary = NULL;
typedef int (ADMINAPI *afsclient_Init_t)(afs_status_p st);
afsclient_TokenGetExisting_t afsclient_TokenGetExistingP = NULL;
afsclient_TokenGetNew_t afsclient_TokenGetNewP = NULL;
afsclient_TokenClose_t afsclient_TokenCloseP = NULL;
afsclient_TokenQuery_t afsclient_TokenQueryP = NULL;
afsclient_CellOpen_t afsclient_CellOpenP = NULL;
afsclient_CellClose_t afsclient_CellCloseP = NULL;
afsclient_LocalCellGet_t afsclient_LocalCellGetP = NULL;
afsclient_Init_t afsclient_InitP = NULL;
BOOL OpenClientLibrary (ULONG *pStatus)
{
BOOL rc = FALSE;
ULONG status = ERROR_DLL_NOT_FOUND;
if ((++g_cReqClientLibrary) == 1)
{
if ( ((g_hiClientLibrary = LoadLibrary (cszLIBRARY_CLIENT)) == NULL) ||
((afsclient_TokenGetExistingP = (afsclient_TokenGetExisting_t)GetProcAddress (g_hiClientLibrary, "afsclient_TokenGetExisting")) == NULL) ||
((afsclient_TokenGetNewP = (afsclient_TokenGetNew_t)GetProcAddress (g_hiClientLibrary, "afsclient_TokenGetNew")) == NULL) ||
((afsclient_TokenCloseP = (afsclient_TokenClose_t)GetProcAddress (g_hiClientLibrary, "afsclient_TokenClose")) == NULL) ||
((afsclient_TokenQueryP = (afsclient_TokenQuery_t)GetProcAddress (g_hiClientLibrary, "afsclient_TokenQuery")) == NULL) ||
((afsclient_CellOpenP = (afsclient_CellOpen_t)GetProcAddress (g_hiClientLibrary, "afsclient_CellOpen")) == NULL) ||
((afsclient_CellCloseP = (afsclient_CellClose_t)GetProcAddress (g_hiClientLibrary, "afsclient_CellClose")) == NULL) ||
((afsclient_LocalCellGetP = (afsclient_LocalCellGet_t)GetProcAddress (g_hiClientLibrary, "afsclient_LocalCellGet")) == NULL) ||
((afsclient_InitP = (afsclient_Init_t)GetProcAddress (g_hiClientLibrary, "afsclient_Init")) == NULL) )
{
status = GetLastError();
CloseClientLibrary();
}
else if (!(*afsclient_InitP)((afs_status_p)&status))
{
CloseClientLibrary();
}
}
if (g_hiClientLibrary)
{
rc = TRUE;
}
if (pStatus)
*pStatus = status;
return rc;
}
void CloseClientLibrary (void)
{
if ((--g_cReqClientLibrary) == 0)
{
if (g_hiClientLibrary)
FreeLibrary (g_hiClientLibrary);
g_hiClientLibrary = NULL;
}
}

View File

@ -0,0 +1,80 @@
#ifndef AL_DYNLINK_H
#define AL_DYNLINK_H
extern "C" {
#include <afs/afs_Admin.h>
#include <afs/afs_utilAdmin.h>
#include <afs/afs_kasAdmin.h>
#include <afs/afs_clientAdmin.h>
} // extern "C"
/*
* PROTOTYPES _________________________________________________________________
*
*/
BOOL OpenUtilLibrary (ULONG *pStatus = NULL);
void CloseUtilLibrary (void);
BOOL OpenKasLibrary (ULONG *pStatus = NULL);
void CloseKasLibrary (void);
BOOL OpenClientLibrary (ULONG *pStatus = NULL);
void CloseClientLibrary (void);
/*
* INTERFACES _________________________________________________________________
*
*/
typedef int (ADMINAPI *util_AdminErrorCodeTranslate_t)(afs_status_t errorCode, int langId, const char **errorTextP, afs_status_p st);
typedef int (ADMINAPI *kas_PrincipalGetBegin_t)(const void *cellHandle, const void *serverHandle, void **iterationIdP, afs_status_p st);
typedef int (ADMINAPI *kas_PrincipalGetNext_t)(const void *iterationId, kas_identity_p who, afs_status_p st);
typedef int (ADMINAPI *kas_PrincipalGetDone_t)(const void *iterationIdP, afs_status_p st);
typedef int (ADMINAPI *kas_PrincipalGet_t) (const void *cellHandle, const void *serverHandle, const kas_identity_p who, kas_principalEntry_p principal, afs_status_p st);
typedef int (ADMINAPI *afsclient_TokenGetExisting_t)(const char *cellName, void **tokenHandle, afs_status_p st);
typedef int (ADMINAPI *afsclient_TokenGetNew_t)(const char *cellName, const char *principal, const char *password, void **tokenHandle, afs_status_p st);
typedef int (ADMINAPI *afsclient_TokenClose_t)(const void *tokenHandle, afs_status_p st);
typedef int (ADMINAPI *afsclient_TokenQuery_t)(void *tokenHandle, unsigned long *expirationDateP, char *principal, char *identity, char *cellName, int *bHasKasTokenP, afs_status_p st);
typedef int (ADMINAPI *afsclient_CellOpen_t)(const char *cellName, const void *tokenHandle, void **cellHandleP, afs_status_p st);
typedef int (ADMINAPI *afsclient_CellClose_t)(const void *cellHandle, afs_status_p st);
typedef int (ADMINAPI *afsclient_LocalCellGet_t)(char *cellName, afs_status_p st);
extern util_AdminErrorCodeTranslate_t util_AdminErrorCodeTranslateP;
extern kas_PrincipalGetBegin_t kas_PrincipalGetBeginP;
extern kas_PrincipalGetNext_t kas_PrincipalGetNextP;
extern kas_PrincipalGetDone_t kas_PrincipalGetDoneP;
extern kas_PrincipalGet_t kas_PrincipalGetP;
extern afsclient_TokenGetExisting_t afsclient_TokenGetExistingP;
extern afsclient_TokenGetNew_t afsclient_TokenGetNewP;
extern afsclient_TokenClose_t afsclient_TokenCloseP;
extern afsclient_TokenQuery_t afsclient_TokenQueryP;
extern afsclient_CellOpen_t afsclient_CellOpenP;
extern afsclient_CellClose_t afsclient_CellCloseP;
extern afsclient_LocalCellGet_t afsclient_LocalCellGetP;
#define util_AdminErrorCodeTranslate (*util_AdminErrorCodeTranslateP)
#define kas_PrincipalGetBegin (*kas_PrincipalGetBeginP)
#define kas_PrincipalGetNext (*kas_PrincipalGetNextP)
#define kas_PrincipalGetDone (*kas_PrincipalGetDoneP)
#define kas_PrincipalGet (*kas_PrincipalGetP)
#define afsclient_TokenGetExisting (*afsclient_TokenGetExistingP)
#define afsclient_TokenGetNew (*afsclient_TokenGetNewP)
#define afsclient_TokenClose (*afsclient_TokenCloseP)
#define afsclient_TokenQuery (*afsclient_TokenQueryP)
#define afsclient_CellOpen (*afsclient_CellOpenP)
#define afsclient_CellClose (*afsclient_CellCloseP)
#define afsclient_LocalCellGet (*afsclient_LocalCellGetP)
#endif

View File

@ -0,0 +1,194 @@
extern "C" {
#include <afs/param.h>
#include <afs/stds.h>
}
#include <WINNT/afsapplib.h>
/*
* PROTOTYPES _________________________________________________________________
*
*/
void cdecl vErrorDialog (BOOL fFatal, DWORD dwStatus, LONG idError, LPTSTR pszFmt, va_list arg);
BOOL CALLBACK Error_DlgProc (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp);
void OnCreateErrorDialog (WPARAM wp, LPARAM lp);
/*
* ERROR DIALOGS ______________________________________________________________
*
*/
typedef struct
{
BOOL fFatal;
LPTSTR pszError;
DWORD dwError;
} ERRORPARAMS;
void cdecl ErrorDialog (DWORD dwStatus, LPTSTR pszError, LPTSTR pszFmt, ...)
{
va_list arg;
va_start (arg, pszFmt);
vErrorDialog (FALSE, dwStatus, (LONG)pszError, pszFmt, arg);
}
void cdecl ErrorDialog (DWORD dwStatus, int idsError, LPTSTR pszFmt, ...)
{
va_list arg;
va_start (arg, pszFmt);
vErrorDialog (FALSE, dwStatus, (LONG)idsError, pszFmt, arg);
}
void cdecl FatalErrorDialog (DWORD dwStatus, LPTSTR pszError, LPTSTR pszFmt, ...)
{
va_list arg;
va_start (arg, pszFmt);
vErrorDialog (TRUE, dwStatus, (LONG)pszError, pszFmt, arg);
}
void cdecl FatalErrorDialog (DWORD dwStatus, int idsError, LPTSTR pszFmt, ...)
{
va_list arg;
va_start (arg, pszFmt);
vErrorDialog (TRUE, dwStatus, (LONG)idsError, pszFmt, arg);
}
void cdecl vErrorDialog (BOOL fFatal, DWORD dwStatus, LONG idError, LPTSTR pszFmt, va_list arg)
{
ERRORPARAMS *lpep = New (ERRORPARAMS);
lpep->fFatal = fFatal;
lpep->pszError = vFormatString (idError, pszFmt, arg);
lpep->dwError = dwStatus;
if (!AfsAppLib_GetMainWindow())
{
OnCreateErrorDialog (0, (LPARAM)lpep);
}
else
{
PostMessage (AfsAppLib_GetMainWindow(), WM_CREATE_ERROR_DIALOG, 0, (LPARAM)lpep);
}
}
void ImmediateErrorDialog (DWORD dwStatus, int idsError, LPTSTR pszFmt, ...)
{
va_list arg;
va_start (arg, pszFmt);
ERRORPARAMS *lpep = New (ERRORPARAMS);
lpep->fFatal = FALSE;
lpep->pszError = vFormatString (idsError, pszFmt, arg);
lpep->dwError = dwStatus;
ModalDialogParam (IDD_APPLIB_ERROR, NULL, (DLGPROC)Error_DlgProc, (LPARAM)lpep);
FreeString (lpep->pszError);
Delete (lpep);
}
void ImmediateErrorDialog (DWORD dwStatus, LPTSTR pszError, LPTSTR pszFmt, ...)
{
va_list arg;
va_start (arg, pszFmt);
ERRORPARAMS *lpep = New (ERRORPARAMS);
lpep->fFatal = FALSE;
lpep->pszError = vFormatString (pszError, pszFmt, arg);
lpep->dwError = dwStatus;
ModalDialogParam (IDD_APPLIB_ERROR, NULL, (DLGPROC)Error_DlgProc, (LPARAM)lpep);
FreeString (lpep->pszError);
Delete (lpep);
}
void OnCreateErrorDialog (WPARAM wp, LPARAM lp)
{
ERRORPARAMS *lpep = (ERRORPARAMS*)lp;
ModalDialogParam (IDD_APPLIB_ERROR, NULL, (DLGPROC)Error_DlgProc, (LPARAM)lpep);
if (lpep->fFatal)
{
PostQuitMessage (0);
}
FreeString (lpep->pszError);
Delete (lpep);
}
BOOL CALLBACK Error_DlgProc (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp)
{
switch (msg)
{
case WM_INITDIALOG:
TCHAR szApplication[ cchNAME ];
AfsAppLib_GetAppName (szApplication);
if (szApplication[0] != TEXT('\0'))
{
TCHAR szTitle[ cchRESOURCE ];
GetWindowText (hDlg, szTitle, cchRESOURCE);
lstrcat (szTitle, TEXT(" - "));
lstrcat (szTitle, szApplication);
SetWindowText (hDlg, szTitle);
}
ERRORPARAMS *lpep;
if ((lpep = (ERRORPARAMS *)lp) == NULL)
{
TCHAR szError[ cchRESOURCE ];
AfsAppLib_TranslateError (szError, ERROR_NOT_ENOUGH_MEMORY);
SetDlgItemText (hDlg, IDC_ERROR_STATUS, szError);
}
else
{
SetDlgItemText (hDlg, IDC_ERROR_DESC, lpep->pszError);
if (lpep->dwError == 0)
{
RECT rDesc;
GetRectInParent (GetDlgItem (hDlg, IDC_ERROR_DESC), &rDesc);
RECT rStatus;
GetRectInParent (GetDlgItem (hDlg, IDC_ERROR_STATUS), &rStatus);
SetWindowPos (GetDlgItem (hDlg, IDC_ERROR_DESC), NULL,
0, 0, cxRECT(rDesc), rStatus.bottom -rDesc.top,
SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER);
ShowWindow (GetDlgItem (hDlg, IDC_ERROR_STATUS), SW_HIDE);
}
else
{
TCHAR szCode[ cchRESOURCE ];
GetDlgItemText (hDlg, IDC_ERROR_STATUS, szCode, cchRESOURCE);
LPTSTR pszStatus = FormatString (szCode, TEXT("%e"), lpep->dwError);
SetDlgItemText (hDlg, IDC_ERROR_STATUS, pszStatus);
FreeString (pszStatus);
}
}
break;
case WM_COMMAND:
switch (LOWORD(wp))
{
case IDOK:
case IDCANCEL:
EndDialog (hDlg, LOWORD(wp));
break;
}
break;
}
return FALSE;
}

View File

@ -0,0 +1,133 @@
extern "C" {
#include <afs/param.h>
#include <afs/stds.h>
}
#include <WINNT/afsapplib.h>
/*
* DEFINITIONS ______________________________________________________________
*
*/
typedef struct
{
BOOL fInUse;
int idd;
DWORD *adwContext;
int idhOverview;
} DIALOGHELP, *LPDIALOGHELP;
/*
* VARIABLES ________________________________________________________________
*
*/
static TCHAR g_szHelpfile[ MAX_PATH ] = TEXT("");
static DIALOGHELP *g_adh = NULL;
static size_t g_cdh = 0;
/*
* ROUTINES _________________________________________________________________
*
*/
void AfsAppLib_RegisterHelpFile (LPTSTR pszFilename)
{
if (pszFilename)
lstrcpy (g_szHelpfile, pszFilename);
else
g_szHelpfile[0] = TEXT('\0');
}
void AfsAppLib_RegisterHelp (int idd, DWORD *adwContext, int idhOverview)
{
for (size_t ih = 0; ih < g_cdh; ++ih)
{
if (!g_adh[ ih ].fInUse)
continue;
if (g_adh[ ih ].idd == idd)
{
g_adh[ ih ].adwContext = adwContext;
g_adh[ ih ].idhOverview = idhOverview;
return;
}
}
for (ih = 0; ih < g_cdh; ++ih)
{
if (!g_adh[ ih ].fInUse)
break;
}
if (ih == g_cdh)
{
(void)REALLOC (g_adh, g_cdh, 1+ih, 16);
}
if (ih < g_cdh)
{
g_adh[ ih ].fInUse = TRUE;
g_adh[ ih ].idd = idd;
g_adh[ ih ].adwContext = adwContext;
g_adh[ ih ].idhOverview = idhOverview;
}
}
BOOL AfsAppLib_HandleHelp (int idd, HWND hDlg, UINT msg, WPARAM wp, LPARAM lp)
{
BOOL rc = FALSE;
size_t ih;
switch (msg)
{
case WM_COMMAND:
switch (LOWORD(wp))
{
case IDHELP:
for (ih = 0; ih < g_cdh; ++ih)
{
if (idd == g_adh[ ih ].idd)
break;
}
if (ih < g_cdh)
{
if (g_szHelpfile)
WinHelp (hDlg, g_szHelpfile, HELP_CONTEXT, g_adh[ ih ].idhOverview);
rc = TRUE;
}
break;
}
break;
case WM_HELP:
LPHELPINFO lphi;
for (ih = 0; ih < g_cdh; ++ih)
{
if (idd == g_adh[ ih ].idd)
break;
}
if ( (ih == g_cdh) ||
((lphi = (LPHELPINFO)lp) == NULL) ||
(lphi->hItemHandle == NULL) ||
(lphi->hItemHandle == hDlg) )
{
PostMessage (hDlg, WM_COMMAND, (WPARAM)MAKELONG(IDHELP,BN_CLICKED), (LPARAM)GetDlgItem (hDlg, IDHELP));
}
else
{
if (g_szHelpfile)
WinHelp ((HWND)(lphi->hItemHandle), g_szHelpfile, HELP_WM_HELP, (DWORD)g_adh[ ih ].adwContext);
}
rc = TRUE;
break;
}
return rc;
}

View File

@ -0,0 +1,65 @@
#ifndef AL_MESSAGES_H
#define AL_MESSAGES_H
// WM_COVER_WINDOW is used by CoverWindow() and CoverClient() to ensure that
// the proper thread creates a cover window when requested (if any thread
// other than g.hMain's thread creates the window, it will be destroyed
// automatically when the thread terminates).
//
// When used to cover a window:
// LPCOVERPARAMS lpCoverParams = (LPCOVERPARAMS)lParam;
//
// When used to uncover a window:
// HWND hwndToUncover = (HWND)wParam;
//
#define WM_COVER_WINDOW (WM_USER + 0x200)
// WM_CREATE_ERROR_DIALOG is sent by ErrorDialog() to tell g.hMain to
// create a dialog; this way, the error dialog is always created by
// the main thread.
//
// LPERROR_PARAMS = (LPERROR_PARAMS)lParam;
//
#define WM_CREATE_ERROR_DIALOG (WM_USER + 0x201)
// WM_ENDTASK is posted to a window after a task request is created
// (via StartTask()). A background routine handles one request at a time
// on an alternate thread, and posts its results to a specified window by
// means of an allocated structure. That structure should be freed using
// FreeTaskPacket() when this message is received.
//
// LPTASKPACKET ptp = (LPTASKPACKET)lParam;
//
#define WM_ENDTASK (WM_USER + 0x202)
// WM_EXPIRED_CREDENTIALS is sent to the main window when a background
// thread detects that the user's credentials have expired.
//
// BOOL fExpired = (BOOL)wParam;
//
#define WM_EXPIRED_CREDENTIALS (WM_USER + 0x203)
// WM_CLOSE_DIALOG is sent to a modal dialog when the CloseDialog() routine
// is called.
//
// HWND hWnd = (HWND)wParam;
// int rc = (int)lParam;
//
#define WM_CLOSE_DIALOG (WM_USER + 0x204)
// WM_PERMTAB_REFRESH is sent to a Permissions tab to cause its contents
// to be completely recalculated and redrawn. Any changes the user has
// made so far are discarded.
//
#define WM_PERMTAB_REFRESH (WM_USER + 0x205)
// WM_REFRESHED_CREDENTIALS is sent to the main window whenever the
// AfsAppLib_SetCredentials to obtain new credentials.
//
// LPARAM lp = (LPARAM)hCreds
//
#define WM_REFRESHED_CREDENTIALS (WM_USER + 0x206)
#endif

View File

@ -0,0 +1,548 @@
extern "C" {
#include <afs/param.h>
#include <afs/stds.h>
}
#include <WINNT/afsapplib.h>
#include "al_dynlink.h"
#include <WINNT/TaAfsAdmSvrClient.h>
/*
* DEFINITIONS ________________________________________________________________
*
*/
#define GWD_ANIMATIONFRAME TEXT("afsapplib/al_misc.cpp - next animation frame")
/*
* PROTOTYPES _________________________________________________________________
*
*/
BOOL CALLBACK AfsAppLib_TranslateErrorFunc (LPTSTR pszText, ULONG code, LANGID idLanguage);
/*
* STARTUP ____________________________________________________________________
*
*/
static HINSTANCE g_hInst = NULL;
static HINSTANCE g_hInstApp = NULL;
HINSTANCE AfsAppLib_GetInstance (void)
{
return g_hInst;
}
EXPORTED HINSTANCE AfsAppLib_GetAppInstance (void)
{
if (!g_hInstApp)
g_hInstApp = GetModuleHandle(NULL);
return g_hInstApp;
}
EXPORTED void AfsAppLib_SetAppInstance (HINSTANCE hInst)
{
g_hInstApp = hInst;
}
extern "C" BOOLEAN _stdcall DllEntryPoint (HANDLE hInst, DWORD dwReason, PVOID pReserved)
{
switch (dwReason)
{
case DLL_PROCESS_ATTACH:
if (!g_hInst)
{
g_hInst = (HINSTANCE)hInst;
TaLocale_LoadCorrespondingModule (g_hInst);
SetErrorTranslationFunction ((LPERRORPROC)AfsAppLib_TranslateErrorFunc);
InitCommonControls();
RegisterSpinnerClass();
RegisterElapsedClass();
RegisterTimeClass();
RegisterDateClass();
RegisterSockAddrClass();
RegisterCheckListClass();
RegisterFastListClass();
}
break;
}
return TRUE;
}
/*
* IMAGE LISTS ________________________________________________________________
*
*/
HIMAGELIST AfsAppLib_CreateImageList (BOOL fLarge)
{
HIMAGELIST hil;
hil = ImageList_Create ((fLarge)?32:16, (fLarge)?32:16, TRUE, 4, 0);
AfsAppLib_AddToImageList (hil, IDI_SERVER, fLarge);
AfsAppLib_AddToImageList (hil, IDI_SERVER_ALERT, fLarge);
AfsAppLib_AddToImageList (hil, IDI_SERVER_UNMON, fLarge);
AfsAppLib_AddToImageList (hil, IDI_SERVICE, fLarge);
AfsAppLib_AddToImageList (hil, IDI_SERVICE_ALERT, fLarge);
AfsAppLib_AddToImageList (hil, IDI_SERVICE_STOPPED, fLarge);
AfsAppLib_AddToImageList (hil, IDI_AGGREGATE, fLarge);
AfsAppLib_AddToImageList (hil, IDI_AGGREGATE_ALERT, fLarge);
AfsAppLib_AddToImageList (hil, IDI_FILESET, fLarge);
AfsAppLib_AddToImageList (hil, IDI_FILESET_ALERT, fLarge);
AfsAppLib_AddToImageList (hil, IDI_FILESET_LOCKED, fLarge);
AfsAppLib_AddToImageList (hil, IDI_BOSSERVICE, fLarge);
AfsAppLib_AddToImageList (hil, IDI_CELL, fLarge);
AfsAppLib_AddToImageList (hil, IDI_SERVER_KEY, fLarge);
AfsAppLib_AddToImageList (hil, IDI_USER, fLarge);
AfsAppLib_AddToImageList (hil, IDI_GROUP, fLarge);
return hil;
}
void AfsAppLib_AddToImageList (HIMAGELIST hil, int idi, BOOL fLarge)
{
HICON hi = TaLocale_LoadIcon (idi);
ImageList_AddIcon (hil, hi);
}
/*
* ANIMATION __________________________________________________________________
*
*/
void AfsAppLib_AnimateIcon (HWND hIcon, int *piFrameLast)
{
static HICON hiStop;
static HICON hiFrame[8];
static BOOL fLoaded = FALSE;
if (!fLoaded)
{
hiStop = TaLocale_LoadIcon (IDI_SPINSTOP);
hiFrame[0] = TaLocale_LoadIcon (IDI_SPIN1);
hiFrame[1] = TaLocale_LoadIcon (IDI_SPIN2);
hiFrame[2] = TaLocale_LoadIcon (IDI_SPIN3);
hiFrame[3] = TaLocale_LoadIcon (IDI_SPIN4);
hiFrame[4] = TaLocale_LoadIcon (IDI_SPIN5);
hiFrame[5] = TaLocale_LoadIcon (IDI_SPIN6);
hiFrame[6] = TaLocale_LoadIcon (IDI_SPIN7);
hiFrame[7] = TaLocale_LoadIcon (IDI_SPIN8);
fLoaded = TRUE;
}
if (piFrameLast)
{
*piFrameLast = (*piFrameLast == 7) ? 0 : (1+*piFrameLast);
}
SendMessage (hIcon, STM_SETICON, (WPARAM)((piFrameLast) ? hiFrame[ *piFrameLast ] : hiStop), 0);
}
BOOL CALLBACK AnimationHook (HWND hIcon, UINT msg, WPARAM wp, LPARAM lp)
{
PVOID oldProc = Subclass_FindNextHook (hIcon, AnimationHook);
switch (msg)
{
case WM_TIMER:
int iFrame;
iFrame = GetWindowData (hIcon, GWD_ANIMATIONFRAME);
AfsAppLib_AnimateIcon (hIcon, &iFrame);
SetWindowData (hIcon, GWD_ANIMATIONFRAME, iFrame);
break;
case WM_DESTROY:
Subclass_RemoveHook (hIcon, AnimationHook);
break;
}
if (oldProc)
return CallWindowProc ((WNDPROC)oldProc, hIcon, msg, wp, lp);
else
return DefWindowProc (hIcon, msg, wp, lp);
}
void AfsAppLib_StartAnimation (HWND hIcon, int fps)
{
Subclass_AddHook (hIcon, AnimationHook);
SetTimer (hIcon, 0, 1000/((fps) ? fps : 8), NULL);
AfsAppLib_AnimateIcon (hIcon);
}
void AfsAppLib_StopAnimation (HWND hIcon)
{
KillTimer (hIcon, 0);
AfsAppLib_AnimateIcon (hIcon);
Subclass_RemoveHook (hIcon, AnimationHook);
}
/*
* ERROR TRANSLATION __________________________________________________________
*
*/
BOOL CALLBACK AfsAppLib_TranslateErrorFunc (LPTSTR pszText, ULONG code, LANGID idLanguage)
{
DWORD idClient;
if ((idClient = AfsAppLib_GetAdminServerClientID()) != 0)
{
ULONG status;
return asc_ErrorCodeTranslate (idClient, code, idLanguage, pszText, &status);
}
else if (OpenUtilLibrary())
{
const char *pszTextA = NULL;
afs_status_t status;
if (util_AdminErrorCodeTranslate (code, idLanguage, &pszTextA, &status) && (pszTextA))
{
CopyAnsiToString (pszText, pszTextA);
return TRUE;
}
CloseUtilLibrary();
}
return FALSE;
}
BOOL AfsAppLib_TranslateError (LPTSTR pszText, ULONG status, LANGID idLanguage)
{
LANGID idLangOld = TaLocale_GetLanguage();
TaLocale_SetLanguage (idLanguage);
BOOL rc = FormatError (pszText, TEXT("%s"), status);
TaLocale_SetLanguage (idLangOld);
return rc;
}
/*
* CELL LIST __________________________________________________________________
*
*/
#define cREALLOC_CELLLIST 4
LPCELLLIST AfsAppLib_GetCellList (HKEY hkBase, LPTSTR pszRegPath)
{
LPCELLLIST lpcl = New (CELLLIST);
memset (lpcl, 0x00, sizeof(CELLLIST));
if (hkBase && pszRegPath)
{
lpcl->hkBase = hkBase;
lstrcpy (lpcl->szRegPath, pszRegPath);
HKEY hk;
if (RegOpenKey (hkBase, pszRegPath, &hk) == 0)
{
TCHAR szCell[ cchNAME ];
for (size_t ii = 0; RegEnumKey (hk, ii, szCell, cchNAME) == 0; ++ii)
{
if (REALLOC (lpcl->aCells, lpcl->nCells, 1+ii, cREALLOC_CELLLIST))
{
lpcl->aCells[ ii ] = CloneString (szCell);
}
}
RegCloseKey (hk);
}
}
else // Get cell list from AFS
{
// TODO
}
TCHAR szDefCell[ cchNAME ];
if (AfsAppLib_GetLocalCell (szDefCell))
{
for (size_t iclDef = 0; iclDef < lpcl->nCells; ++iclDef)
{
if (lpcl->aCells[ iclDef ] == NULL)
continue;
if (!lstrcmpi (lpcl->aCells[ iclDef ], szDefCell))
break;
}
if (iclDef == lpcl->nCells) // default cell not currently in list?
{
for (iclDef = 0; iclDef < lpcl->nCells; ++iclDef)
{
if (lpcl->aCells[ iclDef ] == NULL)
break;
}
if (REALLOC (lpcl->aCells, lpcl->nCells, 1+iclDef, cREALLOC_CELLLIST))
{
lpcl->aCells[iclDef] = CloneString (szDefCell);
}
}
if ((iclDef > 0) && (iclDef < lpcl->nCells) && (lpcl->aCells[ iclDef ]))
{
LPTSTR pszZero = lpcl->aCells[0];
lpcl->aCells[0] = lpcl->aCells[iclDef];
lpcl->aCells[iclDef] = pszZero;
}
}
for ( ; (lpcl->nCells != 0); (lpcl->nCells)--)
{
if (lpcl->aCells[ lpcl->nCells-1 ] != NULL)
break;
}
return lpcl;
}
LPCELLLIST AfsAppLib_GetCellList (LPCELLLIST lpclCopy)
{
LPCELLLIST lpcl = New (CELLLIST);
memset (lpcl, 0x00, sizeof(CELLLIST));
if (lpclCopy)
{
if (REALLOC (lpcl->aCells, lpcl->nCells, lpclCopy->nCells, cREALLOC_CELLLIST))
{
for (size_t icl = 0; icl < lpcl->nCells; ++icl)
{
if (lpclCopy->aCells[ icl ])
{
lpcl->aCells[ icl ] = CloneString (lpclCopy->aCells[ icl ]);
}
}
}
}
return lpcl;
}
void AfsAppLib_AddToCellList (LPCELLLIST lpcl, LPTSTR pszCell)
{
if (lpcl && lpcl->hkBase && lpcl->szRegPath[0])
{
TCHAR szPath[ MAX_PATH ];
wsprintf (szPath, TEXT("%s\\%s"), lpcl->szRegPath, pszCell);
HKEY hk;
if (RegCreateKey (lpcl->hkBase, szPath, &hk) == 0)
{
RegCloseKey (hk);
}
}
}
void AfsAppLib_FreeCellList (LPCELLLIST lpcl)
{
if (lpcl)
{
if (lpcl->aCells)
{
for (size_t icl = 0; icl < lpcl->nCells; ++icl)
{
if (lpcl->aCells[icl] != NULL)
FreeString (lpcl->aCells[icl]);
}
Free (lpcl->aCells);
}
Delete (lpcl);
}
}
/*
* TRULY MISCELLANEOUS ________________________________________________________
*
*/
BOOL AfsAppLib_IsTimeInFuture (LPSYSTEMTIME pstTest)
{
SYSTEMTIME stNow;
GetSystemTime (&stNow);
FILETIME ftNowGMT;
SystemTimeToFileTime (&stNow, &ftNowGMT);
FILETIME ftTest;
SystemTimeToFileTime (pstTest, &ftTest);
if (CompareFileTime (&ftTest, &ftNowGMT) >= 0)
return TRUE;
return FALSE;
}
void AfsAppLib_UnixTimeToSystemTime (LPSYSTEMTIME pst, ULONG ut, BOOL fElapsed)
{
// A Unix time is the number of seconds since 1/1/1970.
// The first step in this conversion is to change that count-of-seconds
// into a count-of-100ns-intervals...
//
LARGE_INTEGER ldw;
ldw.QuadPart = (LONGLONG)10000000 * (LONGLONG)ut;
// Then adjust the count to be a count-of-100ns-intervals since
// 1/1/1601, instead of 1/1/1970. That means adding a *big* number...
//
ldw.QuadPart += (LONGLONG)0x019db1ded53e8000;
// Now the count is effectively a FILETIME, which we can convert
// to a SYSTEMTIME with a Win32 API.
//
FILETIME ft;
ft.dwHighDateTime = (DWORD)ldw.HighPart;
ft.dwLowDateTime = (DWORD)ldw.LowPart;
FileTimeToSystemTime (&ft, pst);
if (fElapsed)
{
pst->wYear -= 1970;
pst->wMonth -= 1;
pst->wDayOfWeek -= 1;
pst->wDay -= 1;
}
}
void AfsAppLib_SplitCredentials (LPTSTR pszCreds, LPTSTR pszCell, LPTSTR pszID)
{
LPTSTR pszSlash = (LPTSTR)lstrrchr (pszCreds, TEXT('/'));
if (pszSlash == NULL)
{
if (pszCell)
AfsAppLib_GetLocalCell (pszCell);
if (pszID)
lstrcpy (pszID, pszCreds);
}
else // a cell was specified
{
if (pszCell)
lstrzcpy (pszCell, pszCreds, pszSlash -pszCreds);
if (pszID)
lstrcpy (pszID, 1+pszSlash);
}
}
BOOL AfsAppLib_GetLocalCell (LPTSTR pszCell, ULONG *pStatus)
{
static TCHAR szCell[ cchRESOURCE ] = TEXT("");
BOOL rc = TRUE;
ULONG status = 0;
if (szCell[0] == TEXT('\0'))
{
DWORD idClient;
if ((idClient = AfsAppLib_GetAdminServerClientID()) != 0)
{
rc = asc_LocalCellGet (idClient, szCell, &status);
}
else if (OpenClientLibrary())
{
char szCellNameA[ MAX_PATH ];
if ((rc = afsclient_LocalCellGet (szCellNameA, (afs_status_p)&status)) == TRUE)
{
CopyAnsiToString (szCell, szCellNameA);
}
CloseClientLibrary();
}
}
if (rc)
lstrcpy (pszCell, szCell);
else if (pStatus)
*pStatus = status;
return rc;
}
BOOL AfsAppLib_ReallocFunction (LPVOID *ppTarget, size_t cbElement, size_t *pcTarget, size_t cReq, size_t cInc)
{
LPVOID pNew;
size_t cNew;
if (cReq <= *pcTarget)
return TRUE;
if ((cNew = cInc * ((cReq + cInc-1) / cInc)) <= 0)
return FALSE;
if ((pNew = (LPVOID)Allocate (cbElement * cNew)) == NULL)
return FALSE;
memset (pNew, 0x00, cbElement * cNew);
if (*pcTarget != 0)
{
memcpy (pNew, *ppTarget, cbElement * (*pcTarget));
Free (*ppTarget);
}
*ppTarget = pNew;
*pcTarget = cNew;
return TRUE;
}
HFONT AfsAppLib_CreateFont (int idsFont)
{
TCHAR szFont[ cchRESOURCE ];
GetString (szFont, idsFont);
HFONT hf = (HFONT)GetStockObject (DEFAULT_GUI_FONT);
LOGFONT lf;
GetObject (hf, sizeof(lf), &lf);
lf.lfWeight = FW_NORMAL;
LPTSTR pszSection = szFont;
LPTSTR pszNextSection;
if ((pszNextSection = (LPTSTR)lstrchr (pszSection, TEXT(','))) != NULL)
*pszNextSection++ = TEXT('\0');
if (!pszSection || !*pszSection)
return NULL;
lstrcpy (lf.lfFaceName, pszSection);
pszSection = pszNextSection;
if ((pszNextSection = (LPTSTR)lstrchr (pszSection, TEXT(','))) != NULL)
*pszNextSection++ = TEXT('\0');
if (!pszSection || !*pszSection)
return NULL;
HDC hdc = GetDC (NULL);
lf.lfHeight = -MulDiv (_ttol(pszSection), GetDeviceCaps (hdc, LOGPIXELSY), 72);
ReleaseDC (NULL, hdc);
pszSection = pszNextSection;
if ((pszNextSection = (LPTSTR)lstrchr (pszSection, TEXT(','))) != NULL)
*pszNextSection++ = TEXT('\0');
if (pszSection && *pszSection)
{
if (lstrchr (pszSection, TEXT('b')) || lstrchr (pszSection, TEXT('B')))
lf.lfWeight = FW_BOLD;
if (lstrchr (pszSection, TEXT('i')) || lstrchr (pszSection, TEXT('I')))
lf.lfItalic = TRUE;
if (lstrchr (pszSection, TEXT('u')) || lstrchr (pszSection, TEXT('U')))
lf.lfUnderline = TRUE;
}
return CreateFontIndirect(&lf);
}

View File

@ -0,0 +1,325 @@
extern "C" {
#include <afs/param.h>
#include <afs/stds.h>
}
#include <WINNT/al_progress.h>
#include <commctrl.h>
/*
* DEFINITIONS ________________________________________________________________
*
*/
#define WM_UPDATE_PROGRESS WM_TIMER
/*
* PROTOTYPES _________________________________________________________________
*
*/
/*
* ROUTINES ___________________________________________________________________
*
*/
PROGRESSDISPLAY::PROGRESSDISPLAY (HWND hWnd)
{
Init (hWnd);
}
PROGRESSDISPLAY::PROGRESSDISPLAY (HWND hParent, int iddTemplate, DLGPROC dlgproc)
{
if (dlgproc == 0)
dlgproc = (DLGPROC)PROGRESSDISPLAY::ProgressDisplay_StubProc;
HWND hWnd = ModelessDialogParam (iddTemplate, hParent, dlgproc, (LPARAM)this);
Init (hWnd);
m_fCreatedWindow = TRUE;
}
PROGRESSDISPLAY::~PROGRESSDISPLAY (void)
{
m_fFinished = TRUE;
SetWindowLong (m_hWnd, DWL_USER, (LONG)0);
DeleteCriticalSection (&m_cs);
if (m_fCreatedWindow)
DestroyWindow (m_hWnd);
}
void PROGRESSDISPLAY::Init (HWND hWnd)
{
SetWindowLong (hWnd, DWL_USER, (LONG)this);
Subclass_AddHook (hWnd, PROGRESSDISPLAY::ProgressDisplay_HookProc);
m_msgFinish = 0;
m_fFinished = FALSE;
m_dwStatus = 0;
InitializeCriticalSection (&m_cs);
m_hWnd = hWnd;
m_fCreatedWindow = FALSE;
m_pfnUser = NULL;
m_lpUser = 0;
m_iProgress = 0;
m_cRef = 1;
GetDlgItemText (m_hWnd, IDC_OPERATION, m_szOperation, cchRESOURCE);
GetDlgItemText (m_hWnd, IDC_PROGRESSTEXT, m_szProgressText, cchRESOURCE);
SendDlgItemMessage (m_hWnd, IDC_PROGRESS, PBM_SETRANGE, 0, MAKELPARAM(0,100));
SetProgressRange (0, 100);
SetProgress (0);
}
HWND PROGRESSDISPLAY::GetWindow (void)
{
return m_hWnd;
}
void PROGRESSDISPLAY::GetProgressRange (int *piStart, int *piFinish)
{
EnterCriticalSection (&m_cs);
if (piStart)
*piStart = m_iProgressStart;
if (piFinish)
*piFinish = m_iProgressFinish;
LeaveCriticalSection (&m_cs);
}
void PROGRESSDISPLAY::SetProgressRange (int iStart, int iFinish)
{
EnterCriticalSection (&m_cs);
m_iProgressStart = iStart;
m_iProgressFinish = iFinish;
PostMessage (m_hWnd, WM_UPDATE_PROGRESS, 0, 0);
LeaveCriticalSection (&m_cs);
}
int PROGRESSDISPLAY::GetProgress (void)
{
EnterCriticalSection (&m_cs);
int iProgress = m_iProgress;
LeaveCriticalSection (&m_cs);
return iProgress;
}
void PROGRESSDISPLAY::SetProgress (int iProgress)
{
EnterCriticalSection (&m_cs);
m_iProgress = max( m_iProgress, iProgress );
m_iProgress = min( max( m_iProgress, m_iProgressStart ), m_iProgressFinish );
PostMessage (m_hWnd, WM_UPDATE_PROGRESS, 0, 0);
LeaveCriticalSection (&m_cs);
}
void PROGRESSDISPLAY::GetOperation (LPTSTR pszOperation)
{
EnterCriticalSection (&m_cs);
lstrcpy (pszOperation, m_szOperation);
LeaveCriticalSection (&m_cs);
}
void PROGRESSDISPLAY::SetOperation (LPCTSTR pszOperation)
{
EnterCriticalSection (&m_cs);
lstrcpy (m_szOperation, pszOperation);
PostMessage (m_hWnd, WM_UPDATE_PROGRESS, 0, 0);
LeaveCriticalSection (&m_cs);
}
LPPROGRESSDISPLAY PROGRESSDISPLAY::GetProgressDisplay (HWND hWnd)
{
LPPROGRESSDISPLAY ppd = NULL;
try {
if ((ppd = (LPPROGRESSDISPLAY)(GetWindowLong (hWnd, DWL_USER))) != NULL) {
if (ppd->m_hWnd != hWnd)
ppd = NULL;
}
} catch(...) {
ppd = NULL;
}
return ppd;
}
BOOL CALLBACK PROGRESSDISPLAY::ProgressDisplay_StubProc (HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
{
return FALSE;
}
BOOL CALLBACK PROGRESSDISPLAY::ProgressDisplay_HookProc (HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
{
PVOID oldproc = Subclass_FindNextHook (hWnd, PROGRESSDISPLAY::ProgressDisplay_HookProc);
switch (msg)
{
case WM_UPDATE_PROGRESS:
if (!wp && !lp)
{
LPPROGRESSDISPLAY ppd;
if ((ppd = PROGRESSDISPLAY::GetProgressDisplay (hWnd)) != NULL)
ppd->OnUpdate();
return TRUE;
}
break;
case WM_DESTROY:
Subclass_RemoveHook (hWnd, PROGRESSDISPLAY::ProgressDisplay_HookProc);
break;
}
if (oldproc)
return CallWindowProc ((WNDPROC)oldproc, hWnd, msg, wp, lp);
else
return DefWindowProc (hWnd, msg, wp, lp);
}
void PROGRESSDISPLAY::SetFinishMessage (int msgFinish)
{
m_msgFinish = msgFinish;
}
void PROGRESSDISPLAY::Show (DWORD (CALLBACK *pfn)(LPPROGRESSDISPLAY ppd, LPARAM lp), LPARAM lp)
{
m_pfnUser = pfn;
m_lpUser = lp;
InterlockedIncrement (&m_cRef);
ShowWindow (m_hWnd, SW_SHOW);
DWORD dwThreadID;
HANDLE hThread = CreateThread (NULL, 0, (LPTHREAD_START_ROUTINE)(PROGRESSDISPLAY::ThreadProc), this, 0, &dwThreadID);
if (m_msgFinish == 0)
{
MSG msg;
while (GetMessage (&msg, 0, 0, NULL))
{
if (!IsDialogMessage (m_hWnd, &msg))
{
TranslateMessage (&msg);
DispatchMessage (&msg);
}
EnterCriticalSection (&m_cs);
BOOL fBreak = m_fFinished;
LeaveCriticalSection (&m_cs);
if (fBreak)
break;
}
}
}
void PROGRESSDISPLAY::Finish (DWORD dwStatus)
{
EnterCriticalSection (&m_cs);
m_fFinished = TRUE;
m_dwStatus = dwStatus;
if (m_msgFinish)
PostMessage (m_hWnd, m_msgFinish, 0, 0);
else
PostMessage (m_hWnd, WM_UPDATE_PROGRESS, 0, 0);
LeaveCriticalSection (&m_cs);
if (InterlockedDecrement (&m_cRef) == 0)
Delete (this);
}
DWORD PROGRESSDISPLAY::GetStatus (void)
{
EnterCriticalSection (&m_cs);
DWORD dwStatus = (m_fFinished) ? m_dwStatus : ERROR_BUSY;
LeaveCriticalSection (&m_cs);
return dwStatus;
}
void PROGRESSDISPLAY::Close (void)
{
EnterCriticalSection (&m_cs);
if (m_fCreatedWindow)
{
DestroyWindow (m_hWnd);
m_hWnd = NULL;
}
LeaveCriticalSection (&m_cs);
if (InterlockedDecrement (&m_cRef) == 0)
Delete (this);
}
void PROGRESSDISPLAY::OnUpdate (void)
{
EnterCriticalSection (&m_cs);
int perComplete;
if (m_iProgressFinish <= m_iProgressStart)
perComplete = 100;
else
perComplete = 100 * (m_iProgress - m_iProgressStart) / (m_iProgressFinish - m_iProgressStart);
SendDlgItemMessage (m_hWnd, IDC_PROGRESS, PBM_SETPOS, (WPARAM)perComplete, 0);
LPTSTR pszProgressText = FormatString (m_szProgressText, TEXT("%lu"), perComplete);
SetDlgItemText (m_hWnd, IDC_PROGRESSTEXT, pszProgressText);
FreeString (pszProgressText);
SetDlgItemText (m_hWnd, IDC_OPERATION, m_szOperation);
LeaveCriticalSection (&m_cs);
}
DWORD WINAPI PROGRESSDISPLAY::ThreadProc (PVOID lp)
{
LPPROGRESSDISPLAY ppd;
if ((ppd = (LPPROGRESSDISPLAY)lp) != NULL) {
DWORD dwStatus;
try {
dwStatus = (*(ppd->m_pfnUser))(ppd, ppd->m_lpUser);
} catch(...) {
dwStatus = ERROR_PROCESS_ABORTED;
}
ppd->Finish (dwStatus);
}
return 0;
}

View File

@ -0,0 +1,133 @@
#ifndef AL_PROGRESS_H
#define AL_PROGRESS_H
#ifndef EXPORTED
#define EXPORTED
#endif
/*
* PROGRESS DIALOGS ___________________________________________________________
*
* The PROGRESSDISPLAY object is probably one of the most esoteric
* utilities in this library. It provides a convenient way to package
* up a background thread, and associate it with a dialog telling the user
* what's going on. It sounds a little hokey, and honestly isn't that
* terribly useful, but you may find you need it at some point.
*
* Example:
*
* // Copy the files onto the user's machine.
* //
* extern LPTSTR g_apszFilename[];
*
* LPPROGRESSDISPLAY pProg;
* pProg = new PROGRESSDISPLAY (hParent, IDD_COPYING_PROGRESS);
* pProg->SetProgressRange (0, nFILES(g_apszFilename));
* pProg->Show (fnCopyFiles, (LPARAM)g_apszFilename);
*
* // By default, Show() is modal--it pumps messages until the
* // background thread completes. If you have specified a
* // finish message ("pProg->SetFinishMessage (WM_USER+15)"),
* // then Show() is modeless, returning immediately. The WM_USER+15
* // message will be posted to the progress dialog when the background
* // thread completes (you can specify a dlgproc for your progress
* // dialog on the "new PROGRESSDISPLAY" line).
*
* DWORD CALLBACK fnCopyFiles (LPPROGRESSDISPLAY pProg, LPARAM lp)
* {
* LPTSTR *apszFilename = (LPTSTR*)lp;
*
* for (ii = 0; ii < nFILES(apszFilename); ++ii) {
* pProg->SetOperation ("Copying "+apszFilename[ii]);
* CopyFile (apszFilename[ii])
* pProg->SetProgress (ii);
* }
*
* pProg->Close();
* return 0;
* }
*
*/
#include <WINNT/TaLocale.h>
#include <WINNT/subclass.h>
/*
* DEFINITIONS ________________________________________________________________
*
*/
#ifndef THIS_HINST
#define THIS_HINST (HINSTANCE)GetModuleHandle(NULL)
#endif
#define IDC_OPERATION 900
#define IDC_PROGRESS 901
#define IDC_PROGRESSTEXT 902
typedef class EXPORTED PROGRESSDISPLAY PROGRESSDISPLAY, *LPPROGRESSDISPLAY;
/*
* PROGRESSDISPLAY CLASS ______________________________________________________
*
*/
class PROGRESSDISPLAY
{
public:
PROGRESSDISPLAY (HWND hWnd);
PROGRESSDISPLAY (HWND hParent, int iddTemplate, DLGPROC dlgproc = 0);
static LPPROGRESSDISPLAY GetProgressDisplay (HWND hWnd);
void GetProgressRange (int *piStart, int *piFinish);
void SetProgressRange (int iStart, int iFinish);
int GetProgress (void);
void SetProgress (int iProgress);
void GetOperation (LPTSTR pszOperation);
void SetOperation (LPCTSTR pszOperation);
HWND GetWindow (void);
void SetFinishMessage (int msgFinish);
void Show (DWORD (CALLBACK *pfn)(LPPROGRESSDISPLAY ppd, LPARAM lp), LPARAM lp);
void Close (void);
DWORD GetStatus (void);
private:
~PROGRESSDISPLAY (void);
void Init (HWND hWnd);
void Finish (DWORD dwStatus = 0);
void PROGRESSDISPLAY::OnUpdate (void);
static BOOL CALLBACK ProgressDisplay_StubProc (HWND hWnd, UINT msg, WPARAM wp, LPARAM lp);
static BOOL CALLBACK ProgressDisplay_HookProc (HWND hWnd, UINT msg, WPARAM wp, LPARAM lp);
static DWORD WINAPI PROGRESSDISPLAY::ThreadProc (PVOID lp);
BOOL m_fFinished;
LONG m_dwStatus;
LONG m_cRef;
CRITICAL_SECTION m_cs;
HWND m_hWnd;
BOOL m_fCreatedWindow;
int m_msgFinish;
DWORD (CALLBACK *m_pfnUser)(LPPROGRESSDISPLAY ppd, LPARAM lp);
LPARAM m_lpUser;
int m_iProgressStart;
int m_iProgressFinish;
int m_iProgress;
TCHAR m_szOperation[ cchRESOURCE ];
TCHAR m_szProgressText[ cchRESOURCE ];
};
#endif

View File

@ -0,0 +1,338 @@
extern "C" {
#include <afs/param.h>
#include <afs/stds.h>
}
#include <WINNT/afsapplib.h>
/*
* DEFINITIONS ________________________________________________________________
*
*/
#define cREALLOC_MODELESS 16
#define cREALLOC_WINDOWDATA_FIELDS 4
#define cREALLOC_WINDOWDATA_WINDOWS 16
#define cREALLOC_WINDOWDATA_DATA 8
#define GWD_IS_MODELESS TEXT("afsapplib/al_pump.cpp - is window modeless?")
/*
* VARIABLES __________________________________________________________________
*
*/
// Modeless-dialog support
//
static HWND *aModeless = NULL;
static size_t cModeless = 0;
static LPCRITICAL_SECTION pcsPump = NULL;
static void (*g_fnPump)(MSG *lpm) = NULL;
// Window-data support
//
static struct
{
TCHAR szField[ cchNAME ];
} *aFields = NULL;
static size_t cFields = 0;
static struct
{
HWND hWnd;
DWORD *adwData;
size_t cdwData;
} *aWindows = NULL;
static size_t cWindows = 0;
static LPCRITICAL_SECTION pcsData = NULL;
/*
* DIALOG ROUTINES ____________________________________________________________
*
*/
BOOL CALLBACK Modeless_HookProc (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp)
{
PVOID oldProc = Subclass_FindNextHook (hDlg, Modeless_HookProc);
if (msg == WM_DESTROY)
{
EnterCriticalSection (pcsPump);
for (size_t ii = 0; ii < cModeless; ++ii)
{
if (aModeless[ ii ] == hDlg)
aModeless[ ii ] = 0;
}
LeaveCriticalSection (pcsPump);
Subclass_RemoveHook (hDlg, Modeless_HookProc);
}
if (oldProc)
return CallWindowProc ((WNDPROC)oldProc, hDlg, msg, wp, lp);
else
return DefWindowProc (hDlg, msg, wp, lp);
}
BOOL AfsAppLib_IsModelessDialogMessage (MSG *lpm)
{
BOOL rc = FALSE;
if (pcsPump)
{
EnterCriticalSection (pcsPump);
for (size_t ii = 0; (!rc) && (ii < cModeless); ++ii)
{
if (aModeless[ ii ] != 0)
{
if (IsPropSheet (aModeless[ ii ]))
{
if (!PropSheet_GetCurrentPageHwnd(aModeless[ ii ]))
DestroyWindow (aModeless[ ii ]);
if (PropSheet_IsDialogMessage(aModeless[ ii ], lpm))
rc = TRUE;
}
else
{
if (IsDialogMessage (aModeless[ ii ], lpm))
rc = TRUE;
}
}
}
LeaveCriticalSection (pcsPump);
}
return rc;
}
void AfsAppLib_RegisterModelessDialog (HWND hDlg)
{
if (pcsPump == NULL)
{
pcsPump = New (CRITICAL_SECTION);
InitializeCriticalSection (pcsPump);
}
EnterCriticalSection (pcsPump);
for (size_t ii = 0; ii < cModeless; ++ii)
{
if (aModeless[ ii ] == hDlg)
break;
}
if (ii == cModeless)
{
for (ii = 0; ii < cModeless; ++ii)
{
if (aModeless[ ii ] == 0)
break;
}
if (ii == cModeless)
{
(void)REALLOC (aModeless, cModeless, 1+ii, cREALLOC_MODELESS);
}
if (ii < cModeless)
{
aModeless[ ii ] = hDlg;
Subclass_AddHook (hDlg, Modeless_HookProc);
}
}
LeaveCriticalSection (pcsPump);
}
void AfsAppLib_SetPumpRoutine (void (*fnPump)(MSG *lpm))
{
g_fnPump = fnPump;
}
void AfsAppLib_MainPump (void)
{
MSG msg;
while (GetMessage (&msg, NULL, 0, 0))
{
if (AfsAppLib_IsModelessDialogMessage (&msg))
continue;
if (g_fnPump)
(*g_fnPump)(&msg);
else
{
TranslateMessage (&msg);
DispatchMessage (&msg);
}
}
}
/*
* WINDOW-DATA ________________________________________________________________
*
*/
BOOL CALLBACK WindowData_HookProc (HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
{
PVOID oldProc = Subclass_FindNextHook (hWnd, WindowData_HookProc);
if (msg == WM_DESTROY)
{
EnterCriticalSection (pcsData);
for (size_t ii = 0; ii < cWindows; ++ii)
{
if (aWindows[ ii ].hWnd == hWnd)
{
if (aWindows[ ii ].adwData)
Free (aWindows[ ii ].adwData);
memset (&aWindows[ii], 0x00, sizeof(aWindows[ii]));
}
}
LeaveCriticalSection (pcsData);
Subclass_RemoveHook (hWnd, WindowData_HookProc);
}
if (oldProc)
return CallWindowProc ((WNDPROC)oldProc, hWnd, msg, wp, lp);
else
return DefWindowProc (hWnd, msg, wp, lp);
}
size_t GetWindowDataField (LPTSTR pszField)
{
size_t rc = (size_t)-1;
if (pcsData == NULL)
{
pcsData = New (CRITICAL_SECTION);
InitializeCriticalSection (pcsData);
}
EnterCriticalSection (pcsData);
for (size_t ii = 0; ii < cFields; ++ii)
{
if (!lstrcmpi (aFields[ ii ].szField, pszField))
break;
}
if (ii == cFields)
{
for (ii = 0; ii < cFields; ++ii)
{
if (aFields[ ii ].szField[0] == TEXT('\0'))
break;
}
if (ii == cFields)
{
(void)REALLOC (aFields, cFields, 1+ii, cREALLOC_WINDOWDATA_FIELDS);
}
if (ii < cFields)
{
lstrcpy (aFields[ ii ].szField, pszField);
}
}
if (ii < cFields)
{
rc = ii;
}
LeaveCriticalSection (pcsData);
return rc;
}
DWORD GetWindowData (HWND hWnd, LPTSTR pszField)
{
DWORD rc = 0;
if (pcsData == NULL)
{
pcsData = New (CRITICAL_SECTION);
InitializeCriticalSection (pcsData);
}
EnterCriticalSection (pcsData);
size_t iField;
if ((iField = GetWindowDataField (pszField)) != (size_t)-1)
{
for (size_t ii = 0; ii < cWindows; ++ii)
{
if (aWindows[ ii ].hWnd == hWnd)
{
if (iField < aWindows[ ii ].cdwData)
rc = aWindows[ ii ].adwData[ iField ];
break;
}
}
}
LeaveCriticalSection (pcsData);
return rc;
}
DWORD SetWindowData (HWND hWnd, LPTSTR pszField, DWORD dwNewData)
{
DWORD rc = 0;
if (pcsData == NULL)
{
pcsData = New (CRITICAL_SECTION);
InitializeCriticalSection (pcsData);
}
EnterCriticalSection (pcsData);
size_t iField;
if ((iField = GetWindowDataField (pszField)) != (size_t)-1)
{
for (size_t ii = 0; ii < cWindows; ++ii)
{
if (aWindows[ ii ].hWnd == hWnd)
{
if (iField < aWindows[ ii ].cdwData)
rc = aWindows[ ii ].adwData[ iField ];
break;
}
}
if (ii == cWindows)
{
for (ii = 0; ii < cWindows; ++ii)
{
if (aWindows[ ii ].hWnd == 0)
break;
}
if (ii == cWindows)
{
(void)REALLOC (aWindows, cWindows, 1+ii, cREALLOC_WINDOWDATA_WINDOWS);
}
}
if (ii < cWindows)
{
if (aWindows[ ii ].hWnd == 0)
{
aWindows[ ii ].hWnd = hWnd;
Subclass_AddHook (hWnd, WindowData_HookProc);
}
if ((dwNewData) && (iField >= aWindows[ ii ].cdwData))
{
(void)REALLOC (aWindows[ ii ].adwData, aWindows[ ii ].cdwData, 1+iField, cREALLOC_WINDOWDATA_DATA);
}
if (iField < aWindows[ ii ].cdwData)
{
aWindows[ ii ].adwData[ iField ] = dwNewData;
}
}
}
LeaveCriticalSection (pcsData);
return rc;
}

View File

@ -0,0 +1,103 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by afsapplib.rc
//
#define IDC_COVERDLG 0
#define IDS_BADCREDS_DESC_GENERAL 5001
#define IDS_BADCREDS_DESC_EXPIRED 5002
#define IDS_BADCREDS_DESC_BADCHOICE 5003
#define IDS_BADCREDS_DESC2 5004
#define IDS_BADCREDS_DESC3 5005
#define IDS_BADCREDS_DESC3_ADM 5006
#define IDS_BADCREDS_DESC_DESTROYED 5007
#define IDS_ERROR_BAD_CREDENTIALS 5008
#define IDS_BROWSE_WAITING 5009
#define IDS_BROWSE_BADCELL_TITLE 5010
#define IDS_BROWSE_BADCELL_DESC 5011
#define IDS_CREDS_NONE 5012
#define IDS_CREDS_VALID 5013
#define IDS_CREDS_EXPIRED 5014
#define IDC_OPENCELL_CELL 11000
#define IDC_ERROR_STATUS 11001
#define IDC_ERROR_DESC 11002
#define IDC_OPENCELL_ID 11004
#define IDC_OPENCELL_PASSWORD 11005
#define IDC_CREDS_CURRENTID 11006
#define IDC_CREDS_EXPDATE 11007
#define IDC_CREDS_LOGIN 11008
#define IDC_CREDS_ID 11009
#define IDC_CREDS_PASSWORD 11010
#define IDC_CREDS_CELL 11011
#define IDC_BADCREDS_DESC 11016
#define IDC_BADCREDS_SHUTUP 11017
#define IDC_BROWSE_NAMED 11019
#define IDC_BROWSE_LIST 11020
#define IDC_COVER_DESC 11021
#define IDC_COVER_BUTTON 11022
#define IDC_COVER_BORDER 11023
#define IDC_BROWSE_TYPE 11023
#define IDC_BROWSE_CELL 11024
#define IDC_BROWSE_STATUS 11025
#define IDC_BROWSE_SELECT 11026
#define IDC_BROWSE_RESTART 11027
#define IDC_BROWSE_NONE 11028
#define IDC_OPENCELL_OLDCREDS 11030
#define IDD_APPLIB_OPENCELL 15001
#define IDD_APPLIB_CREDENTIALS 15002
#define IDD_APPLIB_ERROR 15003
#define IDD_APPLIB_BADCREDS 15004
#define IDD_APPLIB_COVER 15005
#define IDD_APPLIB_BROWSE 15006
#define IDD_APPLIB_BROWSE_FILESET 15012
#define IDI_SPIN1 20001
#define IDI_SPIN2 20002
#define IDI_SPIN3 20003
#define IDI_SPIN4 20004
#define IDI_SPIN5 20005
#define IDI_SPIN6 20006
#define IDI_SPIN7 20007
#define IDI_SPIN8 20008
#define IDI_SPINSTOP 20009
#define IDI_BOSSERVICE 20010
#define IDB_LOCAL_USER 20011
#define IDB_LOCAL_GROUP 20012
#define IDB_FOREIGN_USER 20013
#define IDB_FOREIGN_GROUP 20014
#define IDI_SERVER 20015
#define IDI_SERVER_ALERT 20016
#define IDI_SERVER_UNMON 20017
#define IDI_SERVICE 20018
#define IDI_SERVICE_ALERT 20019
#define IDI_SERVICE_STOPPED 20020
#define IDI_AGGREGATE 20021
#define IDI_AGGREGATE_ALERT 20022
#define IDI_FILESET 20023
#define IDI_FILESET_ALERT 20024
#define IDI_FILESET_LOCKED 20025
#define IDB_UNAUTHENTICATED 20026
#define IDB_MASK_OBJ 20027
#define IDB_LOCAL_OTHER 20028
#define IDB_FOREIGN_OTHER 20029
#define IDB_ANY_OTHER 20030
#define IDI_MULTIPLE 20031
#define IDI_INITIAL_OBJECT 20032
#define IDI_INITIAL_CONTAINER 20033
#define IDI_ACL 20034
#define IDI_CELL 20035
#define IDI_SERVER_KEY 20036
#define IDI_USER 20037
#define IDI_GROUP 20038
#define IDC_STATIC -1
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NO_MFC 1
#define _APS_3D_CONTROLS 1
#define _APS_NEXT_RESOURCE_VALUE 20035
#define _APS_NEXT_COMMAND_VALUE 9000
#define _APS_NEXT_CONTROL_VALUE 11031
#define _APS_NEXT_SYMED_VALUE 7000
#endif
#endif

View File

@ -0,0 +1,174 @@
extern "C" {
#include <afs/param.h>
#include <afs/stds.h>
}
#include <WINNT/afsapplib.h>
/*
* VARIABLES __________________________________________________________________
*
*/
static LPTASKQUEUE_PARAMS ptqp = NULL;
typedef struct TASKQUEUEITEM
{
struct TASKQUEUEITEM *pNext;
int idTask;
HWND hReply;
PVOID lpUser;
} TASKQUEUEITEM, *LPTASKQUEUEITEM;
static LPTASKQUEUEITEM pTaskQueuePop = NULL;
static LPTASKQUEUEITEM pTaskQueuePushAfter = NULL;
static CRITICAL_SECTION csTaskQueue;
static size_t nThreadsRunning = 0;
static size_t nRequestsActive = 0;
/*
* PROTOTYPES _________________________________________________________________
*
*/
DWORD WINAPI Task_ThreadProc (PVOID lp);
/*
* ROUTINES ___________________________________________________________________
*
*/
void AfsAppLib_InitTaskQueue (LPTASKQUEUE_PARAMS lpp)
{
if (ptqp != NULL)
{
Delete (ptqp);
ptqp = NULL;
}
if (lpp && lpp->fnCreateTaskPacket && lpp->fnPerformTask && lpp->fnFreeTaskPacket)
{
ptqp = New (TASKQUEUE_PARAMS);
memcpy (ptqp, lpp, sizeof(TASKQUEUE_PARAMS));
}
}
void StartTask (int idTask, HWND hReply, PVOID lpUser)
{
if (!ptqp)
return;
static BOOL fStarted = FALSE;
if (!fStarted)
{
fStarted = TRUE;
InitializeCriticalSection (&csTaskQueue);
}
// Then push this notification onto our TaskQueue, so that the task
// thread will pop off each request in turn and take a look at it.
// Ideally, PostThreadMessage() and GetMessage() would implement all this
// garbage, but that doesn't work properly for some reason...
//
EnterCriticalSection (&csTaskQueue);
if ((++nRequestsActive) > nThreadsRunning)
{
if ((!ptqp->nThreadsMax) || (nThreadsRunning < (size_t)(ptqp->nThreadsMax)))
{
DWORD dwThreadID;
HANDLE hThread;
if ((hThread = CreateThread (NULL, 0, (LPTHREAD_START_ROUTINE)Task_ThreadProc, 0, 0, &dwThreadID)) != NULL)
{
SetThreadPriority (hThread, THREAD_PRIORITY_BELOW_NORMAL);
++nThreadsRunning;
}
}
}
LPTASKQUEUEITEM lptqi = New (TASKQUEUEITEM);
lptqi->pNext = NULL;
lptqi->idTask = idTask;
lptqi->hReply = hReply;
lptqi->lpUser = lpUser;
if (pTaskQueuePushAfter != NULL)
pTaskQueuePushAfter->pNext = lptqi;
pTaskQueuePushAfter = lptqi;
if (pTaskQueuePop == NULL)
pTaskQueuePop = lptqi;
LeaveCriticalSection (&csTaskQueue);
}
DWORD WINAPI Task_ThreadProc (PVOID lp)
{
BOOL fJustDidTask = FALSE;
for (;;)
{
BOOL fFound = FALSE;
TASKQUEUEITEM tqi;
EnterCriticalSection (&csTaskQueue);
if (fJustDidTask)
{
--nRequestsActive;
fJustDidTask = FALSE;
}
if (pTaskQueuePop != NULL)
{
LPTASKQUEUEITEM lptqiNext = pTaskQueuePop->pNext;
tqi = *pTaskQueuePop;
Delete (pTaskQueuePop);
if (pTaskQueuePushAfter == pTaskQueuePop)
pTaskQueuePushAfter = NULL;
pTaskQueuePop = lptqiNext;
fFound = TRUE;
fJustDidTask = TRUE;
}
// is this thread unnecessary?--that is, if we couldn't find anything
// to do, then kill off all threads.
//
if (!fFound)
{
--nThreadsRunning;
LeaveCriticalSection (&csTaskQueue);
break;
}
LeaveCriticalSection (&csTaskQueue);
if (fFound)
{
LPTASKPACKET ptp;
if ((ptp = (*ptqp->fnCreateTaskPacket)(tqi.idTask, tqi.hReply, tqi.lpUser)) != NULL)
{
(*ptqp->fnPerformTask)(ptp);
}
if (tqi.hReply && IsWindow (tqi.hReply))
{
PostMessage (tqi.hReply, WM_ENDTASK, 0, (LPARAM)ptp);
}
else if (ptp != NULL)
{
(*ptqp->fnFreeTaskPacket)(ptp);
}
}
}
return 0;
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,133 @@
#ifndef AL_WIZARD_H
#define AL_WIZARD_H
#include <WINNT/TaLocale.h>
#include <WINNT/subclass.h>
#ifndef EXPORTED
#define EXPORTED
#endif
/*
* DEFINITIONS ________________________________________________________________
*
*/
#ifndef THIS_HINST
#define THIS_HINST (HINSTANCE)GetModuleHandle(NULL)
#endif
#define IDC_WIZARD 898 // WM_COMMAND,IDC_WIZARD: HIWORD(wp)=WIZARD_COMAMND
typedef class EXPORTED WIZARD WIZARD, *LPWIZARD;
/*
* WIZARD CLASS _______________________________________________________________
*
*/
typedef enum
{
wcSTATE_ENTER, // now entering state (even w/o display)
wcSTATE_LEAVE, // now leaving state (even w/o display)
wcIS_STATE_DISABLED, // return TRUE if state disabled
} WIZARD_COMMAND;
typedef struct
{
int st; // numeric state identifier
int idd; // dialog template for wizard pane
DLGPROC dlgproc; // dialog procedure for this state
LPARAM lp; // lparam for dialog initialization
} WIZARD_STATE, *LPWIZARD_STATE;
#define BACK_BUTTON 0x0001
#define NEXT_BUTTON 0x0002
class EXPORTED WIZARD
{
public:
WIZARD (void);
~WIZARD (void);
static LPWIZARD GetWizard (HWND hWnd);
HWND GetWindow (void);
void SetDialogTemplate (int iddTemplate, int idcLeftPane, int idcRightPane, int idcBack, int idcNext);
void SetGraphic (int idbGraphic16, int idbGraphic256);
void SetStates (LPWIZARD_STATE aStates, size_t cStates);
void SetGraphicCallback (void (CALLBACK *pfnCallback)(LPWIZARD pWiz, HDC hdcTarget, LPRECT prTarget, HPALETTE hPal));
int GetState (void);
void SetState (int stNew, BOOL fForce = FALSE);
BOOL Show (BOOL fShow = TRUE);
void SetBackground (int iddBackground, BOOL fBlue = TRUE, DLGPROC dlgproc = NULL);
void SetBackgroundText (LPTSTR pszText, HFONT hfText = NULL);
void SetBackgroundText (int idsText, HFONT hfText = NULL);
BOOL ShowBackground (BOOL fShow = TRUE);
HWND GetBackgroundWindow (void);
void EnableButton (int idcButton, BOOL fEnable);
void EnableButtons (DWORD dwButtonFlags = BACK_BUTTON | NEXT_BUTTON);
void SetButtonText (int idcButton, int idsText);
void SetDefaultControl (int idc);
BOOL SendStateCommand (int st, WIZARD_COMMAND wc);
private:
void Refresh (DWORD dwRefFlags);
HWND GetRightHandWindow (void);
void GeneratePalette (RGBQUAD *pargb = NULL);
LPWIZARD_STATE FindState (int stFind);
static BOOL CALLBACK Background_DlgProc (HWND hBkg, UINT msg, WPARAM wp, LPARAM lp);
static BOOL CALLBACK Background_PaintHook (HWND hBkg, UINT msg, WPARAM wp, LPARAM lp);
void Background_OnInitDialog (HWND hBkg);
void Background_OnSize (void);
void Background_OnDestroy (void);
void Background_OnClose (void);
BOOL Background_OnPaint (void);
static BOOL CALLBACK Template_DlgProc (HWND hWnd, UINT msg, WPARAM wp, LPARAM lp);
static BOOL CALLBACK Template_LeftPaneHook (HWND hLHS, UINT msg, WPARAM wp, LPARAM lp);
BOOL Template_ForwardMessage (HWND hWnd, UINT msg, WPARAM wp, LPARAM lp);
void Template_OnInitDialog (HWND hWnd);
BOOL Template_OnPaintLHS (HWND hLHS);
int m_iddTemplate;
int m_idcLeftPane;
int m_idcRightPane;
int m_idcBack;
int m_idcNext;
int m_idbGraphic16;
HBITMAP m_bmpGraphic16;
int m_idbGraphic256;
HBITMAP m_bmpGraphic256;
HPALETTE m_palGraphic;
LPWIZARD_STATE m_aStates;
size_t m_cStates;
int m_stCurrent;
BOOL m_fShowing;
HWND m_hWnd;
int m_iddBackground;
BOOL m_fBlue;
HWND m_hBkg;
DLGPROC m_fnBackground;
TCHAR m_szBackground[ cchRESOURCE ];
HBITMAP m_bmpBackground;
HFONT m_hfBackground;
HBITMAP m_bmpBuffer;
RECT m_rBuffer;
void (CALLBACK *m_pfnCallback)(LPWIZARD pWiz, HDC hdcTarget, LPRECT prTarget, HPALETTE hPal);
};
#endif

View File

@ -0,0 +1,657 @@
extern "C" {
#include <afs/param.h>
#include <afs/stds.h>
}
#include <windows.h>
#include <windowsx.h>
#include <commctrl.h>
#include <WINNT/TaLocale.h>
#include <WINNT/subclass.h>
#include <WINNT/checklist.h>
/*
* DEFINITIONS ________________________________________________________________
*
*/
#define cxCHECKBOX (2+9+2)
#define cyCHECKBOX (2+9+2)
#define cxAFTER_CHECKBOX 4
#define LB_GETHIT (WM_USER+298)
#define LB_SETHIT (WM_USER+299) // int iItem=wp
/*
* int LB_GetHit (HWND hList)
* void LB_SetHit (HWND hList, int iItem)
*
*/
#define LB_GetHit(_hList) \
SendMessage(_hList,LB_GETHIT,(WPARAM)0,(LPARAM)0)
#define LB_SetHit(_hList,_ii) \
SendMessage(_hList,LB_SETHIT,(WPARAM)_ii,(LPARAM)0)
/*
* VARIABLES __________________________________________________________________
*
*/
LONG procListbox = 0;
/*
* PROTOTYPES _________________________________________________________________
*
*/
BOOL CALLBACK CheckListProc (HWND hList, UINT msg, WPARAM wp, LPARAM lp);
BOOL CALLBACK CheckList_DialogProc (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp);
void CheckList_OnDrawItem (HWND hList, int id, LPDRAWITEMSTRUCT lpds);
void CheckList_OnDrawCheckbox (HWND hList, int id, LPDRAWITEMSTRUCT lpds);
void CheckList_OnDrawText (HWND hList, int id, LPDRAWITEMSTRUCT lpds);
BOOL CheckList_OnHitTest (HWND hList, int id);
BOOL CheckList_OnGetHit (HWND hList, WPARAM wp, LPARAM lp);
BOOL CheckList_OnSetHit (HWND hList, WPARAM wp, LPARAM lp);
BOOL CheckList_OnGetCheck (HWND hList, WPARAM wp, LPARAM lp);
BOOL CheckList_OnSetCheck (HWND hList, WPARAM wp, LPARAM lp);
void CheckList_OnButtonDown (HWND hList);
void CheckList_OnButtonUp (HWND hList);
void CheckList_OnDoubleClick (HWND hList);
void CheckList_OnMouseMove (HWND hList);
void CheckList_OnSetCheck_Selected (HWND hList, BOOL fCheck);
void CheckList_RedrawCheck (HWND hList, int ii);
/*
* ROUTINES ___________________________________________________________________
*
*/
#ifndef REALLOC
#define REALLOC(_a,_c,_r,_i) CheckListReallocFunction ((LPVOID*)&_a,sizeof(*_a),&_c,_r,_i)
BOOL CheckListReallocFunction (LPVOID *ppTarget, size_t cbElement, size_t *pcTarget, size_t cReq, size_t cInc)
{
LPVOID pNew;
size_t cNew;
if (cReq <= *pcTarget)
return TRUE;
if ((cNew = cInc * ((cReq + cInc-1) / cInc)) <= 0)
return FALSE;
if ((pNew = Allocate (cbElement * cNew)) == NULL)
return FALSE;
memset (pNew, 0x00, cbElement * cNew);
if (*pcTarget != 0)
{
memcpy (pNew, *ppTarget, cbElement * (*pcTarget));
Free (*ppTarget);
}
*ppTarget = pNew;
*pcTarget = cNew;
return TRUE;
}
#endif
BOOL RegisterCheckListClass (void)
{
static BOOL fRegistered = FALSE;
if (!fRegistered)
{
WNDCLASS wc;
GetClassInfo (THIS_HINST, TEXT("LISTBOX"), &wc);
procListbox = (LONG)wc.lpfnWndProc;
wc.style = CS_GLOBALCLASS;
wc.lpfnWndProc = (WNDPROC)CheckListProc;
wc.hInstance = THIS_HINST;
wc.hCursor = LoadCursor (NULL, MAKEINTRESOURCE (IDC_ARROW));
wc.hbrBackground = CreateSolidBrush (GetSysColor (COLOR_BTNFACE));
wc.lpszClassName = WC_CHECKLIST;
if (RegisterClass (&wc))
fRegistered = TRUE;
}
return fRegistered;
}
BOOL IsCheckList (HWND hList)
{
TCHAR szClassName[256];
if (!GetClassName (hList, szClassName, 256))
return FALSE;
if (lstrcmp (szClassName, WC_CHECKLIST))
return FALSE;
return TRUE;
}
BOOL CALLBACK CheckListProc (HWND hList, UINT msg, WPARAM wp, LPARAM lp)
{
switch (msg)
{
case WM_CREATE:
Subclass_AddHook (GetParent(hList), CheckList_DialogProc);
LB_SetHit (hList, -1);
break;
case WM_DESTROY:
Subclass_RemoveHook (GetParent(hList), CheckList_DialogProc);
break;
case WM_ENABLE:
RECT rClient;
GetClientRect (GetParent(hList), &rClient);
InvalidateRect (GetParent(hList), &rClient, FALSE);
UpdateWindow (GetParent(hList));
break;
case WM_LBUTTONDOWN:
CheckList_OnButtonDown (hList);
if (GetCapture() == hList)
{
if (procListbox)
{
ReleaseCapture ();
CallWindowProc ((WNDPROC)procListbox, hList, WM_LBUTTONDOWN, wp, lp);
CallWindowProc ((WNDPROC)procListbox, hList, WM_LBUTTONUP, wp, lp);
SetCapture (hList);
}
return TRUE;
}
break;
case WM_LBUTTONUP:
CheckList_OnButtonUp (hList);
break;
case WM_LBUTTONDBLCLK:
CheckList_OnDoubleClick (hList);
break;
case WM_MOUSEMOVE:
CheckList_OnMouseMove (hList);
break;
case LB_GETHIT:
return CheckList_OnGetHit (hList, wp, lp);
case LB_SETHIT:
return CheckList_OnSetHit (hList, wp, lp);
case LB_GETCHECK:
return CheckList_OnGetCheck (hList, wp, lp);
case LB_SETCHECK:
return CheckList_OnSetCheck (hList, wp, lp);
}
if (procListbox)
return CallWindowProc ((WNDPROC)procListbox, hList, msg, wp, lp);
else
return DefWindowProc (hList, msg, wp, lp);
}
BOOL CALLBACK CheckList_DialogProc (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp)
{
PVOID procOld = Subclass_FindNextHook (hDlg, CheckList_DialogProc);
switch (msg)
{
case WM_MEASUREITEM:
LPMEASUREITEMSTRUCT lpms;
if ((lpms = (LPMEASUREITEMSTRUCT)lp) != NULL)
{
HDC hdc = GetDC (hDlg);
TEXTMETRIC tm;
GetTextMetrics (hdc, &tm);
ReleaseDC (hDlg, hdc);
lpms->itemHeight = max( tm.tmHeight, cyCHECKBOX );
return TRUE;
}
break;
case WM_DRAWITEM:
LPDRAWITEMSTRUCT lpds;
if ((lpds = (LPDRAWITEMSTRUCT)lp) != NULL)
{
CheckList_OnDrawItem (lpds->hwndItem, lpds->itemID, lpds);
return TRUE;
}
break;
case WM_CTLCOLORLISTBOX:
if (IsCheckList ((HWND)lp))
{
static COLORREF clrLast = (COLORREF)-1;
static HBRUSH hbrStatic = NULL;
COLORREF clrNew = GetSysColor (IsWindowEnabled((HWND)lp) ? COLOR_WINDOW : COLOR_BTNFACE);
if (clrNew != clrLast)
hbrStatic = CreateSolidBrush (clrLast = clrNew);
SetBkColor ((HDC)wp, clrLast);
return (BOOL)hbrStatic;
}
break;
}
if (procOld)
return CallWindowProc ((WNDPROC)procOld, hDlg, msg, wp, lp);
else
return FALSE;
}
void CheckList_OnDrawItem (HWND hList, int id, LPDRAWITEMSTRUCT lpds)
{
if (id >= 0)
{
CheckList_OnDrawCheckbox (hList, id, lpds);
CheckList_OnDrawText (hList, id, lpds);
}
}
void CheckList_OnDrawCheckbox (HWND hList, int id, LPDRAWITEMSTRUCT lpds)
{
// Step 1: erase around the checkbox.
//
COLORREF clrBack = GetSysColor (COLOR_WINDOW);
if (lpds->itemState & ODS_DISABLED)
clrBack = GetSysColor (COLOR_BTNFACE);
HBRUSH hbr = CreateSolidBrush (clrBack);
POINT ptCheckbox;
ptCheckbox.x = lpds->rcItem.left;
ptCheckbox.y = lpds->rcItem.top + ((lpds->rcItem.bottom - lpds->rcItem.top) - cyCHECKBOX) /2;
// step 1a: fill in above the checkbox
RECT rr;
rr.top = lpds->rcItem.top;
rr.left = lpds->rcItem.left;
rr.right = lpds->rcItem.left + cxCHECKBOX;
rr.bottom = ptCheckbox.y;
FillRect (lpds->hDC, &rr, hbr);
// step 1b: fill in below the checkbox
rr.top = ptCheckbox.y + cyCHECKBOX;
rr.bottom = lpds->rcItem.bottom;
FillRect (lpds->hDC, &rr, hbr);
// step 1c: fill in to the right of the checkbox
rr.top = lpds->rcItem.top;
rr.left = lpds->rcItem.left + cxCHECKBOX;
rr.right = lpds->rcItem.left + cxCHECKBOX + cxAFTER_CHECKBOX;
rr.bottom = lpds->rcItem.bottom;
FillRect (lpds->hDC, &rr, hbr);
DeleteObject (hbr);
// Step 2: draw the checkbox itself
//
HPEN hpOld;
HPEN hpNew;
// step 2a: draw the btnshadow upper-left lines
hpNew = CreatePen (PS_SOLID, 1, GetSysColor (COLOR_BTNSHADOW));
hpOld = (HPEN)SelectObject (lpds->hDC, hpNew);
MoveToEx (lpds->hDC, ptCheckbox.x, ptCheckbox.y +cyCHECKBOX -2, NULL);
LineTo (lpds->hDC, ptCheckbox.x, ptCheckbox.y);
LineTo (lpds->hDC, ptCheckbox.x +cxCHECKBOX-1, ptCheckbox.y);
SelectObject (lpds->hDC, hpOld);
DeleteObject (hpNew);
// step 2b: draw the black upper-left lines
hpNew = CreatePen (PS_SOLID, 1, RGB(0,0,0));
hpOld = (HPEN)SelectObject (lpds->hDC, hpNew);
MoveToEx (lpds->hDC, ptCheckbox.x+1, ptCheckbox.y+cyCHECKBOX-3, NULL);
LineTo (lpds->hDC, ptCheckbox.x+1, ptCheckbox.y+1);
LineTo (lpds->hDC, ptCheckbox.x+cxCHECKBOX-2, ptCheckbox.y+1);
SelectObject (lpds->hDC, hpOld);
DeleteObject (hpNew);
// step 2c: draw the btnface lower-right lines
hpNew = CreatePen (PS_SOLID, 1, GetSysColor (COLOR_BTNFACE));
hpOld = (HPEN)SelectObject (lpds->hDC, hpNew);
MoveToEx (lpds->hDC, ptCheckbox.x+1, ptCheckbox.y+cyCHECKBOX-2, NULL);
LineTo (lpds->hDC, ptCheckbox.x+cxCHECKBOX-2, ptCheckbox.y+cyCHECKBOX-2);
LineTo (lpds->hDC, ptCheckbox.x+cxCHECKBOX-2, ptCheckbox.y);
SelectObject (lpds->hDC, hpOld);
DeleteObject (hpNew);
// step 2d: draw the btnhighlight lower-right lines
hpNew = CreatePen (PS_SOLID, 1, GetSysColor (COLOR_BTNHIGHLIGHT));
hpOld = (HPEN)SelectObject (lpds->hDC, hpNew);
MoveToEx (lpds->hDC, ptCheckbox.x, ptCheckbox.y+cyCHECKBOX-1, NULL);
LineTo (lpds->hDC, ptCheckbox.x+cxCHECKBOX-1, ptCheckbox.y+cyCHECKBOX-1);
LineTo (lpds->hDC, ptCheckbox.x+cxCHECKBOX-1, ptCheckbox.y-1);
SelectObject (lpds->hDC, hpOld);
DeleteObject (hpNew);
// step 2e: draw the background field
//
BOOL fHit = CheckList_OnHitTest (hList, id);
BOOL fChecked = LB_GetCheck (hList, id);
clrBack = GetSysColor (COLOR_WINDOW);
if ( (lpds->itemState & ODS_DISABLED) ||
(fHit && (LB_GetHit(hList) == id)))
{
clrBack = GetSysColor (COLOR_BTNFACE);
}
rr.top = ptCheckbox.y +2;
rr.left = ptCheckbox.x +2;
rr.right = ptCheckbox.x +cxCHECKBOX -2;
rr.bottom = ptCheckbox.y +cyCHECKBOX -2;
hbr = CreateSolidBrush (clrBack);
FillRect (lpds->hDC, &rr, hbr);
DeleteObject (hbr);
// step 2f: draw the checkmark (if appropriate)
//
if (fChecked)
{
hpNew = CreatePen (PS_SOLID, 1, (lpds->itemState & ODS_DISABLED) ? GetSysColor(COLOR_BTNSHADOW) : RGB(0,0,0));
hpOld = (HPEN)SelectObject (lpds->hDC, hpNew);
MoveToEx (lpds->hDC, ptCheckbox.x +3, ptCheckbox.y+5, NULL);
LineTo (lpds->hDC, ptCheckbox.x +5, ptCheckbox.y+7);
LineTo (lpds->hDC, ptCheckbox.x+10, ptCheckbox.y+2);
MoveToEx (lpds->hDC, ptCheckbox.x +3, ptCheckbox.y+6, NULL);
LineTo (lpds->hDC, ptCheckbox.x +5, ptCheckbox.y+8);
LineTo (lpds->hDC, ptCheckbox.x+10, ptCheckbox.y+3);
MoveToEx (lpds->hDC, ptCheckbox.x +3, ptCheckbox.y+7, NULL);
LineTo (lpds->hDC, ptCheckbox.x +5, ptCheckbox.y+9);
LineTo (lpds->hDC, ptCheckbox.x+10, ptCheckbox.y+4);
SelectObject (lpds->hDC, hpOld);
DeleteObject (hpNew);
}
}
void CheckList_OnDrawText (HWND hList, int id, LPDRAWITEMSTRUCT lpds)
{
// Step 1: erase around the text.
//
COLORREF clrBack = GetSysColor (COLOR_WINDOW);
COLORREF clrFore = GetSysColor (COLOR_WINDOWTEXT);
if (lpds->itemState & ODS_DISABLED)
{
clrBack = GetSysColor (COLOR_BTNFACE);
clrFore = GetSysColor (COLOR_GRAYTEXT);
}
else if (lpds->itemState & ODS_SELECTED)
{
clrBack = GetSysColor (COLOR_HIGHLIGHT);
clrFore = GetSysColor (COLOR_HIGHLIGHTTEXT);
}
HBRUSH hbr = CreateSolidBrush (clrBack);
// step 1a: find out how big the text is, and where it should go
// (remember to add a few spaces to the front, so there's a little bit
// of highlighted leading space before the text begins)
TCHAR szText[256] = TEXT(" ");
SendMessage (hList, LB_GETTEXT, (WPARAM)id, (LPARAM)&szText[lstrlen(szText)]);
SIZE sText;
GetTextExtentPoint (lpds->hDC, szText, lstrlen(szText), &sText);
POINT ptText;
ptText.x = lpds->rcItem.left + cxCHECKBOX + cxAFTER_CHECKBOX;
ptText.y = lpds->rcItem.top + ((lpds->rcItem.bottom - lpds->rcItem.top) - sText.cy) /2;
// step 1b: fill in above the text
RECT rr;
rr.top = lpds->rcItem.top;
rr.left = ptText.x;
rr.right = lpds->rcItem.right;
rr.bottom = ptText.y;
FillRect (lpds->hDC, &rr, hbr);
// step 1c: fill in below the text
rr.top = ptText.y;
rr.bottom = lpds->rcItem.bottom;
FillRect (lpds->hDC, &rr, hbr);
// step 1d: fill in to the right of the text
rr.top = lpds->rcItem.top;
rr.left = ptText.x + sText.cx;
rr.right = lpds->rcItem.right;
rr.bottom = lpds->rcItem.bottom;
FillRect (lpds->hDC, &rr, hbr);
DeleteObject (hbr);
// Step 2: draw the text itself
//
rr.top = ptText.y;
rr.left = ptText.x;
rr.right = ptText.x + sText.cx;
rr.bottom = ptText.y + sText.cy;
COLORREF clrBG = SetBkColor (lpds->hDC, clrBack);
COLORREF clrFG = SetTextColor (lpds->hDC, clrFore);
DRAWTEXTPARAMS Params;
memset (&Params, 0x00, sizeof(DRAWTEXTPARAMS));
Params.cbSize = sizeof(Params);
Params.iTabLength = 15;
SetBkMode (lpds->hDC, OPAQUE);
DrawTextEx (lpds->hDC, szText, -1, &rr, DT_LEFT | DT_VCENTER | DT_SINGLELINE | DT_EXPANDTABS | DT_NOPREFIX | DT_TABSTOP | DT_NOCLIP, &Params);
SetTextColor (lpds->hDC, clrFG);
SetBkColor (lpds->hDC, clrBG);
// Step 3: draw the focus rect (if appropriate)
//
if (lpds->itemState & ODS_FOCUS)
{
rr.top = lpds->rcItem.top;
rr.left = ptText.x;
rr.right = lpds->rcItem.right;
rr.bottom = lpds->rcItem.bottom;
DrawFocusRect (lpds->hDC, &rr);
}
}
BOOL CheckList_OnHitTest (HWND hList, int id)
{
RECT rr;
SendMessage (hList, LB_GETITEMRECT, (WPARAM)id, (LPARAM)&rr);
rr.right = rr.left + cxCHECKBOX;
DWORD dw = GetMessagePos();
POINT pt = { LOWORD(dw), HIWORD(dw) };
ScreenToClient (hList, &pt);
return PtInRect (&rr, pt);
}
BOOL CheckList_OnGetHit (HWND hList, WPARAM wp, LPARAM lp)
{
return (BOOL)GetWindowLong (hList, GWL_USERDATA);
}
BOOL CheckList_OnSetHit (HWND hList, WPARAM wp, LPARAM lp)
{
int iItem = (int)wp;
SetWindowLong (hList, GWL_USERDATA, iItem);
return TRUE;
}
BOOL CheckList_OnGetCheck (HWND hList, WPARAM wp, LPARAM lp)
{
int iItem = (int)wp;
return (BOOL)SendMessage (hList, LB_GETITEMDATA, (WPARAM)iItem, 0);
}
BOOL CheckList_OnSetCheck (HWND hList, WPARAM wp, LPARAM lp)
{
int iItem = (int)wp;
BOOL fCheck = (BOOL)lp;
SendMessage (hList, LB_SETITEMDATA, (WPARAM)iItem, (LPARAM)fCheck);
CheckList_RedrawCheck (hList, iItem);
return TRUE;
}
void CheckList_OnMouseMove (HWND hList)
{
if (GetCapture() == hList)
{
int ii = LB_GetHit (hList);
if (ii != -1)
{
CheckList_RedrawCheck (hList, ii);
}
}
}
void CheckList_OnButtonDown (HWND hList)
{
if (IsWindowEnabled (hList))
{
DWORD dw = GetMessagePos();
POINT pt = { LOWORD(dw), HIWORD(dw) };
ScreenToClient (hList, &pt);
int ii = SendMessage (hList, LB_ITEMFROMPOINT, 0, MAKELPARAM(pt.x,pt.y));
if (HIWORD(ii) == 0)
{
BOOL fHit = CheckList_OnHitTest (hList, ii);
if (fHit)
{
SetCapture (hList);
LB_SetHit (hList, ii);
CheckList_RedrawCheck (hList, ii);
}
}
}
}
void CheckList_OnButtonUp (HWND hList)
{
if (GetCapture() == hList)
{
ReleaseCapture();
int ii = LB_GetHit (hList);
if (ii != -1)
{
LB_SetHit (hList, -1);
BOOL fHit = CheckList_OnHitTest (hList, ii);
if (!fHit)
CheckList_RedrawCheck (hList, ii);
else
{
BOOL fChecked = LB_GetCheck (hList, ii);
CheckList_OnSetCheck_Selected (hList, !fChecked);
}
}
}
}
void CheckList_OnDoubleClick (HWND hList)
{
if (IsWindowEnabled (hList))
{
DWORD dw = GetMessagePos();
POINT pt = { LOWORD(dw), HIWORD(dw) };
ScreenToClient (hList, &pt);
int ii = SendMessage (hList, LB_ITEMFROMPOINT, 0, MAKELPARAM(pt.x,pt.y));
if (HIWORD(ii) == 0)
{
BOOL fChecked = LB_GetCheck (hList, ii);
CheckList_OnSetCheck_Selected (hList, !fChecked);
}
}
}
void CheckList_OnSetCheck_Selected (HWND hList, BOOL fCheck)
{
static int *aSel = NULL;
static size_t cSel = 0;
if (GetWindowLong(hList,GWL_STYLE) & LBS_MULTIPLESEL)
{
size_t cReq = SendMessage(hList,LB_GETSELCOUNT,0,0);
if ((cReq) && (cReq != LB_ERR) && REALLOC(aSel,cSel,cReq,4))
{
size_t iMax = (size_t)SendMessage (hList, LB_GETSELITEMS, (WPARAM)cSel, (LPARAM)aSel);
if (iMax != LB_ERR)
{
for (size_t ii = 0; ii < iMax; ++ii)
{
LB_SetCheck (hList, aSel[ii], fCheck);
}
}
}
}
else // single-sel listbox
{
int ii = SendMessage (hList, LB_GETCURSEL, 0, 0);
if (ii != LB_ERR)
{
LB_SetCheck (hList, ii, fCheck);
}
}
SendMessage (GetParent(hList), WM_COMMAND, MAKELONG(GetWindowLong(hList,GWL_ID),LBN_CLICKED), (LPARAM)hList);
}
void CheckList_RedrawCheck (HWND hList, int ii)
{
RECT rr;
SendMessage (hList, LB_GETITEMRECT, (WPARAM)ii, (LPARAM)&rr);
rr.right = rr.left + cxCHECKBOX;
InvalidateRect (hList, &rr, TRUE);
UpdateWindow (hList);
}

View File

@ -0,0 +1,46 @@
#ifndef CHECKLIST_H
#define CHECKLIST_H
/*
* DEFINITIONS ________________________________________________________________
*
*/
#ifndef THIS_HINST
#define THIS_HINST (HINSTANCE)GetModuleHandle(NULL)
#endif
#ifndef EXPORTED
#define EXPORTED
#endif
/*
* PROTOTYPES _________________________________________________________________
*
*/
EXPORTED BOOL RegisterCheckListClass (void);
#define WC_CHECKLIST TEXT("CheckList")
#define LB_GETCHECK (WM_USER+300) // int iItem=wp
#define LB_SETCHECK (WM_USER+301) // int iItem=wp, BOOL fChecked=lp
#define LBN_CLICKED BN_CLICKED
/*
* BOOL LB_GetCheck (HWND hList, int iItem)
* void LB_SetCheck (HWND hList, int iItem, BOOL fCheck)
*
*/
#define LB_GetCheck(_hList,_ii) \
SendMessage(_hList,LB_GETCHECK,(WPARAM)_ii,(LPARAM)0)
#define LB_SetCheck(_hList,_ii,_fCheck) \
SendMessage(_hList,LB_SETCHECK,(WPARAM)_ii,(LPARAM)_fCheck)
#endif

Some files were not shown because too many files have changed in this diff Show More