Exemplo n.º 1
0
/*
 * Add a string structure to the symbol.
 * Coordinates assumed to be from top-center.
 */
int render_plot_add_string(struct zint_symbol *symbol,
		unsigned char *text, float x, float y, float fsize, float width,
		struct zint_render_string **last_string)
{
	struct zint_render_string *string;

#ifndef _MSC_VER
	string = malloc(sizeof(struct zint_render_string));
#else
	string = (struct zint_render_string *)_alloca(sizeof(struct zint_render_string));
#endif
	string->next = NULL;
	string->x = x;
	string->y = y;
	string->width = width; 
	string->fsize = fsize;
	string->length = ustrlen(text);
#ifndef _MSC_VER
	string->text = malloc(sizeof(unsigned char) * (ustrlen(text) + 1));
#else
	string->text = (unsigned char *)_alloca((ustrlen(text) + 1) * sizeof(unsigned char));
#endif
	ustrcpy(string->text, text);

	if (*last_string)
		(*last_string)->next = string;
	else
		symbol->rendered->strings = string; // First character
	*last_string = string;

	return 1;
}
Exemplo n.º 2
0
/* enqueue the the kernel message into the message queue.
 * The provided msg string is not freed - thus must be done
 * by the caller.
 * rgerhards, 2008-04-12
 */
static rsRetVal
enqMsg(uchar *msg, uchar* pszTag, int iFacility, int iSeverity)
{
	DEFiRet;
	msg_t *pMsg;

	assert(msg != NULL);
	assert(pszTag != NULL);

	CHKiRet(msgConstruct(&pMsg));
	MsgSetFlowControlType(pMsg, eFLOWCTL_LIGHT_DELAY);
	MsgSetInputName(pMsg, pInputName);
	MsgSetRawMsgWOSize(pMsg, (char*)msg);
	MsgSetMSGoffs(pMsg, 0);	/* we do not have a header... */
	MsgSetRcvFrom(pMsg, glbl.GetLocalHostNameProp());
	MsgSetRcvFromIP(pMsg, pLocalHostIP);
	MsgSetHOSTNAME(pMsg, glbl.GetLocalHostName(), ustrlen(glbl.GetLocalHostName()));
	MsgSetTAG(pMsg, pszTag, ustrlen(pszTag));
	pMsg->iFacility = LOG_FAC(iFacility);
	pMsg->iSeverity = LOG_PRI(iSeverity);
	CHKiRet(submitMsg(pMsg));

finalize_it:
	RETiRet;
}
Exemplo n.º 3
0
/* enqueue the the kernel message into the message queue.
 * The provided msg string is not freed - thus must be done
 * by the caller.
 * rgerhards, 2008-04-12
 */
