diff options
Diffstat (limited to 'src/outstream.c')
-rw-r--r-- | src/outstream.c | 118 |
1 files changed, 0 insertions, 118 deletions
diff --git a/src/outstream.c b/src/outstream.c deleted file mode 100644 index 9ad33715..00000000 --- a/src/outstream.c +++ /dev/null | |||
@@ -1,118 +0,0 @@ | |||
1 | /* Copyrights 2002 Luis Figueiredo (stdio@netc.pt) All rights reserved. | ||
2 | * | ||
3 | * See the LICENSE file | ||
4 | * | ||
5 | * The origin of this software must not be misrepresented, either by | ||
6 | * explicit claim or by omission. Since few users ever read sources, | ||
7 | * credits must appear in the documentation. | ||
8 | * | ||
9 | * date: Sat Mar 30 14:25:25 GMT 2002 | ||
10 | * | ||
11 | * -- stream list functions | ||
12 | */ | ||
13 | |||
14 | |||
15 | #include "outstream.h" | ||
16 | |||
17 | /*********************************************************************************************************/ | ||
18 | /* | ||
19 | * add_outstream, add a file to output (client) stream | ||
20 | */ | ||
21 | int __ILWS_add_outstream(struct outstream *list,char *fname,FILE* stream,int istmp){ | ||
22 | struct outstream *temp=list; | ||
23 | FILE *tmp; | ||
24 | while(temp->next!=NULL)temp=temp->next; | ||
25 | |||
26 | if(!(temp->next=__ILWS_malloc(sizeof(struct outstream)))) { | ||
27 | return 0; | ||
28 | }; | ||
29 | // file check (0.5.3); | ||
30 | tmp=fopen(fname,"rb"); | ||
31 | if(tmp==NULL) { | ||
32 | __ILWS_free(temp->next); | ||
33 | temp->next=NULL; | ||
34 | return 0; | ||
35 | }; | ||
36 | fclose(tmp); | ||
37 | // -- | ||
38 | temp->next->fname=NULL; | ||
39 | if(fname!=NULL) { | ||
40 | if(!(temp->next->fname=__ILWS_malloc(strlen(fname)+1))) { | ||
41 | __ILWS_free(temp->next); | ||
42 | temp->next=NULL; | ||
43 | return 0; | ||
44 | }; | ||
45 | memcpy(temp->next->fname,fname,strlen(fname)); | ||
46 | temp->next->fname[strlen(fname)]='\0'; | ||
47 | }; | ||
48 | temp->next->todelete=istmp; | ||
49 | temp->next->fstream=stream; | ||
50 | temp->next->wsize=1; | ||
51 | temp->next->rsize=0; | ||
52 | temp->next->wrotesize=0; | ||
53 | temp->next->varsize=0; | ||
54 | temp->next->next=NULL; | ||
55 | return 1; | ||
56 | } | ||
57 | |||
58 | /*********************************************************************************************************/ | ||
59 | /* | ||
60 | * Initializate (allocate) outstream list | ||
61 | */ | ||
62 | struct outstream *__ILWS_init_outstream_list() { | ||
63 | struct outstream *ret; | ||
64 | |||
65 | |||
66 | if(!(ret=__ILWS_malloc(sizeof(struct outstream)))) { | ||
67 | return NULL; | ||
68 | }; | ||
69 | ret->todelete=0; | ||
70 | ret->fname=NULL; | ||
71 | ret->flags=0; | ||
72 | ret->fstream=NULL; | ||
73 | ret->next=NULL; | ||
74 | return ret; | ||
75 | } | ||
76 | |||
77 | /*********************************************************************************************************/ | ||
78 | /* | ||
79 | * Delete a especific node | ||
80 | */ | ||
81 | void __ILWS_delete_outstream(struct outstream *node) { // Changed | ||
82 | int rt; | ||
83 | if(node->fstream!=NULL)fclose(node->fstream); // better here; | ||
84 | if(node->todelete) { // is temporary file | ||
85 | rt=unlink(node->fname); | ||
86 | if(rt==-1) { | ||
87 | }; | ||
88 | |||
89 | }; | ||
90 | if(node->fname!=NULL)__ILWS_free(node->fname); | ||
91 | __ILWS_free(node); | ||
92 | } | ||
93 | |||
94 | /*********************************************************************************************************/ | ||
95 | /* | ||
96 | * delete next node | ||
97 | */ | ||
98 | void __ILWS_delete_next_outstream(struct outstream *node) { | ||
99 | struct outstream *temp=node->next; | ||
100 | node->next=node->next->next; | ||
101 | __ILWS_delete_outstream(temp); | ||
102 | } | ||
103 | |||
104 | /*********************************************************************************************************/ | ||
105 | /* | ||
106 | * delete all nodes on the list (reset list) | ||
107 | */ | ||
108 | void __ILWS_delete_outstream_list(struct outstream *list) { | ||
109 | struct outstream *temp=list; | ||
110 | while(temp->next!=NULL) { | ||
111 | |||
112 | __ILWS_delete_next_outstream(temp); | ||
113 | }; | ||
114 | |||
115 | __ILWS_delete_outstream(temp); | ||
116 | |||
117 | } | ||
118 | |||