Exemple #1
0
void
done() {
    time_t tvec;

    if (subchild) {
        if (!qflg) {
            char buf[BUFSIZ];
            tvec = time((time_t *)NULL);
            my_strftime(buf, sizeof buf, "%c\n", localtime(&tvec));
            fprintf(fscript, _("\nScript done on %s"), buf);
        }
        (void) fclose(fscript);
        (void) close(master);

        master = -1;
    } else {
        (void) tcsetattr(0, TCSADRAIN, &tt);
        if (!qflg)
            printf(_("Script done, file is %s\n"), fname);
#ifdef HAVE_LIBUTEMPTER
        if (master >= 0)
            utempter_remove_record(master);
#endif
    }

    if(eflg) {
        if (WIFSIGNALED(childstatus))
            exit(WTERMSIG(childstatus) + 0x80);
        else
            exit(WEXITSTATUS(childstatus));
    }
    exit(0);
}
Exemple #2
0
void
done(void) {
	time_t tvec;

	if (subchild) {
		if (!qflg) {
			char buf[BUFSIZ];
			tvec = time((time_t *)NULL);
			my_strftime(buf, sizeof buf, "%c\n", localtime(&tvec));
			fprintf(fscript, _("\nScript done on %s"), buf);
		}
		if (close_stream(fscript) != 0)
			errx(EXIT_FAILURE, _("write error"));
		close(master);

		master = -1;
	} else {
		tcsetattr(STDIN_FILENO, TCSADRAIN, &tt);
		if (!qflg)
			printf(_("Script done, file is %s\n"), fname);
#ifdef HAVE_LIBUTEMPTER
		if (master >= 0)
			utempter_remove_record(master);
#endif
	}

	if(eflg) {
		if (WIFSIGNALED(childstatus))
			exit(WTERMSIG(childstatus) + 0x80);
		else
			exit(WEXITSTATUS(childstatus));
	}
	exit(EXIT_SUCCESS);
}
Exemple #3
0
static void set_call_log_date(LinphoneCallLog *cl, time_t start_time){
	struct tm loctime;
#ifdef _WIN32
#if !defined(_WIN32_WCE)
	loctime=*localtime(&start_time);
	/*FIXME*/
#endif /*_WIN32_WCE*/
#else
	localtime_r(&start_time,&loctime);
#endif
	my_strftime(cl->start_date,sizeof(cl->start_date),"%c",&loctime);
}
Exemple #4
0
static void     
trace_mrt_header (trace_t *tr, time_t tstamp, int type, int subtype)
{   
    char *stime, **cpp;
    
    stime = my_strftime (tstamp, "%D %T");
    trace (TR_TRACE, tr, "TIME: %s\n", stime);
    if ((cpp = S_MRT_MSG_SUBTYPES[type]) != NULL)
        trace (TR_TRACE, tr, "TYPE: %s/%s\n",
               S_MRT_MSG_TYPES[type], cpp[subtype]);
    else  
        trace (TR_TRACE, tr, "TYPE: %s\n", S_MRT_MSG_TYPES[type]);
    Delete (stime);
}   
Exemple #5
0
void
done() {
	time_t tvec;

	if (subchild) {
		if (!qflg) {
			char buf[BUFSIZ];
			tvec = time((time_t *)NULL);
			my_strftime(buf, sizeof buf, "%c\n", localtime(&tvec));
			fprintf(fscript, _("\nScript done on %s"), buf);
		}
		(void) fclose(fscript);
		(void) close(master);
	} else {
		(void) tcsetattr(0, TCSAFLUSH, &tt);
		if (!qflg)
			printf(_("Script done, file is %s\n"), fname);
	}
	exit(0);
}
Exemple #6
0
INT64_T chirp_client_ticket_modify(struct chirp_client * c, const char *name, const char *path, const char *aclmask, time_t stoptime)
{
	char ticket_subject[CHIRP_LINE_MAX];
	char safepath[CHIRP_LINE_MAX];
	ticket_translate(name, ticket_subject);
	url_encode(path, safepath, sizeof(safepath));
	INT64_T result = simple_command(c, stoptime, "ticket_modify %s %s %s\n", ticket_subject, safepath, aclmask);
	if(result == 0) {
		time_t t;
		struct tm tm;
		char now[1024];

		time(&t);
		localtime_r(&t, &tm);
		my_strftime(now, sizeof(now) / sizeof(char), "%c", &tm);

		FILE *file = fopen(name, "a");
		if(file == NULL)
			return -1;
		fprintf(file, "# %s: Set ACL Mask on %s directory = '%s' mask = '%s'.\n", now, c->hostport, path, aclmask);
		fclose(file);
	}
	return result;
}
Exemple #7
0
void
dooutput() {
	register int cc;
	time_t tvec;
	char obuf[BUFSIZ];
	struct timeval tv;
	double oldtime=time(NULL), newtime;
	int flgs = 0;

	(void) close(0);
#ifdef HAVE_LIBUTIL
	(void) close(slave);
#endif
	tvec = time((time_t *)NULL);
	my_strftime(obuf, sizeof obuf, "%c\n", localtime(&tvec));
	if (!qflg)
		fprintf(fscript, _("Script started on %s"), obuf);

	if (die == 0 && child && kill(child, 0) == -1 && errno == ESRCH)
		/*
		 * the SIGCHLD handler could be executed when the "child"
		 * variable is not set yet. It means that the "die" is zero
		 * althought the child process is already done. We have to
		 * check this thing now. Now we have the "child" variable
		 * already initialized. For more details see main() and
		 * finish().  --kzak 07-Aug-2007
		 */
		die = 1;

	do {
		if (die && flgs == 0) {
			/* ..child is dead, but it doesn't mean that there is
			 * nothing in buffers.
			 */
			flgs = fcntl(master, F_GETFL, 0);
			if (fcntl(master, F_SETFL, (flgs | O_NONBLOCK)) == -1)
				break;
		}
		if (tflg)
			gettimeofday(&tv, NULL);

		errno = 0;
		cc = read(master, obuf, sizeof (obuf));

		if (die && errno == EINTR && cc <= 0)
			/* read() has been interrupted by SIGCHLD, try it again
			 * with O_NONBLOCK
			 */
			continue;
		if (cc <= 0)
			break;
		if (tflg) {
			newtime = tv.tv_sec + (double) tv.tv_usec / 1000000;
			fprintf(stderr, "%f %i\n", newtime - oldtime, cc);
			oldtime = newtime;
		}
		(void) write(1, obuf, cc);
		(void) fwrite(obuf, 1, cc, fscript);
		if (fflg)
			(void) fflush(fscript);
	} while(1);

	if (flgs)
		fcntl(master, F_SETFL, flgs);
	done();
}
Exemple #8
0
void
dooutput(FILE *timingfd) {
	ssize_t cc;
	time_t tvec;
	char obuf[BUFSIZ];
	struct timeval tv;
	double oldtime=time(NULL), newtime;
	int flgs = 0;
	ssize_t wrt;
	ssize_t fwrt;

	close(STDIN_FILENO);
#ifdef HAVE_LIBUTIL
	close(slave);
#endif
	tvec = time((time_t *)NULL);
	my_strftime(obuf, sizeof obuf, "%c\n", localtime(&tvec));
	fprintf(fscript, _("Script started on %s"), obuf);

	do {
		if (die && flgs == 0) {
			/* ..child is dead, but it doesn't mean that there is
			 * nothing in buffers.
			 */
			flgs = fcntl(master, F_GETFL, 0);
			if (fcntl(master, F_SETFL, (flgs | O_NONBLOCK)) == -1)
				break;
		}
		if (tflg)
			gettimeofday(&tv, NULL);

		errno = 0;
		cc = read(master, obuf, sizeof (obuf));

		if (die && errno == EINTR && cc <= 0)
			/* read() has been interrupted by SIGCHLD, try it again
			 * with O_NONBLOCK
			 */
			continue;
		if (cc <= 0)
			break;
		if (tflg) {
			newtime = tv.tv_sec + (double) tv.tv_usec / 1000000;
			fprintf(timingfd, "%f %zd\n", newtime - oldtime, cc);
			oldtime = newtime;
		}
		wrt = write(STDOUT_FILENO, obuf, cc);
		if (wrt < 0) {
			warn (_("write failed"));
			fail();
		}
		fwrt = fwrite(obuf, 1, cc, fscript);
		if (fwrt < cc) {
			warn (_("cannot write script file"));
			fail();
		}
		if (fflg)
			fflush(fscript);
	} while(1);

	if (flgs)
		fcntl(master, F_SETFL, flgs);
	if (close_stream(timingfd) != 0)
		errx(EXIT_FAILURE, _("write error"));
	done();
}
Exemple #9
0
size_t
my_strftime(
	char *s,
	size_t maxsize,
	const char *format,
	struct tm *timeptr)
{
#ifdef HAVE_STRFTIME
	return strftime(s, maxsize, format, timeptr);
#else
	char *endp = s + maxsize;
	char *start = s;
	char tbuf[100];
	int i;

