Changeset 353 in MondoRescue for branches/stable/monitas/from-mondo.c


Ignore:
Timestamp:
Jan 28, 2006, 6:42:59 PM (18 years ago)
Author:
bcornec
Message:

monitas latest version

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/stable/monitas/from-mondo.c

    r352 r353  
    88
    99
    10 extern void log_it_SUB(char*, t_loglevel, char*);
     10//extern void log_it_SUB(char*, t_loglevel, char*);
    1111char *call_program_and_get_last_line_of_output(char*);
    1212int call_program_and_log_output (char *);
     
    1717
    1818
    19 extern char g_logfile[MAX_STR_LEN+1];
    2019
    2120
     
    215214/*************************************************************************
    216215 * strip_spaces() -- Hugo Rabson                                         *
    217  *                                                                       *
    218  * Purpose:                                                              *
     216 *                   rewitten Stefan Huebner                             *
     217 *                                                                       *
     218 * Purpose:   remove leading whitespaces and control characters, replace *
     219 *            TABs by SPACES, remove previous char when followed with BS,*
     220 *            skip control chars, terminate string with '\0' when CR or  *
     221 *            NL is detected                                             *
     222 *            afterwards remove trailing whitespace                      *
    219223 * Called by:                                                            *
    220224 * Returns:                                                              *
     
    223227strip_spaces (char *in_out)
    224228{
     229    char *r, *w;
     230    r = w = in_out;             // initialize read and write pointer
     231
     232    while ( *r && *r <= ' ' )
     233        ++r;                    // skip leading whitespace and control chars
     234
     235    for ( ; *r ; ++r )          // until end of existing string do:
     236      {
     237        if (*r == '\t')                 // TAB
     238          { *w++ = ' ';                     // write SPACE instead
     239            continue; }
     240        if (*r == (char) 8)             // BACKSPACE
     241          { if (w > in_out) --w;            // remove previous character (if any ;-)
     242            continue; }
     243        if (*r == '\n' || *r == '\r')   // CR and LF
     244            break;                          // terminate copying
     245        if (*r < ' ')                   // Control chars
     246            continue;                       // are ignored (skipped)
     247        *w++ = *r;                      // all other chars are copied
     248      }
     249    // all characters are copied
     250    *w = '\0';                  // terminate the copied string
     251    for (--w; w>in_out && *w == ' '; --w)
     252        *w = '\0';              // remove trailing whitespaces
     253    return;
    225254    /** buffers ******************************************************/
    226   char tmp[MAX_STR_LEN+1];
     255//  char tmp[MAX_STR_LEN+1];
    227256
    228257    /** pointers *****************************************************/
    229   char *p;
     258//  char *p;
    230259
    231260    /** int *********************************************************/
    232   int i;
     261//  int i;
    233262
    234263    /** end vars ****************************************************/
    235   for (i = 0; in_out[i] <= ' ' && i < strlen (in_out); i++);
     264/*  for (i = 0; in_out[i] <= ' ' && i < strlen (in_out); i++);
    236265  strcpy (tmp, in_out + i);
    237266  for (i = strlen (tmp); i>0 && tmp[i - 1] <= 32; i--);
     
    277306    }
    278307  in_out[i] = '\0';
     308*/
    279309/*  for(i=strlen(in_out); i>0 && in_out[i-1]<=32; i--) {in_out[i-1]='\0';} */
    280310}
Note: See TracChangeset for help on using the changeset viewer.