コード例 #1
0
ファイル: MAILBOX.C プロジェクト: daemqn/Atari_ST_Sources
/* Find and store all of the directories, and index them in the dpointers array */
long get_directories(void)
{
	char temp[80];
	long count,c,rcnt=0;

	count = getfnl("*", dirs, sizeof(dirs), FA_SUBDIR );
	if (count > 0) {
		if (strbpl(dpointers,300,dirs)!=count) {
			fprintf(stderr, "Too many mailbox directories\n");
			deinitialize();
			exit(1);
		}
		strsrt( dpointers, count );
		for (c=0;c<count;c++) {
			if (dpointers[c][0]=='.') { continue; }
			rcnt++;
		/*	sprintf( temp, "[0][Checking Directory |%s][OK]", dpointers[c] ); */
		/*	form_alert( 1, temp ); */
		}
		sprintf( temp, "[0][You have %ld Mail Directories][OK]", rcnt );
		form_alert( 1, temp );
	} else {
		if (_OSERR) poserr( "DIRS");
		else fprintf(stderr, "Too many mailbox directories\n");
		deinitialize();
		exit(1);
	}
	return(count);
}
コード例 #2
0
ファイル: MAILBOX.C プロジェクト: daemqn/Atari_ST_Sources
/* Count and remember the number of email messages in each directory and a total */
long get_directory_mail(void)
{
	int c,d,index;
	long count=0,mail_cnt=0;
	char temp[FMSIZE];
	char **dmptr;

	for (c=0;c<dcount;c++) {	/* for each directory */
		dmpointers[c] = NULL;
		if (dpointers[c][0]=='.') { continue; }
		chdir( dpointers[c] );
		count = getfnl("mail*.txt", dmail, sizeof(dmail), 0 );
	/*	sprintf( temp, "[0][Directory %s has|%ld messages][OK]", dpointers[c], count ); */
	/*	form_alert( 1, temp ); */
		if (count > 0) {
			dmpointers[c] = calloc( count+1, sizeof(int) );
			dmpointers[c][0] = (int)count;
			dmptr = calloc( count+1, sizeof(size_t) );
			if (strbpl(dmptr,count+1,dmail)==count) {
				for (d=0;d<count;d++) {
					index = get_mail_index( dmptr[d] );
					dmpointers[c][d+1] = index;
				}
			}
			free( dmptr );
			mail_cnt += count;
		}
		chdir( mail_path );
	}
	sprintf( temp, "[0][You have %ld Directory messages][OK]", mail_cnt );
	form_alert( 1, temp );
	return(mail_cnt);
}
コード例 #3
0
ファイル: MAILBOX.C プロジェクト: daemqn/Atari_ST_Sources
/* Find and store all of the mailboxes, and index them in the pointers array */
long get_mailboxes(void)
{
	char temp[80];
	long count;

	count = getfnl("*.MBX", boxes, sizeof(boxes), 0 );
	if (count > 0) {
		if (strbpl(pointers,200,boxes)!=count) {
			fprintf(stderr, "Too many mailbox files\n");
			deinitialize();
			exit(1);
		}
		sprintf( temp, "[0][You have %ld Mailboxes][OK]", count );
		form_alert( 1, temp );
		strsrt( pointers, count );
	} else {
		if (_OSERR) poserr( "FILES");
		else fprintf(stderr, "Too many mailbox files\n");
		deinitialize();
		exit(1);
	}
	return(count);
}
コード例 #4
0
ファイル: qdos.c プロジェクト: QEuphemia/crest
int custom_expand (char * param, char ***argvptr, int *argcptr)
{
    int     count,sl;
    size_t  bufsize;
    char    *filenamebuf;
    char    *ptr,*safeptr;

    /*
     *  Check to see if we should do wild card expansion.
     *  We only perform wildcard expansion if the parameter
     *  was not a string and if it contains one of the
     *  wild card characters.
     *
     *  We also do not expand any option that starts with '-'
     *  as we then assume that it is a unix stylew option.
     */
    if ((*param == '-') ||  (strpbrk(param,"*?") == NULL) ) {
        return 0;
    }

    if ((filenamebuf = malloc (bufsize = FILEBUF_INIT)) == NULL) {
        return -1;
    }
TRYAGAIN:
    count = getfnl(param, filenamebuf, bufsize, QDR_ALL);
    if (count == -1  && errno == ENOMEM) {
        /*
         *  We have overflowed the buffer, so we try
         *  to get a bigger buffer and try again.
         */
        bufsize += FILEBUF_INCR;
        if ((filenamebuf = realloc (filenamebuf, bufsize)) == NULL) {
            return -1;
        } else {
            goto TRYAGAIN;
        }
    }
    /*
     *  If no files were found, then return unexpanded.
     */
    if (count == 0) {
        free (filenamebuf);
        return 0;
    }
    /*
     *  Files were found, so add these to the list instead
     *  of the original parameter typed by the user.
     */
    for ( ptr=filenamebuf ; count > 0 ; count -- ) {
        *argvptr = (char **)realloc (*argvptr, (size_t)(((*argcptr) + 2) * sizeof (char *)));
        safeptr=(char *)malloc((size_t)(sl=strlen(ptr)+1));
        if (safeptr == NULL || *argvptr == NULL) {
            return -1;
        }
        (void) memcpy(safeptr,ptr,(size_t)sl);
        (*argvptr)[*argcptr] = safeptr;
        *argcptr += 1;
        ptr += sl;
    }
    free (filenamebuf);
    return *argcptr;
}