	/*
	 * various tables, useful in North America
	 */
	static const char *days_a[] = {
		"Sun", "Mon", "Tue", "Wed",
		"Thu", "Fri", "Sat",
	};
	static const char *days_l[] = {
		"Sunday", "Monday", "Tuesday", "Wednesday",
		"Thursday", "Friday", "Saturday",
	};
	static const char *months_a[] = {
		"Jan", "Feb", "Mar", "Apr", "May", "Jun",
		"Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
	};
	static const char *months_l[] = {
		"January", "February", "March", "April",
		"May", "June", "July", "August", "September",
		"October", "November", "December",
	};
	static const char *ampm[] = { "AM", "PM", };

	if (s == NULL || format == NULL || timeptr == NULL || maxsize == 0)
		return 0;

	if (strchr(format, '%') == NULL && strlen(format) + 1 >= maxsize)
		return 0;

#ifdef HAVE_TZSET
	tzset();
#else
#	ifdef HAVE_SETTZ
	settz();
#	endif /* HAVE_SETTZ */
#endif /* HAVE_TZSET */

	for (; *format && s < endp - 1; format++) {
		tbuf[0] = '\0';
		if (*format != '%') {
			*s++ = *format;
			continue;
		}
		switch (*++format) {
		case '\0':
			*s++ = '%';
			goto out;

		case '%':
			*s++ = '%';
			continue;

		case 'a':	/* abbreviated weekday name */
			strcpy(tbuf, days_a[timeptr->tm_wday]);
			break;

		case 'A':	/* full weekday name */
			strcpy(tbuf, days_l[timeptr->tm_wday]);
			break;

#	ifdef SYSV_EXT
		case 'h':	/* abbreviated month name */
#	endif /* SYSV_EXT */
		case 'b':	/* abbreviated month name */
			strcpy(tbuf, months_a[timeptr->tm_mon]);
			break;

		case 'B':	/* full month name */
			strcpy(tbuf, months_l[timeptr->tm_mon]);
			break;

		case 'c':	/* appropriate date and time representation */
			sprintf(tbuf, "%s %s %2d %02d:%02d:%02d %d",
				days_a[timeptr->tm_wday],
				months_a[timeptr->tm_mon],
				timeptr->tm_mday,
				timeptr->tm_hour,
				timeptr->tm_min,
				timeptr->tm_sec,
				timeptr->tm_year + 1900);
			break;

		case 'd':	/* day of the month, 01 - 31 */
			sprintf(tbuf, "%02d", timeptr->tm_mday);
			break;

		case 'H':	/* hour, 24-hour clock, 00 - 23 */
			sprintf(tbuf, "%02d", timeptr->tm_hour);
			break;

		case 'I':	/* hour, 12-hour clock, 01 - 12 */
			i = timeptr->tm_hour;
			if (i == 0)
				i = 12;
			else if (i > 12)
				i -= 12;
			sprintf(tbuf, "%02d", i);
			break;

		case 'j':	/* day of the year, 001 - 366 */
			sprintf(tbuf, "%03d", timeptr->tm_yday + 1);
			break;

		case 'm':	/* month, 01 - 12 */
			sprintf(tbuf, "%02d", timeptr->tm_mon + 1);
			break;

		case 'M':	/* minute, 00 - 59 */
			sprintf(tbuf, "%02d", timeptr->tm_min);
			break;

		case 'p':	/* am or pm based on 12-hour clock */
			strcpy(tbuf, ampm[((timeptr->tm_hour < 12) ? 0 : 1)]);
			break;

		case 'S':	/* second, 00 - 61 */
			sprintf(tbuf, "%02d", timeptr->tm_sec);
			break;

		case 'w':	/* weekday, Sunday == 0, 0 - 6 */
			sprintf(tbuf, "%d", timeptr->tm_wday);
			break;

		case 'x':	/* appropriate date representation */
			sprintf(tbuf, "%s %s %2d %d",
				days_a[timeptr->tm_wday],
				months_a[timeptr->tm_mon],
				timeptr->tm_mday,
				timeptr->tm_year + 1900);
			break;

		case 'X':	/* appropriate time representation */
			sprintf(tbuf, "%02d:%02d:%02d",
				timeptr->tm_hour,
				timeptr->tm_min,
				timeptr->tm_sec);
			break;

		case 'y':	/* year without a century, 00 - 99 */
			i = timeptr->tm_year % 100;
			sprintf(tbuf, "%d", i);
			break;

		case 'Y':	/* year with century */
			sprintf(tbuf, "%d", timeptr->tm_year + 1900);
			break;

#	ifdef SYSV_EXT
		case 'n':	/* same as \n */
			tbuf[0] = '\n';
			tbuf[1] = '\0';
			break;

		case 't':	/* same as \t */
			tbuf[0] = '\t';
			tbuf[1] = '\0';
			break;

		case 'D':	/* date as %m/%d/%y */
			my_strftime(tbuf, sizeof tbuf, "%m/%d/%y", timeptr);
			break;

		case 'e':	/* day of month, blank padded */
			sprintf(tbuf, "%2d", timeptr->tm_mday);
			break;

		case 'r':	/* time as %I:%M:%S %p */
			my_strftime(tbuf, sizeof tbuf, "%I:%M:%S %p", timeptr);
			break;

		case 'R':	/* time as %H:%M */
			my_strftime(tbuf, sizeof tbuf, "%H:%M", timeptr);
			break;

		case 'T':	/* time as %H:%M:%S */
			my_strftime(tbuf, sizeof tbuf, "%H:%M:%S", timeptr);
			break;
#	endif /* SYSV_EXT */

		default:
			tbuf[0] = '%';
			tbuf[1] = *format;
			tbuf[2] = '\0';
			break;
		}
		if ((i = strlen(tbuf))) {
			if (s + i < endp - 1) {
				strcpy(s, tbuf);
				s += i;
			} else
				return 0;
		}
	}
out:
	if (s < endp && *format == '\0') {
		*s = '\0';
		return (size_t) (s - start);
	} else
		return 0;

#endif /* HAVE_STRFTIME */
}
int main(int argc, char **argv)
{
    if (argc != 4)
    {
        usage();
    }

    url = argv[1];
    char *username = argv[2];
    char *password = argv[3];

    xmlInitParser();
    xen_init();
    curl_global_init(CURL_GLOBAL_ALL);

#define CLEANUP                                 \
    do {                                        \
        xen_session_logout(session);            \
        curl_global_cleanup();                  \
        xen_fini();                             \
        xmlCleanupParser();                     \
    } while(0)                                  \

    
    xen_session *session =
        xen_session_login_with_password(call_func, NULL, username, password,
                                        xen_api_latest_version);

    const char* ALL_CLASSES = "*";
    char *all_classes = calloc(1, sizeof(all_classes));
    strcpy(all_classes, ALL_CLASSES);

    struct xen_string_set *classes = xen_string_set_alloc(1);
    classes->contents[0] = all_classes;
    
    xen_event_register(session, classes);
    xen_string_set_free(classes);

    if (!session->ok)
    {
        print_error(session);
        CLEANUP;
        return 1;
    }

    while (true)
    {
        struct xen_event_record_set *events;
        if (!xen_event_next(session, &events))
        {
            print_error(session);
            CLEANUP;
            return 1;
        }

        for (size_t i = 0; i < events->size; i++)
        {
            xen_event_record *ev = events->contents[i];
            char time[256];
            struct tm *tm = localtime(&ev->timestamp);
            my_strftime(time, 256, "%c, local time", tm);
            printf("Event received: ID = %"PRId64", %s.\n", ev->id, time);
            switch (ev->operation)
            {
            case XEN_EVENT_OPERATION_ADD:
                printf("%s created with reference %s.\n", ev->class, ev->ref);
                break;

            case XEN_EVENT_OPERATION_DEL:
                printf("%s with reference %s deleted.\n", ev->class, ev->ref);
                break;

            case XEN_EVENT_OPERATION_MOD:
                printf("%s with reference %s modified.\n", ev->class, ev->ref);
                break;
            default:
                assert(false);
            }
        }

        xen_event_record_set_free(events);
    }

    CLEANUP;

    return 0;
}
Exemple #11
0
INT64_T chirp_client_ticket_register(struct chirp_client * c, const char *name, const char *subject, time_t duration, time_t stoptime)
{
	char command[PATH_MAX * 2 + 4096];
	char ticket_subject[CHIRP_LINE_MAX];
	FILE *shell;
	int status;

	if(access(name, R_OK) != 0)
		return -1;	/* the 'name' argument must be a client ticket filename */

	ticket_translate(name, ticket_subject);

	/* BEWARE: we don't bother to escape the filename, a user could
	 * provide a malicious filename that makes us execute code we don't want to.
	 */
	sprintf(command, "if [ -r '%s' ]; then sed '/^\\s*#/d' < '%s' | openssl rsa -pubout 2> /dev/null; exit 0; else exit 1; fi", name, name);
	shell = popen(command, "r");
	if(!shell)
		return -1;

	/* read the ticket file (public key) */
	char *ticket = xxrealloc(NULL, 4096);
	size_t read, length = 0;
	while((read = fread(ticket + length, 1, 4096, shell)) > 0) {
		length += read;
		ticket = xxrealloc(ticket, length + 4096);
	}
	if(ferror(shell)) {
		status = pclose(shell);
		errno = ferror(shell);
		return -1;
	}
	assert(feof(shell));
	status = pclose(shell);
	if(status) {
		errno = EINVAL;
		return -1;
	}

	if(subject == NULL)
		subject = "self";
	INT64_T result = send_command(c, stoptime, "ticket_register %s %llu %zu\n", subject, (unsigned long long) duration, length);
	if(result < 0) {
		free(ticket);
		return result;
	}
	result = link_write(c->link, ticket, length, stoptime);
	free(ticket);
	if(result != (int) length) {
		c->broken = 1;
		errno = ECONNRESET;
		return -1;
	}

	result = get_result(c, stoptime);

	if(result == 0) {
		time_t t;
		struct tm tm;
		char now[1024];
		char expiration[1024];

		time(&t);
		localtime_r(&t, &tm);
		my_strftime(now, sizeof(now) / sizeof(char), "%c", &tm);
		t += duration;
		localtime_r(&t, &tm);
		my_strftime(expiration, sizeof(expiration) / sizeof(char), "%c", &tm);

		FILE *file = fopen(name, "a");
		if(file == NULL)
			return -1;
		fprintf(file, "# %s: Registered with %s as \"%s\". Expires on %s\n", now, c->hostport, subject, expiration);
		fclose(file);
	}
	return result;
}
Exemple #12
0
void
dooutput() {
    register ssize_t cc;
    time_t tvec;
    char obuf[BUFSIZ];
    struct timeval tv;
    double oldtime=time(NULL), newtime;
    int flgs = 0;
    ssize_t wrt;
    size_t fwrt;

    (void) close(0);
#ifdef HAVE_LIBUTIL
    (void) close(slave);
#endif
    tvec = time((time_t *)NULL);
    my_strftime(obuf, sizeof obuf, "%c\n", localtime(&tvec));
    fprintf(fscript, _("Script started on %s"), obuf);

    do {
        if (die && flgs == 0) {
            /* ..child is dead, but it doesn't mean that there is
             * nothing in buffers.
             */
            flgs = fcntl(master, F_GETFL, 0);
            if (fcntl(master, F_SETFL, (flgs | O_NONBLOCK)) == -1)
                break;
        }
        if (tflg)
            gettimeofday(&tv, NULL);

        errno = 0;
        cc = read(master, obuf, sizeof (obuf));

        if (die && errno == EINTR && cc <= 0)
            /* read() has been interrupted by SIGCHLD, try it again
             * with O_NONBLOCK
             */
            continue;
        if (cc <= 0)
            break;
        if (tflg) {
            newtime = tv.tv_sec + (double) tv.tv_usec / 1000000;
            fprintf(stderr, "%f %zd\n", newtime - oldtime, cc);
            oldtime = newtime;
        }
        wrt = write(1, obuf, cc);
        if (wrt < 0) {
            int err = errno;
            fprintf (stderr, _("%s: write error: %s\n"),
                     progname, strerror(err));
            fail();
        }
        fwrt = fwrite(obuf, 1, cc, fscript);
        if (fwrt < cc) {
            int err = errno;
            fprintf (stderr, _("%s: cannot write script file, error: %s\n"),
                     progname, strerror(err));
            fail();
        }
        if (fflg)
            (void) fflush(fscript);
    } while(1);

    if (flgs)
        fcntl(master, F_SETFL, flgs);
    done();
}
int
main(int argc, char **argv)
{
	struct ncp_conn *conn;
	int opt;
	long err;
	struct ncp_file_server_info info;
	struct ncp_bindery_object user;
	time_t login_time;
	int i;
	int do_help = 0;
	int print_addr = 0;
	int print_id = 0;
	int print_file = 0;
	int print_techinfo = 0;
	int print_details = 0;
	int print_dos = 0;
	int print_semaphores = 0;
	int print_stat = 0;
	int print_stat_k = 0;

	setlocale(LC_ALL, "");
	bindtextdomain(NCPFS_PACKAGE, LOCALEDIR);
	textdomain(NCPFS_PACKAGE);
	
	progname = argv[0];

	if ((conn = ncp_initialize(&argc, argv, 1, &err)) == NULL)
	{
		com_err(argv[0], err, _("when initializing"));
		goto finished;
	}
	while ((opt = getopt(argc, argv, "h?aqftdDsiH")) != EOF)
	{
		switch (opt)
		{
		case 'h':
			if (!do_help) {
				do_help = 1;
				break;
			}
		case '?':
			help();
			goto finished;
		case 'a':
			print_addr = 1;
			break;
		case 'q':
			print_id = 1;
			break;
		case 'f':
			print_file = 1;
			break;
		case 't':
			print_techinfo = 1;
			break;
		case 'd':
			print_details = 1;
			break;
		case 'D':
			print_dos = 1;
			break;
		case 's':
			print_semaphores = 1;
			break;
		case 'i':
			print_stat = 1;
			break;
		case 'H':
			print_stat_k = 2;
			break;
		default:
			usage();
			goto finished;
		}
	}
	if (do_help) {
		if (!print_stat || print_stat_k) {
			help();
			goto finished;
		}
		print_stat_k = 1;
	}
	if (ncp_get_file_server_information(conn, &info) != 0)
	{
		perror(_("Could not get server information"));
		ncp_close(conn);
		return 1;
	}
	
	if (isatty(1))
	{
		switch (print_id * 2 + print_addr) {
			case 0:
			printf(_("\n%-6s%-21s%-12s\n"
			       "---------------------------------------------"
			       "------\n"),
			       _("Conn"),
			       _("User name"),
			       _("Login time"));
			break;
			case 1:
			printf(_("\n%-6s%-21s%-27s%-12s\n"
			       "---------------------------------------------"
			       "---------------------------------\n"),
			       _("Conn"),
			       _("User name"),
			       _("Station Address"),
			       _("Login time"));
			break;
			case 2:
			printf(_("\n%-6s%-9s%-21s%-12s\n"
			       "------------------------------------------------------"
			       "------\n"),
			       _("Conn"),
			       _("ObjectID"),
			       _("User name"),
			       _("Login time"));
			break;
			case 3:
			printf(_("\n%-6s%-9s%-21s%-27s%-12s\n"
			       "------------------------------------------------------"
			       "---------------------------------\n"),
			       _("Conn"),
			       _("ObjectID"),
			       _("User name"),
			       _("Station Address"),
			       _("Login time"));
			break;
		}
	}
	for (i = 0; i <= info.MaximumServiceConnections; i++)
	{
		char name[49];
		name[48] = '\0';
		if (ncp_get_stations_logged_info(conn, i, &user,
						 &login_time) != 0)
		{
			continue;
		}
		memcpy(name, user.object_name, 48);
		str_trim_right(name, ' ');
		if (print_id)
			printf(_("%4d: %08X %-20s "), i, (unsigned int)user.object_id, name);
		else
			printf(_("%4d: %-20s "), i, name);

		if (print_addr != 0)
		{
			union ncp_sockaddr addr;
			u_int8_t conn_type;

			memset(&addr, 0, sizeof(addr));
			if (ncp_get_internet_address(conn, i, &addr.any, &conn_type)) {
				printf("XXXXXXXX:YYZZYYXXTTXX:QQQQ");
			} else switch (addr.any.sa_family) {
#ifdef NCP_IPX_SUPPORT
				case AF_IPX:	ipx_print_saddr(&addr.ipx);
						break;
#endif
#ifdef NCP_IN_SUPPORT
				case AF_INET:	{
							char q[30];
							u_int32_t sa = ntohl(addr.inet.sin_addr.s_addr);
							sprintf(q, "%d.%d.%d.%d/%d", (u_int8_t)(sa >> 24), (u_int8_t)(sa >> 16),
										     (u_int8_t)(sa >> 8), (u_int8_t)(sa), 
										     ntohs(addr.inet.sin_port));
     							printf("%-26s", q);
     						}
     						break;
#endif
				default:	printf("%-26s", _("Unknown format"));
						break;
			}
			printf(" ");
		}
		{
			char text_login_time[200];
			struct tm* tm;
			
			tm = localtime(&login_time);
			my_strftime(text_login_time, sizeof(text_login_time), "%c", tm);
			printf("%s\n", text_login_time);
		}
		if (print_file) {
			OPEN_FILE_CONN_CTRL ofcc;
			OPEN_FILE_CONN ofc;
			nuint16 ih;
			
			ih = 0;
			while (!NWScanOpenFilesByConn2(conn, i, &ih, &ofcc, &ofc)) {
				char tmp[1000];
				NWCCODE err2;
				char* fname;
				
				err2 = ncp_ns_get_full_name(conn, NW_NS_DOS, print_dos ? NW_NS_DOS : ofc.nameSpace, 1, 
					ofc.volNumber, ofc.dirEntry, NULL, 0, tmp, sizeof(tmp));
				if (err2) {
					fname = ofc.fileName;
				} else {
					fname = tmp;
				}
				if (print_techinfo) {
					printf(_("        File: (%02X:%08X) %s\n"), ofc.volNumber, ofc.dirEntry, fname);
				} else {
					printf(_("        File: %s\n"), fname);
				}
				if (print_details) {
					static const char* lock_bits[] = {N_("locked"), N_("open shareable"),
					                                 N_("logged"), N_("open normal"),
									 N_("rsvd"), N_("rsvd"),
									 N_("TTS locked"), N_("TTS")};
					static const char* acc_bits[] = {N_("read"), N_("write"),
									 N_("deny read"), N_("deny write"),
									 N_("detached"), N_("TTS holding detach"),
									 N_("TTS holding open"), N_("rsvd")};
					char lstr[200];
					char accstr[200];
					char* l2str;
					const char* nmstr;
					char* p;
					int li;
					
					p = NULL;
					for (li = 0; li < 8; li++) {
						if (ofc.lockType & (1 << li)) {
							if (p) {
								strcpy(p, ", ");
								p = strchr(p, 0);
							} else {
								p = lstr;
							}
							strcpy(p, _(lock_bits[li]));
							p = strchr(p, 0);
						}
					}
					if (!p) {
						strcpy(p, _("unlocked"));
					}
					switch (ofc.lockFlag) {
						case 0x00:	l2str = _("Not locked"); break;
						case 0xFE:	l2str = _("Locked by a file lock"); break;
						case 0xFF:	l2str = _("Locked by Begin Share File Set"); break;
						default:	l2str = _("Unknown lock state"); break;
					}
					nmstr = ncp_namespace_to_str(NULL, ofc.nameSpace);
					p = NULL;
					for (li = 0; li < 8; li++) {
						if (ofc.accessControl & (1 << li)) {
							if (p) {
								strcpy(p, ", ");
								p = strchr(p, 0);
							} else {
								p = accstr;
							}
							strcpy(p, _(acc_bits[li]));
							p = strchr(p, 0);
						}
					}
					if (!p) {
						strcpy(p, _("unlocked"));
					}
					if (print_techinfo) {
						printf(_("          Task: %-5u             Lock:   (%02X) %s\n"), ofc.taskNumber, ofc.lockType, lstr);
						printf(_("          Fork count: %-3u                 (%02X) %s\n"), ofc.forkCount, ofc.lockFlag, l2str);
						printf(_("          Namespace:  (%02X) %-5s  Access: (%02X) %s\n"), ofc.nameSpace, nmstr, ofc.accessControl, accstr);
					} else {
						printf(_("          Task: %-5u        Lock:   %s\n"), ofc.taskNumber, lstr);
						printf(_("          Fork count: %-3u            %s\n"), ofc.forkCount, l2str);
						printf(_("          Namespace:  %-5s  Access: %s\n"), nmstr, accstr);
					}
				}
			}
		}
		if (print_semaphores) {
			CONN_SEMAPHORES css;
			CONN_SEMAPHORE cs;
			nuint16 ih;
			
			ih = 0;
			while (!NWScanSemaphoresByConn(conn, i, &ih, &cs, &css) && cs.openCount) {
				printf(_("        Semaphore: %s\n"), cs.semaphoreName);
				if (print_details) {
					printf(_("          Task: %-5u     Value: %-5d     Open Count: %-5u\n"),
						cs.taskNumber, cs.semaphoreValue, cs.openCount);
				}
			}
		}
		if (print_stat) {
			NWFSE_USER_INFO fseui;
			
			err = NWGetUserInfo(conn, i, NULL, &fseui);
			if (!err) {
#define ui fseui.userInfo				
				if (print_techinfo) {
					printf(_("        Type: (%02X) %-9.9s Status: (%08X) %s\n"),
						ui.connServiceType, conntype(ui.connServiceType),
						ui.status, connstatus(ui.status));
					printf(_("        Use count: %-9u ExpTime: %08X  ObjType: %08X\n"), ui.useCount,
						ui.expirationTime, ui.objType);
					printf(_("        Transaction flag: %9u  Filler: %18u\n"),
						ui.transactionFlag, ui.filler);
					printf(_("        Logical lock threshold: %3u  Record lock threshold: %3u\n"),
						ui.logicalLockThreshold, ui.recordLockThreshold);
					printf(_("        File write flags:      0x%02X  File write state:     0x%02X\n"),
						ui.fileWriteFlags, ui.fileWriteState);
					printf(_("        File lock count: %10u  Record lock count: %7u\n"),
						ui.fileLockCount, ui.recordLockCount);
				} else {
					printf(_("        Type: %-14s Status: %s\n"),
						conntype(ui.connServiceType),
						connstatus(ui.status));
				}
				print_value(print_stat_k, _("Bytes read:"), _("B"), ui.totalBytesRead);
				print_value(print_stat_k, _("Bytes written:"), _("B"), ui.totalBytesWritten);
				print_value(print_stat_k, _("Requests:"), "", ui.totalRequests);
				if (ui.heldRequests || ui.heldBytesRead || ui.heldBytesWritten) {
					print_value(print_stat_k, _("Held bytes read:"), _("B"), ui.heldBytesRead);
					print_value(print_stat_k, _("Held bytes written:"), _("B"), ui.heldBytesWritten);
					print_value(print_stat_k, _("Held requests:"), "", ui.heldRequests);
				}
#undef ui
			}
		}
	}

finished:
	ncp_close(conn);
	return 0;
}