Thank you Peter, but it's difficult for me to make it work. i modify the
alias.c carefully. but i get a lot of error when compile it. I just not
understand why not Ken add this useful feature to the qmail admin.
First error message:
gmake[1]: Entering directory `/var/download/qmailadmin/tmp/qmailadmin-0.40'
gmake[2]: Entering directory `/var/download/qmailadmin/tmp/qmailadmin-0.40'
gcc -I. -I/var/vpopmail/include -g -O2 -c alias.c
alias.c: In function `show_dotqmail_lines':
alias.c:72: `alphasort' undeclared (first use in this function)
alias.c:72: (Each undeclared identifier is reported only once
alias.c:72: for each function it appears in.)
gmake[2]: *** [alias.o] Error 1
gmake[2]: Leaving directory `/var/download/qmailadmin/tmp/qmailadmin-0.40'
gmake[1]: *** [all-recursive] Error 1
gmake[1]: Leaving directory `/var/download/qmailadmin/tmp/qmailadmin-0.40'
gmake: *** [all-recursive-am] Error 2
I read the scandir manpage and add
#include <sys/types.h>
#include <sys/dir.h>
to the alias.c. but it don't work. because there is no file "dir.h" in
/usr/include/sys
so i change them to
#include </usr/ucbinclude/sys/types.h>
#include </usr/ucbinclude/sys/dir.h>
Wow! there are another errors:
gmake[1]: Entering directory `/var/download/qmailadmin/tmp/qmailadmin-0.40'
gmake[2]: Entering directory `/var/download/qmailadmin/tmp/qmailadmin-0.40'
gcc -I. -I/var/vpopmail/include -g -O2 -c alias.c
In file included from alias.c:28:
/usr/include/dirent.h:30: warning: `MAXNAMLEN' redefined
/usr/ucbinclude/sys/dir.h:65: warning: this is the location of the previous
definition
/usr/include/dirent.h:114: warning: `rewinddir' redefined
/usr/ucbinclude/sys/dir.h:189: warning: this is the location of the previous
definition
In file included from alias.c:28:
/usr/include/dirent.h:42: conflicting types for `DIR'
/usr/ucbinclude/sys/dir.h:122: previous declaration of `DIR'
/usr/include/dirent.h:76: conflicting types for `opendir'
/usr/ucbinclude/sys/dir.h:153: previous declaration of `opendir'
/usr/include/dirent.h:77: conflicting types for `readdir'
/usr/ucbinclude/sys/dir.h:154: previous declaration of `readdir'
/usr/include/dirent.h:80: conflicting types for `telldir'
/usr/ucbinclude/sys/dir.h:155: previous declaration of `telldir'
/usr/include/dirent.h:81: conflicting types for `seekdir'
/usr/ucbinclude/sys/dir.h:156: previous declaration of `seekdir'
/usr/include/dirent.h:83: parse error before `('
/usr/include/dirent.h:84: conflicting types for `closedir'
/usr/ucbinclude/sys/dir.h:162: previous declaration of `closedir'
/usr/include/dirent.h:89: conflicting types for `readdir64'
/usr/ucbinclude/sys/dir.h:177: previous declaration of `readdir64'
alias.c: In function `show_dotqmail_lines':
alias.c:74: warning: passing arg 2 of `scandir' from incompatible pointer
type
gmake[2]: *** [alias.o] Error 1
gmake[2]: Leaving directory `/var/download/qmailadmin/tmp/qmailadmin-0.40'
gmake[1]: *** [all-recursive] Error 1
gmake[1]: Leaving directory `/var/download/qmailadmin/tmp/qmailadmin-0.40'
gmake: *** [all-recursive-am] Error 2
######### the scandir manpage #############
SunOS/BSD Compatibility Library Functions scandir(3UCB)
NAME
scandir, alphasort - scan a directory
SYNOPSIS
/usr/ucb/cc [ flag ... ] file ...
#include <sys/types.h>
#include <sys/dir.h>
int scandir(dirname, namelist, select, dcomp);
char *dirname;
struct direct *(*namelist[]);
int (*select(.),(*dcomp)();
int alphasort(d1, d2);
struct direct **d1, **d2;
DESCRIPTION
The scandir() function reads the directory dirname and
builds an array of pointers to directory entries using
malloc(3C). The second parameter is a pointer to an array of
structure pointers. The third parameter is a pointer to a
routine which is called with a pointer to a directory entry
and should return a non zero value if the directory entry
should be included in the array. If this pointer is NULL,
then all the directory entries will be included. The last
argument is a pointer to a routine which is passed to
qsort(3C), which sorts the completed array. If this pointer
is NULL, the array is not sorted.
The alphasort() function is a routine that sorts the array
alphabetically.
RETURN VALUES
The scandir() function returns the number of entries in the
array and a pointer to the array through the parameter
namelist. The scandir() function returns -1 if the directory
cannot be opened for reading or if malloc(3C) cannot allo-
cate enough memory to hold all the data structures.
USAGE
The scandir() and alphasort() functions have transitional
interfaces for 64-bit file offsets. See lf64(5).
SEE ALSO
getdents(2), malloc(3C), qsort(3C), readdir(3UCB),
readdir(3C), lf64(5)
NOTES
Use of these interfaces should be restricted to only appli-
cations written on BSD platforms. Use of these interfaces
with any of the system libraries or in multi-thread applica-
tions is unsupported.
SunOS 5.8 Last change: 28 Jan 1998 1
----
Chris Chan
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
----- Original Message -----
From: "Peter Green" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, December 31, 2000 9:40 PM
Subject: Re: HOW TO: sort Alias a-z?
* Chris Chan <[EMAIL PROTECTED]> [001231 03:59]:
> Anyone know how to modify the qmailadmin pre1 4.0 to sort the Alias from
a-z
A number of versions ago, I modified qmailadmin to do this and submitted a
patch. Lamentably, it didn't seem to make it into later versions.
Basically, you need to invoke scandir(3) on the directory before iterating
through the .qmail files. See the manpage for more.
I've attached my patch against qmailadmin-0.35. Since I'm not really
developing with vpopmail and its associated tools much anymore, I haven't
ported it, but it should be fairly straightforward.
Good luck!
/pg
--
Peter Green : Gospel Communications Network, SysAdmin : [EMAIL PROTECTED]
---
"A journey of a thousand miles continues with the second step."
--- Larry Wall