IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 3, 2005, 5:50:08 PM (21 years ago)
Author:
eugene
Message:

psched / pscontrol / pclient dev work

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/lib.shell/memstr.c

    r4689 r4705  
    11# include "shell.h"
    22
     3/* memstr returns a view, not an allocated string : don't free */
    34/* returns pointer to start of m2 in m1, or NULL if failure */
    45char *memstr (char *m1, char *m2, int n) {
     
    1213
    1314}
     15
     16/* formatted write statement, with intelligent allocation */
     17int write_fmt (int fd, char *format, ...) {
     18
     19  int Nbyte, status;
     20  char tmp, *line;
     21  va_list argp; 
     22
     23  va_start (argp, format);
     24  Nbyte = vsnprintf (&tmp, 0, format, argp);
     25  va_end (argp);
     26
     27  va_start (argp, format);
     28  ALLOCATE (line, char, Nbyte + 1);
     29  vsnprintf (line, Nbyte + 1, format, argp);
     30  status = write (fd, line, strlen(line));
     31  va_end (argp);
     32
     33  free (line);
     34  return (status);
     35}
Note: See TracChangeset for help on using the changeset viewer.