Esempio n. 1
0
void
main(int argc, char **argv)
{
	char           *s_dpyname, *d_dpyname;
	/* Source and destination displays */
	Display        *source_d, *dest_d;
	/* Source and destination Windows */
	Window          s_w, d_w;

	if (argc < 3) {
		fprintf(stderr, "Usage:  %s d_display d_id\n", argv[0]);
		exit(1);
	}
	d_dpyname = argv[1];
	sscanf(argv[2], "0x%x", &d_w);

	s_dpyname = getenv("DISPLAY");
	if (s_dpyname == NULL) {
		s_dpyname = ":0";
	}
	source_d = XOpenDisplay(s_dpyname);
	if (source_d == NULL) {
		fprintf(stderr, "Blah, can't open source display: %s\n", s_dpyname);
		exit(10);
	}
	dest_d = XOpenDisplay(d_dpyname);
	if (source_d == NULL) {
		fprintf(stderr, "Blah, can't open destination display: %s\n",
			d_dpyname);
		exit(10);
	}
	s_w = openInputWindow(source_d);

	docopy(source_d, s_w, dest_d, d_w);
}
Esempio n. 2
0
	void vlong::load( unsigned * a, unsigned n )
	{
		docopy();
		value->clear();
		for (unsigned i=0;i<n;i+=1)
			value->set(i,a[i]);
	}
Esempio n. 3
0
    const SourceString &SourceString::operator=(const SourceString &other)
    {
        if (this != &other) {
            Source::operator=(other);
            delete[] source;
            docopy(other);
        }

        return *this;
    }
Esempio n. 4
0
int main(void)
{
    getarguments();
    openpar();
    openfile();
    docopy();
    cleanup(NULL, 0);
    
    return 0;
}
Esempio n. 5
0
	vlong& vlong::operator +=(const vlong& x)
	{
		if ( negative == x.negative )
		{
			docopy();
			value->add( *x.value );
		}
		else if ( value->cf( *x.value ) >= 0 )
		{
			docopy();
			value->subtract( *x.value );
		}
		else
		{
			vlong tmp = *this;
			*this = x;
			*this += tmp;
		}
		return *this;
	}
