Commit 0a3c9668a98596b5881a8985b45f0317c795499d

Authored by perry.werneck@gmail.com
1 parent 3a0ae668

Limpando funções sem uso

@@ -326,6 +326,7 @@ AC_SUBST(JRE_HOME) @@ -326,6 +326,7 @@ AC_SUBST(JRE_HOME)
326 AC_CHECK_HEADER(malloc.h, AC_DEFINE(HAVE_MALLOC_H,,[do we have malloc.h?])) 326 AC_CHECK_HEADER(malloc.h, AC_DEFINE(HAVE_MALLOC_H,,[do we have malloc.h?]))
327 327
328 AC_CHECK_FUNCS(getaddrinfo, AC_DEFINE(HAVE_GETADDRINFO) ) 328 AC_CHECK_FUNCS(getaddrinfo, AC_DEFINE(HAVE_GETADDRINFO) )
  329 +AC_CHECK_FUNC(vasprintf, AC_DEFINE(HAVE_VASPRINTF) )
329 330
330 PKG_CHECK_EXISTS 331 PKG_CHECK_EXISTS
331 332
src/include/lib3270/config.h.in
@@ -43,6 +43,7 @@ @@ -43,6 +43,7 @@
43 #undef HAVE_GETADDRINFO 43 #undef HAVE_GETADDRINFO
44 #undef HAVE_SYSLOG 44 #undef HAVE_SYSLOG
45 #undef HAVE_DBUS 45 #undef HAVE_DBUS
  46 + #undef HAVE_VASPRINTF
46 47
47 #undef HAVE_ICONV 48 #undef HAVE_ICONV
48 #undef ICONV_CONST 49 #undef ICONV_CONST
src/lib3270/util.c
1 /* 1 /*
2 * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 2 * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
3 * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a 3 * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
4 - * aplicativos mainframe. Registro no INPI sob o nome G3270. Registro no INPI sob o nome G3270. 4 + * aplicativos mainframe. Registro no INPI sob o nome G3270. Registro no INPI sob
  5 + * o nome G3270.
5 * 6 *
6 * Copyright (C) <2008> <Banco do Brasil S.A.> 7 * Copyright (C) <2008> <Banco do Brasil S.A.>
7 * 8 *
@@ -18,7 +19,7 @@ @@ -18,7 +19,7 @@
18 * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin 19 * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
19 * St, Fifth Floor, Boston, MA 02110-1301 USA 20 * St, Fifth Floor, Boston, MA 02110-1301 USA
20 * 21 *
21 - * Este programa está nomeado como util.c e possui 978 linhas de código. 22 + * Este programa está nomeado como util.c e possui - linhas de código.
22 * 23 *
23 * Contatos: 24 * Contatos:
24 * 25 *
@@ -35,6 +36,8 @@ @@ -35,6 +36,8 @@
35 * Utility functions for x3270/c3270/s3270/tcl3270 36 * Utility functions for x3270/c3270/s3270/tcl3270
36 */ 37 */
37 38
  39 +#define _GNU_SOURCE
  40 +
38 #if defined(_WIN32) 41 #if defined(_WIN32)
39 #include <winsock2.h> 42 #include <winsock2.h>
40 #include <windows.h> 43 #include <windows.h>
@@ -230,7 +233,7 @@ xs_error(const char *fmt, ...) @@ -230,7 +233,7 @@ xs_error(const char *fmt, ...)
230 lib3270_free(r); 233 lib3270_free(r);
231 } 234 }
232 235
233 -/* Prettyprinter for strings with unprintable data. */ 236 +/* Prettyprinter for strings with unprintable data. */ /*
234 void 237 void
235 fcatv(FILE *f, char *s) 238 fcatv(FILE *f, char *s)
236 { 239 {
@@ -256,8 +259,9 @@ fcatv(FILE *f, char *s) @@ -256,8 +259,9 @@ fcatv(FILE *f, char *s)
256 } 259 }
257 } 260 }
258 } 261 }
  262 +*/
259 263
260 -/* String version of fcatv. */ 264 +/* String version of fcatv. */ /*
261 char * 265 char *
262 scatv(const char *s, char *buf, size_t len) 266 scatv(const char *s, char *buf, size_t len)
263 { 267 {
@@ -268,7 +272,7 @@ scatv(const char *s, char *buf, size_t len) @@ -268,7 +272,7 @@ scatv(const char *s, char *buf, size_t len)
268 char cbuf[5]; 272 char cbuf[5];
269 char *t = cbuf; 273 char *t = cbuf;
270 274
271 - /* Expand this character. */ 275 + // Expand this character.
272 switch (c) { 276 switch (c) {
273 case '\n': 277 case '\n':
274 (void) strcpy(cbuf, "\\n"); 278 (void) strcpy(cbuf, "\\n");
@@ -288,7 +292,7 @@ scatv(const char *s, char *buf, size_t len) @@ -288,7 +292,7 @@ scatv(const char *s, char *buf, size_t len)
288 } 292 }
289 break; 293 break;
290 } 294 }
291 - /* Copy as much as will fit. */ 295 + // Copy as much as will fit.
292 while ((c = *t++) && len > 0) { 296 while ((c = *t++) && len > 0) {
293 *dst++ = c; 297 *dst++ = c;
294 len--; 298 len--;
@@ -299,6 +303,7 @@ scatv(const char *s, char *buf, size_t len) @@ -299,6 +303,7 @@ scatv(const char *s, char *buf, size_t len)
299 303
300 return buf; 304 return buf;
301 } 305 }
  306 +*/
