summaryrefslogtreecommitdiffstats
path: root/perl-install/harddrake/data.pm
blob: 0d13c25b07f2493a48bf43eb9c88fc5cd99f9cfd (plain)
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
package harddrake::data;

use strict;
use detect_devices;
use common;

our @ISA = qw(Exporter);
our @EXPORT_OK = qw(version tree);
our ($version, $sbindir, $bindir) = ("9.1.0", "/usr/sbin", "/usr/bin");

my @devices = detect_devices::probeall(1);

# Update me each time you handle one more devices class (aka configurator)
sub unknown {
    grep { $_->{media_type} !~ /BRIDGE|class\|Mouse|DISPLAY|Hub|MEMORY_RAM|MULTIMEDIA_(VIDEO|AUDIO|OTHER)|NETWORK|Printer|SERIAL_(USB|SMBUS)|STORAGE_(IDE|OTHER|SCSI)|tape/
	       && $_->{driver} !~ /^(ohci1394|scanner|usbvision|mod_quickcam)$|Mouse:USB|class\|Mouse|Removable:zip|www.linmodems.org|nvnet/
	       && $_->{type} ne 'network'
	       && $_->{description} !~ /Alcatel|ADSL Modem/
	   } @devices;
}


# tree format ("CLASS_ID", "type", "type_icon", configurator, detect_sub)
# NEVER, NEVER alter CLASS_ID or you'll see harddrake2 service detect changes
# in hw configuration ... :-(

# FIXME: add translated items

sub is_removable { $_[0] =~ /FLOPPY|ZIP|DVDROM|CDROM|BURNER/ }

sub set_removable_configurator {
    my ($class, $device) = @_;
    return "/usr/sbin/diskdrake --removable=$device->{device}" if is_removable($class);
}

sub set_removable_remover {
    my ($class, $device) = @_;
    return "/usr/sbin/drakupdate_fstab --auto --no-flag --del $device->{device}" if is_removable($class);
}