static rsRetVal
enqMsg(uchar *msg, uchar* pszTag, syslog_pri_t pri, struct timeval *tp, struct json_object *json)
{
	struct syslogTime st;
	msg_t *pMsg;
	DEFiRet;

	assert(msg != NULL);
	assert(pszTag != NULL);

	if(tp == NULL) {
		CHKiRet(msgConstruct(&pMsg));
	} else {
		datetime.timeval2syslogTime(tp, &st);
		CHKiRet(msgConstructWithTime(&pMsg, &st, tp->tv_sec));
	}
	MsgSetFlowControlType(pMsg, eFLOWCTL_LIGHT_DELAY);
	MsgSetInputName(pMsg, pInputName);
	MsgSetRawMsgWOSize(pMsg, (char*)msg);
	MsgSetMSGoffs(pMsg, 0);	/* we do not have a header... */
	MsgSetRcvFrom(pMsg, glbl.GetLocalHostNameProp());
	MsgSetRcvFromIP(pMsg, pLocalHostIP);
	MsgSetHOSTNAME(pMsg, glbl.GetLocalHostName(), ustrlen(glbl.GetLocalHostName()));
	MsgSetTAG(pMsg, pszTag, ustrlen(pszTag));
	msgSetPRI(pMsg, pri);
	pMsg->json = json;
	CHKiRet(submitMsg(pMsg));

finalize_it:
	RETiRet;
}
Exemplo n.º 4
0
void uconcat(unsigned char dest[], const unsigned char source[])
{ /* Concatinates dest[] with the contents of source[], copying /0 as well */
	unsigned int i, j;

	j = ustrlen(dest);
	for(i = 0; i <= ustrlen(source); i++) {
		dest[i + j] = source[i]; }
}
Exemplo n.º 5
0
Bkmk::Bkmk(const Bkmk& rhs)
    : m_name(0)
    , m_namelen(0)
    , m_anno(0)
    , m_annolen(0)
    , m_position(0)
{
    init(rhs.name(), sizeof(tchar)*(ustrlen(rhs.name())+1), rhs.anno(),
         sizeof(tchar)*(ustrlen(rhs.anno())+1), rhs.value());
}
Exemplo n.º 6
0
int ustrcat(wchar *dest, wchar *src)
{
	int dest_len, src_len;
	
	dest_len=ustrlen(dest);
	src_len=ustrlen(src);

	for(int src_index=0; src_index<=src_len; src_index++)
		dest[dest_len+src_index]=src[src_index];

	return dest_len+src_len;
}
Exemplo n.º 7
0
/* Parse and a word config line option. A word is a consequtive
 * sequence of non-whitespace characters. pVal must be
 * a pointer to a string which is to receive the option
 * value. The returned string must be freed by the caller.
 * rgerhards, 2007-09-07
 * To facilitate multiple instances of the same command line
 * directive, doGetWord() now checks if pVal is already a
 * non-NULL pointer. If so, we assume it was created by a previous
 * incarnation and is automatically freed. This happens only when
 * no custom handler is defined. If it is, the customer handler
 * must do the cleanup. I have checked and this was al also memory
 * leak with some code. Obviously, not a large one. -- rgerhards, 2007-12-20
 * Just to clarify: if pVal is parsed to a custom handler, this handler
 * is responsible for freeing pVal. -- rgerhards, 2008-03-20
 */
static rsRetVal doGetWord(uchar **pp, rsRetVal (*pSetHdlr)(void*, uchar*), void *pVal)
{
	DEFiRet;
	cstr_t *pStrB = NULL;
	uchar *pNewVal;

	ASSERT(pp != NULL);
	ASSERT(*pp != NULL);

	CHKiRet(getWord(pp, &pStrB));
	CHKiRet(cstrConvSzStrAndDestruct(&pStrB, &pNewVal, 0));

	DBGPRINTF("doGetWord: get newval '%s' (len %d), hdlr %p\n",
		  pNewVal, (int) ustrlen(pNewVal), pSetHdlr);
	/* we got the word, now set it */
	if(pSetHdlr == NULL) {
		/* we should set value directly to var */
		if(*((uchar**)pVal) != NULL)
			free(*((uchar**)pVal)); /* free previous entry */
		*((uchar**)pVal) = pNewVal; /* set new one */
	} else {
		/* we set value via a set function */
		CHKiRet(pSetHdlr(pVal, pNewVal));
	}

	skipWhiteSpace(pp); /* skip over any whitespace */

finalize_it:
	if(iRet != RS_RET_OK) {
		if(pStrB != NULL)
			cstrDestruct(&pStrB);
	}

	RETiRet;
}
Exemplo n.º 8
0
/* add new listener port to listener port list
 * rgerhards, 2009-05-21
 */
