/** \file * \brief IupScanf implementation. * * See Copyright Notice in "iup.h" */ #include #include #include #include #include "iup.h" #include "iup_predial.h" #include "iup_str.h" #include "iup_assert.h" #define ALLOC(n,t) ((t *)calloc((n),sizeof(t))) #define REQUIRE(b) {if (!(b)) goto cleanup;} int IupScanf (const char *format, ...) { int i; int fields_out_count=(-1); /* return code if not error (error < 0) */ int error=(-1); /* return code if error (error >= 0) */ int fields_in_count; int *width=NULL; int *scroll=NULL; char **prompt=NULL; char **text=NULL; char *title=NULL; char *s=NULL; char *s1=NULL; char *outf=NULL; va_list va; iupASSERT(format!=NULL); if (!format) return 0; fields_in_count=iupStrCountChar(format,'\n')-1; REQUIRE(fields_in_count>0); width=ALLOC(fields_in_count, int); REQUIRE(width!=NULL); scroll=ALLOC(fields_in_count, int); REQUIRE(scroll!=NULL); prompt=ALLOC(fields_in_count, char *); REQUIRE(prompt!=NULL); text=ALLOC(fields_in_count, char *); REQUIRE(text!=NULL); va_start(va,format); REQUIRE ((s1=s=(char *)iupStrDup(format)) != NULL); title=iupStrCopyUntil(&s,'\n'); REQUIRE(title!=NULL); for (i=0; i0); fields_out_count=0; va_start(va,format); s=strchr(format,'\n')+1; for (i=0; i