source: app/src/lib/iotools.h @ 25ae32e

help
Last change on this file since 25ae32e was 25ae32e, checked in by obrebski <obrebski@…>, 16 years ago

git-svn-id: svn://atos.wmid.amu.edu.pl/utt@4 e293616e-ec6a-49c2-aa92-f4a8b91c5d16

  • Property mode set to 100644
File size: 1.4 KB
Line 
1#include "const.h"
2#include <string.h>
3#include <stdio.h>
4#include <stdio.h>
5#include <string.h>
6#include <stdlib.h>
7
8
9// napisy zostaj na miejscu (w line), tylko wskazniki sa ustawian
10// i zara dopisywane zera s dopisywane
11
12inline
13int parsetok(char* line, int* a, int* b, char** c, char** d, char** e, char** f)
14{
15  char* field;
16  if((field=strtok(line,FIELD_SEP))!=NULL)
17    *a=atoi(field); // nie sprawdzana poprawnosc
18  else
19    return 0;
20  if((field=strtok(NULL,FIELD_SEP))!=NULL)
21    *b=atoi(field); // nie sprawdzana poprawnosc
22  else return 1;
23  if((*c=strtok(NULL,FIELD_SEP))==NULL) return 2;
24  if((*d=strtok(NULL,FIELD_SEP))==NULL) return 3;
25  if((*e=strtok(NULL,FIELD_SEP))==NULL) return 4;
26  if((*f=strtok(NULL,FIELD_SEP))==NULL) return 6;
27  return 6;
28}
29
30// napisy s kopiowane
31inline
32int scantok(const char* line, int* a, int* b, char* c, char* d, char* e=NULL, char* f=NULL)
33{
34  return sscanf(line," %d %d %s %s %s %s", a, b, c, d, e, f);
35}
36
37inline
38int printtok(char* line, int a, int b, char* c, char* d, char* e, char* f, char* parms)
39{
40  sprintf(line,"%04d %02d %s %s %s %s `%s\n", a, b, c, d, e, f, parms);
41}
42
43inline
44int printtok(char* line, int a, int b, char* c, char* d, char* e, char* f)
45{
46  sprintf(line,"%04d %02d %s %s %s %s\n", a, b, c, d, e, f);
47}
48
49inline
50int printtok(char* line, int a, int b, char* c, char* d)
51{
52  sprintf(line,"%04d %02d %s %s\n", a, b, c, d);
53}
Note: See TracBrowser for help on using the repository browser.