This file is indexed.

/usr/include/ncp/ncplib.h is in libncp-dev 2.2.6-8.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

   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
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
/*
    ncplib.h
    Copyright (C) 1995, 1996 by Volker Lendecke
    Copyright (C) 1997-2001  Petr Vandrovec

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA


    Revision history:

	0.00  1995			Volker Lendecke
		Initial revision.

	0.01  1995-1999			Petr Vandrovec <vandrove@vc.cvut.cz>
					Dave Woodhouse <dave@imladris.demon.co.uk>
					Roumen Petrov <rpetrov@usa.net>
					Arne de Bruijn <arne@knoware.nl>
		New APIs
		Big-endian support
		Glibc2 support
		Glibc2.1 support

	1.00  1999, November 20		Petr Vandrovec <vandrove@vc.cvut.cz>
		Added license.
		
	1.01  2000, May 17		Bruce Richardson <brichardson@lineone.net>
		Added ncp_perms_to_str and ncp_str_to_perms.
		
	1.02  2000, May 24		Petr Vandrovec <vandrove@vc.cvut.cz>
		Added NWLogoutFromFileServer.

	1.03  2001, September 15	Petr Vandrovec <vandrove@vc.cvut.cz>
		Fixes for SWIG. Unwind nested structs so that names are defined
		here and not by SWIG.

	1.04  2001, November 4		Petr Vandrovec <vandrove@vc.cvut.cz>
		Next set of SWIG fixes.

	1.05  2001, December 12		Hans Grobler <grobh@sun.ac.za>
		Added NCP_PERM_ALL, ncp_ns_delete_entry and full NET_ADDRESS_TYPE
		definition.

 */

#ifndef _NCPLIB_H
#define _NCPLIB_H

#include <ncp/ncp.h>
#include <ncp/ext/socket.h>
#include <sys/param.h>
#include <stdio.h>
#include <time.h>

#include <ncp/ipxlib.h>

typedef u_int8_t byte;
typedef u_int16_t word;
typedef u_int32_t dword;

typedef int32_t NWCCODE;

typedef enum NET_ADDRESS_TYPE {
	NT_UNKNOWN	       = -1,
	NT_IPX                 = 0,
	NT_IP                  = 1,
	NT_SDLC                = 2,
	NT_TOKENRING_ETHERNET  = 3,
	NT_OSI                 = 4,
	NT_APPLETALK           = 5,
	NT_NETBEUI             = 6,
	NT_SOCKADDR            = 7,
	NT_UDP                 = 8,
	NT_TCP                 = 9,
	NT_UDP6                = 10,
	NT_TCP6                = 11,
	NT_INTERNAL            = 12,
	NT_URL                 = 13,
	NT_COUNT               = 14
} NET_ADDRESS_TYPE;

#ifdef SWIG
/* ncp_off64_t is defined to double by Perl interface */
#else
typedef u_int64_t ncp_off64_t;
#endif

#define BVAL(buf,pos) (((const u_int8_t *)(buf))[pos])
#define BWVAL(buf,pos) (((u_int8_t*)(buf))[pos])
#define PVAL(buf,pos) ((unsigned int)BVAL(buf,pos))
#define BSET(buf,pos,val) (BWVAL(buf,pos) = (val))

