Whamcloud - gitweb
Check in ext2ed version 0.1
[tools/e2fsprogs.git] / ext2ed / general_com.c
1 /*
2
3 /usr/src/ext2ed/general_com.c
4
5 A part of the extended file system 2 disk editor.
6
7 ---------------------
8 General user commands
9 ---------------------
10
11 First written on: April 9 1995
12
13 Copyright (C) 1995 Gadi Oxman
14
15 */
16
17 #include <stdio.h>
18 #include <stdlib.h>
19 #include <string.h>
20
21 #include "ext2ed.h"
22
23 void help (char *command_line)
24
25 {
26         int i,max_line=0;
27         char argument [80],*ptr;
28
29         werase (show_pad);wmove (show_pad,0,0);
30
31         ptr=parse_word (command_line,argument);
32
33         if (*ptr!=0) {
34                  ptr=parse_word (ptr,argument);
35                  if (*argument!=0) {             
36                          detailed_help (argument);
37                          return;
38                 }
39         }
40
41         if (current_type!=NULL) {
42                 
43                 wprintw (show_pad,"Type %s specific commands:\n",current_type->name);max_line++;
44                 
45                 if (current_type->type_commands.last_command==-1) {
46                         wprintw (show_pad,"\nnone\n");max_line+=2;
47                 }
48                 else
49                         for (i=0;i<=current_type->type_commands.last_command;i++) {
50                                 if (i%5==0) {
51                                         wprintw (show_pad,"\n");max_line++;
52                                 }
53                                 wprintw (show_pad,"%-13s",current_type->type_commands.names [i]);
54                                 if (i%5!=4)
55                                         wprintw (show_pad,";  ");                               
56                         }
57                 
58                 wprintw (show_pad,"\n\n");max_line+=2;
59         }               
60
61         if (ext2_commands.last_command != -1) {
62                 wprintw (show_pad,"ext2 filesystem general commands: \n");max_line++;
63                 for (i=0;i<=ext2_commands.last_command;i++) {
64                         if (i%5==0) {
65                                 wprintw (show_pad,"\n");max_line++;
66                         }
67                         wprintw (show_pad,"%-13s",ext2_commands.names [i]);
68                         if (i%5!=4)
69                                 wprintw (show_pad,";  ");                               
70
71                 }
72                 wprintw (show_pad,"\n\n");max_line+=2;
73         }
74
75         wprintw (show_pad,"General commands: \n");
76         
77         for (i=0;i<=general_commands.last_command;i++) {
78                 if (i%5==0) {
79                         wprintw (show_pad,"\n");max_line++;
80                 }
81                 wprintw (show_pad,"%-13s",general_commands.names [i]);
82                 if (i%5!=4)
83                         wprintw (show_pad,";  ");                               
84         }
85         
86         wprintw (show_pad,"\n\n");max_line+=2;
87         
88         wprintw (show_pad,"EXT2ED ver %d.%d (%s)\n",version_major,version_minor,revision_date);
89         wprintw (show_pad,"Copyright (C) 1995 Gadi Oxman\n");
90         wprintw (show_pad,"EXT2ED is hereby placed under the terms of the GNU General Public License.\n\n");
91         wprintw (show_pad,"EXT2ED was programmed as a student project in the software laboratory\n");
92         wprintw (show_pad,"of the faculty of electrical engineering in the\n");
93         wprintw (show_pad,"Technion - Israel Institute of Technology\n");
94         wprintw (show_pad,"with the guide of Avner Lottem and Dr. Ilana David.\n");
95
96         max_line+=6;
97         
98         wprintw (show_pad,"\n\n");max_line+=2;
99         
100         wprintw (show_pad,"Please feel free to mail me at (currently) %s\n",email_address);
101         wprintw (show_pad,"with any commet, suggestion, and of-course, bug report concerning EXT2ED.\n");
102         
103         max_line+=2;
104         
105         show_pad_info.line=0;show_pad_info.max_line=max_line;
106
107         werase (show_win);wmove (show_win,0,0);
108         wprintw (show_win,"EXT2ED help");
109         
110         refresh_show_win ();
111         refresh_show_pad ();
112 }
113
114 void detailed_help (char *text)
115
116 {
117         int i;
118         
119         if (current_type != NULL)
120                 for (i=0;i<=current_type->type_commands.last_command;i++) {
121                         if (strcmp (current_type->type_commands.names [i],text)==0) {
122                                 wprintw (show_pad,"%s - %s\n",text,current_type->type_commands.descriptions [i]);
123                                 refresh_show_pad ();return;
124                         }
125                 }
126
127         for (i=0;i<=ext2_commands.last_command;i++) {
128                 if (strcmp (ext2_commands.names [i],text)==0) {
129                                 wprintw (show_pad,"%s - %s\n",text,ext2_commands.descriptions [i]);
130                                 refresh_show_pad ();return;
131                 }
132         }
133
134         for (i=0;i<=general_commands.last_command;i++) {
135                 if (strcmp (general_commands.names [i],text)==0) {
136                                 wprintw (show_pad,"%s - %s\n",text,general_commands.descriptions [i]);
137                                 refresh_show_pad ();return;
138                 }
139         }
140
141         if (strcmp ("quit",text)==0) {
142                 wprintw (show_pad,"quit - Exists EXT2ED");
143                 refresh_show_pad ();return;
144         }
145
146         wprintw (show_pad,"Error - Command %s not aviable now\n",text);
147         refresh_show_pad ();return;
148 }
149
150
151
152 void set_device (char *command_line)
153
154 {
155         char *ptr,new_device [80];
156         
157         ptr=parse_word (command_line,new_device);
158         if (*ptr==0) {
159                 wprintw (command_win,"Error - Device name not specified\n");
160                 refresh_command_win ();return;
161         }
162         parse_word (ptr,new_device);    
163         check_mounted (new_device);
164         if (mounted && !AllowMountedRead) {
165                 wprintw (command_win,"Error - Filesystem is mounted, aborting\n");
166                 wprintw (command_win,"You may wish to use the AllowMountedRead on configuration option\n");
167                 refresh_command_win ();return;
168         }
169         
170         if (mounted && AllowMountedRead) {
171                 wprintw (command_win,"Warning - Filesystem is mounted. Displayed data may be unreliable.\n");
172                 refresh_command_win ();
173         }
174
175         if (device_handle!=NULL)
176                 fclose (device_handle);
177                 
178         if ( (device_handle=fopen (new_device,"rb"))==NULL) {
179                 wprintw (command_win,"Error - Can not open device %s\n",new_device);refresh_command_win ();
180                 return;
181         }
182         else {
183                 strcpy (device_name,new_device);
184                 write_access=0;                         /* Write access disabled */
185                 current_type=NULL;                      /* There is no type now */
186                 remember_lifo.entries_count=0;          /* Empty Object memory */
187                 free_user_commands (&ext2_commands);    /* Free filesystem specific objects */
188                 free_struct_descriptors ();
189                 if (!set_file_system_info ()) {         /* Error while getting info --> abort */
190                         free_user_commands (&ext2_commands);
191                         free_struct_descriptors ();
192                         fclose (device_handle);
193                         device_handle=NULL;             /* Notice that our device is still not set up */
194                         device_offset=-1;
195                         return;
196                 }
197                 if (*AlternateDescriptors)              /* Check if user defined objects exist */
198                         set_struct_descriptors (AlternateDescriptors);
199                 dispatch ("setoffset 0");
200                 dispatch ("help");                      /* Show help screen */
201                 wprintw (command_win,"Device changed to %s",device_name);refresh_command_win ();
202         }
203 }
204
205 void set_offset (char *command_line)
206
207 {
208         long mult=1;
209         long new_offset;
210         char *ptr,new_offset_buffer [80];
211         
212         if (device_handle==NULL) {
213                 wprintw (command_win,"Error - No device opened\n");refresh_command_win ();
214                 return;
215         }
216         
217         ptr=parse_word (command_line,new_offset_buffer);
218         
219         if (*ptr==0) {
220                 wprintw (command_win,"Error - No argument specified\n");refresh_command_win ();
221                 return;
222         }
223
224         ptr=parse_word (ptr,new_offset_buffer);
225
226         if (strcmp (new_offset_buffer,"block")==0) {
227                 mult=file_system_info.block_size;
228                 ptr=parse_word (ptr,new_offset_buffer);
229         }
230
231         if (strcmp (new_offset_buffer,"type")==0) {
232                 if (current_type==NULL) {
233                         wprintw (command_win,"Error - No type set\n");refresh_command_win ();
234                         return;
235                 }
236
237                 mult=current_type->length;
238                 ptr=parse_word (ptr,new_offset_buffer);
239         }
240
241         if (*new_offset_buffer==0) {
242                 wprintw (command_win,"Error - No offset specified\n");refresh_command_win ();
243                 return;
244         }
245
246         if (new_offset_buffer [0]=='+') {
247                 if (device_offset==-1) {
248                         wprintw (command_win,"Error - Select a fixed offset first\n");refresh_command_win ();
249                         return;
250                 }
251                 new_offset=device_offset+atol (new_offset_buffer+1)*mult;
252         }
253         
254         else if (new_offset_buffer [0]=='-') {
255                 if (device_offset==-1) {
256                         wprintw (command_win,"Error - Select a fixed offset first\n");refresh_command_win ();
257                         return;
258                 }
259                 new_offset=device_offset-atol (new_offset_buffer+1)*mult;
260                 if (new_offset<0) new_offset=0;
261         }
262         
263         else 
264                 new_offset=atol (new_offset_buffer)*mult;
265         
266         if ( (fseek (device_handle,new_offset,SEEK_SET))==-1) {
267                 wprintw (command_win,"Error - Failed to seek to offset %ld in device %s\n",new_offset,device_name);
268                 refresh_command_win ();
269                 return;
270         };
271         device_offset=new_offset;
272         wprintw (command_win,"Device offset changed to %ld\n",device_offset);refresh_command_win ();
273         load_type_data ();
274         type_data.offset_in_block=0;
275 }
276
277 void set (char *command_line)
278
279 {
280         unsigned short *int_ptr;
281         unsigned char *char_ptr;
282         unsigned long *long_ptr,offset=0;
283         int i,found=0;
284         char *ptr,buffer [80],variable [80],value [80];
285         
286         if (device_handle==NULL) {
287                 wprintw (command_win,"Error - No device opened\n");refresh_command_win ();
288                 return;
289         }
290
291         if (current_type==NULL) {
292                 hex_set (command_line);
293                 return;
294         }
295
296         ptr=parse_word (command_line,buffer);
297         if (ptr==NULL || *ptr==0) {
298                 wprintw (command_win,"Error - Missing arguments\n");refresh_command_win ();
299                 return;
300         }
301         parse_word (ptr,buffer);
302         ptr=strchr (buffer,'=');
303         if (ptr==NULL) {
304                 wprintw (command_win,"Error - Bad syntax\n");refresh_command_win ();return;
305         }
306         strncpy (variable,buffer,ptr-buffer);variable [ptr-buffer]=0;
307         strcpy (value,++ptr);
308
309         if (current_type==NULL) {
310                 wprintw (command_win,"Sorry, not yet supported\n");refresh_command_win ();return;
311         }
312         
313         for (i=0;i<current_type->fields_num && !found;i++) {
314                 if (strcmp (current_type->field_names [i],variable)==0) {
315                         found=1;
316                         ptr=type_data.u.buffer+offset;
317                         switch (current_type->field_lengths [i]) {
318                                 case 1:
319                                         char_ptr=(unsigned char *) ptr;
320                                         *char_ptr=(char) atoi (value);
321                                         wprintw (command_win,"Variable %s set to %u\n",variable,*char_ptr);refresh_command_win ();
322                                         break;
323                                 case 2:
324                                         int_ptr=(unsigned short *) ptr;
325                                         *int_ptr=atoi (value);
326                                         wprintw (command_win,"Variable %s set to %u\n",variable,*int_ptr);refresh_command_win ();
327                                         break;
328
329                                 case 4:
330                                         long_ptr=(unsigned long *) ptr;
331                                         *long_ptr=atol (value);
332                                         wprintw (command_win,"Variable %s set to %lu\n",variable,*long_ptr);refresh_command_win ();
333                                         break;
334                         }
335                 }
336                 offset+=current_type->field_lengths [i];
337         }
338         if (found)
339                 dispatch ("show");
340         else {
341                 wprintw (command_win,"Error - Variable %s not found\n",variable);
342                 refresh_command_win ();
343         }
344 }
345
346 void hex_set (char *command_line)
347
348 {
349         unsigned char tmp;
350         char *ptr,buffer [80],*ch_ptr;
351         int mode=HEX;
352         
353         ptr=parse_word (command_line,buffer);
354         if (*ptr==0) {
355                 wprintw (command_win,"Error - Argument not specified\n");refresh_command_win ();return;
356         }
357
358         ptr=parse_word (ptr,buffer);
359
360         if (strcasecmp (buffer,"text")==0) {
361                 mode=TEXT;
362                 strcpy (buffer,ptr);
363         }
364
365         else if (strcasecmp (buffer,"hex")==0) {
366                 mode=HEX;
367                 ptr=parse_word (ptr,buffer);
368         }
369
370         if (*buffer==0) {
371                 wprintw (command_win,"Error - Data not specified\n");refresh_command_win ();return;
372         }
373
374         if (mode==HEX) {
375                 do {
376                         tmp=(unsigned char) strtol (buffer,NULL,16);
377                         type_data.u.buffer [type_data.offset_in_block]=tmp;
378                         type_data.offset_in_block++;
379                         ptr=parse_word (ptr,buffer);
380                         if (type_data.offset_in_block==file_system_info.block_size) {
381                                 if (*ptr) {
382                                         wprintw (command_win,"Error - Ending offset outside block, only partial string changed\n");
383                                         refresh_command_win ();
384                                 }
385                                 type_data.offset_in_block--;
386                         }
387                 } while (*buffer) ;
388         }
389
390         else {
391                 ch_ptr=buffer;
392                 while (*ch_ptr) {
393                         tmp=(unsigned char) *ch_ptr++;
394                         type_data.u.buffer [type_data.offset_in_block]=tmp;
395                         type_data.offset_in_block++;
396                         if (type_data.offset_in_block==file_system_info.block_size) {
397                                 if (*ch_ptr) {
398                                         wprintw (command_win,"Error - Ending offset outside block, only partial string changed\n");
399                                         refresh_command_win ();
400                                 }
401                                 type_data.offset_in_block--;
402                         }
403                 }
404         }
405         
406         strcpy (buffer,"show");dispatch (buffer);
407 }
408
409
410
411 void set_type (char *command_line)
412
413 {
414         struct struct_descriptor *descriptor_ptr;
415         char *ptr,buffer [80],tmp_buffer [80];
416         short found=0;
417
418         if (!load_type_data ())
419                 return;
420
421         ptr=parse_word (command_line,buffer);
422         parse_word (ptr,buffer);
423         
424         if (strcmp (buffer,"none")==0 || strcmp (buffer,"hex")==0) {
425                 wprintw (command_win,"Data will be shown as hex dump\n");refresh_command_win ();
426                 current_type=NULL;
427                 sprintf (tmp_buffer,"show");dispatch (tmp_buffer);
428                 return;
429         }
430         
431         descriptor_ptr=first_type;
432         while (descriptor_ptr!=NULL && !found) {
433                 if (strcmp (descriptor_ptr->name,buffer)==0)
434                         found=1;
435                 else
436                         descriptor_ptr=descriptor_ptr->next;
437         }
438         if (found) {
439                 wprintw (command_win,"Structure type set to %s\n",buffer);refresh_command_win ();
440                 current_type=descriptor_ptr;
441                 sprintf (tmp_buffer,"show");dispatch (tmp_buffer);
442         }
443         else {
444                 wprintw (command_win,"Error - %s is not a valid type\n",buffer);refresh_command_win ();
445         }
446 }    
447
448
449 void show (char *command_line)
450
451 {
452         unsigned int i,l,temp_int;
453         unsigned long offset=0,temp_long;       
454         unsigned char temp_char,*ch_ptr;
455         void *ptr;
456
457         if (device_handle==NULL)
458                 return;
459
460         show_pad_info.line=0;
461         
462         if (current_type==NULL) {
463                 wmove (show_pad,0,0);
464                 ch_ptr=type_data.u.buffer;
465                 for (l=0;l<file_system_info.block_size/16;l++) {
466                         wprintw (show_pad,"%08ld :  ",offset);
467                         for (i=0;i<16;i++) {
468                                 if (type_data.offset_in_block==offset+i)
469                                         wattrset (show_pad,A_REVERSE);
470                         
471                                 if (ch_ptr [i]>=' ' && ch_ptr [i]<='z')
472                                         wprintw (show_pad,"%c",ch_ptr [i]);
473                                 else
474                                         wprintw (show_pad,".");
475                                 if (type_data.offset_in_block==offset+i)
476                                         wattrset (show_pad,A_NORMAL);
477                         }
478                         wprintw (show_pad,"   ");
479                         for (i=0;i<16;i++) {
480                                 if (type_data.offset_in_block==offset+i)
481                                         wattrset (show_pad,A_REVERSE);
482                         
483                                 wprintw (show_pad,"%02x",ch_ptr [i]);
484
485                                 if (type_data.offset_in_block==offset+i) {
486                                         wattrset (show_pad,A_NORMAL);
487                                         show_pad_info.line=l-l % show_pad_info.display_lines;
488                                 }
489
490                                 wprintw (show_pad," ");
491                         }
492                         wprintw (show_pad,"\n");
493                         offset+=16;
494                         ch_ptr+=16;
495                 }
496                 show_pad_info.max_line=l-1;show_pad_info.max_col=COLS-1;
497                 refresh_show_pad ();show_info ();
498         }
499         else {
500                 wmove (show_pad,0,0);l=0;
501                 for (i=0;i<current_type->fields_num;i++) {
502                         wprintw (show_pad,"%-20s = ",current_type->field_names [i]);
503                         ptr=type_data.u.buffer+offset;
504                         switch (current_type->field_lengths [i]) {
505                                 case 1:
506                                         temp_char=*((unsigned char *) ptr);
507                                         wprintw (show_pad,"%3u (0x%02x",temp_char,temp_char);
508                                         if (temp_char>=' ' && temp_char<='z')
509                                                 wprintw (show_pad," , %c)\n",temp_char);
510                                         else
511                                                 wprintw (show_pad,")\n");
512
513                                         offset ++;l++;
514                                         break;
515                                 case 2:
516                                         temp_int=*((unsigned short *) ptr);
517                                         wprintw (show_pad,"%u (0x%x)\n",temp_int,temp_int);
518                                         offset +=2;l++;
519                                         break;
520                                 case 4:
521                                         temp_long=*((unsigned long *) ptr);
522                                         wprintw (show_pad,"%lu\n",temp_long);
523                                         offset +=4;l++;
524                                         break;
525                         }
526 /*                      offset+=current_type->field_lengths [i]; */
527                 }
528                 current_type->length=offset;
529                 show_pad_info.max_line=l-1;
530                 refresh_show_pad ();show_info ();
531         }
532 }
533
534 void next (char *command_line)
535
536 {
537         long offset=1;
538         char *ptr,buffer [80];
539
540         ptr=parse_word (command_line,buffer);
541         
542         if (*ptr!=0) {
543                 ptr=parse_word (ptr,buffer);
544                 offset*=atol (buffer);
545         }
546         
547         if (current_type!=NULL) {
548                 sprintf (buffer,"setoffset type +%ld",offset);
549                 dispatch (buffer);
550                 return;
551         }
552
553         if (type_data.offset_in_block+offset < file_system_info.block_size) {
554                 type_data.offset_in_block+=offset;
555                 sprintf (buffer,"show");dispatch (buffer);
556         }
557                 
558         else {
559                 wprintw (command_win,"Error - Offset out of block\n");refresh_command_win ();
560         }
561 }
562
563 void prev (char *command_line)
564
565 {
566         long offset=1;
567         char *ptr,buffer [80];
568
569         ptr=parse_word (command_line,buffer);
570         
571         if (*ptr!=0) {
572                 ptr=parse_word (ptr,buffer);
573                 offset*=atol (buffer);
574         }
575         
576         if (current_type!=NULL) {
577                 sprintf (buffer,"setoffset type -%ld",offset);
578                 dispatch (buffer);
579                 return;
580         }
581
582         if (type_data.offset_in_block-offset >= 0) {
583                 type_data.offset_in_block-=offset;
584                 sprintf (buffer,"show");dispatch (buffer);
585         }
586         
587         else {
588                 wprintw (command_win,"Error - Offset out of block\n");refresh_command_win ();
589         }
590 }
591
592 void pgdn (char *commnad_line) 
593
594 {
595         show_pad_info.line+=show_pad_info.display_lines;
596         refresh_show_pad ();refresh_show_win ();
597 }
598
599 void pgup (char *command_line)
600
601 {
602         show_pad_info.line-=show_pad_info.display_lines;
603         refresh_show_pad ();refresh_show_win ();
604 }
605
606 void redraw (char *command_line)
607
608 {
609         redraw_all ();
610         dispatch ("show");
611 }
612
613 void remember (char *command_line)
614
615 {
616         long entry_num;
617         char *ptr,buffer [80];
618         
619         if (device_handle==NULL) {
620                 wprintw (command_win,"Error - No device opened\n");refresh_command_win ();
621                 return;
622         }
623
624         ptr=parse_word (command_line,buffer);
625         
626         if (*ptr==0) {
627                 wprintw (command_win,"Error - Argument not specified\n");refresh_command_win ();
628                 return;         
629         }
630         
631         ptr=parse_word (ptr,buffer);
632
633         entry_num=remember_lifo.entries_count++;
634         if (entry_num>REMEMBER_COUNT-1) {
635                 entry_num=0;
636                 remember_lifo.entries_count--;
637         }
638         
639         remember_lifo.offset [entry_num]=device_offset;
640         remember_lifo.type [entry_num]=current_type;
641         strcpy (remember_lifo.name [entry_num],buffer);
642         
643         if (current_type!=NULL)
644                 wprintw (command_win,"Object %s in Offset %ld remembered as %s\n",current_type->name,device_offset,buffer);
645         else
646                 wprintw (command_win,"Offset %ld remembered as %s\n",device_offset,buffer);
647                         
648         refresh_command_win ();
649 }
650
651 void recall (char *command_line)
652
653 {
654         char *ptr,buffer [80];
655         long entry_num;
656
657         if (device_handle==NULL) {
658                 wprintw (command_win,"Error - No device opened\n");refresh_command_win ();
659                 return;
660         }
661
662         ptr=parse_word (command_line,buffer);
663
664         if (*ptr==0) {
665                 wprintw (command_win,"Error - Argument not specified\n");refresh_command_win ();
666                 return;         
667         }
668
669         ptr=parse_word (ptr,buffer);
670
671         
672         for (entry_num=remember_lifo.entries_count-1;entry_num>=0;entry_num--) {
673                 if (strcmp (remember_lifo.name [entry_num],buffer)==0)
674                         break;  
675         }
676         
677         if (entry_num==-1) {
678                 wprintw (command_win,"Error - Can not recall %s\n",buffer);refresh_command_win ();
679                 return;
680         }
681
682         sprintf (buffer,"setoffset %ld",remember_lifo.offset [entry_num]);dispatch (buffer);
683         if (remember_lifo.type [entry_num] != NULL) {
684                 sprintf (buffer,"settype %s",remember_lifo.type [entry_num]->name);dispatch (buffer);   
685         }
686
687         else {
688                 sprintf (buffer,"settype none");dispatch (buffer);      
689         }
690                         
691         wprintw (command_win,"Object %s in Offset %ld recalled\n",current_type->name,device_offset);
692         refresh_command_win ();
693 }
694
695 void enable_write (char *command_line)
696
697 {
698         FILE *fp;
699
700         if (device_handle==NULL) {
701                 wprintw (command_win,"Error - No device opened\n");refresh_command_win ();
702                 return;
703         }
704
705         if (!AllowChanges) {
706                 wprintw (command_win,"Sorry, write access is not allowed\n");
707                 return;
708         }
709         
710         if (mounted) {
711                 wprintw (command_win,"Error - Filesystem is mounted\n");
712                 return;                 
713         }
714         
715         if ( (fp=fopen (device_name,"r+b"))==NULL) {
716                 wprintw (command_win,"Error - Can not open device %s for reading and writing\n",device_name);refresh_command_win ();
717                 return;
718         }
719         fclose (device_handle);
720         device_handle=fp;write_access=1;
721         wprintw (command_win,"Write access enabled - Be careful\n");refresh_command_win ();
722 }
723
724 void disable_write (char *command_line)
725
726 {
727         FILE *fp;
728
729         if (device_handle==NULL) {
730                 wprintw (command_win,"Error - No device opened\n");refresh_command_win ();
731                 return;
732         }
733
734         if ( (fp=fopen (device_name,"rb"))==NULL) {
735                 wprintw (command_win,"Error - Can not open device %s\n",device_name);refresh_command_win ();
736                 return;
737         }
738         
739         fclose (device_handle);
740         device_handle=fp;write_access=0;
741         wprintw (command_win,"Write access disabled\n");refresh_command_win ();
742 }
743
744 void write_data (char *command_line)
745
746 {
747         write_type_data ();
748 }