302 307
303 /* 308 /*
304 * Definition resource splitter, for resources of the repeating form: 309 * Definition resource splitter, for resources of the repeating form:
@@ -527,7 +532,7 @@ get_message(const char *key) @@ -527,7 +532,7 @@ get_message(const char *key)
527 532
528 // #define ex_getenv getenv 533 // #define ex_getenv getenv
529 534
530 -/* Variable and tilde substitution functions. */ 535 +/* Variable and tilde substitution functions. */ /*
531 static char * 536 static char *
532 var_subst(const char *s) 537 var_subst(const char *s)
533 { 538 {
@@ -606,7 +611,7 @@ var_subst(const char *s) @@ -606,7 +611,7 @@ var_subst(const char *s)
606 (void) strncpy(o, vn_start, vn_len); 611 (void) strncpy(o, vn_start, vn_len);
607 o += vn_len; 612 o += vn_len;
608 state = VS_BASE; 613 state = VS_BASE;
609 - continue; /* rescan */ 614 + continue; // rescan
610 } 615 }
611 vn = lib3270_malloc(vn_len + 1); 616 vn = lib3270_malloc(vn_len + 1);
612 (void) strncpy(vn, vn_start, vn_len); 617 (void) strncpy(vn, vn_start, vn_len);
@@ -617,10 +622,10 @@ var_subst(const char *s) @@ -617,10 +622,10 @@ var_subst(const char *s)
617 { 622 {
618 *o = '\0'; 623 *o = '\0';
619 o_len = o_len 624 o_len = o_len
620 - - 1 /* '$' */  
621 - - (state == VS_VNB) /* { */  
622 - - vn_len /* name */  
623 - - (state == VS_VNB) /* } */ 625 + - 1 // '$'
  626 + - (state == VS_VNB) //
  627 + - vn_len // name
  628 + - (state == VS_VNB) // }
624 + strlen(vv); 629 + strlen(vv);
625 ob = Realloc(ob, o_len); 630 ob = Realloc(ob, o_len);
626 o = strchr(ob, '\0'); 631 o = strchr(ob, '\0');
@@ -634,7 +639,7 @@ var_subst(const char *s) @@ -634,7 +639,7 @@ var_subst(const char *s)
634 state = VS_BASE; 639 state = VS_BASE;
635 break; 640 break;
636 } else { 641 } else {
637 - /* Rescan this character */ 642 + // Rescan this character
638 state = VS_BASE; 643 state = VS_BASE;
639 continue; 644 continue;
640 } 645 }
@@ -649,12 +654,14 @@ var_subst(const char *s) @@ -649,12 +654,14 @@ var_subst(const char *s)
649 } 654 }
650 return ob; 655 return ob;
651 } 656 }
  657 +*/
652 658
653 -#if !defined(_WIN32) /*[*/ 659 +#if !defined(_WIN32)
654 /* 660 /*
655 * Do tilde (home directory) substitution on a string. Returns a malloc'd 661 * Do tilde (home directory) substitution on a string. Returns a malloc'd
656 * result. 662 * result.
657 */ 663 */
  664 + /*
658 static char * 665 static char *
659 tilde_subst(const char *s) 666 tilde_subst(const char *s)
660 { 667 {
@@ -665,11 +672,11 @@ tilde_subst(const char *s) @@ -665,11 +672,11 @@ tilde_subst(const char *s)
665 char *r; 672 char *r;
666 char *mname = CN; 673 char *mname = CN;
667 674
668 - /* Does it start with a "~"? */ 675 + // Does it start with a "~"?
669 if (*s != '~') 676 if (*s != '~')
670 return NewString(s); 677 return NewString(s);
671 678
672 - /* Terminate with "/". */ 679 + // Terminate with "/".
673 slash = strchr(s, '/'); 680 slash = strchr(s, '/');
674 if (slash) { 681 if (slash) {
675 int len = slash - s; 682 int len = slash - s;
@@ -684,16 +691,16 @@ tilde_subst(const char *s) @@ -684,16 +691,16 @@ tilde_subst(const char *s)
684 rest = strchr(name, '\0'); 691 rest = strchr(name, '\0');
685 } 692 }
686 693
687 - /* Look it up. */  
688 - if (!strcmp(name, "~")) /* this user */ 694 + // Look it up.
  695 + if (!strcmp(name, "~")) // this user
