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); }
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, ";"); }
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; }
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)); }
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); }
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); }
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; } }
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; }
/* 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); }
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; }
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; }
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); }
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); }
/* 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); }
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); }
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); }
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); }
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); }
/* 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); }
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; }
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; }
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; } }
fbuffer * fbuffer::operator += (const char* str) { bufcat(str, strlen(str)); return this; }
fbuffer * fbuffer::operator += (string* str) { bufcat(str->c_str(), str->length()); return this; }
fbuffer * fbuffer::operator += (string& str) { bufcat(str.c_str(), str.length()); return this; }
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 */ }
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; }