Doh, sorry about the double post, I didn't finish my thought...
Quoting "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>:
>
>
> Ok, I'm diving in... but I'm already lost ;)
> I thought maybe the code in vlimits.c would be simple enough to use, but I
> don't
> understand how it could work... Maybe it doesn't yet ;)
>
> Anyways, here's an excerpt:
>
> /*
> * vlimits.c
> * handle domain limits in both file format
> * Brian Kolaci <[EMAIL PROTECTED]>
> */
> ...
> #define TOKENS " :\t\n\r"
> ...
> /* find/read the .qmailadmin-limits file */
> int vget_limits(const char *domain, struct vlimits *limits)
> {
> ...
> /* open file */
> if ((fs = fopen(dir, "r")) != NULL) {
> while (fgets(buf, sizeof(buf), fs) != NULL) {
> if ((s1 = strtok(buf, TOKENS)) == NULL)
> continue;
>
> if (!strcmp(s1, "maxpopaccounts")) {
> if ((s2 = strtok(NULL, TOKENS)) == NULL)
> continue;
> limits->maxpopaccounts = atoi(s2);
> }
>
> if (!strcmp(s1, "maxaliases")) {
> if ((s2 = strtok(NULL, TOKENS)) == NULL)
> continue;
> limits->maxaliases = atoi(s2);
> }
>
>
> Ok... so I assume the .qmailadmin-limits file looks like:
> maxpopaccounts12
> maxaliases44
>
> I'm trying to understand this..
> while not EOF..
> if not empty..
And Here's where I'm really lost:
> if (!strcmp(s1, "maxpopaccounts")) {
? If s1 does NOT contain maxpopaccts?
> if ((s2 = strtok(NULL, TOKENS)) == NULL)
? if the next token of NULL is null loop? (I haven't looked up continue yet,
but I assume its to restart the while.. but that's not a source of confusion yet ;)
> continue;
> limits->maxpopaccounts = atoi(s2);
> }
>
> so first s1 should be "maxpopacccounts" because fgets ends at \n
> But I don't get the strtok(). How can s2 be anything if NULL is being split
> up by \t\n\r ? Shouldn't that be buf?
>
I can usually figure this stuff out with google, and some common sense, but this
time I don't get it. Sorry about the double post.
Thanks
Rick