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

📄 support.c

📁 一个功能全面的电子邮件客户端
💻 C
📖 第 1 页 / 共 2 页
字号:
		first=ptemp;		while (first->prev) {			first=first->prev;		}		return first;	} else {		return NULL;	}}Llist *llist_detach (Llist *begin, void *data) {	Llist *seek=llist_seek (begin, data);	return llist_detach_by_node (seek);}int llist_set_node_name (Llist *node, char *name) {	if (node) {		if (name) {			node->name=strdup (name);		} else {			return FALSE;		}		return TRUE;	} else {		return FALSE;	}	return FALSE; /* to satisfy the pedants */}Llist *llist_remove (Llist *begin, void *data) {	Llist *seek=llist_seek (begin, data);	return llist_remove_by_node (seek);}Llist *llist_blow_away (Llist *begin) {  Llist *seek=begin;  Llist *ntemp;  while( seek ) {    ntemp = seek ;    seek = seek -> next ;    free( ntemp ) ;  }  return NULL;}Llist *llist_blow_away_and_destroy (Llist *begin) {	Llist *seek=begin, *dseek;	while (seek) {		dseek=seek->next;		if (seek->data) free (seek->data);		if (seek->name) free (seek->name);		free (seek);		seek=dseek;	}	return NULL;}int llist_length (Llist *begin) {	int count=0;	Llist *seek;	for (seek=begin;seek;seek=seek->next) 		count++;	return count;}void save_string_final (char *filename, SaveStringInfo *info) {	FILE *fp=fopen (filename, "w");	if (!fp) {		insert_warning (_("Unable to write file %s: Permission denied\n"), filename);		return;	}	if ( fwrite ((void *)info->data, info->size, 1*sizeof(char), fp) != 1) {		insert_warning (_("Unable to write file %s: Quota full or no space left on device\n"), filename);	} else {	  insert_message( "The file has been successfully saved as '%s'.\n", filename ) ;	}	fclose (fp);}void save_string_cancel_yesno (GtkWidget *widget, gpointer data) {	SaveStringInfo *info=(SaveStringInfo *)data;	if (info) {		if (info->data) free (info->data);		if (info->filename) free (info->filename);		free (info);	}	gtk_widget_destroy (lookup_widget (widget, "yesno"));}void save_string_accept_yesno (GtkWidget *widget, gpointer data) {	SaveStringInfo *info=(SaveStringInfo *)data;	save_string_final (info->filename, info);	save_string_cancel_yesno (widget, data);}void save_string_accept (GtkWidget *widget, char *filename, gpointer data) {	GtkWidget *yesno;	SaveStringInfo *info=(SaveStringInfo *)data;	if (access (filename, W_OK)==0) {		info->filename=filename;		yesno=create_yesno (_("File Exists"), _("Do you want to overwrite the file?"), GTK_SIGNAL_FUNC (save_string_accept_yesno), data);		gtk_signal_disconnect_by_func (GTK_OBJECT (lookup_widget (yesno, "cancel_button")), GTK_SIGNAL_FUNC (destroy_yesno), NULL);		gtk_signal_connect (GTK_OBJECT (lookup_widget (yesno, "cancel_button")), "clicked",		                    GTK_SIGNAL_FUNC (save_string_cancel_yesno), data);		gtk_widget_show (yesno);		gtk_widget_destroy (lookup_widget (widget, "win"));		return;	}	save_string_final (filename, info);	if (info->data) free (info->data);	free (info);		free (filename);	gtk_widget_destroy (lookup_widget (widget, "win"));}void save_string_cancel (GtkWidget *widget, gpointer data) {	SaveStringInfo *info=(SaveStringInfo *)data;	if (info->data) free (info->data);	free (info);	gtk_widget_destroy (widget);}void save_string (char *data, unsigned long size, char *filename) {	SaveStringInfo *info=(SaveStringInfo *)calloc (1, sizeof (SaveStringInfo));	GtkWidget *widget;	info->data=data;	info->size=size;	widget=file_selector_new (NULL, filename, GTK_SIGNAL_FUNC (save_string_accept), 	                          GTK_SIGNAL_FUNC (save_string_cancel), (gpointer)info);	gtk_widget_show (widget);}GList *pop_create_glist () {	GList *ret=NULL;	PopAccount *pop=first_popaccount ();	while (pop) {		ret = g_list_append (ret, pop->name);		pop=pop->next;	}	return ret;}/* * deq_strtok() behaves like strtok() (on spaces only) but dequotes text * * rules: "xxx" => xxx *        "x'x" => x'x *        'x"x' => x"x *        'x\x' => x\x *        "x\x" => xx *         x\x  => xx * no environment variable interpretation */static	char	*deq_strtok(char *text){static	char	*Last = NULL;char		*rv;char		*source;char		*dest;int		quot;	if (text == NULL)		text = Last;	if (text == NULL)		return NULL;		/* at end */	for (rv = text; *rv; ++rv) {		if (*rv != ' ')			break;	}	if (!*rv) {		/* at end */		Last = NULL;		return NULL;	}	for (source = dest = rv, quot = 0; *source; ++source) {		if (!quot && (*source == '"' || *source == '\'')) {			quot = *source;			continue;		}		if (quot && *source == quot) {			quot = 0;			continue;		}		if (!quot && *source == ' ')			break;	/* end on unquoted space */		if ((!quot || quot == '"') && *source == '\\') {			++source;			if (*source == 0)				break;		/* oops */		}		*dest++ = *source;	}	if (*source == 0) {		Last = NULL;	} else {		*source++ = 0;		Last = source;	}	*dest = 0;	return rv;}/* * splits line into array of char*s, *will modify contents of line* */static	char	**split_line(char *line){int	count;int	ndx;char	*cp;char	**args;	for (count = 0, cp = line; *cp; ++cp) {		if (*cp == ' ') {			++count;		}	}	/*	 * no spaces => 1 parameter plus null, so we always need two extra	 * entries	 *	 * it's possible this will allocate too many entries, but deq_strtok()	 * will ignore extra spaces, and we don't care about too many trailing	 * nulls	 */	count += 2;	if ((args = calloc(count, sizeof(*args))) == NULL)		return NULL;	for (ndx = 0, cp = line; ndx < count - 1; ++ndx, cp = NULL) {		args[ndx] = deq_strtok(cp);		if (args[ndx] == NULL)			break;	/* early at end, that's okay */	}	args[ndx] = NULL;	return args;}/* * spawn_with_status runs a command like system() except allows background * execution with status sent to status window (this last waiting on new * IPC) */void	spawn_with_status(char *cmd, int wait){char	*cp = strdup(cmd);char	**args = NULL;int	pid;#define	DEBUGFORK 0	if (cp == NULL || ((args = split_line(cp)) == NULL)) {		insert_warning("memory error in spawn\n");	}	pid = fork();	if (pid) {		free(args);		free(cp);		/*		 * always wait for child, but child may immediately exit		 */		waitpid(pid, NULL, 0);		return;	}	if (!wait) {		pid = fork();		if (pid) {			_exit(0);		}	}	/*	 * in subshell, only error is failure to exec	 */	execvp(args[0], args);	cp = strerror(errno);	/*	 * THIS MUST WRITE BACK TO STATUS MESSAGE QUEUE	 */	printf("STATUS MESSAGE: %s: %s\n", args[0], cp);	printf("                (will write to status message in new IPC)\n");	_exit(0);}/* * This function replaces a macro that did its best to properly * format a name.  Only this much improves on it.  In stead of * just building a first name, last name as best as is possible, * we will build it ready for inclusion into an rfc822 header * as to, cc, bcc, which includes the actual email address. */intformat_name( int bufSize, char *dest, char *first, char *last, char *email ){  int retValue ;  int length ;  retValue = 0 ;  length = 0 ;  if( first ) length += strlen( first ) ;  if( last ) length += strlen( last ) ;  if( email ) length += strlen( email ) ;  /* This compare accounts for the extra quotes, space, and brackets */  dest[0] = 0x00 ;  if( bufSize < length+6 ) retValue = 1 ;  else    {      if( !first && !last && !email )	{	  strcat( dest, "\"Unknown Recipient\" <postmaster@localhost>" ) ;	}      else	{	  if( first || last ) 	    {#if 0	      strcat( dest, "\"" ) ;#endif	      if( first ) strcat( dest, first ) ;	      if( last ) 		{		  if( first ) strcat( dest, " " ) ;		  strcat( dest, last ) ;		}#if 0	      strcat( dest, "\"" ) ;#endif	    }	  if ((email) && (first || last))	    {	      strcat( dest, " <" ) ;	      strcat( dest, email ) ;	      strcat( dest, ">" ) ;	    }          else if (email)	    {	      strcat (dest, email);	    }	}    }  return retValue ;}voidright_align (GtkWidget *widget){	gtk_misc_set_alignment (GTK_MISC (widget), 1, 0.5);}

⌨️ 快捷键说明

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