Esempio n. 1
0
static int add_to_backup_list(char ***backups, int *b, const char *tok)
{
	const char *str=NULL;
	if(!(str=get_backup_str(tok))) return 0;
	if(!(*backups=(char **)realloc(*backups, ((*b)+2)*sizeof(char *)))
	  || !((*backups)[*b]=strdup(str)))
	{
		log_out_of_memory(__FUNCTION__);
		return -1;
	}
	(*backups)[(*b)+1]=NULL;
	(*b)++;
	return 0;
}
Esempio n. 2
0
static void show_all_backups(char *toks[], int t, int *x, int col)
{
	int i=2;
	char msg[256]="";
	for(; i<t; i++)
	{
		char *str=NULL;
		str=get_backup_str(toks[i], FALSE);

		if(i==2)
		{
		  snprintf(msg, sizeof(msg), "Backup list: %s", str);
		  print_line(msg, (*x)++, col);
		}
		else
		{
		  snprintf(msg, sizeof(msg), "             %s", str);
		  print_line(msg, (*x)++, col);
		}
	}
}
Esempio n. 3
0
// Returns 1 if it printed a line, 0 otherwise.
static int summary(char **toks, int t, int count, int row, int col)
{
	char msg[1024]="";

	if(*(toks[1])==STATUS_IDLE)
	{
		if(t>2)
		  snprintf(msg, sizeof(msg),
			"%-14.14s %-14s last backup: %s",
			toks[0], "idle",
			get_backup_str(toks[2], TRUE));
		else
		  snprintf(msg, sizeof(msg), "%-14.14s %-14s",
			toks[0], "idle");
	}
	if(*(toks[1])==STATUS_SERVER_CRASHED)
	{
		if(t>2)
		  snprintf(msg, sizeof(msg),
			"%-14.14s %-14s last backup: %s",
			toks[0], "server crashed",
				get_backup_str(toks[2], TRUE));
		else
		  snprintf(msg, sizeof(msg), "%-14.14s %-14s",
			toks[0], "server crashed");
	}
	if(*(toks[1])==STATUS_CLIENT_CRASHED)
	{
		if(t>2)
		  snprintf(msg, sizeof(msg),
			"%-14.14s %-14s last backup: %s",
			toks[0], "client crashed",
				get_backup_str(toks[2], TRUE));
		else
		  snprintf(msg, sizeof(msg), "%-14.14s %-14s",
			toks[0], "client crashed");
	}
	if(*(toks[1])==STATUS_RUNNING)
	{
		char f[64]="";
		char b[64]="";
		const char *s="";
		if(t<3) return 0;
		s=running_status_to_text(*(toks[2]));
		if(t>3 && *(toks[3]))
		{
			unsigned long long a=0;
			unsigned long long b=0;
			unsigned long long c=0;
			unsigned long long d=0;
			unsigned long long t=0;
	  		unsigned long long p=0;
			if(!extract_ul(toks[3], &a, &b, &c, &d, &t))
			{
				if(d) p=(t*100)/d;
				snprintf(f, sizeof(f), "%llu/%llu %llu%%",
					t, d, p);
			}
		}
		if(t>16 && *(toks[16]) && strcmp(toks[16], "0"))
		{
			//snprintf(b, sizeof(b), "%s bytes%s", toks[14],
			//	bytes_to_human_str(toks[14]));
			snprintf(b, sizeof(b), "%s",
				bytes_to_human_str(toks[16]));
		}
		snprintf(msg, sizeof(msg), "%-14.14s %-14s %s%s",
			toks[0], s, f, b);
	}
	if(*msg)
	{
		print_line(msg, count, col);
		return 1;
	}
	return 0;
}