home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
-
- #include <Types.h>
- #include <Files.h>
- #include <Folders.h>
- #include <Components.h>
-
- #ifndef THINK_C
- #include <Strings.h>
- #endif
-
- #include "IC Types.h"
- #include "IC API.h"
- #include "IC Keys.h"
- #include "IC Component API.h"
- #include "IC Component Selectors.h"
- #include "IC Component Utils.h"
-
- void DumpPrefs(void);
-
- ICInstance inst;
-
- int main(void);
- int main(void){
- ICError err;
- ICDirSpecArray folder_spec;
- Str255 email_address;
- long attr;
- long size;
- long seed;
- short vref;
- long dirid;
- ComponentInstance ci;
-
- printf("Internet Config: C Example\n\n");
-
- // ICDisableComponent();
- ICDisableLinkedCode();
-
- err = ICStart(&inst, 'CREA'); /* tell it your application creator */
- printf("ICStart: %ld\n", err);
-
- printf("ICUsingComponent: %s\n",ICUsingComponent(inst)?"true":"false");
-
- if (ICUsingComponent(inst)){
- long ver;
- err=ICGetComponentInstance(inst,(Ptr*)&ci);
-
- if (err==noErr){
- ver=GetComponentVersion(ci);
- printf("Vers is %ld (%lx)\n",ver,ver);
- } else
- printf("Get inst error %ld\n",err);
- }
-
- FindFolder(kOnSystemDisk,kPreferencesFolderType,kCreateFolder,&vref,&dirid);
-
- folder_spec[0].vRefNum = vref; /* search for prefs in root of the system */
- folder_spec[0].dirID = dirid; /* volume, obviously you'd use other things */
- err = ICFindConfigFile(inst, 1, (ICDirSpecArrayPtr) &folder_spec);
- printf("ICFindConfigFile: %ld\n", err);
-
- err = ICBegin(inst, icReadWritePerm);
- printf("ICBegin: %ld %#lx\n", err,err);
- size = sizeof(email_address);
- err = ICGetPref(inst, "\pEmail", &attr, (Ptr) email_address, &size);
- printf("ICGetPref: %ld\n", err);
-
- p2cstr(email_address);
- printf("Your Email address is %s\n", email_address);
- DumpPrefs();
- err = ICEnd(inst);
- printf("ICEnd: %ld\n", err);
-
- err = ICGetSeed(inst, &seed);
- printf("ICGetSeed: %ld = %ld\n", err, seed);
- /* now monitor this seed to see if any preferences have changed */
-
- err = ICStop(inst);
- printf("ICStop: %ld\n", err);
-
- fflush(stdout);
-
- return 0;
- }
-
- void DumpPrefs()
- {
- ICError err;
- long count;
- long i;
- Str255 key;
-
- err = ICCountPref(inst, &count);
- printf("ICCountPref: %ld\n", err);
- for (i = 1; i <= count; i++) {
- err = ICGetIndPref(inst, i, key);
- p2cstr(key);
- printf(" ICGetIndPref: %ld - %s\n", err, &key);
- };
- }
-