Esempio n. 6
0
File: xfer.C Progetto: bougyman/sfs
int
main (int argc, char **argv)
{
  setprogname (argv[0]);

  bool opt_force = false;
  int ch;
  while ((ch = getopt (argc, argv, "ft:")) != -1)
    switch (ch) {
    case 'f':
      opt_force = true;
      break;
    case 't':
      if (!convertint (optarg, &timeout))
	usage ();
      break;
    default:
      usage ();
      break;
    }
  argc -= optind;
  argv += optind;
  if (argc != 2)
    usage ();

  struct sigaction sa;
  bzero (&sa, sizeof (sa));
  sa.sa_handler = cleanup;
#ifdef SA_RESETHAND
  sa.sa_flags = SA_NODEFER | SA_RESETHAND;
#endif /* SA_RESETHAND */
  sigaction (SIGINT, &sa, NULL);
  sigaction (SIGTERM, &sa, NULL);
  sigaction (SIGALRM, &sa, NULL);

  if (!opt_force && !outofdate (argv[0], argv[1]))
    exit (0);

  docopy (argv[0], argv[1]);
  warn ("copied %s -> %s\n", argv[0], argv[1]);
  return 0;
}
Esempio n. 7
0
void MainScreen(char *InstallName) {
   char fromdrive[2], todrive[3], tmp1[3], topath[9], tmp[9], drive[2];
   EditClass EditToDrive(WINDOW_LEFT+26,WINDOW_TOP+3,1, DEF_DRIVE);
   EditClass EditPath(WINDOW_LEFT+32,WINDOW_TOP+4,8, DEF_DIRECTORY);
   char ok;

   sprintf(fromdrive, "%c", getdisk()+'A');
   strcpy(todrive, "C");
   strcpy(tmp, "\\EDIR");
   _setcursortype(_NORMALCURSOR);
   putxy(WINDOW_LEFT+3,WINDOW_TOP+2,0,STANDARD,"Installing from drive %c:", fromdrive[0]);
   putxy(WINDOW_LEFT+3,WINDOW_TOP+3,0,STANDARD,"Install to what drive?  :");
   putxy(WINDOW_LEFT+3,WINDOW_TOP+4,0,STANDARD,"Install to what directory?  :", topath);
   EditToDrive.Display();
   EditPath.Display();
   putxy(WINDOW_LEFT+30, WINDOW_TOP+4, 0, STANDARD, "%c", toupper(todrive[0]));
   strcpy(todrive, EditToDrive.GetInput());
   putxy(WINDOW_LEFT+30, WINDOW_TOP+4, 0, STANDARD, "%c", toupper(todrive[0]));
   strcpy(tmp, EditPath.GetInput());
   descr(NULL);
   sprintf(topath, "%c:%s", todrive[0], tmp);
   putxy(WINDOW_LEFT+3,WINDOW_TOP+5,0,STANDARD,"Is this ok (Y/N/Q)? ");
   ok = (int) tolower((char) getch());
   if(ok == 121) {
      if(CheckDrive(todrive[0], "Invalid disk drive to copy files to") == 1) {
	 _setcursortype(_NOCURSOR);
	 putxy(WINDOW_LEFT+3,WINDOW_TOP+5,0,STANDARD,"Please wait...installing files...");
	 sprintf(tmp1, "%c:", fromdrive[0]);
	 docopy(tmp1, topath, InstallName);
	 getch();
      }
      else MainScreen(InstallName);
   }
   else if(ok == 113);
   else {
      putxy(WINDOW_LEFT+3,WINDOW_TOP+5,0,STANDARD,"%s", space(20));
      MainScreen(InstallName);
   }
}
Esempio n. 8
0
int main(int argc, char **argv)
{
	int c;
	int len;
	char buf[128];
	KeySym keysym;
	int oldx = 0;
	int oldy = 0;
	int resolution = -1;
	int pageno = 1;
	fd_set fds;
	int width = -1;
	int height = -1;
	fz_context *ctx;
	struct timeval tmo_at;
	struct timeval now;
	struct timeval tmo;
	struct timeval *timeout;
	struct timeval tmo_advance_delay;

	ctx = fz_new_context(NULL, NULL, FZ_STORE_DEFAULT);
	if (!ctx)
	{
		fprintf(stderr, "cannot initialise context\n");
		exit(1);
	}

	while ((c = fz_getopt(argc, argv, "p:r:b:")) != -1)
	{
		switch (c)
		{
		case 'p': password = fz_optarg; break;
		case 'r': resolution = atoi(fz_optarg); break;
		case 'b': fz_set_aa_level(ctx, atoi(fz_optarg)); break;
		default: usage();
		}
	}

	if (argc - fz_optind == 0)
		usage();

	filename = argv[fz_optind++];

	if (argc - fz_optind == 1)
		pageno = atoi(argv[fz_optind++]);

	pdfapp_init(ctx, &gapp);

	winopen();

	if (resolution == -1)
		resolution = winresolution();
	if (resolution < MINRES)
		resolution = MINRES;
	if (resolution > MAXRES)
		resolution = MAXRES;

	gapp.transitions_enabled = 1;
	gapp.scrw = DisplayWidth(xdpy, xscr);
	gapp.scrh = DisplayHeight(xdpy, xscr);
	gapp.resolution = resolution;
	gapp.pageno = pageno;

	pdfapp_open(&gapp, filename, 0);

	FD_ZERO(&fds);

	signal(SIGHUP, signal_handler);

	tmo_at.tv_sec = 0;
	tmo_at.tv_usec = 0;

	while (!closing)
	{
		while (!closing && XPending(xdpy) && !transition_dirty)
		{
			XNextEvent(xdpy, &xevt);

			switch (xevt.type)
			{
			case Expose:
				dirty = 1;
				break;

			case ConfigureNotify:
				if (gapp.image)
				{
					if (xevt.xconfigure.width != reqw ||
						xevt.xconfigure.height != reqh)
						gapp.shrinkwrap = 0;
				}
				width = xevt.xconfigure.width;
				height = xevt.xconfigure.height;

				break;

			case KeyPress:
				len = XLookupString(&xevt.xkey, buf, sizeof buf, &keysym, NULL);

				if (!gapp.isediting)
					switch (keysym)
					{
					case XK_Escape:
						len = 1; buf[0] = '\033';
						break;

					case XK_Up:
						len = 1; buf[0] = 'k';
						break;
					case XK_Down:
						len = 1; buf[0] = 'j';
						break;

					case XK_Left:
						len = 1; buf[0] = 'b';
						break;
					case XK_Right:
						len = 1; buf[0] = ' ';
						break;

					case XK_Page_Up:
						len = 1; buf[0] = ',';
						break;
					case XK_Page_Down:
						len = 1; buf[0] = '.';
						break;
					}
				if (xevt.xkey.state & ControlMask && keysym == XK_c)
					docopy(&gapp, XA_CLIPBOARD);
				else if (len)
					onkey(buf[0]);

				onmouse(oldx, oldy, 0, 0, 0);

				break;

			case MotionNotify:
				oldx = xevt.xmotion.x;
				oldy = xevt.xmotion.y;
				onmouse(xevt.xmotion.x, xevt.xmotion.y, 0, xevt.xmotion.state, 0);
				break;

			case ButtonPress:
				onmouse(xevt.xbutton.x, xevt.xbutton.y, xevt.xbutton.button, xevt.xbutton.state, 1);
				break;

			case ButtonRelease:
				copytime = xevt.xbutton.time;
				onmouse(xevt.xbutton.x, xevt.xbutton.y, xevt.xbutton.button, xevt.xbutton.state, -1);
				break;

			case SelectionRequest:
				onselreq(xevt.xselectionrequest.requestor,
					xevt.xselectionrequest.selection,
					xevt.xselectionrequest.target,
					xevt.xselectionrequest.property,
					xevt.xselectionrequest.time);
				break;

			case ClientMessage:
				if (xevt.xclient.format == 32 && xevt.xclient.data.l[0] == WM_DELETE_WINDOW)
					closing = 1;
				break;
			}
		}

		if (closing)
			continue;

		if (width != -1 || height != -1)
		{
			pdfapp_onresize(&gapp, width, height);
			width = -1;
			height = -1;
		}

		if (dirty || dirtysearch)
		{
			if (dirty)
				winblit(&gapp);
			else if (dirtysearch)
				winblitsearch(&gapp);
			dirty = 0;
			transition_dirty = 0;
			dirtysearch = 0;
			pdfapp_postblit(&gapp);
		}

		if (showingpage && !tmo_at.tv_sec && !tmo_at.tv_usec)
		{
			tmo.tv_sec = 2;
			tmo.tv_usec = 0;

			gettimeofday(&now, NULL);
			timeradd(&now, &tmo, &tmo_at);
		}

		if (XPending(xdpy) || transition_dirty)
			continue;

		timeout = NULL;

		if (tmo_at.tv_sec || tmo_at.tv_usec)
		{
			gettimeofday(&now, NULL);
			timersub(&tmo_at, &now, &tmo);
			if (tmo.tv_sec <= 0)
			{
				tmo_at.tv_sec = 0;
				tmo_at.tv_usec = 0;
				timeout = NULL;
				showingpage = 0;
				winrepaint(&gapp);
			}
			else
				timeout = &tmo;
		}

		if (advance_scheduled)
		{
			gettimeofday(&now, NULL);
			timersub(&tmo_advance, &now, &tmo_advance_delay);
			if (tmo_advance_delay.tv_sec <= 0)
			{
				/* Too late already */
				onkey(' ');
				onmouse(oldx, oldy, 0, 0, 0);
				advance_scheduled = 0;
			}
			else if (timeout == NULL)
			{
				timeout = &tmo_advance_delay;
			}
			else
			{
				struct timeval tmp;
				timersub(&tmo_advance_delay, timeout, &tmp);
				if (tmp.tv_sec < 0)
				{
					timeout = &tmo_advance_delay;
				}
			}
		}

		FD_SET(x11fd, &fds);
		if (select(x11fd + 1, &fds, NULL, NULL, timeout) < 0)
		{
			if (reloading)
			{
				winreloadfile(&gapp);
				reloading = 0;
			}
		}
		if (!FD_ISSET(x11fd, &fds))
		{
			if (timeout == &tmo_advance_delay)
			{
				onkey(' ');
				onmouse(oldx, oldy, 0, 0, 0);
				advance_scheduled = 0;
			}
			else
			{
				tmo_at.tv_sec = 0;
				tmo_at.tv_usec = 0;
				timeout = NULL;
				showingpage = 0;
				winrepaint(&gapp);
			}
		}
	}

	cleanup(&gapp);

	return 0;
}
Esempio n. 9
0
void windocopy(pdfapp_t *app)
{
	docopy(app, XA_PRIMARY);
}
Esempio n. 10
0
int main(int argc, char *argv[]) {
	const struct option long_options[] = {
		{
			"help\0usage",
			no_argument,
			NULL,
			'h'
		},
		{
			"source\0source file",
			required_argument,
			NULL,
			's'
		},
		{
			"destination\0destination file",
			required_argument,
			NULL,
			'd'
		},
		{
			NULL,
			0,
			NULL,
			0
		}
	};
	char optstring[1024];
	char *source = NULL;
	char *destination = NULL;
	int c;

	if (!getoptutil_short_from_long(long_options, optstring, sizeof(optstring))) {
		fprintf(stderr, "Too  many options");
		exit(1);
	}
	while (
		(c = getopt_long(
			argc,
			argv,
			optstring,
			long_options,
			NULL
		)) != -1
	) {
		switch(c) {
			case 's':
				source = optarg;
			break;
			case 'd':
				destination = optarg;
			break;
			case 'h':
			default:
				getoptutil_usage(stdout, argv[0], "", long_options);
				exit(1);
			break;
		}
	}

	if (
		optind < argc ||
		source == NULL ||
		destination == NULL
	) {
		fprintf(stderr, "Invalid usage\n");
		exit(1);
	}

	{
		struct stat info;

		if (stat(source, &info) == -1) {
			perror("stat failed");
			exit(1);
		}

		printf(
			(
				"Information for %s:\n"
				" uid=%d\n"
				" gid=%d\n"
				" size=%ld\n"
			),
			source,
			info.st_uid,
			info.st_gid,
			info.st_size
		);
	}


	return !docopy(source, destination);
}
Esempio n. 11
0
/*this is the main routine*/
void doshell()
{
	char line[80];

	/*run forever - the shell shouldn't end*/
	while(1==1)
	{
		/*read in a line*/
		printstring("SHELL>\0");
		readstring(line);

		/*match it against each possible command*/
		/*if the user presses return, ignore it*/
		if (line[0]==0xd)
			continue;
		else if (iscommand(line,"CLS\0")==1)
			doclear();
		else if (iscommand(line,"cls\0")==1)
			doclear();
		else if (iscommand(line,"COPY\0")==1)
			docopy();
		else if (iscommand(line,"copy\0")==1)
			docopy();
		else if (iscommand(line,"CREATE \0")==1)
			docreate(line);
		else if (iscommand(line,"create \0")==1)
			docreate(line);
		else if (iscommand(line,"DELETE \0")==1)
			dodelete(line);
		else if (iscommand(line,"delete \0")==1)
			dodelete(line);
		else if (iscommand(line,"DIR\0")==1)
			dodir();
		else if (iscommand(line,"dir\0")==1)
			dodir();
		else if (iscommand(line,"EXEC \0")==1)
			doexecute(line,1);
		else if (iscommand(line,"exec \0")==1)
			doexecute(line,1);
		else if (iscommand(line,"EXECBACK \0")==1)
			doexecute(line,0);
		else if (iscommand(line,"execback \0")==1)
			doexecute(line,0);
		else if (iscommand(line,"HELP\0")==1)
			dohelp();
		else if (iscommand(line,"help\0")==1)
			dohelp();
		else if (line[0]=='?')
			dohelp();
		else if (iscommand(line,"TYPE \0")==1)
			dotype(line);
		else if (iscommand(line,"type \0")==1)
			dotype(line);
		else if (iscommand(line,"KILL \0")==1)
			dokill(line);
		else if (iscommand(line,"kill \0")==1)
			dokill(line);
		else if (iscommand(line,"mkdir \0")==1)
			domkdir(line);
		else if (iscommand(line,"MKDIR\0")==1)
			domkdir(line);	
		else if (iscommand(line,"FORMAT\0")==1)
			doFormat();	
		else if (iscommand(line,"format\0")==1)
			doFormat();	
		else if (iscommand(line,"remove\0")==1)
			doRemove(line);	
		else if (iscommand(line,"REMOVE\0")==1)
			doRemove(line);	
		else if (iscommand(line,"list\0")==1)
			doList();	
		else if (iscommand(line,"LIST\0")==1)
			doList();	
		else if (iscommand(line,"count\0")==1)
			doCount(line);
		else if (iscommand(line,"WRITE\0")==1)
				doCreateFile(line);	
		else if (iscommand(line,"write\0")==1)
			doCreateFile(line);
		else if (iscommand(line,"READ\0")==1)
				doEcho(line);	
		else if (iscommand(line,"read\0")==1)
			doEcho(line);
		else
			printstring("Command not found\r\n\0");
		printstring("\r\n\0");
	}
}
Esempio n. 12
0
static int
docopynul(char *buf, size_t *bufoffp, size_t buflen)
{

	return docopy(buf, bufoffp, buflen, "", 1);
}
Esempio n. 13
0
static int
docopystr(char *buf, size_t *bufoffp, size_t buflen, const char *datap)
{

	return docopy(buf, bufoffp, buflen, datap, strlen(datap));
}
Esempio n. 14
0
void
dofile(const char *name)
{
  int		fd;
  struct stat	st;
  char		*s;

  if ((fd=open(name, O_RDWR))<0)
    swrite("?");
  else if (fstat(fd, &st) ||
	   !S_ISREG(st.st_mode))
    ex("open");
  else
    swrite_free(md5sum(fd, st.st_size));

  s	= sread();
  switch (*s)
    {
    case 'o':
      close(fd);
      free(s);
      return;

    case 'a':
      if (fd<0)
	ex("!fd");
      if (lseek(fd, st.st_size, SEEK_SET)!=st.st_size)
	ex("lseek");
      break;

    case 'w':
      if (fd<0)
	ex("!fd");
      close(fd);
      fd	= -1;
      free(s);
      s	= newname(name);
      if (rename(name, s))
	ex("name");
    case 'c':
      if (fd>=0)
	ex("fd!");
      mkparent(name);
      if ((fd=open(name, O_WRONLY|O_CREAT|O_EXCL, 0644))<0)
	ex("create");
      break;

    default:
      ex("prot");
    }
  free(s);

  swrite("OK");

  if (docopy(sock, fd, 1))
    ex("broken stream");
  if (close(fd))
    ex("close");

  swrite("NEXT");
}