Example #1
0
static void set_leds(void)
{
	wait_for_output();
	isa->write_io_8(0x60, 0xed);
	wait_for_output();
	isa->write_io_8(0x60, leds);
}
Example #2
0
static void maybe_write(struct thread *thread)
{
    obj_t *fp = thread->fp;
    int fd = fixnum_value(fp[-9]);
    int nfound, res;
    obj_t *old_sp;

    nfound = output_writable(fd);
    if (nfound < 0) {
        if (errno != EINTR) {
            old_sp = pop_linkage(thread);
            thread->sp = old_sp + 2;
            old_sp[0] = obj_False;
            old_sp[1] = make_fixnum(errno);
            do_return(thread, old_sp, old_sp);
        } else {
            wait_for_output(thread, fd, maybe_write);
        }
    } else if (nfound == 0)
        wait_for_output(thread, fd, maybe_write);
    else {
                res = write(fd,
                    buffer_data(fp[-8]) + fixnum_value(fp[-7]),
                    fixnum_value(fp[-6]));
                results(thread, pop_linkage(thread), res, make_fixnum(res));
    }
}
Example #3
0
static int FILE_send_binary(FILE *in, FILE *out)
{
	size_t n;
	char *buf;
	time_t then = time(0) - 1;
	time_t now;

	ftp_set_close_handler();

	if(foo_hookf)
		foo_hookf(&ftp->ti);
	ftp->ti.begin = false;

	clearerr(in);
	clearerr(out);

	buf = (char *)xmalloc(FTP_BUFSIZ);
	while(!feof(in)) {
		n = fread(buf, sizeof(char), FTP_BUFSIZ, in);
		if(n <= 0)
			break;

		if(ftp_sigints() > 0)
			break;

		if(wait_for_output() != 0)
			break;
#ifdef SECFTP
		if(sec_write(fileno(out), buf, n) != n)
			break;
#else
		if(fwrite(buf, sizeof(char), n, out) != n)
			break;
#endif
		ftp->ti.size += n;
		if(foo_hookf) {
			now = time(0);
			if(now > then) {
				foo_hookf(&ftp->ti);
				then = now;
			}
		}
	}
#ifdef SECFTP
	sec_fflush(out);
#endif

	free(buf);

	return maybe_abort(in, out);
}
Example #4
0
static int FILE_send_ascii(FILE *in, FILE *out)
{
	char *buf = (char *)xmalloc(FTP_BUFSIZ);
	int c;
	time_t then = time(0) - 1;
	time_t now;

	ftp_set_close_handler();

	if(foo_hookf)
		foo_hookf(&ftp->ti);
	ftp->ti.begin = false;

	clearerr(in);
	clearerr(out);

	while((c = fgetc(in)) != EOF) {
		if(ftp_sigints() > 0)
			break;

		if(wait_for_output() != 0)
			break;

		if(c == '\n') {
			if(fputc('\r', out) == EOF)
				break;
			ftp->ti.size++;
		}
		if(fputc(c, out) == EOF)
			break;
		ftp->ti.size++;
		if(foo_hookf) {
			now = time(0);
			if(now > then) {
				foo_hookf(&ftp->ti);
				then = now;
			}
		}
	}

	free(buf);

	return maybe_abort(in, out);
}
Example #5
0
static int FILE_send_binary(FILE *in, Socket *out)
{
	time_t then = time(0) - 1;
	time_t now;

	ftp_set_close_handler();

	if(foo_hookf)
		foo_hookf(&ftp->ti);
	ftp->ti.begin = false;

	clearerr(in);
	sock_clearerr_out(out);

	char* buf = xmalloc(FTP_BUFSIZ);
	while(!feof(in)) {
		ssize_t n = fread(buf, sizeof(char), FTP_BUFSIZ, in);
		if(n <= 0)
			break;

		if(ftp_sigints() > 0)
			break;

		if(wait_for_output() != 0)
			break;

    if (sock_write(out, buf, n) != n)
      break;
		ftp->ti.size += n;
		if(foo_hookf) {
			now = time(0);
			if(now > then) {
				foo_hookf(&ftp->ti);
				then = now;
			}
		}
	}
	sock_flush(out);
	free(buf);

	return maybe_abort_out(in, out);
}
Example #6
0
static int FILE_send_ascii(FILE* in, Socket* out)
{
	time_t then = time(0) - 1;
	time_t now;

	ftp_set_close_handler();

	if(foo_hookf)
		foo_hookf(&ftp->ti);
	ftp->ti.begin = false;

	clearerr(in);
	sock_clearerr_out(out);

  int c;
	while((c = fgetc(in)) != EOF) {
		if(ftp_sigints() > 0)
			break;

		if(wait_for_output() != 0)
			break;

		if(c == '\n') {
			if(sock_put(out, '\r') == EOF)
				break;
			ftp->ti.size++;
		}
		if(sock_put(out, c) == EOF)
			break;
		ftp->ti.size++;
		if(foo_hookf) {
			now = time(0);
			if(now > then) {
				foo_hookf(&ftp->ti);
				then = now;
			}
		}
	}

	return maybe_abort_out(in, out);
}