コード例 #1
0
ファイル: bat_table.c プロジェクト: Clay-Birkett/monetdb
/* returns table rids, for the given select ranges */
static rids *
rids_select( sql_trans *tr, sql_column *key, void *key_value_low, void *key_value_high, ...)
{
	va_list va;
	BAT *b = NULL, *s = NULL, *d = NULL;
	sql_column *nc;
	void *nvl, *nvh;
	rids *rs = ZNEW(rids);
	sql_dbat *bat = key->t->data;

	/* special case, key_value_low and high NULL, ie return all */
	if (bat->dbid) 
		d = store_funcs.bind_del(tr, key->t, RDONLY);
	if (key_value_low || key_value_high) {
		va_start(va, key_value_high);
		while ((nc = va_arg(va, sql_column *)) != NULL) {
			nvl = va_arg(va, void *);
			nvh = va_arg(va, void *);
	
			b = full_column(key, d, s);
			if (s)
				bat_destroy(s);
			if (!key_value_low)
				key_value_low = ATOMnilptr(b->ttype);
			if (!key_value_high)
				key_value_high = ATOMnilptr(b->ttype);
			s = BATselect(b, key_value_low, key_value_high);
			bat_destroy(b);
			key = nc;
			key_value_low = nvl;
			key_value_high = nvh;
		}
		va_end(va);
	}
コード例 #2
0
ファイル: z-file.c プロジェクト: antoine-from-rgrd/Minimal
/*
 * Open file 'fname', in mode 'mode', with filetype 'ftype'.
 * Returns file handle or NULL.
 */
ang_file *file_open(const char *fname, file_mode mode, file_type ftype)
{
	ang_file *f = ZNEW(ang_file);
	char buf[1024];

	(void)ftype;

	/* Get the system-specific path */
	path_parse(buf, sizeof(buf), fname);

	switch (mode)
	{
		case MODE_WRITE:  f->fh = fopen(buf, "wb"); break;
		case MODE_READ:   f->fh = fopen(buf, "rb"); break;
		case MODE_APPEND: f->fh = fopen(buf, "a+"); break;
		default:          f->fh = fopen(buf, "__");
	}

	if (f->fh == NULL)
	{
		FREE(f);
		return NULL;
	}

	f->fname = string_make(buf);
	f->mode = mode;

	if (mode != MODE_READ && file_open_hook)
		file_open_hook(buf, ftype);

	return f;
}
コード例 #3
0
ファイル: mcontext.c プロジェクト: panyam/mango
/**
 * Creates a new mango context.  This is required to do practially anything
 * with/in mango.  Particular utilities can be over ridden by callers (ie
 * specialised strings etc.
 *
 * Passing NULL would create default values.
 */
MangoContext *mango_context_new(MangoStringFactory *    string_factory,
                                MangoLibrary *          filter_library,
                                MangoLibrary *          var_library,
                                MangoLibrary *          tag_library,
                                MangoTemplateLoader *   tmpl_loader)
{
    MangoContext *ctx = ZNEW(MangoContext);

    if (string_factory == NULL)
        string_factory = (MangoStringFactory *)mango_rcstringfactory_default();

    if (filter_library == NULL)
        filter_library = mango_filter_library_singleton();

    if (var_library == NULL)
        var_library = mango_var_library_singleton();

    if (tag_library == NULL)
        tag_library = mango_tagparser_library_singleton();

    ctx->string_factory = OBJ_INCREF(string_factory);
    ctx->filter_library = OBJ_INCREF(filter_library);
    ctx->var_library    = OBJ_INCREF(var_library);
    ctx->tag_library    = OBJ_INCREF(tag_library);
    ctx->tmpl_loader    = OBJ_INCREF(tmpl_loader);

    return ctx;
}
コード例 #4
0
ファイル: sql_mvc.c プロジェクト: f7753/monetdb
mvc *
mvc_create(int clientid, backend_stack stk, int debug, bstream *rs, stream *ws)
{
	int i;
	mvc *m;

 	m = ZNEW(mvc);
	if (mvc_debug)
		fprintf(stderr, "#mvc_create\n");

	m->errstr[0] = '\0';
	/* if an error exceeds the buffer we don't want garbage at the end */
	m->errstr[ERRSIZE-1] = '\0';

	m->qc = qc_create(clientid, 0);
	m->sa = NULL;

	m->params = NULL;
	m->sizevars = MAXPARAMS;
	m->vars = NEW_ARRAY(sql_var, m->sizevars);
	m->topvars = 0;
	m->frame = 1;
	m->use_views = 0;
	m->argmax = MAXPARAMS;
	m->args = NEW_ARRAY(atom*,m->argmax);
	m->argc = 0;
	m->sym = NULL;

	m->rowcnt = m->last_id = m->role_id = m->user_id = -1;
	m->timezone = 0;
	m->clientid = clientid;

	m->emode = m_normal;
	m->emod = mod_none;
	m->reply_size = 100;
	m->debug = debug;
	m->cache = DEFAULT_CACHESIZE;
	m->caching = m->cache;
	m->history = 0;

	m->label = 0;
	m->cascade_action = NULL;
	for(i=0;i<MAXSTATS;i++)
		m->opt_stats[i] = 0;

	store_lock();
	m->session = sql_session_create(stk, 1 /*autocommit on*/);
	store_unlock();

	m->type = Q_PARSE;
	m->pushdown = 1;

	m->result_id = 0;
	m->results = NULL;

	scanner_init(&m->scanner, rs, ws);
	return m;
}
コード例 #5
0
ファイル: sql_list.c プロジェクト: sekcheong/monetdb
list *
list_new(sql_allocator *sa, fdestroy destroy)
{
	list *l = (sa)?SA_ZNEW(sa, list):ZNEW(list);

	l->sa = sa;
	l->destroy = destroy;
	l->h = l->t = NULL;
	l->cnt = 0;
	l->ht = NULL;
	MT_lock_init(&l->ht_lock, "sa_ht_lock");
	return l;
}
コード例 #6
0
ファイル: z-file.c プロジェクト: DaPortlyJester/angband
/*
 * Open file 'fname', in mode 'mode', with filetype 'ftype'.
 * Returns file handle or NULL.
 */
ang_file *file_open(const char *fname, file_mode mode, file_type ftype)
{
	ang_file *f = ZNEW(ang_file);
	char buf[1024];

	(void)ftype;

	/* Get the system-specific path */
	path_parse(buf, sizeof(buf), fname);

	switch (mode) {
		case MODE_WRITE: { 
			if (ftype == FTYPE_SAVE) {
				/* open only if the file does not exist */
				int fd;
				fd = open(buf, O_CREAT | O_EXCL | O_WRONLY | O_BINARY, S_IRUSR | S_IWUSR);
				if (fd < 0) {
					/* there was some error */
					f->fh = NULL;
				} else {
					f->fh = fdopen(fd, "wb");
				}
			} else {
				f->fh = fopen(buf, "wb");
			}
			break;
		}
		case MODE_READ:
			f->fh = fopen(buf, "rb");
			break;
		case MODE_APPEND:
			f->fh = fopen(buf, "a+");
			break;
		default:
			assert(0);
	}

	if (f->fh == NULL)
	{
		FREE(f);
		return NULL;
	}

	f->fname = string_make(buf);
	f->mode = mode;

	if (mode != MODE_READ && file_open_hook)
		file_open_hook(buf, ftype);

	return f;
}
コード例 #7
0
ファイル: z-file.c プロジェクト: cinereaste/angband
/*
 * Open file 'fname', in mode 'mode', with filetype 'ftype'.
 * Returns file handle or NULL.
 */
ang_file *file_open(const char *fname, file_mode mode, file_type ftype)
{
	ang_file *f = ZNEW(ang_file);
	char buf[1024];

	(void)ftype;

	/* Get the system-specific path */
	path_parse(buf, sizeof(buf), fname);

	switch (mode)
	{
		case MODE_WRITE:  f->fh = fopen(buf, "wb"); break;
		case MODE_READ:   f->fh = fopen(buf, "rb"); break;
		case MODE_APPEND: f->fh = fopen(buf, "a+"); break;
		default:          f->fh = fopen(buf, "__");
	}

	if (f->fh == NULL)
	{
		FREE(f);
		return NULL;
	}

	f->fname = string_make(buf);
	f->mode = mode;

#ifdef MACH_O_CARBON
	extern void fsetfileinfo(cptr path, u32b fcreator, u32b ftype);

	/* OS X uses its own kind of filetypes */
	if (mode != MODE_READ)
	{
		u32b mac_type = 'TEXT';

		if (ftype == FTYPE_RAW) mac_type = 'DATA';
		else if (ftype == FTYPE_SAVE) mac_type = 'SAVE';

		fsetfileinfo(buf, 'A271', mac_type);
	}
#endif /* MACH_O_CARBON */

#if defined(RISCOS) && 0
	/* do something for RISC OS here? */
	if (mode != MODE_READ)
		File_SetType(n, ftype);
#endif

	return f;
}
コード例 #8
0
ファイル: z-file.c プロジェクト: cinereaste/angband
ang_dir *my_dopen(const char *dirname)
{
	WIN32_FIND_DATA fd;
	HANDLE h;
   	ang_dir *dir;
	
	/* Try to open it */
	h = FindFirstFile(format("%s\\*", dirname), &fd);

	/* Abort */
	if (h == INVALID_HANDLE_VALUE)
		return NULL;

	/* Set up the handle */
	dir = ZNEW(ang_dir);
	dir->h = h;
	dir->first_file = string_make(fd.cFileName);

	/* Success */
	return dir;
}
コード例 #9
0
ファイル: z-file.c プロジェクト: cinereaste/angband
ang_dir *my_dopen(const char *dirname)
{
	ang_dir *dir;
	DIR *d;

	/* Try to open the directory */
	d = opendir(dirname);
	if (!d) return NULL;

	/* Allocate memory for the handle */
	dir = ZNEW(ang_dir);
	if (!dir) 
	{
		closedir(d);
		return NULL;
	}

	/* Set up the handle */
	dir->d = d;
	dir->dirname = string_make(dirname);

	/* Success */
	return dir;
}
コード例 #10
0
ファイル: res_table.c プロジェクト: jaiminpan/Monetdb
res_table *
res_table_create(sql_trans *tr, int res_id, int nr_cols, int type, res_table *next, void *O)
{
	BAT *order = (BAT*)O;
	res_table *t = ZNEW(res_table);

	(void) tr;
	t->id = res_id;

	t->query_type = type;
	t->nr_cols = nr_cols;
	t->cur_col = 0;
	t->cols = NEW_ARRAY(res_col, nr_cols);
	memset((char*) t->cols, 0, nr_cols * sizeof(res_col));
	t->tsep = t->rsep = t->ssep = t->ns = NULL;

	t->order = 0;
	if (order) {
		t->order = order->batCacheid;
		bat_incref(t->order);
	} 
	t->next = next;
	return t;
}
コード例 #11
0
ファイル: bat_table.c プロジェクト: MonetDB/MonetDB
/* returns table rids, for the given select ranges */
static rids *
rids_select( sql_trans *tr, sql_column *key, const void *key_value_low, const void *key_value_high, ...)
{
	va_list va;
	BAT *b = NULL, *r = NULL, *s = NULL;
	rids *rs = ZNEW(rids);
	const void *kvl = key_value_low, *kvh = key_value_high;
	/* if pointers are equal, make it an inclusive select */
	bool hi = key_value_low == key_value_high;

	if(!rs)
		return NULL;
	s = delta_cands(tr, key->t);
	if (s == NULL) {
		GDKfree(rs);
		return NULL;
	}
	b = full_column(tr, key);
	if (b == NULL) {
		bat_destroy(s);
		GDKfree(rs);
		return NULL;
	}
	if (!kvl)
		kvl = ATOMnilptr(b->ttype);
	if (!kvh && kvl != ATOMnilptr(b->ttype))
		kvh = ATOMnilptr(b->ttype);
	if (key_value_low) {
		BAThash(b);
		r = BATselect(b, s, kvl, kvh, true, hi, false);
		bat_destroy(s);
		s = r;
	}
	full_destroy(key, b);
	if (s == NULL) {
		GDKfree(rs);
		return NULL;
	}
	if (key_value_low || key_value_high) {
		va_start(va, key_value_high);
		while ((key = va_arg(va, sql_column *)) != NULL) {
			kvl = va_arg(va, void *);
			kvh = va_arg(va, void *);
	
			b = full_column(tr, key);
			if (!kvl)
				kvl = ATOMnilptr(b->ttype);
			if (!kvh && kvl != ATOMnilptr(b->ttype))
				kvh = ATOMnilptr(b->ttype);
			assert(kvh);
			r = BATselect(b, s, kvl, kvh, true, hi, false);
			bat_destroy(s);
			s = r;
			full_destroy(key, b);
			if (s == NULL) {
				GDKfree(rs);
				va_end(va);
				return NULL;
			}
		}
		va_end(va);
	}
コード例 #12
0
ファイル: txmsg.c プロジェクト: LuoZhongYao/yabps
unsigned abcsp_sendmsg(ABCSP_TXMSG *msg, unsigned chan, unsigned rel)
{
        TXMSG *m;

        /* Reject all traffic if the choke is applied.

        BCSP-LE messages are transmitted from code below this entry point.

        The choke should be applied at the "mux" layer.  Applying it here
        means that if the choke is turned on while messages are queued for
        transmission then those messages will drain out.  This is strictly
        incorrect, but this won't harm any real system as the choke is only
        set TRUE by abcsp library init, so any peer is going to see
        disrupted traffic for a while anyway.  (Ideally, bcsp-le messages
        from here will tell the peer that we've restarted, so it should
        reinit and rechoke.) */

        if(abcsp_txrx.choke) {
                ABCSP_EVENT(ABCSP_EVT_TX_CHOKE_DISCARD);
                return(0);
                }

        /* Parameter sanity checks. */
        if(rel > 1 || chan < 2 || chan > 15 || msg == (ABCSP_TXMSG*)(NULL))
                return(0);

        /* We queue enough reliable messages to fill the WINSIZE window. */
        if(rel && msgq_len(relq) >= ABCSP_TXWINSIZE) {
                ABCSP_EVENT(ABCSP_EVT_TX_WINDOW_FULL_DISCARD);
                return(0);
                }

        /* Package the message. */
        if((m = ZNEW(TXMSG)) == (TXMSG*)(NULL))
                return(0);
        m->m = msg;
        m->chan = chan;

        if(rel) {
                /* We've already checked the reliable queue has room. */
                m->seq = msgq_txseq;
                msgq_txseq = incrmod8(msgq_txseq);
                msgq_add(&relq, m);
                }
        else {
                /* The unreliable channel is biased towards supporting
                sco, for which the data has to be fresh.  The queue
                holds only one message, so we displace any message that's
                already in the queue. */

                (void) msgq_pop_destroy(&unrelq);

                msgq_add(&unrelq, m);
                }

        /* Tell external code that it needs to call abcsp_pumptxmsgs(). */
        ABCSP_REQ_PUMPTXMSGS();

        /* Report message accepted. */
        return(1);
}
コード例 #13
0
ファイル: readpref.c プロジェクト: blubaron/tilesetpref
sint32 tsbReadPrefFile(char *filename)
{
  // read 2 lines. If the second character of the second line is a colon, then
  // process this line as an assigned entry, and check the previous line for a
  // note in the comment and for the placeholder symbol. If the third character
  // of the second line is a colon, clear any assignment for the id, and check
  // the previous line for a note.
  int bytesread=0, i;
  char *pChar, *pEnd;
  sint32 id = 0;
  char line[256];
  sint32 x,y;
  char letter;
  int idsegments;

  tsbInfoEntry *entry;
  FILE *fp = file_open(filename, MODE_READ, FTYPE_TEXT);
  if (!fp) {
    return -2;
  }
  // read each line, and see if we have an entry for it
  while(file_getl(fp, line,160)) {
    bytesread = strlen(line);
    if (bytesread < 2) {
      continue;
    }
    idsegments = 2;
    pChar = line;
    if ((line[1] == ':') || (strncmp(pChar,"GF:",3) == 0)) {
      letter = line[0];
      if (letter == '?') {
        continue;
      } else
      if (letter == '#') {
        continue;
      } else
      if (letter == '%') {
        // build the file path/name that this will use
        char *n,*p,*file;
        int len = strlen(filename);
        file = (char*) malloc(sizeof(char)*(len+1));
        strncpy(file, filename, len);
        file[len] = 0;
        p = NULL;
        n = file;
        while (n = strstr(n+1,"graf")) {
          p = n;
        }
        if (strstr(pChar,"flvr")) {
          if (p) {
            strncpy(p,"flvr",4);
            tsbReadFlvrFile(file);
          } else {
            tsbReadFlvrFile(pChar+2);
          }
        }
        if (strstr(pChar,"xtra")) {
          if (p) {
            strncpy(p,"xtra",4);
            tsbReadXtraFile(file);
          } else {
            tsbReadXtraFile(pChar+2);
          }
        }
        continue;
      } else
      if (letter == 'K') {
        idsegments = 3;
      } else
      if (strncmp(pChar,"GF:",3) == 0) {
        idsegments = 3;
      } else
      if (letter == 'F') {
        idsegments = 3;
      }
      entry = ZNEW(tsbInfoEntry);
      if (!entry) {
        file_close(fp);
        return -3;
      }
      entry->letter = letter;
      entry->id = id;
      entry->flags = 0;
      entry->bright_x = 0;
      entry->bright_y = 0;
      entry->dark_x = 0;
      entry->dark_y = 0;
      entry->x = 0;
      entry->y = 0;
      
      entry->name_len = 0;
      entry->zName = 0;
      entry->filename_len = 0;
      entry->zFilename = NULL;

      entry->pNext = NULL;
      tsbAddInfoEntryS(entry, &g_pInfoRoot);

      for (i=0; i < idsegments; ++i) {
        pEnd = strchr(pChar+1,':');
        pChar = pEnd;
      }
      entry->name_len = pEnd - line;
      entry->zName = (char*) malloc(sizeof(char) * (entry->name_len+1));
      if (!entry->zName) {
        file_close(fp);
        return -3;
      }
      strncpy(entry->zName,line,entry->name_len);
      entry->zName[entry->name_len] = 0;
      pChar = line;

      if (*(pChar+3) == 'x') {
        // id is in hex
        id = strtol(pChar+4,NULL, 16);
      } else {
        id = strtol(pChar+2,NULL, 10);
      }
      // read the image location
      if (*(pEnd+2) == 'x') {
        // attr is in hex
        y = strtol(pEnd+3,&pChar, 16)-128;
      } else {
        y = strtol(pEnd+1,&pChar, 10)-128;
        // subtract 128 here because all of this is for vanilla
        // if for eg SAngband, which uses decimal numbers without the high bit,
        // you would want to remove this -128
      }
      if (*(pChar+2) == 'x') {
        // char is in hex
        x = strtol(pChar+3,&pEnd, 16)-128;
      } else {
        x = strtol(pChar+1,&pEnd, 10)-128;
        // subtract 128 here because all of this is for vanilla
        // if for eg SAngband, which uses decimal numbers without the high bit,
        // you would want to remove this -128
      }

      entry->y = y;
      entry->x = x;
      if ((letter == 'F') && pEnd && (*pEnd == ':')) {// _tcschr(pEnd+1, ':')) {
        // see if there are additional coordinates on the line
        // read the image location
        if (*(pEnd+2) == 'x') {
          // id is in hex
          entry->dark_y = strtol(pEnd+3,&pChar, 16)-128;
        } else {
          entry->dark_y = strtol(pEnd+1,&pChar, 10)-128;
        }
        if (*(pChar+2) == 'x') {
          // id is in hex
          entry->dark_x = strtol(pChar+3,&pEnd, 16)-128;
        } else {
          entry->dark_x = strtol(pChar+1,&pEnd, 10)-128;
        }
        //entry->u16Flags |= FLAG_SHADE_ON;
        if (pEnd && (*pEnd == ':')) { // _tcschr(pEnd+1, ':')) {
          // see if there are additional coordinates on the line
          // read the image location
          if (*(pEnd+2) == 'x') {
            // id is in hex
            entry->bright_y = strtol(pEnd+3,&pChar, 16)-128;
          } else {
            entry->bright_y = strtol(pEnd+1,&pChar, 10)-128;
          }
          if (*(pChar+2) == 'x') {
            // id is in hex
            entry->bright_x = strtol(pChar+3,&pEnd, 16)-128;
          } else {
            entry->bright_x = strtol(pChar+1,&pEnd, 10)-128;
          }
        } else {
          entry->bright_y = entry->y;
          entry->bright_x = entry->x;
        }
      } else {
        //entry->u16Flags &= ~(FLAG_SHADE_ON|FLAG_SHADE_OFF);
        entry->dark_y = entry->y;
        entry->dark_x = entry->x;
        entry->bright_y = entry->y;
        entry->bright_x = entry->x;
      }
    }
  } // while
  
  file_close(fp);
  return 0;
}
コード例 #14
0
bool init_graphics_modes(const char *filename) {
	int i = 0;
	int line = 0;
	int previd;
	char *zz[16];
	char buf[1024];
	ang_file *fp;
	graphics_mode *mode = NULL,*next;

	/* Build the filename */
	path_make(buf, ANGBAND_DIR_USER, filename);

	fp = file_open(buf, MODE_READ, FTYPE_TEXT);
	if (!fp) {
		/* Build the filename */
		path_make(buf, ANGBAND_DIR_XTRA_GRAF, filename);

		fp = file_open(buf, MODE_READ, FTYPE_TEXT);
	}

	if (!fp) {
		return FALSE;
	}
	while (0 <= file_getl(fp, buf, 1024))
	{
		/* Count lines */
		line++;


		/* Skip "empty" lines */
		if (!buf[0]) continue;

		/* Skip "blank" lines */
		if (isspace(buf[0])) continue;

		/* Skip comments */
		if (buf[0] == '#') continue;

    
		/* Require "?:*" format */
		if (buf[1] != ':') return FALSE;/*(1);*/

		/* process the line */
		/* Process "N:<id>:<menuname>" -- start a new record */
		if (buf[0] == 'N') {
			if (tokenize(buf + 2, 2, zz, TOKENIZE_CHECKQUOTE) == 2) {
				mode = ZNEW(graphics_mode);
				if (mode) {
					mode->grafID = strtol(zz[0], NULL, 0);
					strncpy(mode->menuname, zz[1], 32);
					mode->menuname[31] = 0;
					if (graphics_mode_high_id < mode->grafID) {
						graphics_mode_high_id = mode->grafID;
					}
					mode->pNext = graphics_modes;
					graphics_modes = mode;
				} else {
					return FALSE;/*(PARSE_ERROR_OUT_OF_MEMORY);*/
				}
			} else {
				return FALSE;/*(PARSE_ERROR_GENERIC);*/
			}

		}
		/* Process "P:<prefname>:<preffile>" -- set the name used with pref files */
		else if (buf[0] == 'P') {
			byte count = tokenize(buf + 2, 2, zz, TOKENIZE_CHECKQUOTE);
			if (count >= 1) {
				if (mode) {
					strncpy(mode->pref, zz[0], 32);
					if (count == 2) {
						/* overwrite the pref name with the pref filename */
						strncpy(mode->pref, zz[1], 32);
					}
					mode->pref[31] = 0;
				} else {
					return FALSE;/*(PARSE_ERROR_MISSING_RECORD_HEADER);*/
				}
			} else {
				return FALSE;/*(PARSE_ERROR_GENERIC);*/
			}
		}
		/* Process "I:<cell width>:<cell height>:<filename>" -- read the tileset info */
		else if (buf[0] == 'I') {
			if (tokenize(buf + 2, 3, zz, TOKENIZE_CHECKQUOTE) == 3) {
				if (mode) {
					mode->cell_width = strtol(zz[0], NULL, 0);
					mode->cell_height = strtol(zz[1], NULL, 0);
					strncpy(mode->file, zz[2], 32);
					mode->file[31] = 0;
				} else {
					return FALSE;/*(PARSE_ERROR_MISSING_RECORD_HEADER);*/
				}
			} else {
				return FALSE;/*(PARSE_ERROR_GENERIC);*/
			}
		}
		/* Process "X:<alpha>:<overdraw_min>:<overdraw_max>" -- read some extra info */
		else if (buf[0] == 'X') {
			if (tokenize(buf + 2, 3, zz, TOKENIZE_CHECKQUOTE) == 3) {
				if (mode) {
					mode->alphablend = strtol(zz[0], NULL, 0);
					mode->overdrawRow = strtol(zz[1], NULL, 0);
					mode->overdrawMax = strtol(zz[2], NULL, 0);
				} else {
					return FALSE;/*(PARSE_ERROR_MISSING_RECORD_HEADER);*/
				}
			} else {
				return FALSE;/*(PARSE_ERROR_GENERIC);*/
			}
		}
		else {
			/* Oops */
			return FALSE;/*(PARSE_ERROR_UNDEFINED_DIRECTIVE);*/
		}
	}

	/* close the file */
	file_close(fp);

	mode = graphics_modes;
	graphics_modes = C_RNEW(graphics_mode_high_id+1,graphics_mode);

	/* set the default mode */
	graphics_modes[0].grafID = 0;
	graphics_modes[0].alphablend = 0;
	graphics_modes[0].cell_height = 1;
	graphics_modes[0].cell_width = 1;
	graphics_modes[0].overdrawRow = 0;
	graphics_modes[0].overdrawMax = 0;
	strncpy(graphics_modes[0].menuname, "None", 32);
	strncpy(graphics_modes[0].pref, "font.prf", 32);
	strncpy(graphics_modes[0].file, "", 32);
	if (mode) {
		next = mode;
		while (next->pNext) next = next->pNext;
		graphics_modes[0].pNext = &(graphics_modes[next->grafID]);
	} else {
		graphics_modes[0].pNext = NULL;
	}
	previd = 0;
	while (mode) {
		next = mode->pNext;
		i = mode->grafID;
		graphics_modes[i].grafID = mode->grafID;
		graphics_modes[i].cell_height = mode->cell_height;
		graphics_modes[i].cell_width = mode->cell_width;
		graphics_modes[i].alphablend = mode->alphablend;
		graphics_modes[i].overdrawRow = mode->overdrawRow;
		graphics_modes[i].overdrawMax = mode->alphablend;
		strncpy(graphics_modes[i].menuname, mode->menuname, 32);
		strncpy(graphics_modes[i].pref, mode->pref, 32);
		strncpy(graphics_modes[i].file, mode->file, 32);
		if (previd) {
			graphics_modes[i].pNext = &(graphics_modes[previd]);
		} else {
			graphics_modes[i].pNext = NULL;
		}
		previd = i;
		FREE(mode);
		mode = next;
	}
	return TRUE;
}
コード例 #15
0
ファイル: mnode.c プロジェクト: panyam/mango
/**
 * Create a default node context instance.
 * \param   proto       Prototype to associate the context with.
 * \param   node        The node to which this context belongs to.
 * \param   parent      Context of the node's parent node.
 * \return  A NodeContext object.
 */
MangoNodeContext *mango_nodecontext_new(MangoPrototype *proto, MangoNode *node, MangoNodeContext *parent)
{
    return mango_nodecontext_init(ZNEW(MangoNodeContext),
                                  (MangoPrototype *)proto,
                                  node, parent);
}