689 p = getpwuid(getuid()); 696 p = getpwuid(getuid());
690 - else /* somebody else */ 697 + else // somebody else
691 p = getpwnam(name + 1); 698 p = getpwnam(name + 1);
692 699
693 - /* Free any temporary copy. */ 700 + // Free any temporary copy.
694 lib3270_free(mname); 701 lib3270_free(mname);
695 702
696 - /* Substitute and return. */ 703 + // Substitute and return.
697 if (p == (struct passwd *)NULL) 704 if (p == (struct passwd *)NULL)
698 r = NewString(s); 705 r = NewString(s);
699 else { 706 else {
@@ -702,9 +709,9 @@ tilde_subst(const char *s) @@ -702,9 +709,9 @@ tilde_subst(const char *s)
702 (void) strcat(r, rest); 709 (void) strcat(r, rest);
703 } 710 }
704 return r; 711 return r;
705 -}  
706 -#endif /*]*/  
707 - 712 +} */
  713 +#endif
  714 +/*
708 char * 715 char *
709 do_subst(const char *s, Boolean do_vars, Boolean do_tilde) 716 do_subst(const char *s, Boolean do_vars, Boolean do_tilde)
710 { 717 {
@@ -715,7 +722,7 @@ do_subst(const char *s, Boolean do_vars, Boolean do_tilde) @@ -715,7 +722,7 @@ do_subst(const char *s, Boolean do_vars, Boolean do_tilde)
715 char *t; 722 char *t;
716 723
717 t = var_subst(s); 724 t = var_subst(s);
718 -#if !defined(_WIN32) /*[*/ 725 +#if !defined(_WIN32)
719 if (do_tilde) { 726 if (do_tilde) {
720 char *u; 727 char *u;
721 728
@@ -723,17 +730,19 @@ do_subst(const char *s, Boolean do_vars, Boolean do_tilde) @@ -723,17 +730,19 @@ do_subst(const char *s, Boolean do_vars, Boolean do_tilde)
723 lib3270_free(t); 730 lib3270_free(t);
724 return u; 731 return u;
725 } 732 }
726 -#endif /*]*/ 733 +#endif
727 return t; 734 return t;
728 } 735 }
729 736
730 -#if !defined(_WIN32) /*[*/ 737 +#if !defined(_WIN32)
731 return tilde_subst(s); 738 return tilde_subst(s);
732 -#else /*][*/ 739 +#else
733 return NewString(s); 740 return NewString(s);
734 -#endif /*]*/ 741 +#endif
735 } 742 }
736 743
  744 +*/
  745 +
737 /* 746 /*
738 * ctl_see 747 * ctl_see
739 * Expands a character in the manner of "cat -v". 748 * Expands a character in the manner of "cat -v".
src/lib3270/utilc.h
@@ -20,12 +20,12 @@ @@ -20,12 +20,12 @@
20 20
21 LIB3270_INTERNAL void add_resource(const char *name, const char *value); 21 LIB3270_INTERNAL void add_resource(const char *name, const char *value);
22 LIB3270_INTERNAL char *ctl_see(int c); 22 LIB3270_INTERNAL char *ctl_see(int c);
23 -LIB3270_INTERNAL char *do_subst(const char *s, Boolean do_vars, Boolean do_tilde);  
24 -LIB3270_INTERNAL void fcatv(FILE *f, char *s); 23 +// LIB3270_INTERNAL char *do_subst(const char *s, Boolean do_vars, Boolean do_tilde);
  24 +// LIB3270_INTERNAL void fcatv(FILE *f, char *s);
25 LIB3270_INTERNAL const char *get_message(const char *key); 25 LIB3270_INTERNAL const char *get_message(const char *key);
26 LIB3270_INTERNAL const char *get_fresource(H3270 *hSession, const char *fmt, ...) printflike(2, 3); 26 LIB3270_INTERNAL const char *get_fresource(H3270 *hSession, const char *fmt, ...) printflike(2, 3);
27 LIB3270_INTERNAL const char *get_resource(H3270 *hSession, const char *name); 27 LIB3270_INTERNAL const char *get_resource(H3270 *hSession, const char *name);
28 -LIB3270_INTERNAL char *scatv(const char *s, char *buf, size_t len); 28 +// LIB3270_INTERNAL char *scatv(const char *s, char *buf, size_t len);
29 LIB3270_INTERNAL int split_dbcs_resource(const char *value, char sep, char **part1, 29 LIB3270_INTERNAL int split_dbcs_resource(const char *value, char sep, char **part1,
30 char **part2); 30 char **part2);
31 LIB3270_INTERNAL int split_dresource(char **st, char **left, char **right); 31 LIB3270_INTERNAL int split_dresource(char **st, char **left, char **right);