OSDN Git Service

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