File: wncstl.c

package info (click to toggle)
libwn6 6.0-17
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, sarge
  • size: 6,012 kB
  • ctags: 3,903
  • sloc: ansic: 45,078; makefile: 960; csh: 274; sh: 17
file content (129 lines) | stat: -rw-r--r-- 2,467 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/******************************************************************************

wn_make_file_parse_cstream(&stream,f)
wn_make_file_write_cstream(&stream,f)
wn_make_string_parse_cstream(&stream,string)

void wn_file_parse_move_block(block,pactually_moved,request_moved,pf)
void wn_file_write_move_block(block,pactually_moved,request_moved,pf)

void wn_string_parse_move_block(block,pactually_moved,request_moved,pstring)

******************************************************************************/
/****************************************************************************

COPYRIGHT NOTICE:

  The source code in this file is provided free of charge
  to the author's consulting clients.  It is in the
  public domain and therefore may be used by anybody for
  any purpose.

AUTHOR:

  Will Naylor

****************************************************************************/

#include "wnlib.h"
#include "wncstr.h"
#include "wnio.h"
#include "wnmax.h"



wn_make_file_parse_cstream(pstream,f)

wn_cstream *pstream;
wn_file f;

{
  void wn_file_parse_move_block();

  wn_make_cstream(pstream,(wn_file_parse_move_block),(ptr)f,2048,WN_PARSE);
}



wn_make_file_write_cstream(pstream,f)

wn_cstream *pstream;
wn_file f;

{
  void wn_file_write_move_block();

  wn_make_cstream(pstream,(wn_file_write_move_block),(ptr)f,2048,WN_WRITE);
}



wn_make_string_parse_cstream(pstream,string)

wn_cstream *pstream;
char string[];

{
  void wn_string_parse_move_block();

  wn_make_cstream(pstream,(wn_string_parse_move_block),(ptr)string,32,
                  WN_PARSE);
}



void wn_file_parse_move_block(block,pactually_moved,request_moved,pf)

char block[];
int *pactually_moved,request_moved;
wn_file *pf;

{
  *pactually_moved = wn_fread(block,1,request_moved,*pf);
}



void wn_file_write_move_block(block,pactually_moved,request_moved,pf)

char block[];
int *pactually_moved,request_moved;
wn_file *pf;

{
  *pactually_moved = wn_fwrite(block,1,request_moved,*pf);
}



void wn_string_parse_move_block(block,pactually_moved,request_moved,pstring)

register char *block;
int *pactually_moved;
register int request_moved;
char **pstring;

{
  register char *string;
  register int actually_moved;

  actually_moved = 0;

  for(string = *pstring;*string != '\0';string++)
  {
    if(actually_moved >= request_moved)
    {
      break;
    }

    *block = *string;

    block++; actually_moved++;
  }

  *pactually_moved = actually_moved;
  *pstring = string;
}