Esempio n. 1
0
File: uuid.c Progetto: bihai/xchain
/*
 * uuid() is called to set the uuid[] bytes for the uuid load command.
 */
extern
void
uuid(
uint8_t *uuid)
{
    struct uuid_command u;
#if !(defined(KLD) && defined(__STATIC__))
    void (*uuid_func)(uint8_t *out);
    NSSymbol nssymbol;
    int fd;
    ssize_t n;

	/*
	 * We would like to just #include <uuid/uuid.h> and but that header
	 * file did not exist on system until Mac OS 10.4 .  So instead we
	 * dynamically lookup uuid_generate_random() and if it is defined we
	 * call it indirectly.
	 */
#if HAVE_NSISSYMBOLNAMEDEFINED
	if(NSIsSymbolNameDefined("_uuid_generate_random")){
	    nssymbol = (void *)NSLookupAndBindSymbol("_uuid_generate_random");
	    uuid_func = NSAddressOfSymbol(nssymbol);
	    uuid_func(uuid);
#else
	if (0){
#endif
	}
	/*
	 * Since we don't have uuid_generate() just read bytes from /dev/urandom
	 */
	else{
	    fd = open("/dev/urandom", O_RDONLY, 0);
	    if(fd == -1){
		system_warning("can't open: /dev/urandom to fill in uuid load "
		    "command (using bytes of zero)");
		memset(uuid, '\0', sizeof(u.uuid));
	    }
	    else{
		n = read(fd, uuid, sizeof(u.uuid));
		if(n != sizeof(u.uuid)){
		    system_warning("can't read bytes from: /dev/urandom to "
			"fill in uuid load command (using bytes of zero)");
		    memset(uuid, '\0', sizeof(u.uuid));
		}
		(void)close(fd);
	    }
	}
#else /* defined(KLD) && defined(__STATIC__) */
	memset(uuid, '\0', sizeof(u.uuid));
#endif /* !(defined(KLD) && defined(__STATIC__)) */
}
Esempio n. 2
0
void
edit_interface_rep::handle_repaint (SI x1, SI y1, SI x2, SI y2) {
  if (is_nil (eb)) apply_changes ();
  if (env_change != 0) {
    system_warning ("Invalid situation (" * as_string (env_change) * ")",
		    "(edit_interface_rep::handle_repaint)");
    return;
  }

  /*
  // In the past, we used the code below in order to hide the trace of
  // a moving cursor. This code is now incorrect, because the rectangle
  // (x1, y1)--(x2, y2) does not correspond to the repaint region clipping.
  // Nevertheless, the code seems no longer necessary. In case it would be,
  // it should be moved somewhere inside the internal repaint routines.
  SI extra= 3 * get_init_int (FONT_BASE_SIZE) * PIXEL / (2*sfactor);
  SI X1= (x1-extra) * sfactor, Y1= (y1-extra) * sfactor;
  SI X2= (x2+extra) * sfactor, Y2= (y2+extra) * sfactor;
  draw_with_stored (rectangle (X1, Y1, X2, Y2));
  */

  // cout << "Repainting\n";
  draw_with_stored (rectangle (x1, y1, x2, y2) * sfactor);
  if (last_change-last_update > 0)
    last_change = texmacs_time ();
  // cout << "Repainted\n";
}