format_data.h File Reference

Go to the source code of this file.

Functions

char * format_data_after_int (char *_buffer)
int format_data_get_data (char *_input, char *_buffer, char *_pattern, int size, int n_arg)


Function Documentation

char* format_data_after_int ( char *  _buffer  ) 

Definition at line 43 of file DATA_EXTRACT/format_data.c.

Referenced by format_data_after_float(), and format_data_get_data().

00044 {
00045      int stop = 0;
00046 
00047      // If there is a negative character, skip it
00048      if (*_buffer == '-')
00049         _buffer++;
00050      // loop until the character is in the range [0;9]
00051      while(*_buffer && !stop)
00052      {
00053           if (*_buffer < '0' || *_buffer > '9')
00054               stop = 1;
00055           else
00056               _buffer++;
00057      }
00058 
00059      // Returns the pointer
00060      return _buffer;
00061 }

int format_data_get_data ( char *  _input,
char *  _buffer,
char *  _pattern,
int  size,
int  n_arg 
)

Definition at line 82 of file DATA_PRINT/format_data.c.

References ADD_DATA, format_data_after_float(), format_data_after_int(), SET_ERROR, and templates_get_string().

00083 {
00084      char _str[256];
00085      char _cur_pattern[256];
00086      char _value[32];
00087      char _str_value[256];
00088      char *_ppattern, *_pcur_pattern, *_pstr;
00089      int stop = 0;
00090      int cur_arg;
00091      int i_buffer = 0;
00092      int i;
00093      float f;
00094 
00095      char _temp[256];
00096      char _buffer_temp[256];
00097 
00098      size *= sizeof(float);
00099 
00100      while(*_input && !stop)
00101      {
00102          // to compute one line
00103          _ppattern = _pattern;
00104          cur_arg = 0;
00105          while(*_ppattern && !stop)
00106          {
00107              _input = templates_get_string(_input, _str);
00108              _ppattern = templates_get_string(_ppattern, _cur_pattern);
00109     
00110              _pstr = _str;
00111              _pcur_pattern = _cur_pattern;
00112              while(*_pstr && !stop)
00113              {
00114                    switch(*_pcur_pattern)  
00115                    {
00116                    case '%':
00117                         _pcur_pattern++;
00118                         cur_arg++;
00119                         switch(*_pcur_pattern)
00120                         {
00121                         case 'd':
00122                         case 'i':
00123                              // MessageBox(NULL, "%i", _pstr, 0);
00124                              if (!sscanf(_pstr, "%f", &i))
00125                                 stop = 1;
00126                              else
00127                              {
00128                                  _pstr = format_data_after_int(_pstr);
00129                                  ADD_DATA(i);
00130                              }
00131                              break;
00132                         case 'f':
00133                             //  MessageBox(NULL, "%f", _pstr, 0);
00134                              if (!sscanf(_pstr, "%f", &f))
00135                                 stop = 1;
00136                              else
00137                              {
00138                                  _pstr = format_data_after_float(_pstr);
00139                                  ADD_DATA(f);
00140                              }
00141                              break;
00142                         case '%':
00143                              cur_arg--;
00144                              if (*_pstr != '%')
00145                                 stop = 1;
00146                              else
00147                                 _pstr++;
00148                              break;
00149                         default:
00150                              SET_ERROR("Pattern not supported!");
00151                              stop = 1;
00152                              break;
00153                         }
00154                         _pcur_pattern++;
00155                         break;
00156                    default:
00157                         // MessageBox(NULL, _pstr, _pcur_pattern, 0);
00158                         if (*_pstr != *_pcur_pattern)
00159                            stop = 1;
00160                         else
00161                         {
00162                             _pstr++;
00163                             _pcur_pattern++;
00164                         }
00165                    }
00166              }
00167          }
00168     }
00169 
00170     return i_buffer/sizeof(float);
00171 }


Generated on Fri Feb 19 02:23:19 2010 for AVR32 UC3 - EVK1104 DSPLib Demo Documentation by  doxygen 1.5.5