/*----------------------------------------------------------------------
      Expand a folder name, taking account of the folders_dir.

  Args: filename -- The name of the file that is the folder
 
 Result: The folder name is expanded in place.  
         Returns 0 and queues status message if unsuccessful.
         Input string is overwritten with expanded name.
         Returns 1 if successful.

BUG should limit length to MAXPATH
  ----*/
int
expand_foldername(filename)
    char *filename;
{
    char         temp_filename[MAXPATH+1];

    dprint(5, (debugfile, "=== expand_foldername called (%s) ===\n",filename));

    /*
     * We used to check for valid filename chars here if "filename"
     * didn't refer to a remote mailbox.  This has been rethought
     */

    strcpy(temp_filename, filename);
    if(strucmp(temp_filename, "inbox") == 0) {
        strcpy(filename, ps_global->VAR_INBOX_PATH == NULL ? "inbox" :
               ps_global->VAR_INBOX_PATH);
    } else if(temp_filename[0] == '*' || temp_filename[0] == '{'){
        strcpy(filename, temp_filename);
    } else if(temp_filename[0] == '\\'
	      || (isalpha((unsigned char)temp_filename[0])
		  && temp_filename[1] == ':')) {
	fixpath(temp_filename, MAXPATH);
        strcpy(filename, temp_filename);
    } else if(F_ON(F_USE_CURRENT_DIR, ps_global)){
	strcpy(filename, temp_filename);
    } else if(ps_global->VAR_OPER_DIR){
	build_path(filename, ps_global->VAR_OPER_DIR, temp_filename);
    } else {
	build_path(filename, ps_global->folders_dir, temp_filename);
    }
    dprint(5, (debugfile, "returning \"%s\"\n", filename));    
    return(1);
}
