void
buffmt_man(struct html *h, 
		const char *name, const char *sec)
{
	const char	*p, *pp;

	pp = h->base_man;
	
	bufinit(h);
	while (NULL != (p = strchr(pp, '%'))) {
		bufncat(h, pp, (size_t)(p - pp));
		switch (*(p + 1)) {
		case('S'):
			bufcat(h, sec ? sec : "1");
			break;
		case('N'):
			bufcat_fmt(h, "%s", name);
			break;
		default:
			bufncat(h, p, 2);
			break;
		}
		pp = p + 2;
	}
	if (pp)
		bufcat(h, pp);
}
예제 #2
0
static void sendadc1(struct socket *sk, int sep, wchar_t *arg)
{
    char *mbsbuf;
    wchar_t *buf;
    size_t bufsize, bufdata;
    
    buf = NULL;
    bufsize = bufdata = 0;
    if(sep)
	addtobuf(buf, L' ');
    for(; *arg != L'\0'; arg++) {
	if(*arg == L' ')
	    bufcat(buf, L"\\s", 2);
	else if(*arg == L'\n')
	    bufcat(buf, L"\\n", 2);
	else if(*arg == L'\\')
	    bufcat(buf, L"\\\\", 2);
	else
	    addtobuf(buf, *arg);
    }
    addtobuf(buf, L'\0');
    mbsbuf = icwcstombs(buf, "utf-8");
    sockqueue(sk, mbsbuf, strlen(mbsbuf));
    free(mbsbuf);
}
void
bufcat_style(struct html *h, const char *key, const char *val)
{

	bufcat(h, key);
	bufcat(h, ":");
	bufcat(h, val);
	bufcat(h, ";");
}
예제 #4
0
static int
tclUsageGen(char **buf, DCL_NOM_STR *nom, char *prefix)
{
   char *type, *name;		/* input type */

   if (prefix == NULL) prefix = "";

   /* Find requested type */
   dcl_nom_decl(nom, &type, &name);

   switch (nom->type->type) {

      case CHAR:
      case SHORT:
      case INT:
      case FLOAT:
      case DOUBLE:
	 bufcat(buf,"%s%s %s\\\\n", prefix, type, name);
	 break;
	 
      case STRUCT:
      case UNION:
      {
	 DCL_NOM_LIST *m;
	 char *newPrefix = NULL;

	 bufcat(buf, "%s%s\\\\n", prefix, type);
	 bufcat(&newPrefix, "%s| ", prefix);

	 for (m = nom->type->members; m != NULL; m = m->next)
	    if (tclUsageGen(buf, m->dcl_nom, newPrefix))
	       fprintf(stderr, "Warning: struct member %s was problematic.\n",
		       m->dcl_nom->name);

	 if (newPrefix != NULL) free(newPrefix);
	 break;
      }

      /* Affichage en clair des symboles de l'enum */
      case ENUM:
	 bufcat(buf,"%s%s %s\\\\n", prefix, type, name);
	 /* 	  genScanEnum(out, t->members); */
	 break;

      case TYPEDEF:
	 fprintf(stderr, "Warning: encountered a typedef for %s.\n", nom->name);
	 break;
   }

   if (type != NULL) free(type);
   if (name != NULL) free(name);

   return 0;
}
예제 #5
0
파일: trace.c 프로젝트: jmscott/blobio
void
trace(char *msg)
{
	char buf[PIPE_MAX];

	buf[0] = 0;

	bufcat(buf, sizeof buf, "TRACE: ");
	if (verb)
		buf2cat(buf, sizeof buf, verb, ": ");
	if (msg)
		bufcat(buf, sizeof buf, msg);
	bufcat(buf, sizeof buf, "\n");

	uni_write(trace_fd, buf, strlen(buf));
}
예제 #6
0
static int
mdoc_sh_pre(MDOC_ARGS)
{
	struct htmlpair	 tag;

	switch (n->type) {
	case MDOC_BLOCK:
		PAIR_CLASS_INIT(&tag, "section");
		print_otag(h, TAG_DIV, 1, &tag);
		return(1);
	case MDOC_BODY:
		if (n->sec == SEC_AUTHORS)
			h->flags &= ~(HTML_SPLIT|HTML_NOSPLIT);
		return(1);
	default:
		break;
	}

	bufinit(h);
	bufcat(h, "x");

	for (n = n->child; n && MDOC_TEXT == n->type; ) {
		bufcat_id(h, n->string);
		if (NULL != (n = n->next))
			bufcat_id(h, " ");
	}

	if (NULL == n) {
		PAIR_ID_INIT(&tag, h->buf);
		print_otag(h, TAG_H1, 1, &tag);
	} else
		print_otag(h, TAG_H1, 0, NULL);

	return(1);
}
예제 #7
0
static int
mdoc_ss_pre(MDOC_ARGS)
{
	struct htmlpair	 tag;

	if (MDOC_BLOCK == n->type) {
		PAIR_CLASS_INIT(&tag, "subsection");
		print_otag(h, TAG_DIV, 1, &tag);
		return(1);
	} else if (MDOC_BODY == n->type)
		return(1);

	bufinit(h);
	bufcat(h, "x");

	for (n = n->child; n && MDOC_TEXT == n->type; ) {
		bufcat_id(h, n->string);
		if (NULL != (n = n->next))
			bufcat_id(h, " ");
	}

	if (NULL == n) {
		PAIR_ID_INIT(&tag, h->buf);
		print_otag(h, TAG_H2, 1, &tag);
	} else
		print_otag(h, TAG_H2, 0, NULL);

	return(1);
}
예제 #8
0
파일: buffer.c 프로젝트: rfrey/ft_script
void			output_buffer(int fd, char *buf, int size, int tl)
{
	static time_t	clock = 0;
	struct timeval	now;
	static char		obuf[OUTPUT_BUFFER];
	static int		osize = 0;

	gettimeofday(&now, NULL);
	if (clock == 0)
		clock = now.tv_sec;
	if (osize + size > OUTPUT_BUFFER || size > OUTPUT_BUFFER)
	{
		put_buf(fd, obuf, &osize);
		if (size > OUTPUT_BUFFER)
		{
			write(fd, buf, size);
			return ;
		}
	}
	bufcat(obuf, buf, &osize, size);
	if (now.tv_sec - clock >= tl)
	{
		put_buf(fd, obuf, &osize);
		clock = now.tv_sec;
	}
}
예제 #9
0
int genTypeName(const DCL_NOM_STR* dcl, char* buf)
{
	char buf2[80];
	char *addr = NULL;
	int i;

	switch(dcl->type->type) {
		case CHAR:
			sprintf(buf2, "c_char");
			break;
		case INT:
			if (dcl->type->flags & SHORT_INT) {
				if (dcl->type->flags & UNSIGNED_TYPE) 
					sprintf(buf2, "c_ushort");
				else 
					sprintf(buf2, "c_short");
			} else if (dcl->type->flags & LONG_INT) {
				if (dcl->type->flags & UNSIGNED_TYPE) 
					sprintf(buf2, "c_ulong");
				else 
					sprintf(buf2, "c_long");
			} else if (dcl->type->flags & LONG_LONG_INT) {
				if (dcl->type->flags & UNSIGNED_TYPE) 
					sprintf(buf2, "c_ulonglong");
				else 
					sprintf(buf2, "c_longlong");
			} else {
				if (dcl->type->flags & UNSIGNED_TYPE) 
					sprintf(buf2, "c_uint");
				else 
					sprintf(buf2, "c_int");
			}
			break;
		case FLOAT:
			sprintf(buf2, "c_float");
			break;
		case DOUBLE:
			sprintf(buf2, "c_double");
			break;
		case ENUM:
			sprintf(buf2, "c_uint");
			break;

		default:
			sprintf(buf2, "%s", dcl->type->name);
	}

	if (IS_ARRAY(dcl) || IS_STRING(dcl)) {
		for (i = 0; i < dcl->ndimensions; i++) {
			bufcat(&addr, " * %d", dcl->dimensions[i]);
		}
		sprintf(buf, "%s %s", buf2, addr);
		free(addr);
	} else {
		sprintf(buf, "%s", buf2);
	}

	return 0;
}
예제 #10
0
/* ARGSUSED */
static void
print_mdoc_head(MDOC_ARGS)
{

	print_gen_head(h);
	bufinit(h);
	buffmt(h, "%s(%s)", m->title, m->msec);

	if (m->arch) {
		bufcat(h, " (");
		bufcat(h, m->arch);
		bufcat(h, ")");
	}

	print_otag(h, TAG_TITLE, 0, NULL);
	print_text(h, h->buf);
}
예제 #11
0
int get_msg(socket_queue *sock, buffer *buf)
{
    int len;
    int RetCode;

    buf->used = 0;
    sock->msgbuf.used = 0;

    if (sock->restbuf.used < _MSG_LEN + _MSG_MSG)
    {
        sock->status = NO_NEXT_MSG;
        sock->msg = NO_MSG;
        return 0;
    }

    len = (int) stoi(sock->restbuf.buf,_MSG_LEN);

    /* printf("stoi %d,%d\n",len,sock->restbuf.used); */

    if (len > sock->restbuf.used)
    {
        sock->status = NO_NEXT_MSG;
        sock->msg = NO_MSG;
        return 0;
    }

    sock->msg = (int) stoi(sock->restbuf.buf+_MSG_LEN,_MSG_MSG);

    if ((RetCode = bufcat(buf,&(sock->restbuf),0,sock->restbuf.used)) != 0)
        return RetCode;

    if ((RetCode = bufcat(&(sock->msgbuf),buf,_MSG_LEN+_MSG_MSG,len - _MSG_LEN - _MSG_MSG)) != 0)
        return RetCode;

    sock->restbuf.used = 0;
    if ((RetCode = bufcat(&(sock->restbuf),buf,len,buf->used - len)) != 0)
        return RetCode;

    if (sock->restbuf.used >= _MSG_LEN + _MSG_MSG          &&
            stoi(sock->restbuf.buf,_MSG_LEN) <= sock->restbuf.used)
        sock->status = NEXT_MSG;
    else
        sock->status = NO_NEXT_MSG;

    return buf->used;
}
예제 #12
0
static int
tclGenEnumList(char **buf, TYPE_STR *type)
{
   DCL_NOM_LIST *member;

   if (type->type != ENUM) return -1;

   for(member = type->members; member != NULL; member = member->next) {
      bufcat(buf, "\"%s\" ", member->dcl_nom->name);
   }

   return 0;
}
예제 #13
0
파일: html.c 프로젝트: AgamAgarwal/minix
void
buffmt_includes(struct html *h, const char *name)
{
	const char	*p, *pp;

	pp = h->base_includes;
	
	while (NULL != (p = strchr(pp, '%'))) {
		bufncat(h, pp, (size_t)(p - pp));
		switch (*(p + 1)) {
		case('I'):
			bufcat(h, name);
			break;
		default:
			bufncat(h, p, 2);
			break;
		}
		pp = p + 2;
	}
	if (pp)
		bufcat(h, pp);
}
예제 #14
0
파일: trace.c 프로젝트: jmscott/blobio
void
trace4(char *msg1, char *msg2, char *msg3, char *msg4)
{
	if (msg1) {
		char buf[PIPE_MAX];

		buf[0] = 0;
		bufcat(buf, sizeof buf, msg1);
		if (msg2)
			buf2cat(buf, sizeof buf, ": ", msg2);
		trace3(buf, msg3, msg4);
	} else 
		trace3(msg2, msg3, msg4);
}
예제 #15
0
/* ARGSUSED */
static int
mdoc_mt_pre(MDOC_ARGS)
{
	struct htmlpair	 tag[2];
	struct tag	*t;

	PAIR_CLASS_INIT(&tag[0], "link-mail");

	for (n = n->child; n; n = n->next) {
		assert(MDOC_TEXT == n->type);

		bufinit(h);
		bufcat(h, "mailto:");
		bufcat(h, n->string);

		PAIR_HREF_INIT(&tag[1], h->buf);
		t = print_otag(h, TAG_A, 2, tag);
		print_text(h, n->string);
		print_tagq(h, t);
	}
	
	return(0);
}
예제 #16
0
파일: callfcgi.c 프로젝트: dolda2000/ashd
static void bufcatkv(struct charbuf *dst, char *key, char *val)
{
    size_t kl, vl;
    
    if((kl = strlen(key)) < 128) {
	bufadd(*dst, kl);
    } else {
	bufadd(*dst, ((kl & 0x7f000000) >> 24) | 0x80);
	bufadd(*dst, (kl & 0x00ff0000) >> 16);
	bufadd(*dst, (kl & 0x0000ff00) >> 8);
	bufadd(*dst, kl & 0x000000ff);
    }
    if((vl = strlen(val)) < 128) {
	bufadd(*dst, vl);
    } else {
	bufadd(*dst, ((vl & 0x7f000000) >> 24) | 0x80);
	bufadd(*dst, (vl & 0x00ff0000) >> 16);
	bufadd(*dst, (vl & 0x0000ff00) >> 8);
	bufadd(*dst, vl & 0x000000ff);
    }
    bufcat(*dst, key, kl);
    bufcat(*dst, val, vl);
}
예제 #17
0
static void
print_mdoc_head(MDOC_ARGS)
{

	print_gen_head(h);
	bufinit(h);
	bufcat(h, meta->title);
	if (meta->msec)
		bufcat_fmt(h, "(%s)", meta->msec);
	if (meta->arch)
		bufcat_fmt(h, " (%s)", meta->arch);

	print_otag(h, TAG_TITLE, 0, NULL);
	print_text(h, h->buf);
}
예제 #18
0
파일: trace.c 프로젝트: jmscott/blobio
void
trace2(char *msg1, char *msg2)
{

	if (msg1) {
		char buf[PIPE_MAX];

		buf[0] = 0;
		bufcat(buf, sizeof buf, msg1);
		if (msg2)
			buf2cat(buf, sizeof buf, ": ", msg2);
		trace(buf);
	} else
		trace(msg2);
}
예제 #19
0
int Write(socket_queue* sock)
{
    /* ACHTUNG IN DIESER FKT DARF KEIN print_msg() AUFGERUFEN WERDEN !!!!! */
    int RetCode;
    static buffer *buf = NULL;
    char          *Ptr;

    if (sock->descriptor  < 0)
    {
#ifdef DEBUG
        syslog(LOG_DEBUG,"Write: Invalid Descriptor %d",sock->descriptor);
#endif
        return 1;
    }

    if (!buf)
    {
        buf = (buffer*) calloc(1,sizeof(buffer));

        if (!buf)
            return NO_MEMORY;

        if ((RetCode = initbuf(buf)) != 0)
            return RetCode;
    }

    if ((Ptr = itos(sock->msgbuf.used+_MSG_LEN+_MSG_MSG,_MSG_LEN)) == NULL)
        return -1;

    memcpy(buf->buf,Ptr,_MSG_LEN);
    buf->used = _MSG_LEN;

    if ((Ptr = itos(sock->msg,_MSG_MSG)) == NULL)
        return -1;

#ifdef DEBUG
    syslog(LOG_DEBUG,"Write: Message %d:*%s*",sock->msg,sock->msgbuf.buf);
#endif
    sock->msg = NO_MSG;

    memcpy(buf->buf+_MSG_LEN,Ptr,_MSG_MSG);
    buf->used += _MSG_MSG;

    if ((RetCode = bufcat(buf,&(sock->msgbuf),0,sock->msgbuf.used)) != 0)
        return RetCode;

    return write(sock->descriptor,buf->buf,buf->used);
}
예제 #20
0
/* ARGSUSED */
static int
mdoc_sx_pre(MDOC_ARGS)
{
	struct htmlpair	 tag[2];

	bufinit(h);
	bufcat(h, "#x");
	for (n = n->child; n; n = n->next) {
		bufcat_id(h, n->string);
		if (n->next)
			bufcat_id(h, " ");
	}

	PAIR_CLASS_INIT(&tag[0], "link-sec");
	PAIR_HREF_INIT(&tag[1], h->buf);

	print_otag(h, TAG_I, 1, tag);
	print_otag(h, TAG_A, 2, tag);
	return(1);
}
예제 #21
0
static int
tclOutputFormatGen(char **buf, char *name, DCL_NOM_STR *nom)
{
   int i;

   if (IS_POINTER(nom)) {
      fprintf(stderr, "Pointer %s does not make sense here.\n", name);
      return -1;
   }

   /* List of dimensions */
   bufcat(buf, "{ ");
   for(i=0;i<nom->ndimensions-IS_STRING(nom)?1:0;i++) {
      bufcat(buf, "%d ", nom->dimensions[i]);
   }
   bufcat(buf, "} ");

   if (nom->type->type != STRUCT && nom->type->type != UNION) {
      bufcat(buf, "%s ", name);
   } else {
      /* recurse */
      DCL_NOM_LIST *m;

      bufcat(buf, "{ %s ", name);

      for (m = nom->type->members; m != NULL; m = m->next) {
	 if (m->dcl_nom->name == NULL) { 
	    fprintf(stderr, "Warning: null member name in %s.\n", name);
	    continue;
	 }

	 if (tclOutputFormatGen(buf, m->dcl_nom->name, m->dcl_nom))
	    fprintf(stderr,
		    "Warning: struct member %s was problematic.\n",
		    m->dcl_nom->name);
      }

      bufcat(buf, "} ");
   }
   return 0;
}
예제 #22
0
int
tclClientGen(FILE *out)
{
   int n;
   char *buf = NULL, *type = NULL, *var = NULL, *tmp;
   RQST_LIST *rqst;
   POSTER_LIST *poster;
   RQST_INPUT_INFO_LIST *iinfo;

   /* Client part */
   script_open(out);
   subst_begin(out, PROTO_TCLCLIENT);
   print_sed_subst(out, "module", module->name);

   for(rqst = requetes; rqst != NULL; rqst=rqst->next) {
      bufcat(&buf, "\"%s\" ", rqst->name);
   }
   for(poster = posters; poster != NULL; poster=poster->next) {
      if (poster->data != NULL) {
	 /* SDI Reference list: generate one function per struct */
	 DCL_NOM_LIST *memberList;

	 for(memberList = poster->type->members;
	     memberList != NULL; memberList = memberList->next) {

	    bufcat(&buf, "\"%s%sPosterRead\" ",
		   poster->name, memberList->dcl_nom->name);
	 }
      } else {
	 /* User defined type: generate only one function */

	 bufcat(&buf, "\"%sPosterRead\" ", poster->name);
      }
   }
   print_sed_subst(out, "rqstList", buf);
   if (buf != NULL) free(buf); buf = NULL;

   subst_end(out);

   /* requêtes */

   for(rqst = requetes; rqst != NULL; rqst=rqst->next) {
      subst_begin(out, PROTO_TCLCLIENTRQST);

      print_sed_subst(out, "module", module->name);
      print_sed_subst(out, "requestName", rqst->name);
      if (rqst->rqst->doc == NULL)
	 print_sed_subst(out, "requestDoc", "** undocumented **");
      else {
	 tmp = tclQuoteString(rqst->rqst->doc);
	 print_sed_subst(out, "requestDoc", tmp);
	 free(tmp);
      }

      /* input ------------------------------------------------------- */

      if (rqst->rqst->input == NULL) {
	 print_sed_subst(out, "inputFormat", "");
	 print_sed_subst(out, "requestUsage", "no arguments");
	 print_sed_subst(out, "argNumber", "0");
      } else {
	 dcl_nom_decl(rqst->rqst->input->dcl_nom, &type, &var);

	 if (type == NULL || var == NULL) {
	    /* should not happen */
	    fprintf(stderr, "No input type for %s", rqst->name);
	    return -1;
	 }
      
	 iinfo = rqst->rqst->input_info;
	 tclInputFormatGen(&buf, rqst->rqst->input->dcl_nom->name,
			   rqst->rqst->input->dcl_nom, &iinfo, 0);
/* 	 tmp = tclQuoteString(buf); */
	 print_sed_subst(out, "inputFormat", buf);
/* 	 free(tmp); */
	 if (buf != NULL) free(buf); buf = NULL;

	 n = tclArgNumberGen(rqst->rqst->input->dcl_nom);
	 if (n < 0) {
	    fprintf(stderr,
		    "Error: could not enumerate input of %s.\n", rqst->name);
	    return -1;
	 }
	 print_sed_subst(out, "argNumber", "%d", n);

	 tclUsageGen(&buf, rqst->rqst->input->dcl_nom, NULL);
	 tmp = tclQuoteString(buf);
	 print_sed_subst(out, "requestUsage", tmp);
	 free(tmp);
	 if (buf != NULL) free(buf); buf = NULL;

	 if (type != NULL) free(type);
	 if (var != NULL) free(var);
      }

      /* output ------------------------------------------------------ */

      if (rqst->rqst->output == NULL) {
	 print_sed_subst(out, "outputFormat", "{} status ");
      } else {
	 if (rqst->rqst->output->dcl_nom->name == NULL) {
	    /* should not happen */
	    fprintf(stderr, "No output name for %s", rqst->name);
	    return -1;
	 }
	 
	 bufcat(&buf, "{} status ");
	 tclOutputFormatGen(&buf, rqst->rqst->output->dcl_nom->name,
			    rqst->rqst->output->dcl_nom);
	 tmp = tclQuoteString(buf);
	 print_sed_subst(out, "outputFormat", tmp);
	 free(tmp);
	 if (buf != NULL) free(buf); buf = NULL;
      }

      subst_end(out);
   }

   /* posters */

   for(poster = posters; poster != NULL; poster=poster->next) {
      DCL_NOM_LIST *memberList;

      if (poster->data != NULL) {
	 /* SDI Reference list: generate one function per struct */

	 for(memberList = poster->type->members;
	     memberList != NULL; memberList = memberList->next) {

	    subst_begin(out, PROTO_TCLCLIENTPOSTER);

	    print_sed_subst(out, "module", module->name);
	    bufcat(&buf, "%s%s", poster->name, memberList->dcl_nom->name);
	    print_sed_subst(out, "posterName", buf);
	    if (buf != NULL) free(buf); buf = NULL;

	    bufcat(&buf, "{} status ");

	    tclOutputFormatGen(&buf, memberList->dcl_nom->name,
			       memberList->dcl_nom);
	    tmp = tclQuoteString(buf);
	    print_sed_subst(out, "outputFormat", tmp);
	    free(tmp);
	    if (buf != NULL) free(buf); buf = NULL;
	    
	    tclUsageGen(&buf, memberList->dcl_nom, NULL);
	    tmp = tclQuoteString(buf);
	    print_sed_subst(out, "posterDoc", tmp);
	    free(tmp);
	    if (buf != NULL) free(buf); buf = NULL;
	    
	    subst_end(out);
	 }
      } else {
	 /* User defined type: generate only one function */

	 subst_begin(out, PROTO_TCLCLIENTPOSTER);

	 print_sed_subst(out, "module", module->name);
	 print_sed_subst(out, "posterName", poster->name);

	 bufcat(&buf, "{} status ");

	 for(memberList = poster->type->members;
	     memberList != NULL; memberList = memberList->next) {

	    tclOutputFormatGen(&buf, memberList->dcl_nom->name,
			       memberList->dcl_nom);
	 }
	 tmp = tclQuoteString(buf);
	 print_sed_subst(out, "outputFormat", tmp);
	 free(tmp);
	 if (buf != NULL) free(buf); buf = NULL;
	 
	 for(memberList = poster->type->members;
	     memberList != NULL; memberList = memberList->next) {

	    tclUsageGen(&buf, memberList->dcl_nom, NULL);
	 }
	 tmp = tclQuoteString(buf);
	 print_sed_subst(out, "posterDoc", tmp);
	 free(tmp);
	 if (buf != NULL) free(buf); buf = NULL;

	 subst_end(out);
      }
   }

   script_close(out, "server/tcl/%sClient.tcl", module->name);
   return 0;
}
예제 #23
0
int
get_pkgconfig_cflags(char *package, char** cpp_options, int first_option)
{
    const char *pkgconfig = getenv("PKG_CONFIG");
    int outpipe[2];
    pid_t pid;

    if (pkgconfig == NULL) pkgconfig = "pkg-config";

    if (pipe(outpipe) == -1)
    {
        fprintf(stderr, "error running %s: ", pkgconfig);
	perror("");
	exit(2);
    }

    pid = fork();
    if (! pid)
    {
	close(outpipe[0]);
	close(fileno(stdout));
	dup2(outpipe[1], fileno(stdout));

	if (execlp(pkgconfig, pkgconfig, "--cflags", package, (char*)NULL) == -1)
	{
	    fprintf(stderr, "error running %s: ", pkgconfig);
	    perror("");
	    exit(1);
	}
	// never reached
	return -1;
    }
    else
    {
	char* cflags = 0;
	int option_count = 0;
	char buffer[1024];
	int read_chars;
	int status;

	close(outpipe[1]);

	if (waitpid(pid, &status, 0) == -1 || !WIFEXITED(status) || WEXITSTATUS(status))
	{
            fprintf(stderr, "error running %s\n", pkgconfig);
	    exit(1);
	}

	while ( (read_chars = read(outpipe[0], buffer, 1023)) > 0)
	{
	    buffer[read_chars] = 0;
	    string_strip_end(buffer); /* remove whitespace at the end */
	    bufcat(&cflags, buffer);
	}

	/* Split cflags at \s+- and add the fields in cpp_options */
	if (!cflags || cflags[0] == '\0')
	    return 0;
	/* XXX pkgconfig < 0.15 leaves a space in front of cflags
	 * this causes problems here. This is why pkg-config >= 0.15
	 * is required */

	option_count = split(cflags, " -", 1, cpp_options + first_option, MAX_CPP_OPT - first_option);
	if (option_count == -1)
	{
	    fprintf(stderr, "too many options for the preprocessor");
	    exit(1);
	}
	free(cflags);
	cflags = 0;

	if (verbose)
	{
	    int i;
	    if (option_count > 0)
		    for (i = 0; i < option_count; ++i) {
			    fprintf(stderr, "%s: found '%s' for package %s\n",
				    pkgconfig, cpp_options[first_option + i],
				    package);
		    }
	    else
		fprintf(stderr, "%s: no cflags needed for package %s\n",
			pkgconfig, package);
	}
	return option_count;
    }
}
예제 #24
0
fbuffer * fbuffer::operator += (const char* str)
{
	bufcat(str, strlen(str));
	return this;
}
예제 #25
0
fbuffer * fbuffer::operator += (string* str)
{
	bufcat(str->c_str(), str->length());
	return this;
}
예제 #26
0
fbuffer * fbuffer::operator += (string& str)
{
	bufcat(str.c_str(), str.length());
	return this;
}
예제 #27
0
int Read(socket_queue* sock)
{
    int RetCode;
    int SelRet;
    fd_set readmask;
    struct timeval timeout = {0,0};
    static buffer *buf = NULL;


    if (sock->descriptor  < 0)
    {
#ifdef DEBUG
        syslog(LOG_DEBUG,"Write: Invalid Descriptor %d",sock->descriptor);
#endif
        return 1;
    }

    if (sock->restbuf.len > BUF_SIZE && sock->restbuf.used == 0)
    {
        free(sock->restbuf.buf);
        sock->restbuf.buf = NULL;
        initbuf(&(sock->restbuf));
    }

    if (sock->msgbuf.len > BUF_SIZE && sock->msgbuf.used == 0)
    {
        free(sock->msgbuf.buf);
        sock->msgbuf.buf = NULL;
        initbuf(&(sock->msgbuf));
    }
    else
        sock->msgbuf.used = 0;

    if (!buf)
    {
        if ((buf = (buffer*) calloc(1,sizeof(buffer))) == NULL)
            return NO_MEMORY;

        if ((RetCode = initbuf(buf)) != 0)
            return RetCode;
    }
    else if (buf->len > BUF_SIZE)
    {
        free(buf->buf);
        buf->buf = NULL;
        initbuf(buf);
    }

    FD_ZERO(&readmask);
    FD_SET(sock->descriptor,&readmask);

    while ((SelRet = select(sock->descriptor+1,&readmask,NULL,NULL,&timeout)) > 0 &&
            FD_ISSET(sock->descriptor,&readmask))
        if ((RetCode = buf->used = read(sock->descriptor,buf->buf,buf->len)) > 0)
        {
            if ((RetCode = bufcat(&(sock->restbuf),buf,0,buf->used)) != 0)
                return RetCode;
        }
        else
            return -1;

    if (SelRet < 0)
        return -1;

    if (sock->restbuf.used)
        if ((RetCode = get_msg(sock,buf)) != 0)
            return RetCode;

    return -1; /* Sollte nur ein Wert > 0 zurueckliefern */
}
예제 #28
0
static int
tclInputFormatGen(char **buf, char *name, DCL_NOM_STR *nom,
		  RQST_INPUT_INFO_LIST **iinfo, int level)
{
   char *arrayName = NULL;	/* in the case of an array */
   static char defaultDefault[20];

   if (IS_POINTER(nom)) {
      fprintf(stderr, "Pointer %s does not make sense here.\n", name);
      return -1;
   }

   /* For an array, must do some loop */
   if (IS_ARRAY(nom)) {
      int i;

      bufcat(&arrayName, name);

      for(i=0;i<nom->ndimensions-IS_STRING(nom)?1:0;i++) {
	 bufcat(buf,"    for {set loop%d(%d) 0} "
		"{ \\$loop%d(%d)<%d } { incr loop%d(%d)} {\n",
		level, i, level, i, nom->dimensions[i], level, i);
	 bufcat(&arrayName, "\\\\[\\$loop%d(%d)\\\\]", level, i);
      }

      if (arrayName == NULL) {
	 /* must give up */
	 fprintf(stderr, "Warning: could not generate array name for %s.\n",
		 name);
	 return -1;
      }

      name = arrayName;
   }

   if (nom->type->type != STRUCT && nom->type->type != UNION) {

      bufcat(buf, "    lappend format [list ");

      /* Echo the tcl func call */
      switch (nom->type->type) {

	 case CHAR:
	    if (IS_STRING(nom))
	       bufcat(buf, "string");
	    else
	       bufcat(buf, "short");
	    strcpy(defaultDefault, "\"\"");
	    break;
	 
	 case SHORT:
	    bufcat(buf, "short");
	    strcpy(defaultDefault, "0");
	    break;

	 case INT:
	    if (nom->type->flags & LONG_LONG_INT)
	       bufcat(buf, "wide");
	    else 
	       bufcat(buf, "int");
	    strcpy(defaultDefault, "0");
	    break;
		
	 case FLOAT:
	    bufcat(buf, "float");
	    strcpy(defaultDefault, "0.0");
	    break;

	 case DOUBLE:
	    bufcat(buf, "double");
	    strcpy(defaultDefault, "0.0");
	    break;
	 
	 case STRUCT:
	 case UNION:
	    /* see 'else' statement below */
	    break;

	    /* Affichage en clair des symboles de l'enum */
	 case ENUM:
	    bufcat(buf, "{ ");
	    if (tclGenEnumList(buf, nom->type) != 0)
	       return -1;
	    bufcat(buf, "}");
	    strcpy(defaultDefault, "\"\"");
	    break;

	 case TYPEDEF:
	    fprintf(stderr, "Warning: encountered a typedef for %s.\n", name);
	    break;
      }

      if (*iinfo != NULL && (*iinfo)->doc != NULL) {
	 bufcat(buf, " \"%s\"", (*iinfo)->doc);
	 switch((*iinfo)->type) {
	    case INT:
	       if (nom->type->type == ENUM) {
		  int ok = 0;
		  DCL_NOM_LIST *member;

		  for(member = nom->type->members;
		      member != NULL;
		      member = member->next) {
		     if (member->dcl_nom->pointeur ==
			 (*iinfo)->default_val.i_val) {
			bufcat(buf, " \"%s\"", member->dcl_nom->name);
			ok = 1;
			break;
		     }
		  }
		  if (!ok)
		     bufcat(buf, " %d", (*iinfo)->default_val.i_val);

	       } else
		  bufcat(buf, " %d", (*iinfo)->default_val.i_val);
	       break;
	    case DOUBLE:
	       bufcat(buf, " %f", (*iinfo)->default_val.d_val);
	       break;
	    case CHAR:
	       bufcat(buf, " \"%s\"", (*iinfo)->default_val.str_val);
	       break;
	 }
      }
      else
	 bufcat(buf, " \"%s\" %s", name, defaultDefault);

      bufcat(buf, " ]\n");

   } else { /* STRUCT || UNION */
      /* recurse */
      DCL_NOM_LIST *m;
      char *var;

      for (m = nom->type->members; m != NULL; m = m->next) {
	 var = NULL;

	 bufcat(&var, "%s.%s", name, m->dcl_nom->name);
	 if (var == NULL) { 
	    fprintf(stderr, "Warning: null member name in %s.\n", name);
	    continue;
	 }

	 if (tclInputFormatGen(buf, var, m->dcl_nom, iinfo, level+1))
	    fprintf(stderr, "Warning: struct member %s was problematic.\n",
		    var);

	 free(var);
      }
   }
	  
   if (IS_ARRAY(nom)) {
      int i;

      /* End array scanning */
      for(i=IS_STRING(nom)?1:0;i<nom->ndimensions;i++) {
	 bufcat(buf, "}\n");
      }
      free(arrayName);
   }

   if (nom->type->type != STRUCT && nom->type->type != UNION)
      if ((*iinfo) != NULL) *iinfo = (*iinfo)->next;
   return 0;
}