static inline rsRetVal
addNewLstnPort(tcpsrv_t *pThis, uchar *pszPort, int bSuppOctetFram, uchar *pszAddr)
{
	tcpLstnPortList_t *pEntry;
	uchar statname[64];
	DEFiRet;

	ISOBJ_TYPE_assert(pThis, tcpsrv);

	/* create entry */
	CHKmalloc(pEntry = MALLOC(sizeof(tcpLstnPortList_t)));
	if((pEntry->pszPort = ustrdup(pszPort)) == NULL) {
		DBGPRINTF("tcpsrv/addNewLstnPort: OOM in strdup()\n");
		free(pEntry);
		ABORT_FINALIZE(RS_RET_OUT_OF_MEMORY);
	}

        pEntry->pszAddr = NULL;
        /* only if a bind adress is defined copy it in struct */
        if (pszAddr != NULL) {
		if((pEntry->pszAddr = ustrdup(pszAddr)) == NULL) {
			DBGPRINTF("tcpsrv/addNewLstnPort: OOM in strdup() 2\n");
			free(pEntry->pszPort);
			free(pEntry);
			ABORT_FINALIZE(RS_RET_OUT_OF_MEMORY);
		}
	}

	strcpy((char*)pEntry->dfltTZ, (char*)pThis->dfltTZ);
	pEntry->bSPFramingFix = pThis->bSPFramingFix;
	pEntry->pSrv = pThis;
	pEntry->pRuleset = pThis->pRuleset;
	pEntry->bSuppOctetFram = bSuppOctetFram;

	/* we need to create a property */ 
	CHKiRet(prop.Construct(&pEntry->pInputName));
	CHKiRet(prop.SetString(pEntry->pInputName, pThis->pszInputName, ustrlen(pThis->pszInputName)));
	CHKiRet(prop.ConstructFinalize(pEntry->pInputName));

	/* and add to list */
	pEntry->pNext = pThis->pLstnPorts;
	pThis->pLstnPorts = pEntry;

	/* support statistics gathering */
	CHKiRet(statsobj.Construct(&(pEntry->stats)));
	snprintf((char*)statname, sizeof(statname), "%s(%s)", pThis->pszInputName, pszPort);
	statname[sizeof(statname)-1] = '\0'; /* just to be on the save side... */
	CHKiRet(statsobj.SetName(pEntry->stats, statname));
	CHKiRet(statsobj.SetOrigin(pEntry->stats, pThis->pszOrigin));
	CHKiRet(ratelimitNew(&pEntry->ratelimiter, "tcperver", NULL));
	ratelimitSetLinuxLike(pEntry->ratelimiter, pThis->ratelimitInterval, pThis->ratelimitBurst);
	ratelimitSetThreadSafe(pEntry->ratelimiter);
	STATSCOUNTER_INIT(pEntry->ctrSubmit, pEntry->mutCtrSubmit);
	CHKiRet(statsobj.AddCounter(pEntry->stats, UCHAR_CONSTANT("submitted"),
		ctrType_IntCtr, CTR_FLAG_RESETTABLE, &(pEntry->ctrSubmit)));
	CHKiRet(statsobj.ConstructFinalize(pEntry->stats));

finalize_it:
	RETiRet;
}
Exemplo n.º 9
0
/* actually submit a message to the rsyslog core
 */
