Changeset 3472845
- Timestamp:
- Feb 11, 2011, 5:18:45 PM (14 years ago)
- Branches:
- master, release-1.10, release-1.8, release-1.9
- Children:
- 8a97586
- Parents:
- d4927a7
- git-author:
- Anders Kaseorg <andersk@mit.edu> (08/27/09 00:56:39)
- git-committer:
- Anders Kaseorg <andersk@mit.edu> (02/11/11 17:18:45)
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
aim.c
rd4927a7 r3472845 201 201 owl_global_set_doaimevents(&g); /* this should already be on */ 202 202 owl_function_makemsg("%s logged in", screenname); 203 buff= owl_sprintf("Logged in to AIM as %s", screenname);203 buff=g_strdup_printf("Logged in to AIM as %s", screenname); 204 204 owl_function_adminmsg("", buff); 205 205 g_free(buff); -
cmd.c
rd4927a7 r3472845 147 147 cmd->name = g_strdup(name); 148 148 cmd->cmd_aliased_to = g_strdup(aliased_to); 149 cmd->summary = owl_sprintf("%s%s", OWL_CMD_ALIAS_SUMMARY_PREFIX, aliased_to);149 cmd->summary = g_strdup_printf("%s%s", OWL_CMD_ALIAS_SUMMARY_PREFIX, aliased_to); 150 150 return(0); 151 151 } … … 186 186 } else { 187 187 cmdbuffargs = skiptokens(cmdbuff, 1); 188 newcmd = owl_sprintf("%s %s", cmd->cmd_aliased_to, cmdbuffargs);188 newcmd = g_strdup_printf("%s %s", cmd->cmd_aliased_to, cmdbuffargs); 189 189 rv = owl_function_command(newcmd); 190 190 g_free(newcmd); … … 247 247 char *owl_cmd_describe(const owl_cmd *cmd) { 248 248 if (!cmd || !cmd->name || !cmd->summary) return NULL; 249 return owl_sprintf("%-25s - %s", cmd->name, cmd->summary);249 return g_strdup_printf("%-25s - %s", cmd->name, cmd->summary); 250 250 } 251 251 -
commands.c
rd4927a7 r3472845 1413 1413 return NULL; 1414 1414 } 1415 return owl_sprintf("%d", owl_global_get_rightshift(&g));1415 return g_strdup_printf("%d", owl_global_get_rightshift(&g)); 1416 1416 } 1417 1417 -
functions.c
rd4927a7 r3472845 96 96 owl_fmtext *fm = user_data; 97 97 owl_timer *timer = data; 98 char *str = owl_sprintf("- %s: in %d seconds",99 timer->name ? timer->name : "(unnamed)",100 (int)(timer->time - time(NULL)));98 char *str = g_strdup_printf("- %s: in %d seconds", 99 timer->name ? timer->name : "(unnamed)", 100 (int)(timer->time - time(NULL))); 101 101 owl_fmtext_append_normal(fm, str); 102 102 g_free(str); 103 103 if (timer->interval) { 104 str = owl_sprintf(", repeat every %d seconds", timer->interval);104 str = g_strdup_printf(", repeat every %d seconds", timer->interval); 105 105 owl_fmtext_append_normal(fm, str); 106 106 g_free(str); … … 133 133 desc = "???"; 134 134 } 135 s = owl_sprintf("%-20s - %s%s", name,136 0==owl_style_validate(style)?"":"[INVALID] ",137 desc);135 s = g_strdup_printf("%-20s - %s%s", name, 136 0 == owl_style_validate(style) ? "" : "[INVALID] ", 137 desc); 138 138 return s; 139 139 } … … 216 216 char *perlquickstart = owl_perlconfig_execute("BarnOwl::Hooks::_get_quickstart()"); 217 217 if (perlquickstart) { 218 char *result = owl_sprintf("%s%s", message, perlquickstart);218 char *result = g_strdup_printf("%s%s", message, perlquickstart); 219 219 owl_function_adminmsg("BarnOwl Quickstart", result); 220 220 g_free(result); … … 311 311 owl_global_get_msg_history(&g)); 312 312 owl_editwin_set_dotsend(e); 313 s = owl_sprintf("----> %s\n", line);313 s = g_strdup_printf("----> %s\n", line); 314 314 owl_editwin_set_locktext(e, s); 315 315 g_free(s); … … 354 354 /* TODO: We probably actually want an owl_aimwrite object like 355 355 * owl_zwrite. */ 356 char *line = owl_sprintf("aimwrite %s", to);356 char *line = g_strdup_printf("aimwrite %s", to); 357 357 owl_function_write_setup("message"); 358 358 owl_function_start_edit_win(line, … … 438 438 old_msg = g_strdup(owl_zwrite_get_message(z)); 439 439 440 zcrypt = owl_sprintf("%s/zcrypt", owl_get_bindir());440 zcrypt = g_strdup_printf("%s/zcrypt", owl_get_bindir()); 441 441 argv[0] = "zcrypt"; 442 442 argv[1] = "-E"; … … 1991 1991 1992 1992 buff = skiptokens(buff, 1); 1993 newbuff = owl_sprintf("%s%s", buff, redirect);1993 newbuff = g_strdup_printf("%s%s", buff, redirect); 1994 1994 1995 1995 if (type == OWL_OUTPUT_POPUP) { … … 2193 2193 newname=g_strdup(filtername+4); 2194 2194 } else { 2195 newname= owl_sprintf("not-%s", filtername);2195 newname=g_strdup_printf("not-%s", filtername); 2196 2196 } 2197 2197 … … 2245 2245 } 2246 2246 tmp = owl_filter_print(f); 2247 buff = owl_sprintf("%s: %s", owl_filter_get_name(f), tmp);2247 buff = g_strdup_printf("%s: %s", owl_filter_get_name(f), tmp); 2248 2248 owl_function_popless_text(buff); 2249 2249 g_free(buff); … … 2305 2305 /* name for the filter */ 2306 2306 if (!instance) { 2307 filtname = owl_sprintf("%sclass-%s", related ? "related-" : "", class);2308 } else { 2309 filtname = owl_sprintf("%sclass-%s-instance-%s", related ? "related-" : "", class, instance);2307 filtname = g_strdup_printf("%sclass-%s", related ? "related-" : "", class); 2308 } else { 2309 filtname = g_strdup_printf("%sclass-%s-instance-%s", related ? "related-" : "", class, instance); 2310 2310 } 2311 2311 /* downcase it */ … … 2379 2379 /* name for the filter */ 2380 2380 shortuser = short_zuser(longuser); 2381 filtname = owl_sprintf("user-%s", shortuser);2381 filtname = g_strdup_printf("user-%s", shortuser); 2382 2382 g_free(shortuser); 2383 2383 … … 2425 2425 2426 2426 /* name for the filter */ 2427 filtname= owl_sprintf("aimuser-%s", user);2427 filtname=g_strdup_printf("aimuser-%s", user); 2428 2428 2429 2429 /* if it already exists then go with it. This lets users override */ … … 2435 2435 escuser = owl_text_quote(user, OWL_REGEX_QUOTECHARS, OWL_REGEX_QUOTEWITH); 2436 2436 2437 argbuff = owl_sprintf(2437 argbuff = g_strdup_printf( 2438 2438 "( type ^aim$ and ( ( sender ^%1$s$ and recipient ^%2$s$ ) or " 2439 2439 "( sender ^%2$s$ and recipient ^%1$s$ ) ) )", … … 2462 2462 2463 2463 /* name for the filter */ 2464 filtname= owl_sprintf("type-%s", type);2464 filtname=g_strdup_printf("type-%s", type); 2465 2465 2466 2466 /* if it already exists then go with it. This lets users override */ … … 2521 2521 ccs = owl_message_get_attribute_value(m, "zephyr_ccs"); 2522 2522 2523 filtname = owl_sprintf("conversation-%s", ccs);2523 filtname = g_strdup_printf("conversation-%s", ccs); 2524 2524 owl_text_tr(filtname, ' ', '-'); 2525 2525 … … 2763 2763 2764 2764 for(i = 8; i < COLORS; ++i) { 2765 char* str1 = owl_sprintf("%4i: ",i);2766 char* str2 = owl_sprintf("%i\n",i);2765 char* str1 = g_strdup_printf("%4i: ",i); 2766 char* str2 = g_strdup_printf("%i\n",i); 2767 2767 owl_fmtext_append_normal(&fm,str1); 2768 2768 owl_fmtext_append_normal_color(&fm, str2, i, OWL_COLOR_DEFAULT); … … 3392 3392 date[strlen(date)-1]='\0'; 3393 3393 3394 buff = owl_sprintf("%s %s", date, string);3394 buff = g_strdup_printf("%s %s", date, string); 3395 3395 3396 3396 owl_errqueue_append_err(owl_global_get_errqueue(&g), buff); -
global.c
rd4927a7 r3472845 94 94 g->confdir = NULL; 95 95 g->startupfile = NULL; 96 cd = owl_sprintf("%s/%s", g->homedir, OWL_CONFIG_DIR);96 cd = g_strdup_printf("%s/%s", g->homedir, OWL_CONFIG_DIR); 97 97 owl_global_set_confdir(g, cd); 98 98 g_free(cd); … … 382 382 g->confdir = g_strdup(cd); 383 383 g_free(g->startupfile); 384 g->startupfile = owl_sprintf("%s/startup", cd);384 g->startupfile = g_strdup_printf("%s/startup", cd); 385 385 } 386 386 … … 965 965 g->debug_file = NULL; 966 966 967 path = owl_sprintf("%s.%d", filename, getpid());967 path = g_strdup_printf("%s.%d", filename, getpid()); 968 968 fd = open(path, O_CREAT|O_WRONLY|O_EXCL, 0600); 969 969 g_free(path); -
keymap.c
rd4927a7 r3472845 85 85 { 86 86 if (!km || !km->name || !km->desc) return NULL; 87 return owl_sprintf("%-15s - %s", km->name, km->desc);87 return g_strdup_printf("%-15s - %s", km->name, km->desc); 88 88 } 89 89 -
logging.c
rd4927a7 r3472845 149 149 to = short_zuser(owl_message_get_recipient(m)); 150 150 } else if (owl_message_is_type_jabber(m)) { 151 to = owl_sprintf("jabber:%s", owl_message_get_recipient(m));151 to = g_strdup_printf("jabber:%s", owl_message_get_recipient(m)); 152 152 owl_text_tr(to, '/', '_'); 153 153 } else if (owl_message_is_type_aim(m)) { … … 155 155 temp = owl_aim_normalize_screenname(owl_message_get_recipient(m)); 156 156 temp2 = g_utf8_strdown(temp,-1); 157 to = owl_sprintf("aim:%s", temp2);157 to = g_strdup_printf("aim:%s", temp2); 158 158 g_free(temp2); 159 159 g_free(temp); … … 269 269 temp = owl_aim_normalize_screenname(owl_message_get_sender(m)); 270 270 normalto = g_utf8_strdown(temp, -1); 271 from=frombuff= owl_sprintf("aim:%s", normalto);271 from=frombuff=g_strdup_printf("aim:%s", normalto); 272 272 g_free(normalto); 273 273 g_free(temp); … … 276 276 } else if (owl_message_is_type_jabber(m)) { 277 277 if (personal) { 278 from=frombuff= owl_sprintf("jabber:%s",owl_message_get_sender(m));279 } else { 280 from=frombuff= owl_sprintf("jabber:%s",owl_message_get_recipient(m));278 from=frombuff=g_strdup_printf("jabber:%s",owl_message_get_sender(m)); 279 } else { 280 from=frombuff=g_strdup_printf("jabber:%s",owl_message_get_recipient(m)); 281 281 } 282 282 } else { -
message.c
rd4927a7 r3472845 127 127 for (i=0; i<j; i++) { 128 128 p=owl_list_get_element(&(m->attributes), i); 129 buff= owl_sprintf(" %-15.15s: %-35.35s\n", owl_pair_get_key(p), owl_pair_get_value(p));129 buff=g_strdup_printf(" %-15.15s: %-35.35s\n", owl_pair_get_key(p), owl_pair_get_value(p)); 130 130 if(buff == NULL) { 131 buff= owl_sprintf(" %-15.15s: %-35.35s\n", owl_pair_get_key(p), "<error>");131 buff=g_strdup_printf(" %-15.15s: %-35.35s\n", owl_pair_get_key(p), "<error>"); 132 132 if(buff == NULL) 133 133 buff=g_strdup(" <error>\n"); … … 888 888 char *zcrypt; 889 889 890 zcrypt = owl_sprintf("%s/zcrypt", owl_get_bindir());890 zcrypt = g_strdup_printf("%s/zcrypt", owl_get_bindir()); 891 891 892 892 rv = call_filter(zcrypt, argv, owl_message_get_body(m), &out, &status); -
owl.c
rd4927a7 r3472845 434 434 } 435 435 436 err = owl_sprintf("[stderr]\n%s", buf);436 err = g_strdup_printf("[stderr]\n%s", buf); 437 437 438 438 owl_function_log_err(err); -
perlconfig.c
rd4927a7 r3472845 150 150 utype = g_strdup(type); 151 151 utype[0] = toupper(type[0]); 152 blessas = owl_sprintf("BarnOwl::Message::%s", utype);152 blessas = g_strdup_printf("BarnOwl::Message::%s", utype); 153 153 154 154 hr = newRV_noinc((SV*)h); … … 240 240 n->z_multinotice = zstr("[zephyr created from perl]"); 241 241 n->z_num_other_fields = 0; 242 n->z_message = owl_sprintf("%s%c%s", owl_message_get_zsig(m), '\0', owl_message_get_body(m));242 n->z_message = g_strdup_printf("%s%c%s", owl_message_get_zsig(m), '\0', owl_message_get_body(m)); 243 243 n->z_message_len = strlen(owl_message_get_zsig(m)) + strlen(owl_message_get_body(m)) + 1; 244 244 } … … 404 404 /* Add the system lib path to @INC */ 405 405 inc = get_av("INC", 0); 406 path = owl_sprintf("%s/lib", owl_get_datadir());406 path = g_strdup_printf("%s/lib", owl_get_datadir()); 407 407 av_unshift(inc, 1); 408 408 av_store(inc, 0, owl_new_sv(path)); -
util.c
rd4927a7 r3472845 285 285 286 286 if (days>0) { 287 out= owl_sprintf("%i d %2.2i:%2.2li", days, hours, run);287 out=g_strdup_printf("%i d %2.2i:%2.2li", days, hours, run); 288 288 } else { 289 out= owl_sprintf(" %2.2i:%2.2li", hours, run);289 out=g_strdup_printf(" %2.2i:%2.2li", hours, run); 290 290 } 291 291 return(out); 292 }293 294 /* allocates memory and returns the string or null.295 * caller must free the string.296 */297 char *owl_sprintf(const char *fmt, ...)298 {299 va_list ap;300 char *ret = NULL;301 va_start(ap, fmt);302 ret = g_strdup_vprintf(fmt, ap);303 va_end(ap);304 return ret;305 292 } 306 293 … … 468 455 return -1; /* resolving the symlink failed, but we already logged this error */ 469 456 470 newfile = owl_sprintf("%s.new", actual_filename);457 newfile = g_strdup_printf("%s.new", actual_filename); 471 458 if ((new = fopen(newfile, "w")) == NULL) { 472 459 owl_function_error("Cannot open %s (for writing): %s", … … 500 487 501 488 if (backup) { 502 backupfile = owl_sprintf("%s.backup", actual_filename);489 backupfile = g_strdup_printf("%s.backup", actual_filename); 503 490 unlink(backupfile); 504 491 if (link(actual_filename, backupfile) != 0) { -
zephyr.c
rd4927a7 r3472845 25 25 return g_strdup(input); 26 26 else 27 return owl_sprintf("%s/%s", owl_global_get_homedir(&g), name);27 return g_strdup_printf("%s/%s", owl_global_get_homedir(&g), name); 28 28 } 29 29 … … 588 588 field4 = owl_zephyr_get_field(n, 4); 589 589 590 msg = owl_sprintf("%s service on %s %s\n%s", n->z_opcode, n->z_class_inst, field3, field4);590 msg = g_strdup_printf("%s service on %s %s\n%s", n->z_opcode, n->z_class_inst, field3, field4); 591 591 g_free(field3); 592 592 g_free(field4); … … 606 606 field5 = owl_zephyr_get_field(n, 5); 607 607 608 msg = owl_sprintf("New transaction [%s] entered in %s\nFrom: %s (%s)\nSubject: %s", field1, field2, field3, field5, field4);608 msg = g_strdup_printf("New transaction [%s] entered in %s\nFrom: %s (%s)\nSubject: %s", field1, field2, field3, field5, field4); 609 609 g_free(field1); 610 610 g_free(field2); … … 622 622 field1 = owl_zephyr_get_field(n, 1); 623 623 624 msg = owl_sprintf("MOIRA %s on %s: %s", n->z_class_inst, owl_message_get_hostname(m), field1);624 msg = g_strdup_printf("MOIRA %s on %s: %s", n->z_class_inst, owl_message_get_hostname(m), field1); 625 625 g_free(field1); 626 626 if (msg) { … … 882 882 myuser=short_zuser(to); 883 883 if (!strcasecmp(owl_message_get_instance(m), "personal")) { 884 tmpbuff = owl_sprintf("zwrite %s", myuser);884 tmpbuff = g_strdup_printf("zwrite %s", myuser); 885 885 } else { 886 tmpbuff = owl_sprintf("zwrite -i %s %s", owl_message_get_instance(m), myuser);886 tmpbuff = g_strdup_printf("zwrite -i %s %s", owl_message_get_instance(m), myuser); 887 887 } 888 888 g_free(myuser); … … 927 927 ret = ZLocateUser(zstr(user), &numlocs, auth ? ZAUTH : ZNOAUTH); 928 928 if (ret != ZERR_NONE) 929 return owl_sprintf("Error locating user %s: %s\n",930 929 return g_strdup_printf("Error locating user %s: %s\n", 930 user, error_message(ret)); 931 931 932 932 myuser = short_zuser(user); 933 933 if (numlocs == 0) { 934 result = owl_sprintf("%s: Hidden or not logged in\n", myuser);934 result = g_strdup_printf("%s: Hidden or not logged in\n", myuser); 935 935 } else { 936 936 result = g_strdup(""); 937 937 for (; numlocs; numlocs--) { 938 938 ZGetLocations(&locations, &one); 939 p = owl_sprintf("%s%s: %s\t%s\t%s\n",939 p = g_strdup_printf("%s%s: %s\t%s\t%s\n", 940 940 result, myuser, 941 941 locations.host ? locations.host : "?", … … 1017 1017 char *owl_zephyr_makesubline(const char *class, const char *inst, const char *recip) 1018 1018 { 1019 return owl_sprintf("%s,%s,%s\n", class, inst, !strcmp(recip, "") ? "*" : recip);1019 return g_strdup_printf("%s,%s,%s\n", class, inst, !strcmp(recip, "") ? "*" : recip); 1020 1020 } 1021 1021 … … 1146 1146 } else { 1147 1147 /* g_string_append_printf would be backwards. */ 1148 char *tmp = owl_sprintf("<%s,%s,%s>\n",1149 sub.zsub_class,1150 sub.zsub_classinst,1151 sub.zsub_recipient);1148 char *tmp = g_strdup_printf("<%s,%s,%s>\n", 1149 sub.zsub_class, 1150 sub.zsub_classinst, 1151 sub.zsub_recipient); 1152 1152 g_string_prepend(buf, tmp); 1153 1153 g_free(tmp); … … 1203 1203 return(g_strdup(in)); 1204 1204 } 1205 return( owl_sprintf("%s@%s", in, owl_zephyr_get_realm()));1205 return(g_strdup_printf("%s@%s", in, owl_zephyr_get_realm())); 1206 1206 } 1207 1207 -
zwrite.c
rd4927a7 r3472845 176 176 for (i=0; i<j; i++) { 177 177 if (strcmp(z->realm, "")) { 178 to = owl_sprintf("%s@%s", (const char *) owl_list_get_element(&(z->recips), i), z->realm);178 to = g_strdup_printf("%s@%s", (const char *) owl_list_get_element(&(z->recips), i), z->realm); 179 179 } else { 180 180 to = g_strdup(owl_list_get_element(&(z->recips), i)); … … 207 207 tmp = toline; 208 208 if (strcmp(z->realm, "")) { 209 toline = owl_sprintf( "%s%s@%s ", toline, (const char *) owl_list_get_element(&(z->recips), i), z->realm);209 toline = g_strdup_printf( "%s%s@%s ", toline, (const char *) owl_list_get_element(&(z->recips), i), z->realm); 210 210 } else { 211 toline = owl_sprintf( "%s%s ", toline, (const char *) owl_list_get_element(&(z->recips), i));211 toline = g_strdup_printf( "%s%s ", toline, (const char *) owl_list_get_element(&(z->recips), i)); 212 212 } 213 213 g_free(tmp); … … 216 216 tmp = owl_validate_utf8(msg); 217 217 tmp2 = owl_text_expand_tabs(tmp); 218 z->message= owl_sprintf("%s\n%s", toline, tmp2);218 z->message=g_strdup_printf("%s\n%s", toline, tmp2); 219 219 g_free(toline); 220 220 g_free(tmp); … … 250 250 for (i=0; i<j; i++) { 251 251 if (strcmp(z->realm, "")) { 252 to = owl_sprintf("%s@%s", (const char *) owl_list_get_element(&(z->recips), i), z->realm);252 to = g_strdup_printf("%s@%s", (const char *) owl_list_get_element(&(z->recips), i), z->realm); 253 253 } else { 254 254 to = g_strdup( owl_list_get_element(&(z->recips), i)); … … 262 262 } 263 263 } else { 264 to = owl_sprintf( "@%s", z->realm);264 to = g_strdup_printf( "@%s", z->realm); 265 265 ret = send_zephyr(z->opcode, z->zsig, z->class, z->inst, to, z->message); 266 266 }
Note: See TracChangeset
for help on using the changeset viewer.