Changeset 924ee11


Ignore:
Timestamp:
Mar 29, 2009, 11:35:26 AM (12 years ago)
Author:
James M. Kretchmar <kretch@mit.edu>
Branches:
owl
Children:
73d8a88
Parents:
5345ea7
Message:
sprintf cleanup
File:
1 edited

Legend:

Unmodified
Added
Removed
  • functions.c

    r5345ea7 r924ee11  
    18251825void owl_function_status()
    18261826{
    1827   char buff[5000];
     1827  char cwdbuff[MAXPATHLEN+1];
     1828  char *buff;
    18281829  time_t start;
    18291830  int up, days, hours, minutes;
     
    18451846
    18461847  owl_fmtext_append_normal(&fm, "  Current Directory: ");
    1847   (void) getcwd(buff, MAXPATHLEN);
     1848  if(getcwd(cwdbuff, MAXPATHLEN) == NULL) {
     1849    owl_fmtext_append_normal(&fm, "<Error in getcwd>");
     1850  } else {
     1851    owl_fmtext_append_normal(&fm, cwdbuff);
     1852  }
     1853  owl_fmtext_append_normal(&fm, "\n");
     1854
     1855  buff=owl_sprintf("  Startup Time: %s", ctime(&start));
    18481856  owl_fmtext_append_normal(&fm, buff);
    1849   owl_fmtext_append_normal(&fm, "\n");
    1850 
    1851   sprintf(buff, "  Startup Time: %s", ctime(&start));
    1852   owl_fmtext_append_normal(&fm, buff);
     1857  owl_free(buff);
    18531858
    18541859  up=owl_global_get_runtime(&g);
     
    18591864  minutes=up/60;
    18601865  up-=minutes*60;
    1861   sprintf(buff, "  Run Time: %i days %2.2i:%2.2i:%2.2i\n", days, hours, minutes, up);
     1866
     1867  buff=owl_sprintf("  Run Time: %i days %2.2i:%2.2i:%2.2i\n", days, hours, minutes, up);
    18621868  owl_fmtext_append_normal(&fm, buff);
     1869  owl_free(buff);
    18631870
    18641871  owl_fmtext_append_normal(&fm, "\nProtocol Options:\n");
     
    18841891  owl_fmtext_append_normal(&fm, "\nMemory Usage:\n");
    18851892  owl_fmtext_append_normal(&fm, "  Not currently available.\n");
    1886   /*
    1887   sprintf(buff, "%sMemory Malloced: %i\n", buff, owl_global_get_malloced(&g));
    1888   sprintf(buff, "%sMemory Freed: %i\n", buff, owl_global_get_freed(&g));
    1889   sprintf(buff, "%sMemory In Use: %i\n", buff, owl_global_get_meminuse(&g));
    1890   */
    18911893
    18921894  owl_fmtext_append_normal(&fm, "\nAIM Status:\n");
     
    19131915{
    19141916  owl_fmtext fm;
    1915   char buff[LINE];
     1917  char *buff;
    19161918
    19171919  owl_fmtext_init_null(&fm);
    1918   sprintf(buff, "Terminal Lines: %i\nTerminal Columns: %i\n",
    1919           owl_global_get_lines(&g),
    1920           owl_global_get_cols(&g));
     1920  buff=owl_sprintf("Terminal Lines: %i\nTerminal Columns: %i\n",
     1921                   owl_global_get_lines(&g),
     1922                   owl_global_get_cols(&g));
    19211923  owl_fmtext_append_normal(&fm, buff);
     1924  owl_free(buff);
    19221925
    19231926  if (owl_global_get_hascolors(&g)) {
    19241927    owl_fmtext_append_normal(&fm, "Color: Yes\n");
    1925     sprintf(buff, "Number of color pairs: %i\n", owl_global_get_colorpairs(&g));
     1928    buff=owl_sprintf("Number of color pairs: %i\n", owl_global_get_colorpairs(&g));
    19261929    owl_fmtext_append_normal(&fm, buff);
    1927     sprintf(buff, "Can change colors: %s\n", can_change_color() ? "yes" : "no");
     1930    owl_free(buff);
     1931    buff=owl_sprintf("Can change colors: %s\n", can_change_color() ? "yes" : "no");
    19281932    owl_fmtext_append_normal(&fm, buff);
     1933    owl_free(buff);
    19291934  } else {
    19301935    owl_fmtext_append_normal(&fm, "Color: No\n");
     
    19421947void owl_function_reply(int type, int enter)
    19431948{
    1944   char *buff=NULL, *oldbuff;
     1949  char *buff=NULL, *tmpbuff;
    19451950  owl_message *m;
    19461951  owl_filter *f;
     
    20262031        buff=owl_strdup("zcrypt");
    20272032      } else {
    2028         buff = owl_strdup("zwrite");
     2033        buff=owl_strdup("zwrite");
    20292034      }
    20302035      if (strcasecmp(class, "message")) {
    2031         buff = owl_sprintf("%s -c %s%s%s", oldbuff=buff, owl_getquoting(class), class, owl_getquoting(class));
    2032         owl_free(oldbuff);
     2036        tmpbuff=owl_sprintf("%s -c %s%s%s", buff, owl_getquoting(class), class, owl_getquoting(class));
     2037        owl_free(buff);
     2038        buff=tmpbuff;
    20332039      }
    20342040      if (strcasecmp(inst, "personal")) {
    2035         buff = owl_sprintf("%s -i %s%s%s", oldbuff=buff, owl_getquoting(inst), inst, owl_getquoting(inst));
    2036         owl_free(oldbuff);
     2041        tmpbuff=owl_sprintf("%s -i %s%s%s", buff, owl_getquoting(inst), inst, owl_getquoting(inst));
     2042        owl_free(buff);
     2043        buff=tmpbuff;
    20372044      }
    20382045      if (*to != '\0') {
     
    20422049          tmp = owl_util_uniq(oldtmp=tmp, cc, "-");
    20432050          owl_free(oldtmp);
    2044           buff = owl_sprintf("%s -C %s", oldbuff=buff, tmp);
    2045           owl_free(oldbuff);
     2051          tmpbuff=owl_sprintf("%s -C %s", buff, tmp);
     2052          owl_free(buff);
     2053          buff=tmpbuff;
    20462054        } else {
    20472055          if (owl_global_is_smartstrip(&g)) {
     
    20502058            owl_free(tmp2);
    20512059          }
    2052           buff = owl_sprintf("%s %s", oldbuff=buff, tmp);
    2053           owl_free(oldbuff);
     2060          tmpbuff=owl_sprintf("%s %s", buff, tmp);
     2061          owl_free(buff);
     2062          buff=tmpbuff;
    20542063        }
    20552064        owl_free(tmp);
Note: See TracChangeset for help on using the changeset viewer.