home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-03-08 | 2.1 KB | 115 lines | [TEXT/MPS ] |
- /* $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;
-
- MODULE = InternetConfig PACKAGE = InternetConfig PREFIX = IC_
-
- void
- IC_TIEHASH(dbtype)
- char * dbtype
- CODE:
- {
- InternetConfig ic;
- ST(0) = sv_newmortal();
- if (!ICStart(&ic, 'McPL')) {
- sv_setref_pv(ST(0), "InternetConfig", (void*)ic);
- ICFindConfigFile(ic, 0, nil);
- }
- }
-
-
- void
- IC_DESTROY(ic)
- InternetConfig ic
- CODE:
- ICStop(ic);
-
- void
- IC_FETCH(ic, key)
- InternetConfig ic
- Str255 key
- CODE:
- {
- 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);
- }
-
- void
- IC_STORE(ic, key, value, flags)
- InternetConfig ic
- Str255 key
- char * value
- int flags
- CODE:
- {
- ICSetPref(ic, key, 0, SvPVX(ST(2)), SvCUR(ST(2)));
- ICEnd(ic);
- }
-
- void
- IC_DELETE(ic, key)
- InternetConfig ic
- Str255 key
- CODE:
- {
- ICBegin(ic, icReadWritePerm);
- ICDeletePref(ic, key);
- ICEnd(ic);
- }
-
- void
- IC_FIRSTKEY(ic)
- InternetConfig ic
- CODE:
- {
- 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);
- }
-
- char *
- IC_NEXTKEY(ic, key)
- InternetConfig ic
- Str255 key
- CODE:
- {
- ST(0) = sv_newmortal();
- ICBegin(ic, icReadOnlyPerm);
- if (!ICGetIndPref(ic, ++ICIter, key))
- sv_setpvn(ST(0), ((char *) key) + 1, key[0]);
- ICEnd(ic);
- }
-