static inline void
doSubmitMsg(uchar *line)
{
	msg_t *pMsg;
	DEFiRet;

	CHKiRet(msgConstruct(&pMsg));
	MsgSetInputName(pMsg, pInputName);
	MsgSetRawMsgWOSize(pMsg, (char*)line);
	MsgSetHOSTNAME(pMsg, glbl.GetLocalHostName(), ustrlen(glbl.GetLocalHostName()));
	MsgSetRcvFrom(pMsg, glbl.GetLocalHostNameProp());
	MsgSetRcvFromIP(pMsg, glbl.GetLocalHostIP());
	MsgSetMSGoffs(pMsg, 0);
	MsgSetTAG(pMsg, UCHAR_CONSTANT("rsyslogd-pstats:"), sizeof("rsyslogd-pstats:") - 1);
	pMsg->iFacility = runModConf->iFacility;
	pMsg->iSeverity = runModConf->iSeverity;
	pMsg->msgFlags  = 0;

	/* we do not use rate-limiting, as the stats message always need to be emitted */
	submitMsg2(pMsg);
	DBGPRINTF("impstats: submit [%d,%d] msg '%s'\n", runModConf->iFacility,
	          runModConf->iSeverity, line);

finalize_it:
	return;
}
Exemplo n.º 10
0
int ec39(struct zint_symbol *symbol, unsigned char source[], unsigned int length)
{ /* Extended Code 39 - ISO/IEC 16388:2007 Annex A */

	unsigned char buffer[150] = { 0 };
	unsigned int i;
    int error_number = 0;

	if(length > 74) {
		strcpy(symbol->errtxt, "Input too long");
		return ERROR_TOO_LONG;
	}
	
	/* Creates a buffer string and places control characters into it */
	for(i = 0; i < length; i++) {
		if(source[i] > 127) {
			/* Cannot encode extended ASCII */
			strcpy(symbol->errtxt, "Invalid characters in input data");
            return ERROR_INVALID_DATA1;
		}
		concat((char*)buffer, EC39Ctrl[source[i]]);		
	}

	/* Then sends the buffer to the C39 function */
	error_number = c39(symbol, buffer, ustrlen(buffer));
	
	for(i = 0; i < length; i++)
		symbol->text[i] = source[i] ? source[i] : ' ';
	symbol->text[length] = '\0';

	return error_number;
}
Exemplo n.º 11
0
static void set_changelist_internal(path_t *path, uint8_t *filename, uint8_t at_end) {
  FRESULT res;

  /* Assume this isn't the auto-swap list */
  globalflags &= (uint8_t)~AUTOSWAP_ACTIVE;

  /* Remove the old swaplist */
  if (swaplist.fs != NULL) {
    f_close(&swaplist);
    memset(&swaplist,0,sizeof(swaplist));
  }

  if (ustrlen(filename) == 0)
    return;

  /* Open a new swaplist */
  partition[path->part].fatfs.curr_dir = path->dir.fat;
  res = f_open(&partition[path->part].fatfs, &swaplist, filename, FA_READ | FA_OPEN_EXISTING);
  if (res != FR_OK) {
    parse_error(res,1);
    return;
  }

  /* Remember its directory so relative paths work */
  swappath = *path;

  if (at_end)
    linenum = 255;
  else
    linenum = 0;

  if (mount_line())
    confirm_blink(BLINK_HOME);
}
Exemplo n.º 12
0
int ustrwid(wchar_t const *s, int charset)
{
    char buf[256];
    int wid, len = ustrlen(s);
    charset_state state = CHARSET_INIT_STATE;

    wid = 0;

    while (len > 0) {
	int err;
	wchar_t const *s_orig;

	err = 0;
	s_orig = s;
        charset_from_unicode(&s, &len, buf, lenof(buf), charset, &state, &err);
	wid += wcswidth(s_orig, s - s_orig);
	if (err) {
	    assert(len > 0 && *s);
	    s++;
	    len--;
	}
    }

    return wid;
}
Exemplo n.º 13
0
Arquivo: png.c Projeto: domribaut/zint
void to_latin1(unsigned char source[], unsigned char preprocessed[])
{
	int j, i, input_length;

	input_length = ustrlen(source);

	j = 0;
	i = 0;
	do {
		if(source[i] < 128) {
			preprocessed[j] = source[i];
			j++;
			i++;
		} else {
			if(source[i] == 0xC2) {
				preprocessed[j] = source[i + 1];
				j++;
				i += 2;
			}
			if(source[i] == 0xC3) {
				preprocessed[j] = source[i + 1] + 64;
				j++;
				i += 2;
			}
		}
	} while (i < input_length);
	preprocessed[j] = '\0';

	return;
}
Exemplo n.º 14
0
UNCH *ProcessSDATA(UNCH * rslt, UNCH * t, unsigned l, unsigned &intl,ostream &ers){
	UNCH *rp, *rp2, *rtn;
	rp = (UNCH *)malloc(l + 1);
	memcpy(rp, t, l);
	rp[l] = 0;

	unsigned n=0, m;
	intl = 9999;
	while (rp[n] == ' ')n++;
	if (rp[n] == 0){free(rp);rslt[0] = 0;return rslt;}
	if ((rp[n] == '#') && (rp[n+1] >= '0') && (rp[n+1] <= '9')){
		m = n+1;
		while ((rp[m]!=' ')&&(rp[m] != 0))m++;
		rp[m] = 0;
		UNCH *nmb=&rp[n+1];
		intl = unsigned(atoi((char *)nmb));
		rp2 = &rp[m+1];
	}
	else rp2 = &rp[n];
	if (!IntToSeq(rp2, rslt,256,ers))rtn = 0;
	else {
		if (intl==9999)intl = ustrlen(rslt);
		rtn = rslt;
	}
	free(rp);
	return rtn;
};
Exemplo n.º 15
0
/* Push a context holding the replacement text of the macro NODE on
   the context stack.  NODE is either object-like, or a function-like
   macro with no arguments.  */
