Use c2pstrcpy() rather than silly sprintf() tricks.
[u/mdw/putty] / mac / macterm.c
index 220fa2c..18cc392 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: macterm.c,v 1.35 2003/01/05 11:31:51 ben Exp $ */
+/* $Id: macterm.c,v 1.38 2003/01/09 22:51:41 ben Exp $ */
 /*
  * Copyright (c) 1999 Simon Tatham
  * Copyright (c) 1999, 2002 Ben Harris
@@ -223,6 +223,10 @@ void mac_startsession(Session *s)
     sprintf(msg, "Elapsed ticks: %d\015\012", TickCount() - starttime);
     inbuf_putstr(s, msg);
     term_out(s->term);
+    s->next = sesslist;
+    s->prev = s->next->prev;
+    s->next->prev = &s->next;
+    sesslist = s;
 }
 
 static UnicodeToTextFallbackUPP uni_to_font_fallback_upp;
@@ -234,7 +238,7 @@ static void mac_initfont(Session *s) {
     OptionBits fbflags;
 
     SetPort(s->window);
-    macfont[0] = sprintf((char *)&macfont[1], "%s", s->cfg.font);
+    c2pstrcpy(macfont, s->cfg.font);
     GetFNum(macfont, &s->fontnum);
     TextFont(s->fontnum);
     TextFace(s->cfg.fontisbold ? bold : 0);
@@ -300,6 +304,18 @@ static pascal OSStatus uni_to_font_fallback(UniChar *ucp,
     return noErr;
 }
 
+/*
+ * Called every time round the event loop.
+ */
+void mac_pollterm(void)
+{
+    Session *s;
+
+    for (s = sesslist; s != NULL; s = s->next) {
+       term_out(s->term);
+       term_update(s->term);
+    }
+}
 
 /*
  * To be called whenever the window size changes.
@@ -869,6 +885,7 @@ static pascal void mac_growtermdraghook(void)
     GrafPtr portsave;
     Point mouse;
     char buf[20];
+    unsigned char pbuf[20];
     int newrows, newcols;
     
     GetMouse(&mouse);
@@ -880,13 +897,13 @@ static pascal void mac_growtermdraghook(void)
     if (strcmp(buf, growterm_state.oldmsg) == 0)
        return;
     strcpy(growterm_state.oldmsg, buf);
-    c2pstr(buf);
+    c2pstrcpy(pbuf, buf);
 
     GetPort(&portsave);
     SetPort(growterm_state.s->window);
     EraseRect(&growterm_state.msgrect);
     MoveTo(growterm_state.msgorigin.h, growterm_state.msgorigin.v);
-    DrawString((StringPtr)buf);
+    DrawString(pbuf);
     SetPort(portsave);
 }
 
@@ -1252,7 +1269,7 @@ void set_title(void *frontend, char *title) {
     Session *s = frontend;
     Str255 mactitle;
 
-    mactitle[0] = sprintf((char *)&mactitle[1], "%s", title);
+    c2pstrcpy(mactitle, title);
     SetWTitle(s->window, mactitle);
 }