maildirshared2.c
上传用户:s81996212
上传日期:2007-01-04
资源大小:722k
文件大小:1k
源码类别:

WEB邮件程序

开发平台:

C/C++

  1. /*
  2. ** Copyright 2000 Double Precision, Inc.
  3. ** See COPYING for distribution information.
  4. */
  5. #include "config.h"
  6. #include <stdio.h>
  7. #include <string.h>
  8. #include <stdlib.h>
  9. #include <ctype.h>
  10. static const char rcsid[]="$Id: maildirshared2.c,v 1.1 2000/02/14 05:11:39 mrsam Exp $";
  11. FILE *maildir_shared_fopen(const char *maildir, const char *mode)
  12. {
  13. char *m;
  14. FILE *fp;
  15. m=malloc(strlen(maildir)+sizeof("/shared-maildirs"));
  16. if (!m)
  17. {
  18. perror("malloc");
  19. return (0);
  20. }
  21. strcat(strcpy(m, maildir), "/shared-maildirs");
  22. fp=fopen(m, mode);
  23. free(m);
  24. return (fp);
  25. }
  26. void maildir_shared_fparse(char *p, char **name, char **dir)
  27. {
  28. char *q;
  29. *name=0;
  30. *dir=0;
  31. if ((q=strchr(p, 'n')) != 0) *q=0;
  32. if ((q=strchr(p, '#')) != 0) *q=0;
  33. for (q=p; *q; q++)
  34. if (isspace((int)(unsigned char)*q)) break;
  35. if (!*q) return;
  36. *q++=0;
  37. while (*q && isspace((int)(unsigned char)*q))
  38. ++q;
  39. if (*q)
  40. {
  41. *name=p;
  42. *dir=q;
  43. }
  44. }