static void
push_replacement_text (cpp_reader *pfile, cpp_hashnode *node)
{
  size_t len;
  const uchar *text;
  uchar *buf;

  if (node->flags & NODE_BUILTIN)
    {
      text = _cpp_builtin_macro_text (pfile, node);
      len = ustrlen (text);
      buf = _cpp_unaligned_alloc (pfile, len + 1);
      memcpy (buf, text, len);
      buf[len]='\n';
      text = buf;
    }
  else
    {
      cpp_macro *macro = node->value.macro;
      macro->used = 1;
      text = macro->exp.text;
      len = macro->count;
    }

  _cpp_push_text_context (pfile, node, text, len);
}
Exemplo n.º 16
0
UNCH * XlateText::GetInBuf(unsigned & inbsiz)
{
	if (bufdone) {inbsiz = 0; SetEOD(); return 0;}
	inbsiz = ustrlen(buf);
	bufdone = 1;
	return buf;
};
Exemplo n.º 17
0
void XlateTableWriteBase::DoItem(XlateEntryData *p, unsigned lvl){
	RecString tmp;
	tmp.lv = lvl;
	tmp.ch = p->c;
	tmp.ln = p->l + 1; /* "+ 1" is in MAKEBASE j.b. */
	ustrcpy(tmp.sq, p->s);
	WriteData((void *)&tmp, 4+ustrlen(tmp.sq));  //4 = 3 char data, + 0 for sq term
};
Exemplo n.º 18
0
void to_upper(unsigned char source[])
{ /* Converts lower case characters to upper case in a string source[] */
	unsigned int i, src_len = ustrlen(source);

	for (i = 0; i < src_len; i++) {
		if ((source[i] >= 'a') && (source[i] <= 'z')) {
			source [i] = (source[i] - 'a') + 'A'; }
	}
}
Exemplo n.º 19
0
Bkmk::Bkmk(const tchar* _nm, const tchar* _anno, unsigned int _p)
    : m_name(0)
    , m_namelen(0)
    , m_anno(0)
    , m_annolen(0)
    ,m_position(_p)
{
    if (_anno == NULL)
    {
	tchar t = 0;
	init(_nm, sizeof(tchar)*(ustrlen(_nm)+1), &t, sizeof(t), _p);
    }
    else
    {
	init(_nm, sizeof(tchar)*(ustrlen(_nm)+1), _anno,
	     sizeof(tchar)*(ustrlen(_anno)+1), _p);
    }
}
Exemplo n.º 20
0
int ustrcat(wchar *dest, wchar src)
{
	int dest_len=ustrlen(dest);

	dest[dest_len]=src;
	dest[dest_len+1]=0;

	return dest_len+1;
}
Exemplo n.º 21
0
void XlateTable::AddIfAbsent(UNCH cin, UNCH * cout){
	XlateTableRec *xp2 = md[0];
	if (xp2->dat[cin] == 0) xp2->dat[cin] = new XlateEntryData(cin);
	XlateEntryData *p = xp2->dat[cin];
	if (p->s[0] != '\0') return;
	ustrcpy(p->s, cout);
	p->l = ustrlen(cout);
	p->m = '0';
}
Exemplo n.º 22
0
void ustrcpy(unsigned char target[], const unsigned char source[]) {
    /* Local replacement for strcpy() with unsigned char strings */
    int i, len;

    len = ustrlen(source);
    for(i = 0; i < len; i++) {
        target[i] = source[i];
    }
    target[i] = '\0';
}
Exemplo n.º 23
0
Bkmk::Bkmk(const tchar* _nm, const unsigned char* _anno, unsigned short annolen,
	   unsigned int _p)
    : m_name(0)
    , m_namelen(0)
    , m_anno(0)
    , m_annolen(0)
    , m_position(_p)
{
    init(_nm, sizeof(tchar)*(ustrlen(_nm)+1), _anno, annolen, _p);
}
Exemplo n.º 24
0
/** Converts lower case characters to upper case in a string source[] */
void to_upper(unsigned char source[])
{
    unsigned int src_len = ustrlen(source);

    for (unsigned int i = 0; i < src_len; i++) {
        if ((source[i] >= 'a') && (source[i] <= 'z')) {
            source[i] = (source[i] - 'a') + 'A';
        }
    }
}
Exemplo n.º 25
0
int
d_abitmap_list_proc (int msg, DIALOG *d, int c)
{
	if (msg == MSG_DRAW) {
		BITMAP *bmp = gui_get_screen();
		int height, size, i, len, bar, x, y;
		char *sel = d->dp2;
		char s[1024];
		int c = 0;

		if (d->flags & D_GOTFOCUS)
			c = 1;
		if (d->flags & D_DISABLED)
			c = 2;

		(*(char *(*)(int, int *)) d->dp) (-1, &size);
		height = (d->h - 4) / text_height (font);
		bar = (size > height);

		abitmap_draw_area (d, B_LIST, 0, 0, bar ? d->w - 12 : d->w, d->h, 0, 0);
		if (bar)
			abitmap_draw_scroller (d, d->d2, size, height);

		/* draw the contents */
		for (i = 0; i < height; i++) {
			if (d->d2 + i < size) {
				int fg = theme->bitmaps[B_LIST][c].color;

				x = d->x + 2;
				y = d->y + 2 + i * text_height (font);

				if (d->d2 + i == d->d1 || ((sel) && (sel[d->d2 + i]))) {
					abitmap_draw_area (d, B_LIST_ITEM, 0, y - d->y,
						bar ? d->w - 12 : d->w, text_height (font), 0, 0);
					fg = theme->bitmaps[B_LIST_ITEM][c].color;
				}
				ustrzcpy (s, sizeof (s),
					(*(char *(*)(int, int *)) d->dp) (i + d->d2, NULL));

				x += 8;
				len = ustrlen (s);
				while (text_length (font, s) >=
				MAX (d->w - 1 - (bar ? 22 : 11), 1)) {
					len--;
					usetat (s, len, 0);
				}
				textout_ex (bmp, font, s, x, y, fg, -1);
				x += text_length (font, s);

			}
		}
		return D_O_K;
	}
	return d_list_proc (msg, d, c);
}
Exemplo n.º 26
0
/* set the local host IP address to a specific string. Helper to
 * small set of functions. No checks done, caller must ensure it is
 * ok to call. Most importantly, the IP address must not already have 
 * been set. -- rgerhards, 2012-03-21
 */
