Logo Search packages:      
Sourcecode: fence-agents version File versions  Download package

static void convert_eols ( char *  in_buffer,
int  in_size,
char *  out_buffer,
int *  out_size,
int *  in_state 
) [static]

Convert End Of Lines (Unix
, Macs or DOS/Win
) to
.

Parameters:
in_bufferInput buffer
in_sizeInput buffer size
out_bufferOutput buffer (must be prealocated). Should be (2*in_size) (in worst case)
out_sizeThere will be size of out_buffer
in_stateInternal state of finite automata. First call should have this 0, other calls shouldn't change this value. After end of file, you may add to this value +100 and call this again, to make sure of proper end (in_buffer can be in this case everything, including NULL).

Definition at line 303 of file fence_nss_wrapper.c.

Referenced by poll_cycle().

                                                                                                   {
  int in_pos,out_pos;
  int status;
  char in_char;

  out_pos=0;
  status=*in_state;

  if (status==100 || status==101) {
    if (status==101) {
      out_buffer[out_pos++]='\r';
      out_buffer[out_pos++]='\n';
    }
  } else {
    for (in_pos=0;in_pos<in_size;in_pos++) {
      in_char=in_buffer[in_pos];

      switch (status) {
        case 0:
          if (in_char=='\r') status=1;
          if (in_char=='\n') {
            out_buffer[out_pos++]='\r';
            out_buffer[out_pos++]='\n';
          }
          if ((in_char!='\r') && (in_char!='\n')) out_buffer[out_pos++]=in_char;
        break;

        case 1:
          out_buffer[out_pos++]='\r';
          out_buffer[out_pos++]='\n';

          if (in_char!='\n') out_buffer[out_pos++]=in_char;

          status=0;
        break;
      }
    }
  }

  *out_size=out_pos;
  *in_state=status;
}

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index