Example #1
0
/**
 * @brief 
 *	display_single_reservation - display a single reservation
 *
 * @param[in] resv - the reservation to display
 * @param[in] how - 1: long form (all resv info)
 * 		      2: print reservation name
 *		      4: short form
 *                  8: increase header width
 * @return Void
 *
 */
void
display_single_reservation(struct batch_status *resv, int how)
{
	char		*queue_name = NULL;
#ifdef NAS /* localmod 075 */
	char		*resv_name = NULL;
#endif /* localmod 075 */
	char		*user = NULL;
	char		*resv_state = NULL;
	char		*resv_start = NULL;
	char		*resv_end = NULL;
	time_t		resv_duration = 0;
	char		*str;
	struct attrl	*attrp = NULL;
	time_t		tmp_time;
	char		tbuf[64];
	char		*fmt = "%a %b %d %H:%M:%S %Y";
	attrp = resv->attribs;

	if (how & DISP_RESV_NAMES) {			/* display just name of the reservation */
		printf("Resv ID: %s\n", resv->name);
	} else if (how & DISP_RESV_DEFAULT) {		/* display short form, default*/
		while (attrp != NULL) {
			if (strcmp(attrp->name, ATTR_queue) == 0)
				queue_name = attrp->value;
			else if (strcmp(attrp->name, ATTR_auth_u) == 0)
				user = attrp->value;
			else if (strcmp(attrp->name, ATTR_resv_start) == 0)
				resv_start = attrp->value;
			else if (strcmp(attrp->name, ATTR_resv_end) == 0)
				resv_end = attrp->value;
			else if (strcmp(attrp->name, ATTR_resv_duration) == 0)
				resv_duration = strtol(attrp->value, NULL, 10);
			else if (strcmp(attrp->name, ATTR_resv_state) == 0)
				resv_state = convert_resv_state(attrp->value, 0);/*short state str*/
#ifdef NAS /* localmod 075 */
			else if (strcmp(attrp->name, ATTR_resv_name) == 0)
				resv_name = attrp->value;
#endif /* localmod 075 */

			attrp = attrp->next;
		}
		if (how & DISP_INCR_WIDTH) {
			printf("%-15.15s %-13.13s %-8.8s %-5.5s ",
#ifdef NAS /* localmod 075 */
				(resv_name ? resv_name : resv->name),
				queue_name, user, resv_state);
#else
				resv->name, queue_name, user, resv_state);
#endif
		} else {
Example #2
0
/**
 * @brief 
 *	display_single_reservation - display a single reservation
 *
 * @param[in] resv - the reservation to display
 * @param[in] how - 0: print reservation name
 *		    1: short form
 *		    2: long form (all resv info)
 *
 * @return Void
 *
 */
void
display_single_reservation(struct batch_status *resv, int how)
{
	char *queue_name = NULL;
#ifdef NAS /* localmod 075 */
	char *resv_name = NULL;
#endif /* localmod 075 */
	char *user = NULL;
	char *resv_state = NULL;
	char *resv_start = NULL;
	char *resv_end = NULL;
	time_t resv_duration = 0;
	char *str;
	struct attrl *attrp = NULL;
	time_t tmp_time;

	attrp = resv->attribs;

	switch (how) {
		case 0:	/* just name */
			printf("Resv ID: %s\n", resv->name);
			break;

		case 1:	/* short form */
			while (attrp != NULL) {
				if (strcmp(attrp->name, ATTR_queue) == 0)
					queue_name = attrp->value;
				else if (strcmp(attrp->name, ATTR_auth_u) == 0)
					user = attrp->value;
				else if (strcmp(attrp->name, ATTR_resv_start) == 0)
					resv_start = attrp->value;
				else if (strcmp(attrp->name, ATTR_resv_end) == 0)
					resv_end = attrp->value;
				else if (strcmp(attrp->name, ATTR_resv_duration) == 0)
					resv_duration = atoi(attrp->value);
				else if (strcmp(attrp->name, ATTR_resv_state) == 0)
					resv_state = convert_resv_state(attrp->value, 0);/*short state str*/
#ifdef NAS /* localmod 075 */
				else if (strcmp(attrp->name, ATTR_resv_name) == 0)
					resv_name = attrp->value;
#endif /* localmod 075 */

				attrp = attrp->next;
			}

			printf("%-10.10s %-8.8s %-8.8s %-5.5s ",
#ifdef NAS /* localmod 075 */
				(resv_name ? resv_name : resv->name),
				queue_name, user, resv_state);
#else
				resv->name, queue_name, user, resv_state);
#endif /* localmod 075 */
			printf("%17.17s / ", convert_time(resv_start));
			printf("%ld / %-17.17s\n", (long)resv_duration, convert_time(resv_end));
			break;

		case 2:
			printf("Resv ID: %s\n", resv->name);
			while (attrp != NULL) {
				if (attrp->resource != NULL)
					printf("%s.%s = %s\n", attrp->name, attrp->resource, attrp->value);
				else {
					if (strcmp(attrp->name, ATTR_resv_state) == 0)
						str = convert_resv_state(attrp->value, 1);  /* long state str */
					else if (strcmp(attrp->name, ATTR_resv_start) == 0 ||
						strcmp(attrp->name, ATTR_resv_end) == 0    ||
						strcmp(attrp->name, ATTR_ctime) == 0      ||
						strcmp(attrp->name, ATTR_mtime) == 0      ||
						strcmp(attrp->name, ATTR_resv_retry) == 0) {
						tmp_time = atoi(attrp->value);
						str = ctime(&tmp_time);
						/* ctime puts in a newline at the end.  We don't want 2 newlines */
						str[strlen(str)-1] = '\0';
					}
					else if (!strcmp(attrp->name, ATTR_resv_execvnodes)) {
						attrp = attrp->next;
						continue;
					}
					else if (!strcmp(attrp->name, ATTR_resv_standing)) {
						attrp = attrp->next;
						continue;
					}
					else if (!strcmp(attrp->name, ATTR_resv_timezone)) {
						attrp = attrp->next;
						continue;
					}
					else if (!strcmp(attrp->name, ATTR_resv_count))
						str = attrp->value;
					else if (!strcmp(attrp->name, ATTR_resv_rrule))
						str = attrp->value;
					else if (!strcmp(attrp->name, ATTR_resv_idx))
						str = attrp->value;
					else
						str = attrp->value;

					printf("%s = %s\n", attrp->name, str);
				}

				attrp = attrp->next;
			}
			printf("\n");
			break;
	}
}