static inline rsRetVal
storeLocalHostIPIF(uchar *myIP)
{
	DEFiRet;
	CHKiRet(prop.Construct(&propLocalIPIF));
	CHKiRet(prop.SetString(propLocalIPIF, myIP, ustrlen(myIP)));
	CHKiRet(prop.ConstructFinalize(propLocalIPIF));
	DBGPRINTF("rsyslog/glbl: using '%s' as localhost IP\n", myIP);
finalize_it:
	RETiRet;
}
Exemplo n.º 27
0
UNCH LookupHexCode(UNCH * s){
	if (ustrlen(s) != 2) return '\0';
	UNCH b, r = 0;
	for (int i = 0; i<=1; i++){
		if ((s[i] >= '0') && (s[i] <= '9')) b = '0';
		else {if ((s[i] >= 'A') && (s[i] <= 'F')) b = 'A' - 10;
		else return '\0';};
		r = r*16 + (s[i]-b);
	};
	return r;
}
Exemplo n.º 28
0
Bkmk::Bkmk(const tchar* _nm, const tchar* _anno, unsigned int _p,
	   unsigned int _p2)
    : m_name(0)
    , m_namelen(0)
    , m_anno(0)
    , m_annolen(0)
    , m_position(_p)
{
    if (_anno == NULL)
    {
	tchar t = 0;
	init(_nm, sizeof(tchar)*(ustrlen(_nm)+1), &t, sizeof(t), _p);
    }
    else
    {
	init(_nm, sizeof(tchar)*(ustrlen(_nm)+1), _anno,
	     sizeof(tchar)*(ustrlen(_anno)+1), _p);
    }
    m_position2 = _p2;
    m_red = m_green = m_blue = 127;
}
Exemplo n.º 29
0
int main(void)
{
   // Initialization. We choose the longest common substring algorithm.
   struct fc_memo m;
   fc_memo_init(&m, FC_LCSUBSTR, MAX_WORD_LEN, 0);

   // Set the word to find.
   const char32_t *to_find = U"expeditor";
   fc_memo_set_ref(&m, to_find, ustrlen(to_find));

   // Iterate over all words, in lexicographical order, and compute the length
   // of the longest common substring between our chosen word and the current
   // word at each step.
   for (size_t i = 0; lexicon[i]; i++) {
      int32_t substr_len = fc_memo_compute(&m, lexicon[i], ustrlen(lexicon[i]));
      printf("lexicon[%zu]: %"PRId32"\n", i, substr_len);
   }

   // Cleanup.
   fc_memo_fini(&m);
}
Exemplo n.º 30
0
Arquivo: pch.c Projeto: Lao16/gcc
static int
write_macdef (cpp_reader *pfile, cpp_hashnode *hn, void *file_p)
{
  FILE *f = (FILE *) file_p;
  switch (hn->type)
    {
    case NT_VOID:
      if (! (hn->flags & NODE_POISONED))
	return 1;

    case NT_MACRO:
      if ((hn->flags & NODE_BUILTIN)
	  && (!pfile->cb.user_builtin_macro
	      || !pfile->cb.user_builtin_macro (pfile, hn)))
	return 1;

      {
	struct macrodef_struct s;
	const unsigned char *defn;

	s.name_length = NODE_LEN (hn);
	s.flags = hn->flags & NODE_POISONED;

	if (hn->type == NT_MACRO)
	  {
	    defn = cpp_macro_definition (pfile, hn);
	    s.definition_length = ustrlen (defn);
	  }
	else
	  {
	    defn = NODE_NAME (hn);
	    s.definition_length = s.name_length;
	  }

	if (fwrite (&s, sizeof (s), 1, f) != 1
	    || fwrite (defn, 1, s.definition_length, f) != s.definition_length)
	  {
	    cpp_errno (pfile, CPP_DL_ERROR,
		       "while writing precompiled header");
	    return 0;
	  }
      }
      return 1;

    case NT_ASSERTION:
      /* Not currently implemented.  */
      return 1;

    default:
      abort ();
    }
}