home *** CD-ROM | disk | FTP | other *** search
- /* $Header: tyrathect:Development:Perl::RCS:missing.c,v 1.2 1994/05/04 02:12:43 neeri Exp $
- *
- * Copyright (c) 1995 Matthias Neeracher
- *
- * You may distribute under the terms of the Perl Artistic License,
- * as specified in the README file.
- *
- * $Log: missing.c,v $
- */
-
- #include "EXTERN.h"
- #include "perl.h"
- #include "XSUB.h"
- #include <ICAPI.h>
-
- typedef ICInstance InternetConfig;
-
- /* This prevents nested InternetConfig iterators. So what */
-
- static int ICIter = 0;
-
- XS(XS_InternetConfig_IC_TIEHASH)
- {
- dXSARGS;
- if (items != 1) {
- croak("Usage: InternetConfig::TIEHASH(dbtype)");
- }
- {
- char * dbtype = (char *)SvPV(ST(0),na);
- {
- InternetConfig ic;
- ST(0) = sv_newmortal();
- if (!ICStart(&ic, 'McPL')) {
- sv_setref_pv(ST(0), "InternetConfig", (void*)ic);
- ICFindConfigFile(ic, 0, nil);
- }
- }
- }
- XSRETURN(1);
- }
-
- XS(XS_InternetConfig_IC_DESTROY)
- {
- dXSARGS;
- if (items != 1) {
- croak("Usage: InternetConfig::DESTROY(ic)");
- }
- {
- InternetConfig ic;
-
- if (SvROK(ST(0))) {
- IV tmp = SvIV((SV*)SvRV(ST(0)));
- ic = (InternetConfig) tmp;
- }
- else
- croak("ic is not a reference");
- ICStop(ic);
- }
- XSRETURN(1);
- }
-
- XS(XS_InternetConfig_IC_FETCH)
- {
- dXSARGS;
- if (items != 2) {
- croak("Usage: InternetConfig::FETCH(ic, key)");
- }
- {
- InternetConfig ic;
- Str255 key;
-
- if (sv_isa(ST(0), "InternetConfig")) {
- IV tmp = SvIV((SV*)SvRV(ST(0)));
- ic = (InternetConfig) tmp;
- }
- else
- croak("ic is not of type InternetConfig");
-
- CopyC2PStr(SvPVX(ST(1)), key);
- {
- ICAttr attr;
- long size;
-
- ST(0) = sv_newmortal();
- switch (ICGetPref(ic, key, &attr, nil, &size)) {
- case icTruncatedErr:
- case 0:
- ICGetPref(ic, key, &attr, sv_grow(ST(0), size + 1), &size);
- SvCUR(ST(0)) = size;
- *SvEND(ST(0)) = '\0';
- (void)SvPOK_only(ST(0)); /* validate pointer */
- break;
- }
- ICEnd(ic);
- }
- }
- XSRETURN(1);
- }
-
- XS(XS_InternetConfig_IC_STORE)
- {
- dXSARGS;
- if (items != 4) {
- croak("Usage: InternetConfig::STORE(ic, key, value, flags)");
- }
- {
- InternetConfig ic;
- Str255 key;
- char * value = (char *)SvPV(ST(2),na);
- int flags = (int)SvIV(ST(3));
-
- if (sv_isa(ST(0), "InternetConfig")) {
- IV tmp = SvIV((SV*)SvRV(ST(0)));
- ic = (InternetConfig) tmp;
- }
- else
- croak("ic is not of type InternetConfig");
-
- CopyC2PStr(SvPVX(ST(1)), key);
- {
- ICSetPref(ic, key, 0, SvPVX(ST(2)), SvCUR(ST(2)));
- ICEnd(ic);
- }
- }
- XSRETURN(1);
- }
-
- XS(XS_InternetConfig_IC_DELETE)
- {
- dXSARGS;
- if (items != 2) {
- croak("Usage: InternetConfig::DELETE(ic, key)");
- }
- {
- InternetConfig ic;
- Str255 key;
-
- if (sv_isa(ST(0), "InternetConfig")) {
- IV tmp = SvIV((SV*)SvRV(ST(0)));
- ic = (InternetConfig) tmp;
- }
- else
- croak("ic is not of type InternetConfig");
-
- CopyC2PStr(SvPVX(ST(1)), key);
- {
- ICBegin(ic, icReadWritePerm);
- ICDeletePref(ic, key);
- ICEnd(ic);
- }
- }
- XSRETURN(1);
- }
-
- XS(XS_InternetConfig_IC_FIRSTKEY)
- {
- dXSARGS;
- if (items != 1) {
- croak("Usage: InternetConfig::FIRSTKEY(ic)");
- }
- {
- InternetConfig ic;
-
- if (sv_isa(ST(0), "InternetConfig")) {
- IV tmp = SvIV((SV*)SvRV(ST(0)));
- ic = (InternetConfig) tmp;
- }
- else
- croak("ic is not of type InternetConfig");
- {
- Str255 key;
-
- ICBegin(ic, icReadOnlyPerm);
- ST(0) = sv_newmortal();
- if (!ICGetIndPref(ic, ICIter = 1, key))
- sv_setpvn(ST(0), ((char *) key) + 1, key[0]);
- ICEnd(ic);
- }
- }
- XSRETURN(1);
- }
-
- XS(XS_InternetConfig_IC_NEXTKEY)
- {
- dXSARGS;
- if (items != 2) {
- croak("Usage: InternetConfig::NEXTKEY(ic, key)");
- }
- {
- InternetConfig ic;
- Str255 key;
- char * RETVAL;
-
- if (sv_isa(ST(0), "InternetConfig")) {
- IV tmp = SvIV((SV*)SvRV(ST(0)));
- ic = (InternetConfig) tmp;
- }
- else
- croak("ic is not of type InternetConfig");
-
- CopyC2PStr(SvPVX(ST(1)), key);
- {
- ST(0) = sv_newmortal();
- ICBegin(ic, icReadOnlyPerm);
- if (!ICGetIndPref(ic, ++ICIter, key))
- sv_setpvn(ST(0), ((char *) key) + 1, key[0]);
- ICEnd(ic);
- }
- }
- XSRETURN(1);
- }
-
- XS(boot_InternetConfig)
- {
- dXSARGS;
- char* file = __FILE__;
-
- newXS("InternetConfig::TIEHASH", XS_InternetConfig_IC_TIEHASH, file);
- newXS("InternetConfig::DESTROY", XS_InternetConfig_IC_DESTROY, file);
- newXS("InternetConfig::FETCH", XS_InternetConfig_IC_FETCH, file);
- newXS("InternetConfig::STORE", XS_InternetConfig_IC_STORE, file);
- newXS("InternetConfig::DELETE", XS_InternetConfig_IC_DELETE, file);
- newXS("InternetConfig::FIRSTKEY", XS_InternetConfig_IC_FIRSTKEY, file);
- newXS("InternetConfig::NEXTKEY", XS_InternetConfig_IC_NEXTKEY, file);
- ST(0) = &sv_yes;
- XSRETURN(1);
- }
-