format_data.h File Reference

Go to the source code of this file.

Defines

#define __FORMAT_DATA_H

Functions

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


Define Documentation

#define __FORMAT_DATA_H

Definition at line 31 of file DATA_PRINT/format_data.h.


Function Documentation

char* format_data_after_int ( char *  _buffer  ) 

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

Referenced by format_data_after_float(), and format_data_get_data().

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

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

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

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

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


Generated on Thu Dec 17 19:57:24 2009 for AVR32 UC3 - EVK1104 DSPLib Demo Documentation by  doxygen 1.5.5