Changeset 3692 for trunk/Ohana/src/opihi/lib.data/open_graph.c
- Timestamp:
- Apr 8, 2005, 5:38:38 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/opihi/lib.data/open_graph.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/lib.data/open_graph.c
r2598 r3692 51 51 for (i = 0; i < NXGRAPH; i++) { 52 52 if (Xgraph[i] > 0) { 53 write (Xgraph[i], "QUIT", 4);53 SendGraphCommand (Xgraph[i], 4, "QUIT"); 54 54 } 55 55 } … … 247 247 char buffer[64]; 248 248 249 write (Xgraph, "LABL", 4); 250 sprintf (buffer, " %6d %6d ", strlen (string), mode); 251 write (Xgraph, buffer, 16); 249 SendGraphCommand (Xgraph, 4, "LABL"); 250 SendGraphCommand (Xgraph, 16, "%6d %6d", strlen (string), mode); 252 251 write (Xgraph, string, strlen (string)); 253 252 return (TRUE); 254 253 } 254 255 /* send a message of arbitrary size, sending the size first */ 256 int SendGraphMessage (int device, char *format, ...) { 257 258 int Nbyte, status; 259 char *string, tmp; 260 va_list argp; 261 262 va_start (argp, format); 263 Nbyte = vsnprintf (&tmp, 0, format, argp); 264 va_end (argp); 265 266 if (!Nbyte) return (FALSE); 267 268 SendGraphCommand (device, 16, "NBYTES: %6d", Nbyte); 269 status = SendGraphCommandV (device, Nbyte, format, argp); 270 return (status); 271 } 272 273 int SendGraphCommand (int device, int length, char *format, ...) { 274 275 int status; 276 va_list argp; 277 278 va_start (argp, format); 279 status = SendGraphCommandV (device, length, format, argp); 280 va_end (argp); 281 return (status); 282 } 283 284 int SendGraphCommandV (int device, int length, char *format, va_list argp) { 285 286 int Nbyte; 287 char *string, tmp; 288 289 Nbyte = vsnprintf (&tmp, 0, format, argp); 290 if (Nbyte > length) return (FALSE); 291 292 /* I allocated and zero 1 extra byte */ 293 ALLOCATE (string, char, length + 1); 294 memset (string, 0, length + 1); 295 vsnprintf (string, length + 1, format, argp); 296 /* fprintf (stderr, "msg: %s\n", string); */ 297 write (device, string, length); 298 free (string); 299 return (TRUE); 300 }
Note:
See TracChangeset
for help on using the changeset viewer.
