Exemple #1
0
void *dumpTTyStat(int fd){
	Sgttyb *sg;
	int err;
	sg = (Sgttyb*)STRUCT_ALLOC(sizeof(Sgttyb));
	err = TC_getattr(fd,sg);
	return sg;
}
Exemple #2
0
/* Allocates a new object pool node for the given object header. */
static ObjPoolNode * objpoolnode_new(ObjPoolNode * next, void * data) {
  ObjPoolNode * self  = STRUCT_ALLOC(ObjPoolNode);
  if(!self) return NULL;
  self->next          = next;
  self->data          = data;
  return self;
}
Exemple #3
0
static Sgttyb *STTY0(int fd,const char *command){
	Sgttyb *tty;

	if( NO_TTY ) return 0;
	tty = (Sgttyb*)STRUCT_ALLOC( sizeof(*tty) );
	cached_gtty(fd,tty);
	settty(fd,command);
	return tty;
}
Exemple #4
0
char *strpool_add(StrPool *pool, char *s)
{
    char *p;
    if(!pool || !s)
        return NULL;
	if(!pool->dict)
		pool->dict = STRUCT_ALLOC(*pool->dict);
    p = strpool_find(pool,s);
    if(p)
        return p;
	p = strdup(s);
    hash_insert(pool->dict,p,p);
    return p;
}
Exemple #5
0
static int cached_gtty(int fd,Sgttyb *buf){
	int xfd = (0 <= fd && fd < MAXFD) ? fd: MAXFD-1;
	int rcode;

	if( SG_ispeed(&cur_sgttyb[xfd]) == 0 ){
		rcode = TCgetattr(fd,(Sgttyb*)&cur_sgttyb[xfd].SG);
#ifdef hpux
		cur_sgttyb[xfd].SG_lflag = ICANON;
#endif
	}

	if(initial_stty == 0){
		initial_stty = (Sgttyb *)
			STRUCT_ALLOC( sizeof(*initial_stty) );
		*initial_stty = cur_sgttyb[xfd];
	}
	*buf = cur_sgttyb[xfd];
	return 0;
}
Exemple #6
0
int strpool_read(char *fn, StrPool *pool, SerializeCtxt *ctxt)
{
	StrBlock *sb;
	char *s;
	char *strblock = 0;
	int n;
	int i;
	File *fp = absfile_open_read(fn);

    if(!pool || !fp)
        return -1;

	assert(!pool->dict);
	pool->dict = STRUCT_ALLOC(*pool->dict);

	if(!int_binread(fp,&pool->dict->n_used)
	   || !array_binread(fp,&pool->dict->elts,&pool->dict->n_elts)) // read the hashtable
		return -1;

	if(!array_binread(fp,&strblock,&n)) // blob of string data
		return -1;
	
	sb = calloc(sizeof(*sb),1);
	sb->block = strblock;
	sb->n = n;
	ap_push(&pool->strblocks,sb);

	// fixup
	s = strblock;
	for(i = 0; i < pool->dict->n_elts; ++i)
	{
		HashNode *node = pool->dict->elts + i;
		if(!node->key)
			continue;
		serialize_fixup_add_ptr(ctxt,node->key,s);
		node->key = s;
		s += strlen(s)+1;
		assert(s <= strblock + n);
	}

	return 0;
}
Exemple #7
0
/** Allocates a console. */
BBConsole * bbconsole_alloc() {
  return STRUCT_ALLOC(BBConsole);
}
Exemple #8
0
/* Allocates a widget */
BBWidget * bbwidget_allocate() {
  return STRUCT_ALLOC(BBWidget);
}
Exemple #9
0
Camera * camera_alloc() {
  return STRUCT_ALLOC(Camera);
}
Exemple #10
0
/** Allocates a Hatab. */
Hatab * hatab_alloc() {
  return STRUCT_ALLOC(Hatab);
}
Exemple #11
0
/* Allocates a new pail. */
static Pail * pail_alloc() {
  return STRUCT_ALLOC(Pail);
}
Exemple #12
0
/* Allocate a new hash tab pair. */
HatabPair * hatabpair_alloc() {
  return STRUCT_ALLOC(HatabPair);  
}
Exemple #13
0
/** Allocates a Thing. */
Thing * thing_alloc() {
  return STRUCT_ALLOC(Thing);
}