/* This file is part of Lcrzo.
*/

#ifdef LCRZODEF_SYSTEM_Unix
  /* this function is not needed*/

#elif defined LCRZODEF_SYSTEM_Windows

/*-------------------------------------------------------------*/
int lcrzo_priv_conf_device_init_ipl_NTregistery(lcrzo_ipl iplwanted, 
                                           lcrzo_device device)
{ lcrzo_list list, deviplist;
  lcrzo_data devname, ipaddress;
  lcrzo_int32 devnamesize, ipaddresssize, count, i, devipcount, devi;
  lcrzo_string shortdevname, devkey;
  lcrzo_uint32 dhcpenabled;
  lcrzo_ipl ipl;
  lcrzo_bool found;
  char *pc;
  int ret;

  found=LCRZO_FALSE;

  /* get device infos */
  lcrzo_er(lcrzo_priv_winreg_datalist_get(HKEY_LOCAL_MACHINE,
           "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Linkage", "Bind",
           &list));
  lcrzo_efr(lcrzo_list_count(&list, &count), lcrzo_list_close(&list));
  for ( i=1 ; i<=count && !found ; i++ )
  { 
    /* get the device full name */
    ret=lcrzo_datalist_valuem_pos(&list, i, NULL, &devname, &devnamesize);
    if (ret!=LCRZO_ERR_OK) goto badend1;
    devname[devnamesize]='\0';

    /* compute the short device name */
    pc=strrchr((lcrzo_string)devname, '\\');
    if ( pc == NULL ) pc=(lcrzo_string)devname;
    ret=lcrzo_string_initm_text(pc+1, &shortdevname);
    if (ret!=LCRZO_ERR_OK) goto badend2;

    /* construct the key needed to access its parameters */
    ret=lcrzo_string_initm_text("SYSTEM\\CurrentControlSet\\Services\\", &devkey);
    if (ret!=LCRZO_ERR_OK) goto badend3;
    ret=lcrzo_string_appendm_text(shortdevname, &devkey);
    if (ret!=LCRZO_ERR_OK) goto badend3;
    ret=lcrzo_string_appendm_text("\\Parameters\\Tcpip", &devkey);
    if (ret!=LCRZO_ERR_OK) goto badend3;

    /* check if DHCP is enabled */
    ret=lcrzo_priv_winreg_uint32_get(HKEY_LOCAL_MACHINE, devkey, "EnableDHCP", &dhcpenabled);
    if (ret!=LCRZO_ERR_OK) dhcpenabled=LCRZO_FALSE;

    if (dhcpenabled)
    { dhcpenabled=LCRZO_FALSE;
      ret=lcrzo_priv_winreg_data_get(HKEY_LOCAL_MACHINE, devkey, "DhcpIPAddress", &ipaddress, &ipaddresssize);
      if (ret==LCRZO_ERR_OK)
      { /* ok, so we really got an address from a DHCP server */
        dhcpenabled=LCRZO_TRUE;
        /* convert to string */
        ipaddress[ipaddresssize]='\0';
        ret=lcrzo_ipl_init_ips((lcrzo_string)ipaddress, &ipl);
        if ( ret!=LCRZO_ERR_OK ) goto badend8_;
        if ( ipl==iplwanted ) 
        { lcrzo_priv_conf_device_init_devicealias(shortdevname, 1, device);
          found=LCRZO_TRUE;
        }
        /* free */
        lcrzo_data_free(ipaddress);
      }
    }

    if (!dhcpenabled)  
    { /* ask the IPAddress/SubnetMask value for this key */
      ret=lcrzo_priv_winreg_datalist_get(HKEY_LOCAL_MACHINE, devkey, "IPAddress", &deviplist);
      if ( ret==LCRZO_ERR_OK )
      { ret=lcrzo_list_count(&deviplist, &devipcount);
        if ( ret!=LCRZO_ERR_OK ) goto badend6;
        /* get values */        
        for ( devi=1 ; devi<=devipcount ; devi++ )
        { /* get the IP address */
          ret=lcrzo_datalist_valuem_pos(&deviplist, devi, NULL, &ipaddress, &ipaddresssize);
          if ( ret!=LCRZO_ERR_OK ) goto badend6;
          /* convert to string */
          ipaddress[ipaddresssize]='\0';
          /* update conf */
          ret=lcrzo_ipl_init_ips((lcrzo_string)ipaddress, &ipl);
          if ( ret!=LCRZO_ERR_OK ) goto badend8;
          if ( ipl==iplwanted ) 
          { lcrzo_priv_conf_device_init_devicealias(shortdevname, devi, device);
            found=LCRZO_TRUE;
          }
          /* free */
          lcrzo_data_free(ipaddress);
        }
        ret=lcrzo_list_close(&deviplist);
        if ( ret!=LCRZO_ERR_OK ) goto badend4;
      }
    }
    lcrzo_string_free(devkey);
    lcrzo_string_free(shortdevname);
    lcrzo_data_free(devname);
  }
  lcrzo_er(lcrzo_list_close(&list));
  
  if (!found)
  { /* set default device name */
    lcrzo_er(lcrzo_device_init("", device));
    return(LCRZO_ERR_OKUNRESOLVED);
  }
  return(LCRZO_ERR_OK);

  /**/
badend8_:
  lcrzo_data_free(ipaddress);
  goto badend4;

  /**/
badend8:
  lcrzo_data_free(ipaddress);
badend6:
  lcrzo_list_close(&deviplist);
badend4:
  lcrzo_string_free(devkey);
badend3:
  lcrzo_string_free(shortdevname);
badend2:
  lcrzo_string_free((lcrzo_string)devname);
badend1:
  lcrzo_list_close(&list);
  return(ret);
}

/*-------------------------------------------------------------*/
int lcrzo_priv_conf_device_init_ipl_W9xregistery4(lcrzo_conststring keynettrans,
											   lcrzo_ipl iplwanted,
											   lcrzo_bool *pfound,
                         lcrzo_int32 *paddressnumber,
                         lcrzo_bool *ptrywithdhcp);
int lcrzo_priv_conf_device_init_ipl_W9xregistery4(lcrzo_conststring keynettrans,
											   lcrzo_ipl iplwanted,
											   lcrzo_bool *pfound,
                         lcrzo_int32 *paddressnumber,
                         lcrzo_bool *ptrywithdhcp)
{ lcrzo_data value;
  lcrzo_int32 valuesize;
  lcrzo_ipl ip;
  char *pc;
  int ret;

  /* get ip address */
  ret=lcrzo_priv_winreg_data_get(HKEY_LOCAL_MACHINE, keynettrans, "IPAddress",
						         &value, &valuesize);
  if (ret==LCRZO_ERR_OK)
  { value[valuesize]='\0';
    /*printf("device=%s value=%s\n", device, value);*/

    /* first, check if it is a value alone */
    ret=lcrzo_ipl_init_ips((lcrzo_string)value, &ip);
	  /*lcrzo_ipl_print("ip= ", ip, "\n");*/
    if (ret==LCRZO_ERR_OK)
    { lcrzo_data_free(value);
      /* when 0, prehaps use DHCP */
      if ( ip==0 ) *ptrywithdhcp=LCRZO_TRUE;
      /* check if it corresponds to wanted value */
      if ( ip==iplwanted )
      { *pfound=LCRZO_TRUE;
        *paddressnumber=1;
      }
      /* exit now */
      return(LCRZO_ERR_OK);
    }

    /* now check for a list */
    pc=(lcrzo_string)value;
    ret=LCRZO_ERR_OK;
    *paddressnumber=0;
    while( pc!=NULL && ret==LCRZO_ERR_OK && !*pfound )
    { pc=strrchr((lcrzo_string)value, ',');
      if (pc==NULL)
      { ret=lcrzo_ipl_init_ips((lcrzo_string)value, &ip);
      }
	    else
      { ret=lcrzo_ipl_init_ips(pc+1, &ip);
	      *pc='\0';
      }
      /*lcrzo_ipl_print("ip=", ip, "\n");*/
      if (ret==LCRZO_ERR_OK)
      { (*paddressnumber)++;
        /* check if it corresponds to wanted value */
        if ( ip==iplwanted )
        { *pfound=LCRZO_TRUE;
        }
      }
    }

    /* end */
    lcrzo_data_free(value);
  }

  return(ret);
}

/*-------------------------------------------------------------*/
int lcrzo_priv_conf_device_init_ipl_W9xregistery3(lcrzo_conststring keylongmstcpi,
											   lcrzo_ipl iplwanted, 
											   lcrzo_bool *pfound,
                         lcrzo_int32 *paddressnumber,
                         lcrzo_bool *ptrywithdhcp);
int lcrzo_priv_conf_device_init_ipl_W9xregistery3(lcrzo_conststring keylongmstcpi,
											   lcrzo_ipl iplwanted, 
											   lcrzo_bool *pfound,
                         lcrzo_int32 *paddressnumber,
                         lcrzo_bool *ptrywithdhcp)
{ lcrzo_data value;
  lcrzo_int32 valuesize;
  lcrzo_string keynettrans;
  int ret;

  /*printf("%s : %s\n", device, keylongmstcpi);*/

  /* check it is TCP/IP */
  ret=lcrzo_priv_winreg_data_get(HKEY_LOCAL_MACHINE, keylongmstcpi, "DeviceDesc",
						         &value, &valuesize);
  if (ret==LCRZO_ERR_OK)
  { value[valuesize]='\0';
    if ( strcmp((lcrzo_string)value, "TCP/IP") )
	  ret=LCRZO_ERR_OKUNRESOLVED;
	  lcrzo_data_free(value);
  }
  /* simply ignore previous errors */
  if (ret!=LCRZO_ERR_OK) return(LCRZO_ERR_OK);
  /*puts("It is TCP/IP");*/

  /* get the nettrans key */ 
  ret=lcrzo_priv_winreg_data_get(HKEY_LOCAL_MACHINE, keylongmstcpi, "Driver",
						         &value, &valuesize);
  if (ret==LCRZO_ERR_OK)
  { value[valuesize]='\0';
    ret=lcrzo_string_initm_text("System\\CurrentControlSet\\Services\\Class\\", &keynettrans);
    if (ret==LCRZO_ERR_OK)
    { ret=lcrzo_string_appendm_text((lcrzo_string)value, &keynettrans);
      if (ret==LCRZO_ERR_OK)
      { /*printf("nettrans=%s\n", keynettrans);*/
	      ret=lcrzo_priv_conf_device_init_ipl_W9xregistery4(keynettrans, iplwanted, 
                                                   pfound, paddressnumber, ptrywithdhcp);
      }
      lcrzo_string_free(keynettrans);
    }
	  lcrzo_data_free(value);
  }
  
  return(ret);
}

/*-------------------------------------------------------------*/
int lcrzo_priv_conf_device_init_ipl_W9xregistery2(lcrzo_conststring keyname,
											                            lcrzo_ipl iplwanted, 
											                            lcrzo_device device,
                                                  lcrzo_int32 *pdhcpaddressnumber)
{ lcrzo_string keynet, keymstcp, keylongmstcpi;
  lcrzo_data value, value2, keymstcpi;
  lcrzo_int32 valuesize, value2size, keymstcpisize, count, i, addressnumber;
  lcrzo_list list;
  lcrzo_bool found, trywithdhcp;
  int ret;

  addressnumber=0; /* just for the compiler warning */

  /* obtain the name of the key net */
  ret=lcrzo_priv_winreg_data_get(HKEY_LOCAL_MACHINE, keyname, "Driver",
						         &value, &valuesize);
  if (ret==LCRZO_ERR_OK)
  { value[valuesize]='\0';
	/* construct the key containing the device name */
    ret=lcrzo_string_initm_text("System\\CurrentControlSet\\Services\\Class\\", &keynet);
    if (ret==LCRZO_ERR_OK)
    { ret=lcrzo_string_appendm_text((lcrzo_string)value, &keynet);
      if (ret==LCRZO_ERR_OK)
      { /* ensure it is not PPP */
	      ret=lcrzo_priv_winreg_data_get(HKEY_LOCAL_MACHINE, keynet, "PointToPointIP",
						               NULL, NULL);
        if (ret==LCRZO_ERR_OK)
        { lcrzo_string_free(keynet);
	        lcrzo_data_free(value);
		      /* skip it */
		      return(LCRZO_ERR_OK);
        }
        ret=lcrzo_string_appendm_text("\\NDIS", &keynet);
        if (ret==LCRZO_ERR_OK)
        { /* obtain the device name */
		      /*printf("keynet=%s\n", keynet);*/
          ret=lcrzo_priv_winreg_data_get(HKEY_LOCAL_MACHINE, keynet, "LogDriverName",
						                 &value2, &value2size);
          if (ret==LCRZO_ERR_OK)
          { value2[value2size]='\0';
	          ret=lcrzo_device_init((lcrzo_string)value2, device);
		        lcrzo_data_free(value2);
          }
        }
      }
	    lcrzo_string_free(keynet);
    }
	  lcrzo_data_free(value);
  }
  /*printf("Device = %s\n", device);*/

  /* search info corresponding to each device */
  found=LCRZO_FALSE;
  trywithdhcp=LCRZO_FALSE;
  ret=lcrzo_string_initm_text(keyname, &keymstcp);
  if (ret==LCRZO_ERR_OK)
  { ret=lcrzo_string_appendm_text("\\Bindings", &keymstcp);
    if (ret==LCRZO_ERR_OK)
    { ret=lcrzo_priv_winreg_subvallist_get(HKEY_LOCAL_MACHINE, keymstcp, &list);
	    if (ret==LCRZO_ERR_OK)
      { ret=lcrzo_list_count(&list, &count);
	      /*printf("count=%d\n", count);*/
        if (ret==LCRZO_ERR_OK)
        { 
          for ( i=1 ; i<=count && ret==LCRZO_ERR_OK && !found ; i++ )
          { ret=lcrzo_datalist_valuem_pos(&list, i, NULL, &keymstcpi, &keymstcpisize);
            if (ret==LCRZO_ERR_OK)
            { keymstcpi[keymstcpisize]='\0';
			        /*printf("keymstcpi=%s\n", keymstcpi);*/
              ret=lcrzo_string_initm_text("Enum\\Network\\", &keylongmstcpi);
              if (ret==LCRZO_ERR_OK)
              { ret=lcrzo_string_appendm_text((lcrzo_string)keymstcpi, &keylongmstcpi);
                if (ret==LCRZO_ERR_OK)
                { /* verify it is TCP/IP and set values */
			            ret=lcrzo_priv_conf_device_init_ipl_W9xregistery3(keylongmstcpi, iplwanted, 
                                                         &found, &addressnumber, &trywithdhcp);
                }
				        lcrzo_string_free(keylongmstcpi);
              }
			        lcrzo_data_free(keymstcpi);
            }
          }
        }
		    lcrzo_list_close(&list);
      }
    }
	  lcrzo_string_free(keymstcp);
  }

  if ( !found && trywithdhcp )
  { lcrzo_priv_conf_validdhcpinfo vdi;
    lcrzo_device dev;
    ret=lcrzo_priv_device_init_ascii(device, dev);
    if (ret==LCRZO_ERR_OK)
    { ret=lcrzo_priv_conf_validdhcpinfo_get(dev, *pdhcpaddressnumber, &vdi);
      if (ret==LCRZO_ERR_OK)
      { (*pdhcpaddressnumber)++;
        if (vdi.ip==iplwanted)
        { found=LCRZO_TRUE;
          addressnumber=1;
        }
      }
    }
  }

  if (found)
  { lcrzo_er(lcrzo_priv_conf_device_init_devicealias(device, addressnumber, device));
  }
  else
  { lcrzo_er(lcrzo_device_initdefault(device));
  }
  
  return(LCRZO_ERR_OK);
}

/*-------------------------------------------------------------*/
int lcrzo_priv_conf_device_init_ipl_W9xregistery1(lcrzo_conststring keyname1,
											                            lcrzo_ipl iplwanted, 
											                            lcrzo_device device,
                                                  lcrzo_int32 *pdhcpaddressnumber);
int lcrzo_priv_conf_device_init_ipl_W9xregistery1(lcrzo_conststring keyname1,
											                            lcrzo_ipl iplwanted, 
											                            lcrzo_device device,
                                                  lcrzo_int32 *pdhcpaddressnumber)
{ lcrzo_list list2;
  lcrzo_data keyname2, value;
  lcrzo_int32 j, count2, valuesize;
  int ret, retf;

  retf=LCRZO_ERR_OK;
  /* go one step further */
  ret=lcrzo_priv_winreg_subkeylist_get(HKEY_LOCAL_MACHINE, keyname1, &list2);
  if (ret==LCRZO_ERR_OK)
  { ret=lcrzo_list_count(&list2, &count2);
    if (ret==LCRZO_ERR_OK)
    { 
      for ( j=1 ; j<=count2 && ret==LCRZO_ERR_OK && !strlen(device) ; j++ ) 
      { ret=lcrzo_datalist_valuem_pos(&list2, j, NULL, &keyname2, NULL);
        if (ret==LCRZO_ERR_OK)
        { /*printf("%s\n", keyname2);*/

	        ret=lcrzo_priv_winreg_data_get(HKEY_LOCAL_MACHINE, (lcrzo_string)keyname2, "Class",
						                       &value, &valuesize);
          if (ret==LCRZO_ERR_OK)
          { value[valuesize]='\0';
            /*printf("%s\n", value);*/
            if (!strcmp((lcrzo_string)value, "Net"))
            { /*printf("%s\n", keyname2);*/
              retf=ret=lcrzo_priv_conf_device_init_ipl_W9xregistery2((lcrzo_string)keyname2, iplwanted, device, pdhcpaddressnumber);
            }
				    lcrzo_data_free(value);
          }
			    lcrzo_data_free(keyname2);
        }
      }	
    } 
    lcrzo_list_close(&list2);
  }
  return(retf);
}

/*-------------------------------------------------------------*/
int lcrzo_priv_conf_device_init_ipl_W9xregistery(lcrzo_ipl iplwanted, lcrzo_device device)
{ lcrzo_list list0, list1;
  lcrzo_data keyname0, keyname1;
  lcrzo_int32 h, i, count0, count1, dhcpaddressnumber;
  int ret, retf;

  /* set default device name */
  lcrzo_er(lcrzo_device_init("", device));

  /* get device infos */
  retf=LCRZO_ERR_OK;
  dhcpaddressnumber=1;
  lcrzo_er(lcrzo_priv_winreg_subkeylist_get(HKEY_LOCAL_MACHINE, "Enum", &list0));
  ret=lcrzo_list_count(&list0, &count0);
  if (ret==LCRZO_ERR_OK)
  { 
    for ( h=1 ; h<=count0 && ret==LCRZO_ERR_OK && !strlen(device) ; h++ )
    { ret=lcrzo_datalist_valuem_pos(&list0, h, NULL, &keyname0, NULL);
      if (ret==LCRZO_ERR_OK)
      { /*printf("%s\n", keyname0);*/
		    
        /* go one step further */
        ret=lcrzo_priv_winreg_subkeylist_get(HKEY_LOCAL_MACHINE, (lcrzo_string)keyname0, &list1);
        if (ret==LCRZO_ERR_OK)
        { ret=lcrzo_list_count(&list1, &count1);
          if (ret==LCRZO_ERR_OK)
          { 
            for ( i=1 ; i<=count1 && ret==LCRZO_ERR_OK && !strlen(device) ; i++ )
            { ret=lcrzo_datalist_valuem_pos(&list1, i, NULL, &keyname1, NULL);
              if (ret==LCRZO_ERR_OK)
              { 
	    	        /*printf("%s\n", keyname1);*/
                retf=lcrzo_priv_conf_device_init_ipl_W9xregistery1((lcrzo_string)keyname1, iplwanted, device, &dhcpaddressnumber);
                lcrzo_data_free(keyname1);
              }
            }
          }
          lcrzo_list_close(&list1);
        }
        lcrzo_data_free(keyname0);
      }
    }
  }
  lcrzo_list_close(&list0);

  return(ret);
}

/*-------------------------------------------------------------*/
int lcrzo_priv_conf_device_init_ipl_packetdll(lcrzo_ipl iplwanted, 
				                                      lcrzo_device device)
{ lcrzo_int32 i, count;
  lcrzo_ipl ip, mask;
  lcrzo_device dev;
  lcrzo_list list;
  BOOL err;
  int ret;
  
  lcrzo_er(lcrzo_priv_conf_packetgetadapternames(&list));

  /* loop for each adapter name */
  ret=lcrzo_list_count(&list, &count);
  if (ret==LCRZO_ERR_OK)
  {
    for ( i=1 ; i<=count ; i++ )
    { ret=lcrzo_priv_conf_packetgetadapternames_get(&list, i, device);
      if (ret==LCRZO_ERR_OK)
      { /* get the IP address for this device */
        ret=lcrzo_priv_ascii_init_device(device, dev);
        if (ret==LCRZO_ERR_OK)
        { err=PacketGetNetInfo(dev, &ip, &mask);
          if (err)
          { 
            /*lcrzo_ipl_print("packetip=", ip, "\n");*/
            if ( ip == iplwanted )
            { lcrzo_list_close(&list);
              return(LCRZO_ERR_OK);
            }
          }
        }
      }
    }
  }
  lcrzo_list_close(&list);
  return(LCRZO_ERR_OKUNRESOLVED);
}

/*-------------------------------------------------------------*/
int lcrzo_priv_conf_device_init_ipl(lcrzo_ipl iplwanted, 
				                            lcrzo_device device)
{ int ret;
  lcrzo_priv_globalvars *ptrglo;
  
  /* special loopback case */
  if ( iplwanted==0x7F000001 )
  { lcrzo_er(lcrzo_device_init("Loopback", device));
    return(LCRZO_ERR_OK);
  }

  lcrzo_er(lcrzo_priv_globalvars_ptr_get(&ptrglo));
  switch(ptrglo->windows_systemversion)
  { case LCRZO_WINDOWS_SYSTEMVERSION_nt4:
    case LCRZO_WINDOWS_SYSTEMVERSION_2k:
    case LCRZO_WINDOWS_SYSTEMVERSION_xp:
      ret=lcrzo_priv_conf_device_init_ipl_NTregistery(iplwanted, device);
	    if (ret!=LCRZO_ERR_OK)
      { ret=lcrzo_priv_conf_device_init_ipl_packetdll(iplwanted, device);
      }
      break;

    case LCRZO_WINDOWS_SYSTEMVERSION_95:
    case LCRZO_WINDOWS_SYSTEMVERSION_98:
    case LCRZO_WINDOWS_SYSTEMVERSION_me:
      ret=lcrzo_priv_conf_device_init_ipl_W9xregistery(iplwanted, device);
	    if (ret!=LCRZO_ERR_OK)
      { ret=lcrzo_priv_conf_device_init_ipl_packetdll(iplwanted, device);
      }
      break;

	  default:
      ret=lcrzo_priv_conf_device_init_ipl_NTregistery(iplwanted, device);
 	    if (ret!=LCRZO_ERR_OK)
      { ret=lcrzo_priv_conf_device_init_ipl_W9xregistery(iplwanted, device);
      }
	    if (ret!=LCRZO_ERR_OK)
      { ret=lcrzo_priv_conf_device_init_ipl_packetdll(iplwanted, device);
      }
      break;
  }

  return(ret);
}

/*-------------------------------------------------------------*/
int lcrzo_priv_conf_device_init_ipl_debug_fprint(LCRZOFILE *pf);
int lcrzo_priv_conf_device_init_ipl_debug_fprint(LCRZOFILE *pf)
{ lcrzo_priv_confvars *ptrcv;
  lcrzo_priv_conf_devices cd;
  lcrzo_int32 count, i;
  lcrzo_device device;
  int ret;

  fprintf(pf, "\n\nFor each ipl in this table, obtain the device with \nlcrzo_priv_conf_device_init_ipl\n");
  lcrzo_er(lcrzo_priv_confvars_ptr_get(&ptrcv));
  lcrzo_er(lcrzo_list_count(&ptrcv->list_system_devices, &count));
  for ( i=1 ; i<=count ; i++ )
  { lcrzo_er(lcrzo_list_value_pos(&ptrcv->list_system_devices, i, &cd));
    ret=lcrzo_priv_conf_device_init_ipl(cd.ip, device);
    lcrzo_ipl_fprint(pf, "ip=", cd.ip, "\t");
    if (ret==LCRZO_ERR_OK)
    { lcrzo_device_fprint(pf, "device=", device, "\n");
    }
    else
    { lcrzo_err_fprint(pf, ret);
    }
  }

  fprintf(pf, "\n\nFor each ipl in this table, obtain the device with \nlcrzo_priv_conf_device_init_ipl_NTregistery\n");
  lcrzo_er(lcrzo_priv_confvars_ptr_get(&ptrcv));
  lcrzo_er(lcrzo_list_count(&ptrcv->list_system_devices, &count));
  for ( i=1 ; i<=count ; i++ )
  { lcrzo_er(lcrzo_list_value_pos(&ptrcv->list_system_devices, i, &cd));
    ret=lcrzo_priv_conf_device_init_ipl_NTregistery(cd.ip, device);
    lcrzo_ipl_fprint(pf, "ip=", cd.ip, "\t");
    if (ret==LCRZO_ERR_OK)
    { lcrzo_device_fprint(pf, "device=", device, "\n");
    }
    else
    { lcrzo_err_fprint(pf, ret);
    }
  }

  fprintf(pf, "\n\nFor each ipl in this table, obtain the device with \nlcrzo_priv_conf_device_init_ipl_W9xregistery\n");
  lcrzo_er(lcrzo_priv_confvars_ptr_get(&ptrcv));
  lcrzo_er(lcrzo_list_count(&ptrcv->list_system_devices, &count));
  for ( i=1 ; i<=count ; i++ )
  { lcrzo_er(lcrzo_list_value_pos(&ptrcv->list_system_devices, i, &cd));
    ret=lcrzo_priv_conf_device_init_ipl_W9xregistery(cd.ip, device);
    lcrzo_ipl_fprint(pf, "ip=", cd.ip, "\t");
    if (ret==LCRZO_ERR_OK)
    { lcrzo_device_fprint(pf, "device=", device, "\n");
    }
    else
    { lcrzo_err_fprint(pf, ret);
    }
  }

  fprintf(pf, "\n\nFor each ipl in this table, obtain the device with \nlcrzo_priv_conf_device_init_ipl_packetdll\n");
  lcrzo_er(lcrzo_priv_confvars_ptr_get(&ptrcv));
  lcrzo_er(lcrzo_list_count(&ptrcv->list_system_devices, &count));
  for ( i=1 ; i<=count ; i++ )
  { lcrzo_er(lcrzo_list_value_pos(&ptrcv->list_system_devices, i, &cd));
    ret=lcrzo_priv_conf_device_init_ipl_packetdll(cd.ip, device);
    lcrzo_ipl_fprint(pf, "ip=", cd.ip, "\t");
    if (ret==LCRZO_ERR_OK)
    { lcrzo_device_fprint(pf, "device=", device, "\n");
    }
    else
    { lcrzo_err_fprint(pf, ret);
    }
  }

  return(LCRZO_ERR_OK);
}


#else
 #error "Unknown value for LCRZODEF_SYSTEM"
#endif