our @tree =
    (
     [ "FLOPPY", , N("Floppy"), "floppy.png", "", \&detect_devices::floppies, 1 ],
     [ "ZIP", , N("Zip"), "floppy.png", "", \&detect_devices::zips, 1 ],
     [ "HARDDISK", , N("Disk"), "harddisk.png", "$sbindir/diskdrake", \&detect_devices::hds, 1 ],
     [ "CDROM", , N("CDROM"), "cd.png", "", sub { grep { !(detect_devices::isBurner($_) || detect_devices::isDvdDrive($_)) } &detect_devices::cdroms }, 1 ],
     [ "BURNER", , N("CD/DVD burners"), "cd.png", "", \&detect_devices::burners, 1 ],
     [ "DVDROM", , N("DVD-ROM"), "cd.png", "", sub { grep { ! detect_devices::isBurner($_) } detect_devices::dvdroms() }, 1 ],
     [ "TAPE", , N("Tape"), "tape.png", "", \&detect_devices::tapes, 0 ],
     [ "VIDEO", , N("Videocard"), "video.png", "$sbindir/XFdrake",  sub { grep { $_->{driver} =~ /^(Card|Server):/ || $_->{media_type} =~ /DISPLAY_VGA/ } @devices }, 1 ],
     [ "TV", , N("Tvcard"), "tv.png", "/usr/bin/XawTV", sub { grep { $_->{media_type} =~ /MULTIMEDIA_VIDEO/ && $_->{bus} eq 'PCI' || $_->{driver} eq 'usbvision' } @devices }, 0 ],     
     [ "MULTIMEDIA_OTHER", , N("Other MultiMedia devices"), "multimedia.png", "", sub { grep { $_->{media_type} =~ /MULTIMEDIA_OTHER/ } @devices }, 0 ],
     [ "AUDIO", , N("Soundcard"), "sound.png", "$sbindir/draksound", sub { grep { $_->{media_type} =~ /MULTIMEDIA_AUDIO/ } @devices }, 0 ],
     [ "WEBCAM", , N("Webcam"), "webcam.png", "", sub { grep { $_->{media_type} =~ /MULTIMEDIA_VIDEO/ && $_->{bus} ne 'PCI' || $_->{driver} eq 'mod_quickcam' } @devices }, 0 ],
     [ "CPU", , N("Processors"), "cpu.png", "", sub { detect_devices::getCPUs() }, 0 ],
     [ "ETHERNET", , N("Ethernetcard"), "hw_network.png", "$sbindir/drakconnect", sub {
         #- generic NIC detection for USB seems broken (class, subclass, 
         #- protocol report are not accurate) so I'll need to verify against
         #- known drivers :-(
         my @usbnet = qw(CDCEther catc kaweth nvnet pegasus usbnet); # rought hack for nforce2's nvet
         # should be taken from detect_devices.pm or modules.pm. it's identical
         
         grep { $_->{media_type} && $_->{media_type} =~ /^NETWORK/ || member($_->{driver}, @usbnet) || $_->{type} && $_->{type} eq 'network' } @devices }, 1 ],
     [ "MODEM", , N("Modem"), "modem.png", "", sub { detect_devices::getSpeedtouch(), detect_devices::getSagem(), detect_devices::getModem() }, 0 ],
     [ "BRIDGE", , N("Bridges and system controllers"), "memory.png", "", sub { grep { $_->{media_type} =~ /BRIDGE|MEMORY_RAM/ && $_->{driver} ne 'nvnet' } @devices }, 0 ],
     [ "UNKNOWN", , N("Unknown/Others"), "unknown.png", "", \&unknown, 0 ],

     [ "PRINTER", , N("Printer"), "hw_printer.png", "$sbindir/printerdrake", sub { 
         require printer::detect; printer::detect::detect() }, 0 ],
     [ "SCANNER", , N("Scanner"), "scanner.png", "$sbindir/scannerdrake", sub { 
         require scanner; scanner::detect() }, 0 ],
     [ "MOUSE", , N("Mouse"), "hw_mouse.png", "$sbindir/mousedrake", sub { 
         require mouse;
         require modules;
         modules::mergein_conf('/etc/modules.conf') if -r '/etc/modules.conf';
         &mouse::detect() }, 1 ],
     [ "JOYSTICK", , N("Joystick"), "joystick.png", "", sub {}, 0 ],

     [ "ATA_STORAGE", , N("(E)IDE/ATA controllers"), "ide_hd.png", "", sub { grep { $_->{media_type} =~ /STORAGE_(IDE|OTHER)/ } @devices }, 0 ],
     [ "FIREWIRE_CONTROLLER", , N("Firewire controllers"), "usb.png", "", sub { grep { $_->{driver} =~ /ohci1394/ } @devices }, 1 ],
     [ "SCSI_CONTROLLER", , N("SCSI controllers"), "scsi.png", "", sub { grep { $_->{media_type} =~ /STORAGE_SCSI/ } @devices }, 0 ],
     [ "USB_CONTROLLER", , N("USB controllers"), "usb.png", "", sub { grep { $_->{media_type} =~ /SERIAL_USB|Hub/ } @devices }, 0 ],
     [ "SMB_CONTROLLER", , N("SMBus controllers"), "usb.png", "", sub { grep { $_->{media_type} =~ /SERIAL_SMBUS/ } @devices }, 0 ],
     );


sub custom_id {
    my ($device, $str) = @_;
    defined($device->{device}) ? $device->{device} :
        (defined($device->{processor}) ? 
         N("cpu # ") . $device->{processor} . ": " . $device->{'model name'} :
         (defined($device->{description}) ? $device->{description} : $str));
}

1;
l opt">; char *s, *s1; stype = obj->data_type; p = (VOID_STAR) &obj->v.ptr_val; cl = _SLclass_get_class (stype); s = (*cl->cl_string) (stype, p); if (s != NULL) { s1 = SLang_create_slstring (s); SLfree (s); s = s1; } return s; } /*}}}*/ int SLang_run_hooks(char *hook, unsigned int num_args, ...) { unsigned int i; va_list ap; if (SLang_Error) return -1; if (0 == SLang_is_defined (hook)) return 0; (void) SLang_start_arg_list (); va_start (ap, num_args); for (i = 0; i < num_args; i++) { char *arg; arg = va_arg (ap, char *); if (-1 == SLang_push_string (arg)) break; } va_end (ap); (void) SLang_end_arg_list (); if (SLang_Error) return -1; return SLang_execute_function (hook); } static void intrin_getenv_cmd (char *s) { SLang_push_string (getenv (s)); } #ifdef HAVE_PUTENV static void intrin_putenv (void) /*{{{*/ { char *s; /* Some putenv implementations required malloced strings. */ if (SLpop_string(&s)) return; if (putenv (s)) { SLang_Error = SL_INTRINSIC_ERROR; SLfree (s); } /* Note that s is NOT freed */ } /*}}}*/ #endif static void lang_print_stack (void) /*{{{*/ { char buf[32]; unsigned int n; n = (unsigned int) (_SLStack_Pointer - _SLRun_Stack); while (n) { n--; sprintf (buf, "(%u)", n); _SLdump_objects (buf, _SLRun_Stack + n, 1, 1); } } /*}}}*/ static void byte_compile_file (char *f, int *m) { SLang_byte_compile_file (f, *m); } static void intrin_type_info1 (void) { SLang_Object_Type obj; unsigned int type; if (-1 == SLang_pop (&obj)) return; type = obj.data_type; if (type == SLANG_ARRAY_TYPE) type = obj.v.array_val->data_type; SLang_free_object (&obj); _SLang_push_datatype (type); } static void intrin_type_info (void) { SLang_Object_Type obj; if (-1 == SLang_pop (&obj)) return; _SLang_push_datatype (obj.data_type); SLang_free_object (&obj); } void _SLstring_intrinsic (void) /*{{{*/ { SLang_Object_Type x; char *s; if (SLang_pop (&x)) return; if (NULL != (s = _SLstringize_object (&x))) _SLang_push_slstring (s); SLang_free_object (&x); } /*}}}*/ static void intrin_typecast (void) { unsigned char to_type; if (0 == _SLang_pop_datatype (&to_type)) (void) SLclass_typecast (to_type, 0, 1); } #if SLANG_HAS_FLOAT static void intrin_double (void) { (void) SLclass_typecast (SLANG_DOUBLE_TYPE, 0, 1); } #endif static void intrin_int (void) /*{{{*/ { (void) SLclass_typecast (SLANG_INT_TYPE, 0, 1); } /*}}}*/ static char * intrin_function_name (void) { if (NULL == _SLang_Current_Function_Name) return ""; return _SLang_Current_Function_Name; } static void intrin_message (char *s) { SLang_vmessage ("%s", s); } static void intrin_error (char *s) { SLang_verror (SL_USER_ERROR, "%s", s); } static void intrin_pop_n (int *n) { SLdo_pop_n ((unsigned int) *n); } static void intrin_reverse_stack (int *n) { SLreverse_stack (*n); } static void intrin_roll_stack (int *n) { SLroll_stack (*n); } static void usage (void) { char *msg; _SLstrops_do_sprintf_n (SLang_Num_Function_Args - 1); /* do not include format */ if (-1 == SLang_pop_slstring (&msg)) return; SLang_verror (SL_USAGE_ERROR, "Usage: %s", msg); SLang_free_slstring (msg); } /* Convert string to integer */ static int intrin_integer (char *s) { int i; i = SLatoi ((unsigned char *) s); if (SLang_Error) SLang_verror (SL_TYPE_MISMATCH, "Unable to convert string to integer"); return i; } /*}}}*/ static void guess_type (char *s) { _SLang_push_datatype (SLang_guess_type(s)); } static int load_file (char *s) { if (-1 == SLang_load_file (s)) return 0; return 1; } static void get_doc_string (char *file, char *topic) { FILE *fp; char line[1024]; unsigned int topic_len, str_len; char *str; char ch; if (NULL == (fp = fopen (file, "r"))) { SLang_push_null (); return; } topic_len = strlen (topic); ch = *topic; while (1) { if (NULL == fgets (line, sizeof(line), fp)) { fclose (fp); (void) SLang_push_null (); return; } if ((ch == *line) && (0 == strncmp (line, topic, topic_len)) && ((line[topic_len] == '\n') || (line [topic_len] == 0) || (line[topic_len] == ' ') || (line[topic_len] == '\t'))) break; } if (NULL == (str = SLmake_string (line))) { fclose (fp); (void) SLang_push_null (); return; } str_len = strlen (str); while (NULL != fgets (line, sizeof (line), fp)) { unsigned int len; char *new_str; ch = *line; if (ch == '#') continue; if (ch == '-') break; len = strlen (line); if (NULL == (new_str = SLrealloc (str, str_len + len + 1))) { SLfree (str); str = NULL; break; } str = new_str; strcpy (str + str_len, line); str_len += len; } fclose (fp); (void) SLang_push_malloced_string (str); } static int push_string_array_elements (SLang_Array_Type *at) { char **strs; unsigned int num; unsigned int i; if (at == NULL) return -1; strs = (char **)at->data; num = at->num_elements; for (i = 0; i < num; i++) { if (-1 == SLang_push_string (strs[i])) { SLdo_pop_n (i); return -1; } } SLang_push_integer ((int) num); return 0; } static void intrin_apropos (void) { int num_args; char *pat; char *namespace_name; unsigned int flags; SLang_Array_Type *at; num_args = SLang_Num_Function_Args; if (-1 == SLang_pop_uinteger (&flags)) return; if (-1 == SLang_pop_slstring (&pat)) return; namespace_name = NULL; at = NULL; if (num_args == 3) { if (-1 == SLang_pop_slstring (&namespace_name)) goto free_and_return; } at = _SLang_apropos (namespace_name, pat, flags); if (num_args == 3) { (void) SLang_push_array (at, 0); goto free_and_return; } /* Maintain compatibility with old version of the function. That version * did not take three arguments and returned everything to the stack. * Yuk. */ (void) push_string_array_elements (at); free_and_return: /* NULLs ok */ SLang_free_slstring (namespace_name); SLang_free_slstring (pat); SLang_free_array (at); } static int intrin_get_defines (void) { int n = 0; char **s = _SLdefines; while (*s != NULL) { if (-1 == SLang_push_string (*s)) { SLdo_pop_n ((unsigned int) n); return -1; } s++; n++; } return n; } static void intrin_get_reference (char *name) { _SLang_push_ref (1, (VOID_STAR) _SLlocate_name (name)); } #ifdef HAVE_SYS_UTSNAME_H # include <sys/utsname.h> #endif static void uname_cmd (void) { #ifdef HAVE_UNAME struct utsname u; char *field_names [6]; unsigned char field_types[6]; VOID_STAR field_values [6]; char *ptrs[6]; int i; if (-1 == uname (&u)) (void) SLang_push_null (); field_names[0] = "sysname"; ptrs[0] = u.sysname; field_names[1] = "nodename"; ptrs[1] = u.nodename; field_names[2] = "release"; ptrs[2] = u.release; field_names[3] = "version"; ptrs[3] = u.version; field_names[4] = "machine"; ptrs[4] = u.machine; for (i = 0; i < 5; i++) { field_types[i] = SLANG_STRING_TYPE; field_values[i] = (VOID_STAR) &ptrs[i]; } if (0 == SLstruct_create_struct (5, field_names, field_types, field_values)) return; #endif SLang_push_null (); } static void uninitialize_ref_intrin (SLang_Ref_Type *ref) { (void) _SLang_uninitialize_ref (ref); } static SLang_Intrin_Fun_Type SLang_Basic_Table [] = /*{{{*/ { MAKE_INTRINSIC_1("__is_initialized", _SLang_is_ref_initialized, SLANG_INT_TYPE, SLANG_REF_TYPE), MAKE_INTRINSIC_S("__get_reference", intrin_get_reference, SLANG_VOID_TYPE), MAKE_INTRINSIC_1("__uninitialize", uninitialize_ref_intrin, SLANG_VOID_TYPE, SLANG_REF_TYPE), MAKE_INTRINSIC_SS("get_doc_string_from_file", get_doc_string, SLANG_VOID_TYPE), MAKE_INTRINSIC_SS("autoload", SLang_autoload, SLANG_VOID_TYPE), MAKE_INTRINSIC_S("is_defined", SLang_is_defined, SLANG_INT_TYPE), MAKE_INTRINSIC_0("string", _SLstring_intrinsic, SLANG_VOID_TYPE), MAKE_INTRINSIC_0("uname", uname_cmd, SLANG_VOID_TYPE), MAKE_INTRINSIC_S("getenv", intrin_getenv_cmd, SLANG_VOID_TYPE), #ifdef HAVE_PUTENV MAKE_INTRINSIC_0("putenv", intrin_putenv, SLANG_VOID_TYPE), #endif MAKE_INTRINSIC_S("evalfile", load_file, SLANG_INT_TYPE), MAKE_INTRINSIC_I("char", char_cmd, SLANG_VOID_TYPE), MAKE_INTRINSIC_S("eval", SLang_load_string, SLANG_VOID_TYPE), MAKE_INTRINSIC_0("dup", do_dup, SLANG_VOID_TYPE), MAKE_INTRINSIC_S("integer", intrin_integer, SLANG_INT_TYPE), MAKE_INTRINSIC_S("system", SLsystem, SLANG_INT_TYPE), MAKE_INTRINSIC_0("_apropos", intrin_apropos, SLANG_VOID_TYPE), MAKE_INTRINSIC_S("_trace_function", _SLang_trace_fun, SLANG_VOID_TYPE), #if SLANG_HAS_FLOAT MAKE_INTRINSIC_S("atof", _SLang_atof, SLANG_DOUBLE_TYPE), MAKE_INTRINSIC_0("double", intrin_double, SLANG_VOID_TYPE), #endif MAKE_INTRINSIC_0("int", intrin_int, SLANG_VOID_TYPE), MAKE_INTRINSIC_0("typecast", intrin_typecast, SLANG_VOID_TYPE), MAKE_INTRINSIC_0("_stkdepth", _SLstack_depth, SLANG_INT_TYPE), MAKE_INTRINSIC_I("_stk_reverse", intrin_reverse_stack, SLANG_VOID_TYPE), MAKE_INTRINSIC_0("typeof", intrin_type_info, VOID_TYPE), MAKE_INTRINSIC_0("_typeof", intrin_type_info1, VOID_TYPE), MAKE_INTRINSIC_I("_pop_n", intrin_pop_n, SLANG_VOID_TYPE), MAKE_INTRINSIC_0("_print_stack", lang_print_stack, SLANG_VOID_TYPE), MAKE_INTRINSIC_I("_stk_roll", intrin_roll_stack, SLANG_VOID_TYPE), MAKE_INTRINSIC_SI("byte_compile_file", byte_compile_file, SLANG_VOID_TYPE), MAKE_INTRINSIC_0("_clear_error", _SLang_clear_error, SLANG_VOID_TYPE), MAKE_INTRINSIC_0("_function_name", intrin_function_name, SLANG_STRING_TYPE), #if SLANG_HAS_FLOAT MAKE_INTRINSIC_S("set_float_format", _SLset_double_format, SLANG_VOID_TYPE), #endif MAKE_INTRINSIC_S("_slang_guess_type", guess_type, SLANG_VOID_TYPE), MAKE_INTRINSIC_S("error", intrin_error, SLANG_VOID_TYPE), MAKE_INTRINSIC_S("message", intrin_message, SLANG_VOID_TYPE), MAKE_INTRINSIC_0("__get_defined_symbols", intrin_get_defines, SLANG_INT_TYPE), MAKE_INTRINSIC_I("__pop_args", _SLstruct_pop_args, SLANG_VOID_TYPE), MAKE_INTRINSIC_1("__push_args", _SLstruct_push_args, SLANG_VOID_TYPE, SLANG_ARRAY_TYPE), MAKE_INTRINSIC_0("usage", usage, SLANG_VOID_TYPE), MAKE_INTRINSIC_S("implements", _SLang_implements_intrinsic, SLANG_VOID_TYPE), MAKE_INTRINSIC_S("use_namespace", _SLang_use_namespace_intrinsic, SLANG_VOID_TYPE), MAKE_INTRINSIC_0("current_namespace", _SLang_cur_namespace_intrinsic, SLANG_STRING_TYPE), MAKE_INTRINSIC_0("length", length_cmd, SLANG_INT_TYPE), SLANG_END_INTRIN_FUN_TABLE }; /*}}}*/ #ifdef SLANG_DOC_DIR char *SLang_Doc_Dir = SLANG_DOC_DIR; #else char *SLang_Doc_Dir = ""; #endif static SLang_Intrin_Var_Type Intrin_Vars[] = { MAKE_VARIABLE("_debug_info", &_SLang_Compile_Line_Num_Info, SLANG_INT_TYPE, 0), MAKE_VARIABLE("_auto_declare", &_SLang_Auto_Declare_Globals, SLANG_INT_TYPE, 0), MAKE_VARIABLE("_traceback", &SLang_Traceback, SLANG_INT_TYPE, 0), MAKE_VARIABLE("_slangtrace", &_SLang_Trace, SLANG_INT_TYPE, 0), MAKE_VARIABLE("_slang_version", &SLang_Version, SLANG_INT_TYPE, 1), MAKE_VARIABLE("_slang_version_string", &SLang_Version_String, SLANG_STRING_TYPE, 1), MAKE_VARIABLE("_NARGS", &SLang_Num_Function_Args, SLANG_INT_TYPE, 1), MAKE_VARIABLE("_slang_doc_dir", &SLang_Doc_Dir, SLANG_STRING_TYPE, 1), MAKE_VARIABLE("NULL", NULL, SLANG_NULL_TYPE, 1), SLANG_END_INTRIN_VAR_TABLE }; int SLang_init_slang (void) /*{{{*/ { char name[3]; unsigned int i; char **s; static char *sys_defines [] = { #if defined(__os2__) "OS2", #endif #if defined(__MSDOS__) "MSDOS", #endif #if defined(__WIN16__) "WIN16", #endif #if defined (__WIN32__) "WIN32", #endif #if defined(__NT__) "NT", #endif #if defined (VMS) "VMS", #endif #ifdef REAL_UNIX_SYSTEM "UNIX", #endif #if SLANG_HAS_FLOAT "SLANG_DOUBLE_TYPE", #endif NULL }; if (-1 == _SLregister_types ()) return -1; if ((-1 == SLadd_intrin_fun_table(SLang_Basic_Table, NULL)) || (-1 == SLadd_intrin_var_table (Intrin_Vars, NULL)) || (-1 == _SLang_init_slstrops ()) || (-1 == _SLang_init_sltime ()) || (-1 == _SLstruct_init ()) #if SLANG_HAS_COMPLEX || (-1 == _SLinit_slcomplex ()) #endif #if SLANG_HAS_ASSOC_ARRAYS || (-1 == SLang_init_slassoc ()) #endif ) return -1; SLadd_global_variable (SLANG_SYSTEM_NAME); s = sys_defines; while (*s != NULL) { if (-1 == SLdefine_for_ifdef (*s)) return -1; s++; } /* give temp global variables $0 --> $9 */ name[2] = 0; name[0] = '$'; for (i = 0; i < 10; i++) { name[1] = (char) (i + '0'); SLadd_global_variable (name); } SLang_init_case_tables (); /* Now add a couple of macros */ SLang_load_string (".(_NARGS 1 - Sprintf error)verror"); SLang_load_string (".(_NARGS 1 - Sprintf message)vmessage"); if (SLang_Error) return -1; return 0; } /*}}}*/ int SLang_set_argc_argv (int argc, char **argv) { static int this_argc; static char **this_argv; int i; if (argc < 0) argc = 0; this_argc = argc; if (NULL == (this_argv = (char **) SLmalloc ((argc + 1) * sizeof (char *)))) return -1; memset ((char *) this_argv, 0, sizeof (char *) * (argc + 1)); for (i = 0; i < argc; i++) { if (NULL == (this_argv[i] = SLang_create_slstring (argv[i]))) goto return_error; } if (-1 == SLadd_intrinsic_variable ("__argc", (VOID_STAR)&this_argc, SLANG_INT_TYPE, 1)) goto return_error; if (-1 == SLang_add_intrinsic_array ("__argv", SLANG_STRING_TYPE, 1, (VOID_STAR) this_argv, 1, argc)) goto return_error; return 0; return_error: for (i = 0; i < argc; i++) SLang_free_slstring (this_argv[i]); /* NULL ok */ SLfree ((char *) this_argv); return -1; }