#ifdef __cplusplus
extern "C" {
#endif

/* we know that the 386 can handle misalignment and has the "right" 
   byteorder */
#if 0

static inline word
WVAL_LH(const void * buf, int pos)
{
	return *((const word *) (((const u_int8_t*)buf) + pos));
}

static inline dword
DVAL_LH(const void * buf, int pos)
{
	return *((const dword *) (((const u_int8_t*)buf) + pos));
}

static inline u_int64_t
QVAL_LH(const void * buf, int pos)
{
	return *((const u_int64_t *) (((const u_int8_t*)buf) + pos));
}

static inline void
WSET_LH(void * buf, int pos, word val)
{
	*((word *) (((u_int8_t*)buf) + pos)) = val;
}

static inline void
DSET_LH(void * buf, int pos, dword val)
{
	*((dword *) (((u_int8_t*)buf) + pos)) = val;
}

static inline void
QSET_LH(void * buf, int pos, u_int64_t val)
{
	*((u_int64_t *) (((u_int8_t*)buf) + pos)) = val;
}

static inline word
WVAL_HL(const void * buf, int pos)
{
	return ntohs(WVAL_LH(buf, pos));
}

static inline dword
DVAL_HL(const void * buf, int pos)
{
	return ntohl(DVAL_LH(buf, pos));
}

static inline void
WSET_HL(void * buf, int pos, word val)
{
	WSET_LH(buf, pos, htons(val));
}

static inline void
DSET_HL(void * buf, int pos, dword val)
{
	DSET_LH(buf, pos, htonl(val));
}

static inline __attribute__((always_inline)) void
QSET_HL(void * buf, int pos, u_int64_t val) {
	DSET_HL(buf, pos, val >> 32);
	DSET_HL(buf, pos + 4, val);
}

#else

static inline word
WVAL_LH(const void * buf, int pos)
{
	return PVAL(buf, pos) | PVAL(buf, pos + 1) << 8;
}

static inline dword
DVAL_LH(const void * buf, int pos)
{
	return WVAL_LH(buf, pos) | WVAL_LH(buf, pos + 2) << 16;
}

static inline u_int64_t
QVAL_LH(const void * buf, int pos)
{
	return DVAL_LH(buf, pos) | (((u_int64_t)DVAL_LH(buf, pos + 4)) << 32);
}

static inline void
WSET_LH(void * buf, int pos, word val)
{
	BSET(buf, pos, val & 0xff);
	BSET(buf, pos + 1, val >> 8);
}

static inline void
DSET_LH(void * buf, int pos, dword val)
{
	WSET_LH(buf, pos, val & 0xffff);
	WSET_LH(buf, pos + 2, val >> 16);
}

static inline void
QSET_LH(void * buf, int pos, u_int64_t val)
{
	DSET_LH(buf, pos, val);
	DSET_LH(buf, pos + 4, val >> 32);
}

static inline word
WVAL_HL(const void * buf, int pos)
{
	return PVAL(buf, pos) << 8 | PVAL(buf, pos + 1);
}

static inline dword
DVAL_HL(const void * buf, int pos)
{
	return WVAL_HL(buf, pos) << 16 | WVAL_HL(buf, pos + 2);
}

static inline void
WSET_HL(void * buf, int pos, word val)
{
	BSET(buf, pos, val >> 8);
	BSET(buf, pos + 1, val & 0xff);
}

static inline void
DSET_HL(void * buf, int pos, dword val)
{
	WSET_HL(buf, pos, val >> 16);
	WSET_HL(buf, pos + 2, val & 0xffff);
}

static inline void
QSET_HL(void * buf, int pos, u_int64_t val) {
	DSET_HL(buf, pos, val >> 32);
	DSET_HL(buf, pos + 4, val);
}

#endif

static inline u_int64_t
SVAL_LH(const void * buf, int pos)
{
	return DVAL_LH(buf, pos) | (((u_int64_t)WVAL_LH(buf, pos + 4)) << 32);
}

void
str_upper(char *name);

enum connect_state
{
	NOT_CONNECTED = 0,
	CONN_PERMANENT,
	CONN_TEMPORARY,
	CONN_KERNELBASED
};

#define NCP_CONN_INVALID	0
#define NCP_CONN_PERMANENT	1
#define NCP_CONN_TEMPORARY	2
#define NCP_CONN_KERNELBASED	3

#define NCPFS_MAX_CFG_USERNAME	256

/* This is abstract type now. Use NWCCGetConnInfo instead */
struct ncp_conn;

typedef struct ncp_conn * NWCONN_HANDLE;

int ncp_get_fid(NWCONN_HANDLE);

#ifdef SWIG
struct ncp_conn_spec
{
	fixedCharArray server[NCP_BINDERY_NAME_LEN];
	fixedCharArray user[NCPFS_MAX_CFG_USERNAME];
	int uid;
	int login_type;
	fixedCharArray password[NCP_BINDERY_NAME_LEN];
};
#else
struct ncp_conn_spec
{
	char server[NCP_BINDERY_NAME_LEN];
	char user[NCPFS_MAX_CFG_USERNAME];
	uid_t uid;
	int login_type;		/* NCP_BINDERY_USER / NCP_BINDERY_PSERVER */
	char password[NCP_BINDERY_NAME_LEN];
};
#endif

struct ncp_search_seq
{
	struct nw_search_sequence s;
	int name_space;		/* RYP: namespace is reserved word for new C++ compilers (gcc 2.7x, egcc 2.9x, borland cbuilder) */
};

#ifdef SWIG
struct ncp_property_info
{
	fixedCharArray property_name[16];
	u_int8_t property_flags;
	u_int8_t property_security;
	u_int32_t search_instance;
	u_int8_t value_available_flag;
	u_int8_t more_properties_flag;
};
#else
struct ncp_property_info
{
	u_int8_t property_name[16];
	u_int8_t property_flags;
	u_int8_t property_security;
	u_int32_t search_instance;
	u_int8_t value_available_flag;
	u_int8_t more_properties_flag;
};
#endif

/* ncp_initialize is the main entry point for user programs which want
   to connect to a NetWare Server. It looks for -S, -U, -P and -n in
   the argument list, opens the connection and removes the arguments
   from the list. It was designed after the X Windows init
   functions. */
NWCONN_HANDLE ncp_initialize(int *argc, char **argv, int login_necessary, long *err);

/* You can login as another object by this procedure. As a first use
   pserver comes to mind. */
NWCONN_HANDLE ncp_initialize_as(int *argc, char **argv,
		   int login_necessary, int login_type, long *err);

/* You can login as another object by this procedure. As a first use
   pserver comes to mind. If required = 0 and none of -S,-U,-P is
   specified, NULL is returned regardless of configuration files */
NWCONN_HANDLE ncp_initialize_2(int *argc, char **argv, int login_necessary, 
		  int login_type, long *err, int required);


NWCCODE ncp_login_conn(NWCONN_HANDLE conn, const char *username, NWObjectType object_type, const char *password);

/* Open a connection */
NWCONN_HANDLE ncp_open(const struct ncp_conn_spec *spec, long *err);

/* Open a connection on an existing fd - it accepts only ncpfs fd now.
   In future, it can accept also connected IPX, IP and NCP socket (I'll see) */
int
ncp_open_fd(int fd, NWCONN_HANDLE *conn);

/* Open a connection on an existing mount point */
int ncp_open_mount(const char *mount_point, NWCONN_HANDLE * conn);

/* Find a permanent connection that fits the spec, return NULL if
 * there is none. */
char *
ncp_find_permanent(const struct ncp_conn_spec *spec);

/* Find the address of a file server */
long
ncp_find_fileserver(const char *server_name, struct sockaddr* addr, socklen_t addrlen);

/* Find the address of a server */
long
ncp_find_server(const char **server_name, int type, struct sockaddr* addr, socklen_t addrlen);

#ifdef MAKE_NCPLIB
/* Find the address of a server */
NWCCODE
ncp_find_server_addr(const char **server_name, int type, struct sockaddr* addr, socklen_t addrlen, unsigned int transport);
#endif

/* Detach from a permanent connection or destroy a temporary
   connection */
long ncp_close(NWCONN_HANDLE conn);

/* like getmntent, ncp_get_conn_ent scans /etc/mtab for usable
   connections */

#ifdef SWIG
struct ncp_conn_ent
{
	fixedCharArray server[NCP_BINDERY_NAME_LEN];
	char* user;
	uid_t uid;
	fixedCharArray mount_point[MAXPATHLEN];
};
#else
struct ncp_conn_ent
{
	char server[NCP_BINDERY_NAME_LEN];
	char* user;
	uid_t uid;
	char mount_point[MAXPATHLEN];
};
#endif

struct ncp_conn_ent *
ncp_get_conn_ent(FILE * filep);

#ifdef SWIG
#define NWCLIENT ".nwclient"
#define NWC_NOPASSWORD "-"
#else
#define NWCLIENT (".nwclient")
#define NWC_NOPASSWORD ("-")
#endif

/* find an appropriate connection */

struct ncp_conn_spec *
 ncp_find_conn_spec(const char *server, const char *user, const char *password,
		    int login_necessary, uid_t uid, long *err);

struct ncp_conn_spec *
 ncp_find_conn_spec2(const char *server, const char *user, const char *password,
		    int login_necessary, uid_t uid, int allow_multiple_conns, 
		    long *err);

NWCCODE
ncp_find_conn_spec3(const char *server, const char *user, const char *password,
		    int login_necessary, uid_t uid, int allow_multiple_conns, 
		    struct ncp_conn_spec *spec);

long ncp_get_file_server_description_strings(NWCONN_HANDLE conn, char descstring[512]);

long ncp_get_file_server_time(NWCONN_HANDLE conn, time_t * target);
long ncp_set_file_server_time(NWCONN_HANDLE conn, time_t * source);

#ifdef SWIG
struct ncp_file_server_info
{
	fixedCharArray ServerName[48];
	int FileServiceVersion;
	int FileServiceSubVersion;
	int MaximumServiceConnections;
	int ConnectionsInUse;
	int NumberMountedVolumes;
	int Revision;
	int SFTLevel;
	int TTSLevel;
	int MaxConnectionsEverUsed;
	int AccountVersion;
	int VAPVersion;
	int QueueVersion;
	int PrintVersion;
	int VirtualConsoleVersion;
	int RestrictionLevel;
	int InternetBridge;
	fixedArray Reserved[60];
};
#else
struct ncp_file_server_info
{
	u_int8_t ServerName[48];
	u_int8_t FileServiceVersion;
	u_int8_t FileServiceSubVersion;
	u_int16_t MaximumServiceConnections;
	u_int16_t ConnectionsInUse;
	u_int16_t NumberMountedVolumes;
	u_int8_t Revision;
	u_int8_t SFTLevel;
	u_int8_t TTSLevel;
	u_int16_t MaxConnectionsEverUsed;
	u_int8_t AccountVersion;
	u_int8_t VAPVersion;
	u_int8_t QueueVersion;
	u_int8_t PrintVersion;
	u_int8_t VirtualConsoleVersion;
	u_int8_t RestrictionLevel;
	u_int8_t InternetBridge;
	u_int8_t Reserved[60];
} __attribute__((packed));
#endif

struct ncp_file_server_info_2 {
#ifdef SWIG
	fixedArray ServerName[49];
#else
	u_int8_t ServerName[49];
#endif	
	u_int8_t FileServiceVersion;
	u_int8_t FileServiceSubVersion;
	u_int16_t MaximumServiceConnections;
	u_int16_t ConnectionsInUse;
	u_int16_t NumberMountedVolumes;
	u_int8_t Revision;
	u_int8_t SFTLevel;
	u_int8_t TTSLevel;
	u_int16_t MaxConnectionsEverUsed;
	u_int8_t AccountVersion;
	u_int8_t VAPVersion;
	u_int8_t QueueVersion;
	u_int8_t PrintVersion;
	u_int8_t VirtualConsoleVersion;
	u_int8_t RestrictionLevel;
	u_int8_t InternetBridge;
	u_int8_t MixedModePathFlag;
	u_int8_t LocalLoginInfoCcode;
	u_int16_t ProductMajorVersion;
	u_int16_t ProductMinorVersion;
	u_int16_t ProductRevisionVersion;
	u_int8_t OSLanguageID;
	u_int8_t _64BitOffsetsSupportedFlag;
};

long ncp_get_file_server_information(NWCONN_HANDLE conn,
				struct ncp_file_server_info *target);

NWCCODE ncp_get_file_server_information_2(NWCONN_HANDLE conn,
				struct ncp_file_server_info_2 *target, size_t tsize);

long ncp_get_connlist(NWCONN_HANDLE conn,
		  u_int16_t object_type, const char *object_name,
		  int *returned_no, u_int8_t conn_numbers[256]);

long
 ncp_get_stations_logged_info(NWCONN_HANDLE conn,
			      u_int32_t connection,
			      struct ncp_bindery_object *target,
			      time_t * login_time);

long
 ncp_get_internet_address(NWCONN_HANDLE conn,
			  u_int32_t connection,
			  struct sockaddr *station_addr,
			  u_int8_t * conn_type);

long
 ncp_send_broadcast(NWCONN_HANDLE conn,
		    u_int8_t no_conn, const u_int8_t * connections,
		    const char *message);

long
 ncp_send_broadcast2(NWCONN_HANDLE conn,
		     unsigned int no_conn, const unsigned int* connections,
		     const char* message);

long
 ncp_get_encryption_key(NWCONN_HANDLE conn,
			char *encryption_key);
long
 ncp_get_bindery_object_id(NWCONN_HANDLE conn,
			   NWObjectType object_type,
			   const char *object_name,
			   struct ncp_bindery_object *target);
long
 ncp_get_bindery_object_name(NWCONN_HANDLE conn,
			     NWObjectID object_id,
			     struct ncp_bindery_object *target);
NWCCODE NWScanObject(NWCONN_HANDLE conn, const char *searchName,
		     NWObjectType searchType, NWObjectID *objID,
		     char objName[NCP_BINDERY_NAME_LEN + 1], NWObjectType *objType,
		     u_int8_t *hasPropertiesFlag, u_int8_t *objFlags,
		     u_int8_t *objSecurity);

long
 ncp_scan_bindery_object(NWCONN_HANDLE conn,
			 NWObjectID last_id, NWObjectType object_type,
			 const char *search_string,
			 struct ncp_bindery_object *target);
long
 ncp_create_bindery_object(NWCONN_HANDLE conn,
			   NWObjectType object_type,
			   const char *object_name,
			   u_int8_t object_security,
			   u_int8_t object_status);
long
 ncp_delete_bindery_object(NWCONN_HANDLE conn,
			   NWObjectType object_type,
			   const char *object_name);

long
 ncp_change_object_security(NWCONN_HANDLE conn,
			    u_int16_t object_type,
			    const char *object_name,
			    u_int8_t security);

struct ncp_station_addr
{
	u_int32_t NetWork;
#ifdef SWIG
	fixedArray Node[6];
#else
	u_int8_t Node[6];
#endif
	u_int16_t Socket;
} __attribute__((packed));

struct ncp_prop_login_control
{
#ifdef SWIG
	fixedArray AccountExpireDate[3];
#else
	u_int8_t AccountExpireDate[3];
#endif	
	u_int8_t Disabled;
#ifdef SWIG
	fixedArray PasswordExpireDate[3];
#else	
	u_int8_t PasswordExpireDate[3];
#endif	
	u_int8_t GraceLogins;
	u_int16_t PasswordExpireInterval;
	u_int8_t MaxGraceLogins;
	u_int8_t MinPasswordLength;
	u_int16_t MaxConnections;
#ifdef SWIG
	fixedArray ConnectionTimeMask[42];
	fixedArray LastLogin[6];
#else	
	u_int8_t ConnectionTimeMask[42];
	u_int8_t LastLogin[6];
#endif	
	u_int8_t RestrictionMask;
	u_int8_t reserved;
	u_int32_t MaxDiskUsage;
	u_int16_t BadLoginCount;
	u_int32_t BadLoginCountDown;
	struct ncp_station_addr LastIntruder;
} __attribute__((packed));

NWCCODE NWReadPropertyValue(NWCONN_HANDLE conn, const char *objName,
			    NWObjectType objType, const char *propertyName,
			    unsigned int segmentNum, u_int8_t *segmentData,
			    u_int8_t *moreSegments, u_int8_t *flags);

long
 ncp_read_property_value(NWCONN_HANDLE conn,
			 NWObjectType object_type, const char *object_name,
			 int segment, const char *prop_name,
			 struct nw_property *target);
long
 ncp_scan_property(NWCONN_HANDLE conn,
		   NWObjectType object_type, const char *object_name,
		   NWObjectID last_id, const char *search_string,
		   struct ncp_property_info *target);
long
 ncp_add_object_to_set(NWCONN_HANDLE conn,
		       NWObjectType object_type, const char *object_name,
		       const char *property_name,
		       NWObjectType member_type,
		       const char *member_name);
long
 ncp_change_property_security(NWCONN_HANDLE conn,
			      NWObjectType object_type, const char *object_name,
			      const char *property_name,
			      u_int8_t property_security);
long
 ncp_create_property(NWCONN_HANDLE conn,
		     NWObjectType object_type, const char *object_name,
		     const char *property_name,
		     u_int8_t property_flags,
		     u_int8_t property_security);
long
 ncp_delete_object_from_set(NWCONN_HANDLE conn,
			    NWObjectType object_type, const char *object_name,
			    const char *property_name,
			    NWObjectType member_type,
			    const char *member_name);
long
 ncp_delete_property(NWCONN_HANDLE conn,
		     NWObjectType object_type, const char *object_name,
		     const char *property_name);
long
 ncp_write_property_value(NWCONN_HANDLE conn,
			  NWObjectType object_type, const char *object_name,
			  const char *property_name,
			  u_int8_t segment,
			  const struct nw_property *property_value);

/* Bit masks for security flag */
#define NCP_SEC_CHECKSUMMING_REQUESTED        (1)
#define NCP_SEC_SIGNATURE_REQUESTED           (2)
#define NCP_SEC_COMPLETE_SIGNATURES_REQUESTED (4)
#define NCP_SEC_ENCRYPTION_REQUESTED          (8)
#define NCP_SEC_LIP_DISABLED                (128)

long
 ncp_get_big_ncp_max_packet_size(NWCONN_HANDLE conn,
				 u_int16_t proposed_max_size,
				 u_int8_t proposed_security_flag,
				 u_int16_t * accepted_max_size,
				 u_int16_t * echo_socket,
				 u_int8_t * accepted_security_flag);

long
 ncp_login_encrypted(NWCONN_HANDLE conn,
		     const struct ncp_bindery_object *object,
		     const unsigned char *key,
		     const unsigned char *passwd);

long
 ncp_login_unencrypted(NWCONN_HANDLE conn,
		       NWObjectType object_type, const char *object_name,
		       const unsigned char *passwd);

long
 ncp_change_login_passwd(NWCONN_HANDLE conn,
			 const struct ncp_bindery_object *object,
			 const unsigned char *key,
			 const unsigned char *oldpasswd,
			 const unsigned char *newpasswd);

#define NCP_GRACE_PERIOD (0xdf)

#define NCPLIB_ERROR			(0x8700)
/* ~/.nwclient is group/world writeable or readable */
#define NCPLIB_INVALID_MODE		(NCPLIB_ERROR | 0x01)
/* ncp_get_namespace_info_element called with itemid not in nsrim */
#define NCPLIB_INFORMATION_NOT_KNOWN	(NCPLIB_ERROR | 0x02)
/* neither fixed nor variable bit requested */
#define NCPLIB_NSFORMAT_INVALID		(NCPLIB_ERROR | 0x03)
/* referrals disabled, but referral is needed ... */
#define NCPLIB_REFERRAL_NEEDED		(NCPLIB_ERROR | 0x04)
/* ncpd refused to do its work... */
#define NCPLIB_NCPD_DEAD		(NCPLIB_ERROR | 0x05)
#define NCPLIB_PASSWORD_REQUIRED	(NCPLIB_ERROR | 0x06)

#define NWE_REQUESTER_ERROR		(0x8800)
#define NWE_REQ_TOO_MANY_REQ_FRAGS	(NWE_REQUESTER_ERROR | 0x0C)
#define NWE_BUFFER_OVERFLOW		(NWE_REQUESTER_ERROR | 0x0E)
#define NWE_SERVER_NO_CONN		(NWE_REQUESTER_ERROR | 0x0F)
#define NWE_SCAN_COMPLETE		(NWE_REQUESTER_ERROR | 0x12)
#define NWE_UNSUPPORTED_NAME_FORMAT_TYP	(NWE_REQUESTER_ERROR | 0x13)
#define NWE_INVALID_NCP_PACKET_LENGTH	(NWE_REQUESTER_ERROR | 0x16)
#define NWE_BUFFER_INVALID_LEN		(NWE_REQUESTER_ERROR | 0x33)	/* buffer underflow */
#define NWE_USER_NO_NAME		(NWE_REQUESTER_ERROR | 0x34)
#define NWE_PARAM_INVALID		(NWE_REQUESTER_ERROR | 0x36)
#define NWE_SERVER_NOT_FOUND		(NWE_REQUESTER_ERROR | 0x47)
#define NWE_SIGNATURE_LEVEL_CONFLICT	(NWE_REQUESTER_ERROR | 0x61)
#define NWE_INVALID_LEVEL		(NWE_REQUESTER_ERROR | 0x6B)
#define NWE_UNSUPPORTED_TRAN_TYPE	(NWE_REQUESTER_ERROR | 0x70)
#define NWE_UNSUPPORTED_AUTHENTICATOR	(NWE_REQUESTER_ERROR | 0x73)
#define NWE_REQUESTER_FAILURE		(NWE_REQUESTER_ERROR | 0xFF)

#define NWE_SERVER_ERROR		(0x8900)
#define NWE_VOL_INVALID			(NWE_SERVER_ERROR | 0x98)
#define NWE_DIRHANDLE_INVALID		(NWE_SERVER_ERROR | 0x9B)
#define NWE_LOGIN_LOCKOUT		(NWE_SERVER_ERROR | 0xC5)
#define NWE_Q_NO_RIGHTS			(NWE_SERVER_ERROR | 0xD3)
#define NWE_Q_NO_JOB			(NWE_SERVER_ERROR | 0xD5)
#define NWE_Q_NO_JOB_RIGHTS		(NWE_SERVER_ERROR | 0xD6)
#define NWE_PASSWORD_UNENCRYPTED	(NWE_SERVER_ERROR | 0xD6)
#define NWE_PASSWORD_NOT_UNIQUE		(NWE_SERVER_ERROR | 0xD7)
#define NWE_PASSWORD_TOO_SHORT		(NWE_SERVER_ERROR | 0xD8)
#define NWE_LOGIN_MAX_EXCEEDED		(NWE_SERVER_ERROR | 0xD9)
#define NWE_LOGIN_UNAUTHORIZED_TIME	(NWE_SERVER_ERROR | 0xDA)
#define NWE_LOGIN_UNAUTHORIZED_STATION	(NWE_SERVER_ERROR | 0xDB)
#define NWE_ACCT_DISABLED		(NWE_SERVER_ERROR | 0xDC)
#define NWE_PASSWORD_INVALID		(NWE_SERVER_ERROR | 0xDE)
#define NWE_PASSWORD_EXPIRED		(NWE_SERVER_ERROR | 0xDF)
#define NWE_BIND_MEMBER_ALREADY_EXISTS	(NWE_SERVER_ERROR | 0xE9)
#define NWE_NCP_NOT_SUPPORTED		(NWE_SERVER_ERROR | 0xFB)
#define NWE_SERVER_UNKNOWN		(NWE_SERVER_ERROR | 0xFC)
#define NWE_CONN_NUM_INVALID		(NWE_SERVER_ERROR | 0xFD)
#define NWE_SERVER_FAILURE		(NWE_SERVER_ERROR | 0xFF)

const char* strnwerror(int err);

long
 ncp_login_user(NWCONN_HANDLE conn,
		const unsigned char *username,
		const unsigned char *password);

long
 ncp_get_volume_info_with_number(NWCONN_HANDLE conn, int n,
				 struct ncp_volume_info *target);

long
 ncp_get_volume_number(NWCONN_HANDLE conn, const char *name,
		       int *target);

long
 ncp_file_search_init(NWCONN_HANDLE conn,
		      int dir_handle, const char *path,
		      struct ncp_filesearch_info *target);

long
 ncp_file_search_continue(NWCONN_HANDLE conn,
			  struct ncp_filesearch_info *fsinfo,
			  int attributes, const char *path,
			  struct ncp_file_info *target);

long
 ncp_get_finfo(NWCONN_HANDLE conn,
	       int dir_handle, const char *path, const char *name,
	       struct ncp_file_info *target);

long
 ncp_open_file(NWCONN_HANDLE conn,
	       int dir_handle, const char *path,
	       int attr, int accessm,
	       struct ncp_file_info *target);

long ncp_close_file(NWCONN_HANDLE conn, const char fileHandle[6]);

long
 ncp_create_newfile(NWCONN_HANDLE conn,
		    int dir_handle, const char *path,
		    int attr,
		    struct ncp_file_info *target);

long
 ncp_create_file(NWCONN_HANDLE conn,
		 int dir_handle, const char *path,
		 int attr,
		 struct ncp_file_info *target);

long
 ncp_erase_file(NWCONN_HANDLE conn,
		int dir_handle, const char *path,
		int attr);

long
 ncp_rename_file(NWCONN_HANDLE conn,
		 int old_handle, const char *old_path,
		 int attr,
		 int new_handle, const char *new_path);

long
 ncp_create_directory(NWCONN_HANDLE conn,
		      int dir_handle, const char *path,
		      int inherit_mask);

long
 ncp_delete_directory(NWCONN_HANDLE conn,
		      int dir_handle, const char *path);

long
 ncp_rename_directory(NWCONN_HANDLE conn,
		      int dir_handle,
		      const char *old_path, const char *new_path);

#ifdef SWIG
long
 ncp_get_trustee(NWCONN_HANDLE conn, NWObjectID object_id,
		 u_int8_t vol, fixedCharArray OUTPUT[256],
		 u_int16_t * OUTPUT, u_int16_t * REFERENCE);
#else
long
 ncp_get_trustee(NWCONN_HANDLE conn, NWObjectID object_id,
		 u_int8_t vol, char *path,
		 u_int16_t * trustee, u_int16_t * contin);
#endif

long
 ncp_add_trustee(NWCONN_HANDLE conn,
		 int dir_handle, const char *path,
		 NWObjectID object_id, u_int8_t rights);

long
 ncp_delete_trustee(NWCONN_HANDLE conn,
		    int dir_handle, const char *path,
		    NWObjectID object_id);

#ifdef SWIG
long
 ncp_read(NWCONN_HANDLE conn, const char fileHandle[6],
	  __off_t offset, size_t count, char *RETBUFFER_LENPREV);

long
 ncp_write(NWCONN_HANDLE conn, const char fileHandle[6],
	   __off_t offset, size_t IGNORE, const char *STRING_LENPREV);

long
 ncp_copy_file(NWCONN_HANDLE conn,
	       const fixedArray source_file[6],
	       const fixedArray target_file[6],
	       u_int32_t source_offset,
	       u_int32_t target_offset,
	       u_int32_t count,
	       u_int32_t * OUTPUT);
#else
long
 ncp_read(NWCONN_HANDLE conn, const char fileHandle[6],
	  __off_t offset, size_t count, char *target);

long
 ncp_write(NWCONN_HANDLE conn, const char fileHandle[6],
	   __off_t offset, size_t count, const char *source);

NWCCODE ncp_read64(NWCONN_HANDLE conn, const char fileHandle[6],
		ncp_off64_t offset, size_t count, void *target, size_t *bytesread);

NWCCODE ncp_write64(NWCONN_HANDLE conn, const char fileHandle[6],
		ncp_off64_t offset, size_t count, const void *source, size_t *byteswritten);

long
 ncp_copy_file(NWCONN_HANDLE conn,
	       const char source_file[6],
	       const char target_file[6],
	       u_int32_t source_offset,
	       u_int32_t target_offset,
	       u_int32_t count,
	       u_int32_t * copied_count);
#endif

#define SA_NORMAL	(0x0000)
#define SA_HIDDEN	(0x0002)
#define SA_SYSTEM	(0x0004)
#define SA_SUBDIR_ONLY	(0x0010)
#define SA_SUBDIR_FILES	(0x8000)
#define SA_ALL		(SA_SUBDIR_FILES | SA_SYSTEM | SA_HIDDEN)
#define SA_SUBDIR_ALL	(SA_SUBDIR_ONLY | SA_SYSTEM | SA_HIDDEN)
#define SA_FILES_ALL	(SA_NORMAL | SA_SYSTEM | SA_HIDDEN)

#define NCP_DIRSTYLE_HANDLE     0x00
#define NCP_DIRSTYLE_DIRBASE    0x01
#define NCP_DIRSTYLE_NOHANDLE   0xFF

#define NCP_PATH_STD		-1

long
 ncp_obtain_file_or_subdir_info(NWCONN_HANDLE conn,
				u_int8_t source_ns, u_int8_t target_ns,
				u_int16_t search_attribs, u_int32_t rim,
				u_int8_t vol, u_int32_t dirent, 
				const char *path,
				struct nw_info_struct *target);

#define NCP_PERM_READ   (0x001)
#define NCP_PERM_WRITE  (0x002)
#define NCP_PERM_OPEN   (0x004)
#define NCP_PERM_CREATE (0x008)
#define NCP_PERM_DELETE (0x010)
#define NCP_PERM_OWNER  (0x020)
#define NCP_PERM_SEARCH (0x040)
#define NCP_PERM_MODIFY (0x080)
#define NCP_PERM_SUPER  (0x100)
#define NCP_PERM_ALL    (0x1fb)

long
 ncp_get_eff_directory_rights(NWCONN_HANDLE conn,
			      u_int8_t source_ns,
			      u_int8_t target_ns,
			      u_int16_t search_attribs,
			      u_int8_t vol, u_int32_t dirent, const char *path,
			      u_int16_t * my_effective_rights);

long
ncp_do_lookup2(NWCONN_HANDLE conn,
	       u_int8_t _source_ns,
	       const struct nw_info_struct *dir,
	       const char *path,       /* may only be one component */
	       u_int8_t _target_ns,
	       struct nw_info_struct *target);

long
ncp_do_lookup(NWCONN_HANDLE conn,
	      const struct nw_info_struct *dir,
	      const char *path,	/* may only be one component */
	      struct nw_info_struct *target);

long
 ncp_modify_file_or_subdir_dos_info(NWCONN_HANDLE conn,
				    const struct nw_info_struct *file,
				    u_int32_t info_mask,
				    const struct nw_modify_dos_info *info);

long
 ncp_del_file_or_subdir(NWCONN_HANDLE conn,
			const struct nw_info_struct *dir, const char *name);


long
 ncp_open_create_file_or_subdir(NWCONN_HANDLE conn,
				const struct nw_info_struct *dir,
				const char *name,
				int open_create_mode,
				u_int32_t create_attributes,
				int desired_acc_rights,
				struct nw_file_info *target);

long
 ncp_initialize_search(NWCONN_HANDLE conn,
		       const struct nw_info_struct *dir,
		       int name_space,
		       struct ncp_search_seq *target);

long
 ncp_initialize_search2(NWCONN_HANDLE conn,
		        const struct nw_info_struct *dir,
		        int name_space,
		        const unsigned char *enc_subpath, int subpathlen,
		        struct ncp_search_seq *target);

long
ncp_search_for_file_or_subdir2(NWCONN_HANDLE conn,
			       int search_attributes,
			       u_int32_t RIM,
			       struct ncp_search_seq *seq,
			       struct nw_info_struct *target);

long
 ncp_search_for_file_or_subdir(NWCONN_HANDLE conn,
			       struct ncp_search_seq *seq,
			       struct nw_info_struct *target);

long
 ncp_ren_or_mov_file_or_subdir(NWCONN_HANDLE conn,
			       const struct nw_info_struct *old_dir, const char *old_name,
			       const struct nw_info_struct *new_dir, const char *new_name);

long
 ncp_create_queue_job_and_file(NWCONN_HANDLE conn,
			       NWObjectID queue_id,
			       struct queue_job *job);

long
 ncp_get_queue_length(NWCONN_HANDLE conn,
                      NWObjectID queue_id,
                      u_int32_t *queue_length);

long 
 ncp_get_queue_job_ids(NWCONN_HANDLE conn,
                       NWObjectID queue_id,
                       u_int32_t queue_section,
                       u_int32_t *length1,
                       u_int32_t *length2,
                       u_int32_t ids[]);
long 
 ncp_get_queue_job_info(NWCONN_HANDLE conn,
                        NWObjectID queue_id,
                        u_int32_t job_id,
                        struct nw_queue_job_entry *target);

long
NWRemoveJobFromQueue2(NWCONN_HANDLE conn, NWObjectID queue_id,
			u_int32_t job_id);
                        
long
 ncp_close_file_and_start_job(NWCONN_HANDLE conn,
			      NWObjectID queue_id,
			      const struct queue_job *job);

long
 ncp_attach_to_queue(NWCONN_HANDLE conn, NWObjectID queue_id);

long
 ncp_detach_from_queue(NWCONN_HANDLE conn, NWObjectID queue_id);

long
 ncp_service_queue_job(NWCONN_HANDLE conn, NWObjectID queue_id, 
 		       u_int16_t job_type, struct queue_job *target);

long
 ncp_finish_servicing_job(NWCONN_HANDLE conn, NWObjectID queue_id,
			  u_int32_t job_number, u_int32_t charge_info);
			  
long
 ncp_change_job_position(NWCONN_HANDLE conn, NWObjectID queue_id,
			  u_int32_t job_number, unsigned int position);

long
 ncp_abort_servicing_job(NWCONN_HANDLE conn, NWObjectID queue_id,
			 u_int32_t job_number);

NWCCODE NWChangeQueueJobEntry(NWCONN_HANDLE conn, NWObjectID queue_id,
			      const struct nw_queue_job_entry *jobdata);

long
 ncp_get_broadcast_message(NWCONN_HANDLE conn, char message[256]);

long
 ncp_dealloc_dir_handle(NWCONN_HANDLE conn, u_int8_t dir_handle);

#define NCP_ALLOC_PERMANENT (0x0000)
#define NCP_ALLOC_TEMPORARY (0x0001)
#define NCP_ALLOC_SPECIAL   (0x0002)

long
 ncp_alloc_short_dir_handle2(NWCONN_HANDLE conn,
			     u_int8_t _namespace,
			     const struct nw_info_struct *dir,
			     u_int16_t alloc_mode,
			     u_int8_t * target);

long
 ncp_alloc_short_dir_handle(NWCONN_HANDLE conn,
			    const struct nw_info_struct *dir,
			    u_int16_t alloc_mode,
			    u_int8_t * target);

long
 ncp_get_effective_dir_rights(NWCONN_HANDLE conn,
			      const struct nw_info_struct *file,
			      u_int16_t * target);

struct ncp_trustee_struct
{
	NWObjectID object_id;
	u_int16_t rights;
};

long
ncp_add_trustee_set(NWCONN_HANDLE conn,
		     u_int8_t volume_number, u_int32_t dir_entry,
		     u_int16_t rights_mask,
		     int object_count, 
		     const struct ncp_trustee_struct *rights);

struct ncp_deleted_file
{
	int32_t		seq;
	u_int32_t	vol;
	u_int32_t	base;
};

long
ncp_ns_scan_salvageable_file(NWCONN_HANDLE conn, u_int8_t src_ns,
			     int dirstyle, u_int8_t vol_num, 
			     u_int32_t dir_base,
			     const unsigned char* encpath, int pathlen,
			     struct ncp_deleted_file* finfo,
			     char* retname, int retname_maxlen);

long
ncp_ns_purge_file(NWCONN_HANDLE conn, const struct ncp_deleted_file* finfo);

long
ncp_ns_get_full_name(NWCONN_HANDLE conn, u_int8_t src_ns, u_int8_t dst_ns,
	             int dirstyle, u_int8_t vol_num, u_int32_t dir_base,
		     const unsigned char* encpath, size_t pathlen,
	             char* retname, size_t retname_maxlen);

int
ncp_get_conn_type(NWCONN_HANDLE conn);

int
ncp_get_conn_number(NWCONN_HANDLE conn);

NWCCODE
ncp_get_dentry_ttl(NWCONN_HANDLE conn, unsigned int* ttl);

NWCCODE
ncp_set_dentry_ttl(NWCONN_HANDLE conn, unsigned int ttl);

/* What to do with them?! Simply do not use them if you compiled libncp
   without NDS support */
long
ncp_send_nds_frag(NWCONN_HANDLE conn,
    int ndsverb,
    const char *inbuf, size_t inbuflen,
    char *outbuf, size_t outbufsize, size_t *outbuflen);

long
ncp_send_nds(NWCONN_HANDLE conn, int fn,
 const char *data_in, size_t data_in_len, 
 char *data_out, size_t data_out_max, size_t *data_out_len);

long
ncp_change_conn_state(NWCONN_HANDLE conn, int new_state);
/* end of NDS specific... */

NWCONN_HANDLE 
ncp_open_addr(const struct sockaddr *target, long *err);

int
ncp_path_to_NW_format(const char* path, unsigned char* encbuff, int encbuffsize);

long
ncp_obtain_file_or_subdir_info2(NWCONN_HANDLE conn, u_int8_t source_ns,
			u_int8_t target_ns, u_int16_t search_attribs, 
			u_int32_t rim, int dir_style, u_int8_t vol, 
			u_int32_t dirent, 
			const unsigned char* encpath, int pathlen,
			struct nw_info_struct* target);

typedef unsigned int NWVOL_NUM;
typedef unsigned int NWDIR_HANDLE;
typedef u_int32_t NWDIR_ENTRY;

struct NSI_Name {
#ifdef SWIG
%pragma(swig) readonly
	size_t				NameLength;
%pragma(swig) readwrite
	size_tLenPrefixCharArray	Name[256];
#else
	size_t		NameLength;
	char		Name[256];
#endif
};
	
struct NSI_Attributes {
	u_int32_t	Attributes;
	u_int16_t	Flags;
};

struct NSI_TotalSize {
	u_int32_t	TotalAllocated;
	size_t		Datastreams;
};

struct NSI_ExtAttrInfo {
	u_int32_t	DataSize;
	u_int32_t	Count;
	u_int32_t	KeySize;
};

struct NSI_Change {
	u_int16_t	Date;
	u_int16_t	Time;
	NWObjectID	ID;
};

struct NSI_Directory {
	NWDIR_ENTRY	dirEntNum;
	NWDIR_ENTRY	DosDirNum;
	NWVOL_NUM	volNumber;
};

struct NSI_DatastreamFATInfo {
	u_int32_t	Number;
	u_int32_t	FATBlockSize;
};

struct NSI_DatastreamSizes {
	size_t	NumberOfDatastreams;
	struct NSI_DatastreamFATInfo ds[0];
};

struct NSI_DatastreamInfo {
	u_int32_t	Number;
	ncp_off64_t	Size;	/* !! was 32bit in ncpfs-2.2.0.18, but
	                           this type was not used in API !! */
};

struct NSI_DatastreamLogicals {
	size_t	NumberOfDatastreams;
	struct NSI_DatastreamInfo ds[0];
};

struct NSI_DOSName {
#ifdef SWIG
%pragma(swig) readonly
	size_t				NameLength;
%pragma(swig) readwrite
	size_tLenPrefixCharArray	Name[16];
#else
	size_t		NameLength;	/* 0..14 */
	char		Name[16];	/* align... why not... */
#endif
};

struct NSI_MacTimes {
	int32_t CreateTime;
	int32_t BackupTime;
};

struct NSI_Modify {
	struct NSI_Change Modify;
	struct NSI_Change LastAccess;
};

struct NSI_LastAccess {
	u_int16_t	Date;
	u_int16_t	Time;	/* NW5.00+ */
};

#ifdef SWIG
struct nw_info_struct2 {
	ncp_off64_t	SpaceAllocated;
	struct NSI_Attributes Attributes;
	ncp_off64_t	DataSize;
	struct NSI_TotalSize TotalSize;
	struct NSI_ExtAttrInfo ExtAttrInfo;
	struct NSI_Change Archive;
	struct NSI_Change Modify;
	struct NSI_Change Creation;
	struct NSI_LastAccess LastAccess;
	u_int32_t	OwningNamespace;
	struct NSI_Directory Directory;
	u_int16_t	Rights;	/* inherited */
			
	u_int16_t	ReferenceID;
	u_int32_t	NSAttributes;
	/* datastream actual cannot be retrieved this way... */
	/* datastream logical ... dtto ... */
	int32_t		UpdateTime; /* seconds, relative to year 2000... */ /* NW4.11 */
	struct NSI_DOSName DOSName;	/* NW4.11 */
	u_int32_t	FlushTime;	/* NW4.11 */
	u_int32_t	ParentBaseID;	/* NW4.11 */
	fixedArray	MacFinderInfo[32]; /* NW4.11 */
	u_int32_t	SiblingCount;	/* NW4.11 */
	u_int32_t	EffectiveRights; /* NW4.11 */
	struct NSI_MacTimes MacTimes;	/* NW4.11 */
	u_int16_t	Unknown25;
	u_int16_t	reserved3;
	u_int32_t	reserved1[7];	/* future expansion... */
	struct NSI_Name	Name;
	fixedArray	reserved2[512];	/* future expansion... (unicode name?) */
};
#else
struct nw_info_struct2 {
	ncp_off64_t	SpaceAllocated;
	struct NSI_Attributes Attributes;
	ncp_off64_t	DataSize;
	struct NSI_TotalSize TotalSize;
	struct NSI_ExtAttrInfo ExtAttrInfo;
	struct NSI_Change Archive;
	struct NSI_Change Modify;
	struct NSI_Change Creation;
	struct NSI_LastAccess LastAccess;
	u_int32_t	OwningNamespace;
	struct NSI_Directory Directory;
	u_int16_t	Rights;	/* inherited */
			
	u_int16_t	ReferenceID;
	u_int32_t	NSAttributes;
	/* datastream actual cannot be retrieved this way... */
	/* datastream logical ... dtto ... */
	int32_t		UpdateTime; /* seconds, relative to year 2000... */ /* NW4.11 */
	struct NSI_DOSName DOSName;	/* NW4.11 */
	u_int32_t	FlushTime;	/* NW4.11 */
	u_int32_t	ParentBaseID;	/* NW4.11 */
	u_int8_t	MacFinderInfo[32]; /* NW4.11 */
	u_int32_t	SiblingCount;	/* NW4.11 */
	u_int32_t	EffectiveRights; /* NW4.11 */
	struct NSI_MacTimes MacTimes;	/* NW4.11 */
	u_int16_t	Unknown25;
	u_int16_t	reserved3;
	u_int32_t	reserved1[7];	/* future expansion... */
	struct NSI_Name	Name;
	u_int8_t	reserved2[512];	/* future expansion... (unicode name?) */
};
#endif

struct nw_info_struct3 {
	size_t		len;
	void*		data;
};

struct ncp_dos_info_rights {
	u_int16_t	Grant;
	u_int16_t	Revoke;
};

struct ncp_dos_info {
	u_int32_t	Attributes;
	struct NSI_Change Creation;
	struct NSI_Change Modify;
	struct NSI_Change Archive;
	struct NSI_LastAccess LastAccess;	/* Time field ignored */
	struct ncp_dos_info_rights Rights;
	u_int32_t	MaximumSpace;	/* 64bit? It is in 4KB blocks... And NSS does not support this... */
};

struct ncp_namespace_format_BitMask {
	u_int32_t	fixed;
	u_int32_t	variable;
	u_int32_t	huge;
};

struct ncp_namespace_format_BitsDefined {
	size_t		fixed;
	size_t		variable;
	size_t		huge;
};

struct ncp_namespace_format {
	unsigned int	Version;	/* used only by library */
	struct ncp_namespace_format_BitMask BitMask;
	struct ncp_namespace_format_BitsDefined BitsDefined;
	size_t		FieldsLength[32];
};

NWCCODE
ncp_ns_open_create_entry(NWCONN_HANDLE conn,
				/* entry info */
				unsigned int ns,
				unsigned int search_attributes,
				int dirstyle,
				unsigned int vol,
				u_int32_t dirent,
				const unsigned char* encpath, size_t pathlen,
				/*  what to do with entry */
				int datastream,
				int open_create_mode,
				u_int32_t create_attributes,
				u_int16_t desired_access_rights,
				/* what to return */
				u_int32_t rim,
				/* returned */
				/* struct nw_info_struct2 */ void* target, size_t sizeoftarget,
				u_int8_t* oc_action,
				u_int8_t* oc_callback,
				char fileHandle[6]	/* ?? u_int32_t* or NW_FILE_HANDLE* ?? */
				);

NWCCODE
ncp_ns_obtain_entry_info(NWCONN_HANDLE conn, 
				/* entry info */
				unsigned int source_ns,
				unsigned int search_attributes, 
				int dirstyle, 
				unsigned int vol, 
				u_int32_t dirent, 
				const unsigned char* encpath, size_t pathlen,
				/* what to do with entry */
				unsigned int target_ns,
				/* what to return */
				u_int32_t rim,
				/* returned */
				/* struct nw_info_struct2 */ void* target, size_t sizeoftarget);

NWCCODE
ncp_ns_modify_entry_dos_info(NWCONN_HANDLE conn,
				    /* entry info */
				    unsigned int ns,
				    unsigned int search_attributes,
				    int dirstyle,
				    unsigned int vol,
				    u_int32_t dirent,
				    const unsigned char* encpath, size_t pathlen,
				    /* what to do with entry */
				    u_int32_t mim,
				    const struct ncp_dos_info* info
				    /* nothing to return */
				    /* nothing returned */
				    );

NWCCODE
ncp_ns_obtain_namespace_info_format(NWCONN_HANDLE conn,
				  /* entry info */
				  unsigned int vol,
				  /* what to do with entry */
				  unsigned int target_ns,
				  /* returned */
				  struct ncp_namespace_format* format, size_t sizeofformat);

NWCCODE
ncp_ns_obtain_entry_namespace_info(NWCONN_HANDLE conn,
					  /* entry info */
					  unsigned int source_ns,
					  unsigned int vol,
					  u_int32_t dirent,
					  /* what to do with entry */
					  unsigned int target_ns,
					  /* rim */
					  u_int32_t nsrim,
					  /* returned */
					  void* nsibuf, size_t* nsibuflen, size_t nsimaxbuflen);
					  
NWCCODE
ncp_ns_modify_entry_namespace_info(NWCONN_HANDLE conn,
					  /* entry info */
					  unsigned int source_ns,
					  unsigned int vol,
					  u_int32_t dirent,
					  /* what to do with entry */
					  unsigned int target_ns,
					  /* rim */
					  u_int32_t nsrim,
					  /* info */
					  const void* mnsbuf, size_t mnsbuflen);
					  
NWCCODE
ncp_ns_get_namespace_info_element(const struct ncp_namespace_format* nsformat,
			       u_int32_t nsrim, 
			       const void* nsibuf,
			       size_t nsibuflen,
			       unsigned int itemid,
			       void* itembuf, size_t* itembuflen, size_t itemmaxbuflen);

NWCCODE
ncp_ns_alloc_short_dir_handle(NWCONN_HANDLE conn,
			      /* input */
			      unsigned int ns,
			      int dirstyle,
			      unsigned int vol,
			      u_int32_t dirent,
			      const unsigned char* encpath, size_t pathlen,
			      /* alloc short dir handle specific */
			      unsigned int allocate_mode,
			      /* output */
			      NWDIR_HANDLE* dirhandle,
			      NWVOL_NUM* ovol);
			 
#define NSIF_NAME		0x0000	/* NSI_Name */
#define NSIF_SPACE_ALLOCATED	0x0001	/* ncp_off64_t */
#define NSIF_ATTRIBUTES		0x0002	/* NSI_Attributes */
#define NSIF_DATA_SIZE		0x0003	/* ncp_off64_t */
#define NSIF_TOTAL_SIZE		0x0004	/* NSI_TotalSize */
#define NSIF_EXT_ATTR_INFO	0x0005	/* NSI_ExtAttrInfo */
#define NSIF_ARCHIVE		0x0006	/* NSI_Change */
#define NSIF_MODIFY		0x0007	/* NSI_Modify */
#define NSIF_CREATION		0x0008	/* NSI_Change */
#define NSIF_OWNING_NAMESPACE	0x0009	/* u_int32_t */
#define NSIF_DIRECTORY		0x000A	/* NSI_Directory */
#define NSIF_RIGHTS		0x000B	/* u_int16_t */
#define NSIF_REFERENCE_ID	0x000C	/* u_int16_t */
#define NSIF_NS_ATTRIBUTES	0x000D	/* u_int32_t */
#define NSIF_DATASTREAM_SIZES	0x000E	/* NSI_DatastreamSizes */
#define NSIF_DATASTREAM_LOGICALS 0x000F	/* NSI_DatastreamLogicals */
#define NSIF_UPDATE_TIME	0x0010	/* int32_t */
#define NSIF_DOS_NAME		0x0011	/* NSI_Name */
#define NSIF_FLUSH_TIME		0x0012	/* u_int32_t */
#define NSIF_PARENT_BASE_ID	0x0013	/* u_int32_t */
#define NSIF_MAC_FINDER_INFO	0x0014	/* 32 bytes */
#define NSIF_SIBLING_COUNT	0x0015	/* u_int32_t */
#define NSIF_EFFECTIVE_RIGHTS	0x0016	/* u_int32_t */
#define NSIF_MAC_TIMES		0x0017	/* NSI_MacTimes */
#define NSIF_LAST_ACCESS_TIME	0x0018	/* NSI_Modify (alias to NSIF_MODIFY) */
#ifdef MAKE_NCPLIB
#define NSIF_UNKNOWN25		0x0019
#endif
#define NSIF_SIZE64		0x001A	/* ncp_off64_t */

NWCCODE
ncp_ns_extract_info_field_size(
		   const struct nw_info_struct3* rq,
		   u_int32_t field,
		   size_t* destlen);
NWCCODE
ncp_ns_extract_info_field(
		   const struct nw_info_struct3* rq,
		   u_int32_t field,
		   void* dest, size_t destlen);

typedef struct ncp_directory_list_handle * NWDIRLIST_HANDLE;

NWCCODE
ncp_ns_search_init(NWCONN_HANDLE conn,
		   /* input */
		   unsigned int ns,
		   unsigned int search_attributes,
		   unsigned int dirstyle,
		   unsigned int vol,
		   NWDIR_ENTRY dirent,
		   const unsigned char* encpath, size_t enclen,
		   /* search specific */
		   int datastream,
		   const unsigned char* pattern, size_t patlen,
		   u_int32_t rim,
		   /* handle */
		   NWDIRLIST_HANDLE* handle);
		   
NWCCODE
ncp_ns_search_next(NWDIRLIST_HANDLE handle,
		   /* struct nw_info_struct2 */ void* target, size_t sizeoftarget);

NWCCODE
ncp_ns_search_end(NWDIRLIST_HANDLE handle);

typedef struct {
	NWObjectID	objectID;
	u_int16_t	objectRights;
} TRUSTEE_INFO;

NWCCODE
ncp_ns_trustee_add(NWCONN_HANDLE conn,
		   /* input */
		   unsigned int ns,
		   unsigned int search_attributes,
		   int dirstyle,
		   unsigned int vol,
		   u_int32_t dirent,
		   const unsigned char* encpath, size_t pathlen,
		   /* trustee add specific */
		   const TRUSTEE_INFO* trustees,
		   unsigned int object_count,
		   u_int16_t rights_mask);

NWCCODE
ncp_ns_trustee_del(NWCONN_HANDLE conn,
		   /* input */
		   unsigned int ns,
		   int dirstyle,
		   unsigned int vol,
		   u_int32_t dirent,
		   const unsigned char* encpath, size_t pathlen,
		   /* trustee del specific */
		   const TRUSTEE_INFO* trustees,
		   unsigned int object_count);

NWCCODE
ncp_ns_trustee_scan(NWCONN_HANDLE conn,
		    /* input */
		    unsigned int ns,
		    unsigned int search_attributes,
		    int dirstyle,
		    unsigned int vol,
		    u_int32_t dirent,
		    const unsigned char* encpath, size_t pathlen,
		    /* trustee scan specific */
		    u_int32_t* iter,
		    TRUSTEE_INFO* trustees,
		    unsigned int* object_count);

NWCCODE
ncp_ns_delete_entry(NWCONN_HANDLE conn,
		    /* input */
		    unsigned int ns,
		    unsigned int search_attributes,
		    int dirstyle,
		    unsigned int vol,
		    u_int32_t dirent,
		    const unsigned char* encpath, size_t pathlen);

typedef struct ncp_volume_list_handle * NWVOL_HANDLE;

NWCCODE
ncp_volume_list_init(NWCONN_HANDLE conn,
		     /* input */
		     unsigned int ns,
		     unsigned int reqflags,
		     /* output */
		     NWVOL_HANDLE* handle);
		     
NWCCODE
ncp_volume_list_next(NWVOL_HANDLE handle,
		     unsigned int *volnum,
		     char* retname, size_t retname_maxlen);
		     
NWCCODE
ncp_volume_list_end(NWVOL_HANDLE handle);
		     
//NWCCODE ncp_extract_file_info2(u_int32_t rim, const u_int8_t*, size_t,
//		struct nw_info_struct2*);

NWCCODE
ncp_get_file_size(NWCONN_HANDLE conn,
		  /* input */
		  const char fileHandle[6],
		  /* output */
		  ncp_off64_t* fileSize);

int
ncp_get_mount_uid(int fid, uid_t* uid);

#ifndef SWIG
void
com_err(const char* program, int error, const char* msg, ...);
#endif

NWCCODE ncp_renegotiate_siglevel(NWCONN_HANDLE conn, size_t buffsize, int siglevel);

char* ncp_perms_to_str(char r[11], const u_int16_t rights);

int ncp_str_to_perms(const char *r, u_int16_t *rights);

const char* ncp_namespace_to_str(char r[5], unsigned int ns);

#define NCP_PHYSREC_LOG	0x00
#define NCP_PHYSREC_EX	0x01
#define NCP_PHYSREC_SH	0x03

NWCCODE ncp_log_physical_record(NWCONN_HANDLE conn, const char fileHandle[6],
		ncp_off64_t startOffset, u_int64_t length, unsigned int flags,
		unsigned int timeout);

NWCCODE ncp_clear_physical_record(NWCONN_HANDLE conn, const char fileHandle[6],
		ncp_off64_t startOffset, u_int64_t length);

NWCCODE ncp_release_physical_record(NWCONN_HANDLE conn, const char fileHandle[6],
		ncp_off64_t startOffset, u_int64_t length);

#ifdef __cplusplus
}
#endif

#ifdef NCP_OBSOLETE
#include <ncp/obsolete/o_ncplib.h>
#endif

#endif	/* _NCPLIB_H */