⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dummynt.c

📁 mgcp协议源代码。支持多种编码:g711
💻 C
📖 第 1 页 / 共 2 页
字号:
  mm_list (stream,delimiter,name,attributes);  return T;}/* Dummy create mailbox * Accepts: mail stream *	    mailbox name to create * Returns: T on success, NIL on failure */long dummy_create (MAILSTREAM *stream,char *mailbox){  char tmp[MAILTMPLEN];  if (strcmp (ucase (strcpy (tmp,mailbox)),"INBOX") && dummy_file(tmp,mailbox))    return dummy_create_path (stream,tmp);  sprintf (tmp,"Can't create %s: invalid name",mailbox);  mm_log (tmp,ERROR);  return NIL;}/* Dummy create path * Accepts: mail stream *	    path name name to create * Returns: T on success, NIL on failure */long dummy_create_path (MAILSTREAM *stream,char *path){  struct stat sbuf;  char c,*s,tmp[MAILTMPLEN];  int fd;  long ret = NIL;  char *t = strrchr (path,'\\');  char *pt = (path[1] == ':') ? path + 2 : path;  int wantdir = t && !t[1];  if (wantdir) *t = '\0';	/* flush trailing delimiter for directory */				/* found superior to this name? */  if ((s = strrchr (pt,'\\')) && (s != pt)) {    strncpy (tmp,path,(size_t) (s - path));    tmp[s - path] = '\0';	/* make directory name for stat */    c = *++s;			/* tie off in case need to recurse */    *s = '\0';				/* name doesn't exist, create it */    if ((stat (tmp,&sbuf) || ((sbuf.st_mode & S_IFMT) != S_IFDIR)) &&	!dummy_create_path (stream,path)) return NIL;    *s = c;			/* restore full name */  }  if (wantdir) {		/* want to create directory? */    ret = !mkdir (path);    *t = '\\';			/* restore directory delimiter */  }				/* create file */  else if ((fd = open (path,O_WRONLY|O_CREAT|O_EXCL,S_IREAD|S_IWRITE)) >= 0)    ret = !close (fd);		/* close file */  if (!ret) {			/* error? */    sprintf (tmp,"Can't create mailbox node %s: %s",path,strerror (errno));    mm_log (tmp,ERROR);  }  return ret;			/* return status */}/* Dummy delete mailbox * Accepts: mail stream *	    mailbox name to delete * Returns: T on success, NIL on failure */long dummy_delete (MAILSTREAM *stream,char *mailbox){  struct stat sbuf;  char *s,tmp[MAILTMPLEN];				/* no trailing \ */  if ((s = strrchr (dummy_file (tmp,mailbox),'\\')) && !s[1]) *s = '\0';  if (stat (tmp,&sbuf) || ((sbuf.st_mode & S_IFMT) == S_IFDIR) ?      rmdir (tmp) : unlink (tmp)) {    sprintf (tmp,"Can't delete mailbox %s: %s",mailbox,strerror (errno));    mm_log (tmp,ERROR);    return NIL;  }  return T;			/* return success */}/* Mail rename mailbox * Accepts: mail stream *	    old mailbox name *	    new mailbox name * Returns: T on success, NIL on failure */long dummy_rename (MAILSTREAM *stream,char *old,char *newname){  struct stat sbuf;  char c,*s,tmp[MAILTMPLEN],mbx[MAILTMPLEN];  long ret = NIL;				/* no trailing \ allowed */  if (!(s = dummy_file (mbx,newname)) || ((s = strrchr (s,'\\')) && !s[1])) {    sprintf (mbx,"Can't rename %s to %s: invalid name",old,newname);    mm_log (mbx,ERROR);    return NIL;  }				/* found superior to destination name? */  if (s && (s != mbx) && ((mbx[1] != ':') || (s != mbx + 2))) {    c = s[1];			/* remember character after delimiter */    *s = s[1] = '\0';		/* tie off name at delimiter */				/* name doesn't exist, create it */    if (stat (mbx,&sbuf) || ((sbuf.st_mode & S_IFMT) != S_IFDIR)) {      *s = '\\';		/* restore delimiter */      if (!dummy_create (stream,mbx)) return NIL;    }    else *s = '\\';		/* restore delimiter */    s[1] = c;			/* restore character after delimiter */  }				/* rename of non-ex INBOX creates dest */  if (!strcmp (ucase (strcpy (tmp,old)),"INBOX") &&      stat (dummy_file (tmp,old),&sbuf)) return dummy_create (NIL,mbx);  if (rename (dummy_file (tmp,old),mbx)) {    sprintf (tmp,"Can't rename mailbox %s to %s: %s",old,newname,	     strerror (errno));    mm_log (tmp,ERROR);    return NIL;  }  return LONGT;			/* return success */}/* Dummy open * Accepts: stream to open * Returns: stream on success, NIL on failure */MAILSTREAM *dummy_open (MAILSTREAM *stream){  int fd;  char err[MAILTMPLEN],tmp[MAILTMPLEN];  struct stat sbuf;				/* OP_PROTOTYPE call */  if (!stream) return &dummyproto;  err[0] = '\0';		/* no error message yet */				/* can we open the file? */  if ((fd = open (dummy_file (tmp,stream->mailbox),O_RDONLY,NIL)) < 0) {				/* no, error unless INBOX */    if (strcmp (ucase (strcpy (tmp,stream->mailbox)),"INBOX"))      sprintf (err,"%s: %s",strerror (errno),stream->mailbox);  }  else {			/* file had better be empty then */    fstat (fd,&sbuf);		/* sniff at its size */    close (fd);    if (sbuf.st_size)		/* bogus format if non-empty */      sprintf (err,"%s (file %s) is not in valid mailbox format",	       stream->mailbox,tmp);  }  if (err[0]) {			/* if an error happened */    mm_log (err,stream->silent ? WARN : ERROR);    return NIL;  }  else if (!stream->silent) {	/* only if silence not requested */    mail_exists (stream,0);	/* say there are 0 messages */    mail_recent (stream,0);	/* and certainly no recent ones! */    stream->uid_validity = 1;  }  stream->inbox = T;		/* note that it's an INBOX */  return stream;		/* return success */}/* Dummy close * Accepts: MAIL stream *	    options */void dummy_close (MAILSTREAM *stream,long options){				/* return silently */}/* Dummy ping mailbox * Accepts: MAIL stream * Returns: T if stream alive, else NIL */long dummy_ping (MAILSTREAM *stream){				/* time to do another test? */  if (time (0) >= ((time_t) (stream->gensym + 30))) {    MAILSTREAM *test = mail_open (NIL,stream->mailbox,OP_PROTOTYPE);    if (!test) return NIL;	/* can't get a prototype?? */    if (test->dtb == stream->dtb) {      stream->gensym = time (0);/* still hasn't changed */      return T;			/* try again later */    }				/* looks like a new driver? */    if (!(test = mail_open (NIL,stream->mailbox,NIL))) return NIL;    mail_close ((MAILSTREAM *)	/* flush resources used by dummy stream */		memcpy (fs_get (sizeof (MAILSTREAM)),stream,			sizeof (MAILSTREAM)));				/* swap the streams */    memcpy (stream,test,sizeof (MAILSTREAM));    fs_give ((void **) &test);	/* flush test now that copied */  }  return T;}/* Dummy check mailbox * Accepts: MAIL stream * No-op for readonly files, since read/writer can expunge it from under us! */void dummy_check (MAILSTREAM *stream){  dummy_ping (stream);		/* invoke ping */}/* Dummy expunge mailbox * Accepts: MAIL stream */void dummy_expunge (MAILSTREAM *stream){				/* return silently */}/* Dummy copy message(s) * Accepts: MAIL stream *	    sequence *	    destination mailbox *	    options * Returns: T if copy successful, else NIL */long dummy_copy (MAILSTREAM *stream,char *sequence,char *mailbox,long options){  if ((options & CP_UID) ? mail_uid_sequence (stream,sequence) :      mail_sequence (stream,sequence)) fatal ("Impossible dummy_copy");  return NIL;}/* Dummy append message string * Accepts: mail stream *	    destination mailbox *	    append callback function *	    data for callback * Returns: T on success, NIL on failure */long dummy_append (MAILSTREAM *stream,char *mailbox,append_t af,void *data){  struct stat sbuf;  int fd = -1;  int e;  char tmp[MAILTMPLEN];  MAILSTREAM *ts = default_proto (T);  if ((strcmp (ucase (strcpy (tmp,mailbox)),"INBOX")) &&	   ((fd = open (dummy_file (tmp,mailbox),O_RDONLY,NIL)) < 0)) {    if ((e = errno) == ENOENT)	/* failed, was it no such file? */      mm_notify (stream,"[TRYCREATE] Must create mailbox before append",		 (long) NIL);    sprintf (tmp,"%s: %s",strerror (e),mailbox);    mm_log (tmp,ERROR);		/* pass up error */    return NIL;			/* always fails */  }  if (fd >= 0) {		/* found file? */    fstat (fd,&sbuf);		/* get its size */    close (fd);			/* toss out the fd */    if (sbuf.st_size) ts = NIL;	/* non-empty file? */  }  if (ts) return (*ts->dtb->append) (stream,mailbox,af,data);  sprintf (tmp,"Indeterminate mailbox format: %s",mailbox);  mm_log (tmp,ERROR);  return NIL;}/* Dummy mail generate file string * Accepts: temporary buffer to write into *	    mailbox name string * Returns: local file string or NIL if failure */char *dummy_file (char *dst,char *name){  char *s = mailboxfile (dst,name);				/* return our standard inbox */  return (s && !*s) ? strcpy (dst,sysinbox ()) : s;}/* Dummy canonicalize name * Accepts: buffer to write name *	    reference *	    pattern * Returns: T if success, NIL if failure */long dummy_canonicalize (char *tmp,char *ref,char *pat){  char dev[4];				/* initially no device */  dev[0] = dev[1] = dev[2] = dev[3] = '\0';  if (ref) switch (*ref) {	/* preliminary reference check */  case '{':			/* remote names not allowed */    return NIL;			/* disallowed */  case '\0':			/* empty reference string */    break;  default:			/* all other names */    if (ref[1] == ':') {	/* start with device name? */      dev[0] = *ref++; dev[1] = *ref++;    }    break;  }  if (pat[1] == ':') {		/* device name in pattern? */    dev[0] = *pat++; dev[1] = *pat++;    ref = NIL;			/* ignore reference */  }  switch (*pat) {  case '#':			/* namespace names */    if (mailboxfile (tmp,pat)) strcpy (tmp,pat);    else return NIL;		/* unknown namespace */    break;  case '{':			/* remote names not allowed */    return NIL;  case '\\':			/* rooted name */    ref = NIL;			/* ignore reference */    break;  }				/* make sure device names are rooted */  if (dev[0] && (*(ref ? ref : pat) != '\\')) dev[2] = '\\';				/* build name */  sprintf (tmp,"%s%s%s",dev,ref ? ref : "",pat);  ucase (tmp);			/* force upper case */  return T;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -