home *** CD-ROM | disk | FTP | other *** search
/ CLIX - Fazer Clix Custa Nix / CLIX-CD.cdr / mac / lib / Mac / InternetConfig.xs < prev    next >
Text File  |  1998-04-05  |  21KB  |  805 lines

  1. /* $Header: /home/neeri/MacCVS/MacPerl/perl/ext/Mac/InternetConfig/InternetConfig.xs,v 1.2 1997/11/18 00:52:27 neeri Exp $
  2.  *
  3.  *    Copyright (c) 1995 Matthias Neeracher
  4.  *
  5.  *    You may distribute under the terms of the Perl Artistic License,
  6.  *    as specified in the README file.
  7.  *
  8.  * $Log: InternetConfig.xs,v $
  9.  * Revision 1.2  1997/11/18 00:52:27  neeri
  10.  * MacPerl 5.1.5
  11.  *
  12.  * Revision 1.1  1997/04/07 20:49:49  neeri
  13.  * Synchronized with MacPerl 5.1.4a1
  14.  *
  15.  */
  16.  
  17. #define MAC_CONTEXT
  18.  
  19. #include "EXTERN.h"
  20. #include "perl.h"
  21. #include "XSUB.h"
  22.  
  23. #undef pad
  24.  
  25. #include <ICAPI.h>
  26. #include <TFileSpec.h>
  27. #include <Components.h>
  28.  
  29. static SV * MakeHndSV(Handle hdl)
  30. {
  31.     SV * res;
  32.     char state;
  33.     
  34.     state = HGetState(hdl);
  35.     HLock(hdl);
  36.     res = GetHandleSize(hdl) ? newSVpv(*hdl, GetHandleSize(hdl)) : newSVpv("", 0);
  37.     HSetState(hdl, state);
  38.     
  39.     return res;
  40. }
  41.  
  42. #define PLstrcmp(s1, s2) memcmp((void *)s1, (void *)s2, s1[0]+1)
  43. #define PLstrcpy(s1, s2) memcpy((void *)s1, (void *)s2, s1[0]+1)
  44.  
  45. static Boolean EqualMapEntries(ICMapEntry * e1, ICMapEntry *e2)
  46. {
  47.     return e1->file_type    == e2->file_type
  48.         && e1->file_creator == e2->file_creator
  49.         && e1->post_creator == e2->post_creator
  50.         && !PLstrcmp(e1->extension, e2->extension)
  51.         && !PLstrcmp(e1->creator_app_name, e2->creator_app_name)
  52.         && !PLstrcmp(e1->post_app_name, e2->post_app_name)
  53.         && !PLstrcmp(e1->MIME_type, e2->MIME_type)
  54.         && !PLstrcmp(e1->entry_name, e2->entry_name);
  55. }
  56.  
  57. MODULE = Mac::InternetConfig  PACKAGE = Mac::InternetConfig
  58.  
  59. =head2 Types
  60.  
  61. =over 4
  62.  
  63. =item ICMapEntry
  64.  
  65. An entry in the file map. Fields are:
  66.  
  67.     short   version;
  68.     OSType  file_type;
  69.     OSType  file_creator;
  70.     OSType  post_creator;
  71.     long    flags;
  72.     Str255  extension;
  73.     Str255  creator_app_name;
  74.     Str255  post_app_name;
  75.     Str255  MIME_type;
  76.     Str255  entry_name;
  77.  
  78. =cut
  79. STRUCT ICMapEntry
  80.     short   version;
  81.     OSType  file_type;
  82.     OSType  file_creator;
  83.     OSType  post_creator;
  84.     long    flags;
  85.     Str255  extension;
  86.     Str255  creator_app_name;
  87.     Str255  post_app_name;
  88.     Str255  MIME_type;
  89.     Str255  entry_name;
  90.  
  91. MODULE = ICMapEntry  PACKAGE = ICMapEntry
  92.  
  93. ICMapEntry
  94. new(file_type, file_creator, post_creator, flags, extension, creator_app_name, post_app_name, MIME_type, entry_name)
  95.     OSType  file_type
  96.     OSType  file_creator
  97.     OSType  post_creator
  98.     long    flags
  99.     Str255  extension
  100.     Str255  creator_app_name
  101.     Str255  post_app_name
  102.     Str255  MIME_type
  103.     Str255  entry_name
  104.     CODE:
  105.     RETVAL.version      = 0;
  106.     RETVAL.file_type    = file_type;
  107.     RETVAL.file_creator = file_creator;
  108.     RETVAL.post_creator = post_creator;
  109.     RETVAL.flags        = flags;
  110.     PLstrcpy(RETVAL.extension, extension);
  111.     PLstrcpy(RETVAL.creator_app_name, creator_app_name);
  112.     PLstrcpy(RETVAL.post_app_name, post_app_name);
  113.     PLstrcpy(RETVAL.MIME_type, MIME_type);
  114.     PLstrcpy(RETVAL.entry_name, entry_name);
  115.     OUTPUT:
  116.     RETVAL
  117.  
  118. =back
  119.  
  120. =head2 Functions
  121.  
  122. =over 4
  123.  
  124. =item ICStart 
  125.  
  126. =item ICStart CREATOR
  127.  
  128. Call this at application initialisation. Set creator to your application creator to 
  129. allow for future expansion of the IC system (Default is MacPerl's creator). Returns 
  130. a connection to the IC system.
  131.  
  132. =cut
  133. MODULE = Mac::InternetConfig   PACKAGE = Mac::InternetConfig
  134.  
  135. ICInstance
  136. ICStart(creator='McPL')
  137.     OSType  creator;
  138.     CODE:
  139.     if (gLastMacOSErr = ICStart(&RETVAL, creator)) {
  140.         XSRETURN_UNDEF;
  141.     }
  142.     OUTPUT:
  143.     RETVAL
  144.     
  145. =item ICStop INST
  146.  
  147. It is illegal to call this routine inside a ICBegin/End pair.
  148. Call this at application termination, after which INST
  149. is no longer valid connection to IC.
  150.  
  151. =cut
  152.  
  153. MacOSRet
  154. ICStop(inst)
  155.     ICInstance  inst;
  156.  
  157. =item ICGeneralFindConfigFile INST, SEARCH_PREFS, CAN_CREATE, @FOLDERS
  158.  
  159. =item ICGeneralFindConfigFile INST, SEARCH_PREFS, CAN_CREATE
  160.  
  161. =item ICGeneralFindConfigFile INST
  162.  
  163. It is illegal to call this routine inside a ICBegin/End pair.
  164. Call to configure this connection to IC.
  165. This routine acts as a more general replacement for
  166. ICFindConfigFile and ICFindUserConfigFile.
  167. Set search_prefs to 1 (default) if you want it to search the preferences folder.
  168. Set can_create to 1 if you want it to be able to create a new config.
  169. Set count as the number of valid elements in folders.
  170. Set folders to a pointer to the folders to search.
  171. Setting count to 0 and folders to nil is OK.
  172. Searches the specified folders and then optionally the Preferences folder
  173. in a unspecified manner.
  174.  
  175. =cut
  176.  
  177. MacOSRet
  178. ICGeneralFindConfigFile(inst, search_prefs=1, can_create=0, ...)
  179.     ICInstance  inst;
  180.     Boolean     search_prefs;
  181.     Boolean     can_create;
  182.     PREINIT:
  183.     int         i;
  184.     short       count;
  185.     FSSpec      spec;
  186.     ICDirSpec   spex[8];
  187.     CODE:
  188.     count = 0;
  189.     for (i=3; i<items; ++i)
  190.         if (!Path2FSSpec((char *) SvPV(ST(i),na), &spec) && !FSpDown(&spec, "\p")) {
  191.             spex[count].vRefNum = spec.vRefNum;
  192.             spex[count].dirID   = spec.parID;
  193.             ++count;
  194.         }
  195.     RETVAL = ICGeneralFindConfigFile(inst, search_prefs, can_create, count, (ICDirSpecArrayPtr) spex);
  196.     OUTPUT:
  197.     RETVAL
  198.  
  199. =item ICChooseConfig INST
  200.  
  201. Requires IC 1.2.
  202. It is illegal to call this routine inside a ICBegin/End pair.
  203. Requests the user to choose a configuration, typically using some
  204. sort of modal dialog. If the user cancels the dialog the configuration
  205. state will be unaffected.
  206.  
  207. =cut
  208.  
  209. MacOSRet
  210. ICChooseConfig(inst)
  211.     ICInstance  inst;
  212.  
  213. =item ICChooseNewConfig INST
  214.  
  215. Requires IC 1.2.
  216. It is illegal to call this routine inside a ICBegin/End pair.
  217. Requests the user to choose a new configuration, typically using some
  218. sort of modal dialog. If the user cancels the dialog the configuration
  219. state will be unaffected.
  220.  
  221. =cut
  222.  
  223. MacOSRet
  224. ICChooseNewConfig(inst)
  225.     ICInstance  inst;
  226.  
  227. =item ICGetConfigName INST, LONGNAME
  228.  
  229. =item ICGetConfigName INST
  230.  
  231. Requires IC 1.2.
  232. You must specify a configuration before calling this routine.
  233. Returns a string that describes the current configuration at a user
  234. level. Set longname to 1 if you want a long name, up to 255
  235. characters, or 0 (default) if you want a short name, typically about 32
  236. characters.
  237. The returned string is for user display only. If you rely on the
  238. exact format of it, you will conflict with any future IC
  239. implementation that doesn't use explicit preference files.
  240.  
  241. =cut
  242.  
  243. Str255
  244. ICGetConfigName(inst, longname=0)
  245.     ICInstance  inst;
  246.     Boolean     longname;
  247.     CODE:
  248.     if (gLastMacOSErr = ICGetConfigName(inst, longname, RETVAL)) {
  249.         XSRETURN_UNDEF;
  250.     }
  251.     OUTPUT:
  252.     RETVAL
  253.     
  254. =item ICGetConfigReference INST
  255.  
  256. Requires IC 1.2.
  257. You must specify a configuration before calling this routine.
  258. Returns a self-contained reference to the instance's current
  259. configuration.
  260.  
  261. =cut
  262.  
  263. Handle
  264. ICGetConfigReference(inst)
  265.     ICInstance  inst;
  266.     CODE:
  267.     if (!(RETVAL = NewHandle(0))) {
  268.         XSRETURN_UNDEF;
  269.     }
  270.     if (gLastMacOSErr = ICGetConfigReference(inst, (ICConfigRefHandle) RETVAL)) {
  271.         DisposeHandle(RETVAL);
  272.         XSRETURN_UNDEF;
  273.     }
  274.     OUTPUT:
  275.     RETVAL
  276.  
  277. =item ICSetConfigReference INST, REF, FLAGS
  278.  
  279. =item ICSetConfigReference INST, REF
  280.  
  281. Requires IC 1.2.
  282. It is illegal to call this routine inside a ICBegin/End pair.
  283. Reconfigures the instance using a configuration reference that was
  284. got using ICGetConfigReference reference. Set the
  285. icNoUserInteraction_bit in flags if you require that this routine
  286. not present a modal dialog. Other flag bits are reserved and should
  287. be set to zero.
  288.  
  289. =cut
  290.  
  291. MacOSRet
  292. ICSetConfigReference(inst, ref, flags=0)
  293.     ICInstance  inst; 
  294.     Handle      ref;
  295.     long        flags;
  296.     CODE:
  297.     RETVAL = ICSetConfigReference(inst, (ICConfigRefHandle) ref, flags);
  298.     OUTPUT:
  299.     RETVAL
  300.  
  301. =item ICGetSeed INST
  302.  
  303. You do not have to specify a configuration before calling this routine.
  304. You do not have to be inside an ICBegin/End pair to call this routine.
  305. Returns the current seed for the IC prefs database.
  306. This seed changes each time a non-volatile preference is changed.
  307. You can poll this to determine if any cached preferences change.
  308.  
  309. =cut
  310.  
  311. long
  312. ICGetSeed(inst)
  313.     ICInstance  inst;
  314.     CODE:
  315.     if (gLastMacOSErr = ICGetSeed(inst, &RETVAL)) {
  316.         XSRETURN_UNDEF;
  317.     }
  318.     OUTPUT:
  319.     RETVAL
  320.  
  321. =item ICGetComponentInstance INST
  322.  
  323. Requires IC 1.2.
  324. You do not have to specify a configuration before calling this routine.
  325. You do not have to be inside an ICBegin/End pair to call this routine.
  326. Returns the connection to the IC component.
  327.  
  328. =cut
  329.  
  330. ComponentInstance
  331. ICGetComponentInstance(inst)
  332.     ICInstance  inst;
  333.     CODE:
  334.     if (gLastMacOSErr = ICGetComponentInstance(inst, (Ptr *)&RETVAL)) {
  335.         XSRETURN_UNDEF;
  336.     }
  337.     OUTPUT:
  338.     RETVAL
  339.  
  340. =item ICBegin INST, PERM
  341.  
  342. You must specify a configuration before calling this routine. It is illegal to
  343. call this routine inside a ICBegin/End pair. Starting reading or writing
  344. multiple preferences. A call to this must be balanced by a call to ICEnd. Do
  345. not call WaitNextEvent between these calls. The perm specifies whether you
  346. intend to read or read/write. Only one writer is allowed per instance. Note
  347. that this may open resource files that are not closed until you call ICEnd. 
  348.  
  349. =cut
  350.  
  351. MacOSRet
  352. ICBegin(inst, perm)
  353.     ICInstance  inst;
  354.     ICPerm      perm;
  355.  
  356. =item ICGetPref INST, KEY
  357.  
  358. You must specify a configuration before calling this routine.
  359. If you are getting or setting multiple preferences, you should place
  360. these calls within an ICBegin/ICEnd pair.
  361. If you call this routine outside of such a pair, it implicitly
  362. calls ICBegin(inst, icReadOnlyPerm).
  363. Reads the preference specified by key from the IC database to the
  364. buffer pointed to by buf and size.
  365. key must not be the empty string.
  366. If called in a scalar context, return the preference. If called in a list
  367. context, additionally returns the attributes.
  368. Returns icPrefNotFound if there is no preference for the key.
  369.  
  370. =cut
  371.  
  372. void
  373. ICGetPref(inst, key)
  374.     ICInstance  inst;
  375.     Str255      key;
  376.     PREINIT:
  377.     ICAttr  attr;
  378.     Handle  pref;
  379.     PPCODE:
  380.     pref = NewHandle(0);
  381.     gLastMacOSErr = ICFindPrefHandle(inst, key, &attr, pref);
  382.     if (!gLastMacOSErr) 
  383.         if (GIMME != G_ARRAY) {
  384.             XPUSHs(sv_2mortal(MakeHndSV(pref)));
  385.         } else {
  386.             XPUSHs(sv_2mortal(MakeHndSV(pref)));
  387.             XPUSHs(sv_2mortal(newSViv(attr)));
  388.         }
  389.     DisposeHandle(pref);
  390.  
  391. =item ICSetPref INST, KEY, VALUE
  392. =item ICSetPref INST, KEY, VALUE, ATTR
  393.  
  394. You must specify a configuration before calling this routine.
  395. If you are getting or setting multiple preferences, you should place
  396. these calls within an ICBegin/ICEnd pair.
  397. If you call this routine outside of such a pair, it implicitly
  398. calls ICBegin(inst, icReadWritePerm).
  399. Sets the preference specified by KEY from the IC database to the
  400. VALUE. If attr is ICattr_no_change (the default) then the preference attributes 
  401. are not set. Otherwise the preference attributes are set to attr.
  402. Returns icPermErr if the previous ICBegin was passed icReadOnlyPerm.
  403. Returns icPermErr if current attr is locked, new attr is locked.
  404.  
  405. =cut 
  406.  
  407. MacOSRet
  408. ICSetPref(inst, key, value, attr=ICattr_no_change)
  409.     ICInstance  inst;
  410.     Str255      key;
  411.     SV *        value;
  412.     ICAttr      attr;
  413.     PREINIT:
  414.     STRLEN  len;
  415.     Ptr     ptr;
  416.     Handle  pref;
  417.     CODE:
  418.     ptr = SvPV(value, len);
  419.     RETVAL = PtrToHand(ptr, &pref, len);
  420.     if (!RETVAL) {
  421.         RETVAL = ICSetPrefHandle(inst, key, attr, pref);
  422.         DisposeHandle(pref);
  423.     }
  424.     OUTPUT:
  425.     RETVAL
  426.  
  427. =item ICCountPref INST
  428.  
  429. You must specify a configuration before calling this routine.
  430. You must be inside an ICBegin/End pair to call this routine.
  431. Counts the total number of preferences.
  432.  
  433. =cut
  434.  
  435. long
  436. ICCountPref(inst)
  437.     ICInstance  inst;
  438.     CODE:
  439.     if (gLastMacOSErr = ICCountPref(inst, &RETVAL)) {
  440.         XSRETURN_UNDEF;
  441.     }
  442.     OUTPUT:
  443.     RETVAL
  444.     
  445. =item ICGetIndPref  INST, N
  446.  
  447. You must specify a configuration before calling this routine.
  448. You must be inside an ICBegin/End pair to call this routine.
  449. Returns the key of the Nth preference.
  450. n must be positive.
  451. Returns icPrefNotFoundErr if n is greater than the total number of preferences.
  452.  
  453. =cut
  454.  
  455. Str255
  456. ICGetIndPref(inst, n)
  457.     ICInstance  inst;
  458.     long        n;
  459.     CODE:
  460.     if (gLastMacOSErr = ICGetIndPref(inst, n, RETVAL)) {
  461.         XSRETURN_UNDEF;
  462.     }
  463.     OUTPUT:
  464.     RETVAL
  465.  
  466. =item ICDeletePref INST, KEY
  467.  
  468. You must specify a configuration before calling this routine.
  469. You must be inside an ICBegin/End pair to call this routine.
  470. Deletes the preference specified by KEY.
  471. KEY must not be the empty string.
  472. Returns icPrefNotFound if the preference specified by key is not present.
  473.  
  474. =cut
  475.  
  476. MacOSRet
  477. ICDeletePref(inst, key)
  478.     ICInstance  inst;
  479.     Str255      key;
  480.  
  481. =item ICEnd INST
  482.  
  483. You must specify a configuration before calling this routine.
  484. You must be inside an ICBegin/End pair to call this routine.
  485. Terminates a preference session, as started by ICBegin.
  486. You must have called ICBegin before calling this routine.
  487.  
  488. =cut
  489.  
  490. MacOSRet
  491. ICEnd(inst)
  492.     ICInstance  inst;
  493.  
  494. =item ICEditPreferences INST, KEY
  495.  
  496. Requires IC 1.1.
  497. You must specify a configuration before calling this routine.
  498. You do not have to be inside an ICBegin/End pair to call this routine.
  499. Instructs IC to display the user interface associated with editing
  500. preferences and focusing on the preference specified by key.
  501. If key is the empty string then no preference should be focused upon.
  502. You must have specified a configuration before calling this routine.
  503. You do not need to call ICBegin before calling this routine.
  504. In the current implementation this launches the IC application
  505. (or brings it to the front) and displays the window containing
  506. the preference specified by key.
  507. It may have a radically different implementation in future
  508. IC systems.
  509.  
  510. =cut
  511.  
  512. MacOSRet
  513. ICEditPreferences(ic, key)
  514.     ICInstance  ic;
  515.     Str255          key;
  516.  
  517. =item ICParseURL INST, HINT, DATA, START, END
  518.  
  519. =item ICParseURL INST, HINT, DATA
  520.  
  521. Requires IC 1.1.
  522. You must specify a configuration before calling this routine.
  523. You do not have to be inside an ICBegin/End pair to call this routine.
  524. Parses a URL out of the specified text and returns it in a canonical form
  525. in a handle.
  526. HINT indicates the default scheme for URLs of the form "name@address".
  527. If HINT is the empty string then URLs of that form are not allowed.
  528. DATA contains the text.
  529. START and END should be passed in as the current selection of
  530. the text. This selection is given in the same manner as TextEdit,
  531. ie if START == END then there is no selection only an insertion
  532. point. Also START ≤ END and 0 ≤ START ≤ length(DATA) and 0 ≤ END ≤ length(DATA).
  533. If START and END are omitted, the whole of DATA is assumed.
  534. In a scalar context, returns URL. In an array context, returns URL, START, END.
  535.  
  536. =cut
  537.  
  538. void
  539. ICParseURL(ic, hint, sv, start=-1, end=-1)
  540.     ICInstance  ic;
  541.     Str255          hint;
  542.     SV *            sv;
  543.     long            start;
  544.     long            end;
  545.     PREINIT:
  546.     STRLEN  len;
  547.     Ptr     data;
  548.     Handle  url;
  549.     PPCODE:
  550.     url = NewHandle(0);
  551.     data = (Ptr) SvPV(sv, len);
  552.     if (start == -1) {
  553.         start = 0;
  554.         end   = len;
  555.     } else if (end == -1) 
  556.         end   = start;
  557.     gLastMacOSErr = ICParseURL(ic, hint, data, len, &start, &end, url);
  558.     if (!gLastMacOSErr) 
  559.         if (GIMME != G_ARRAY) {
  560.             XPUSHs(sv_2mortal(MakeHndSV(url)));
  561.         } else {
  562.             XPUSHs(sv_2mortal(MakeHndSV(url)));
  563.             XPUSHs(sv_2mortal(newSViv(start)));
  564.             XPUSHs(sv_2mortal(newSViv(end)));
  565.         }
  566.     DisposeHandle(url);
  567.  
  568. =item ICLaunchURL INST, HINT, DATA, START, END
  569.  
  570. =item ICLaunchURL INST, HINT, DATA
  571.  
  572. Requires IC 1.1.
  573. You must specify a configuration before calling this routine.
  574. You do not have to be inside an ICBegin/End pair to call this routine.
  575. Parses a URL out of the specified text and feeds it off to the appropriate helper.
  576. HINT indicates the default scheme for URLs of the form "name@address".
  577. If HINT is the empty string then URLs of that form are not allowed.
  578. DATA contains the text.
  579. START and END should be passed in as the current selection of
  580. the text. This selection is given in the same manner as TextEdit,
  581. ie if START == END then there is no selection only an insertion
  582. point. Also START ≤ END and 0 ≤ START ≤ length(DATA) and 0 ≤ END ≤ length(DATA).
  583. If START and END are omitted, the whole of DATA is assumed.
  584. In a scalar context, returns URL. In an array context, returns URL, START, END.
  585.  
  586. =cut
  587.  
  588. void
  589. ICLaunchURL(ic, hint, sv, start=-1, end=-1)
  590.     ICInstance      ic;
  591.     Str255          hint;
  592.     SV *            sv;
  593.     long            start;
  594.     long            end;
  595.     PREINIT:
  596.     STRLEN  len;
  597.     Ptr     data;
  598.     PPCODE:
  599.     data = (Ptr) SvPV(sv, len);
  600.     if (start == -1) {
  601.         start = 0;
  602.         end   = len;
  603.     } else if (end == -1) 
  604.         end   = start;
  605.     gLastMacOSErr = ICLaunchURL(ic, hint, data, len, &start, &end);
  606.     if (!gLastMacOSErr) 
  607.         if (GIMME != G_ARRAY) {
  608.             XPUSHs(sv_2mortal(newSViv(1)));
  609.         } else {
  610.             XPUSHs(sv_2mortal(newSViv(start)));
  611.             XPUSHs(sv_2mortal(newSViv(end)));
  612.         }
  613.  
  614. =item ICMapFileName INST, NAME
  615.  
  616. Returns the C<ICMapEntry> matching best the given name.
  617.  
  618. =cut
  619. ICMapEntry
  620. ICMapFilename(inst, filename)
  621.     ICInstance      inst    
  622.     Str255          filename
  623.     CODE:
  624.     if (gLastMacOSErr = ICMapFilename(inst, filename, &RETVAL)) {
  625.         XSRETURN_UNDEF;
  626.     }
  627.     OUTPUT:
  628.     RETVAL
  629.  
  630. =item ICMapTypeCreator INST, TYPE, CREATOR [, NAME]
  631.  
  632. Takes the type and creator (and optionally the name) of an outgoing
  633. file and returns the most appropriate C<ICMapEntry>.
  634.  
  635. =cut
  636. ICMapEntry
  637. ICMapTypeCreator(inst, fType, fCreator, filename=)
  638.     ICInstance  inst
  639.     OSType      fType
  640.     OSType      fCreator
  641.     Str255      filename
  642.     CODE:
  643.     if (items < 4)
  644.         filename[0] = 0;
  645.     if (gLastMacOSErr = ICMapTypeCreator(inst, fType, fCreator, filename, &RETVAL)) {
  646.         XSRETURN_UNDEF;
  647.     }
  648.     OUTPUT:
  649.     RETVAL
  650.  
  651. =item ICMapEntriesFileName INST, ENTRIES, NAME
  652.  
  653. Returns the C<ICMapEntry> matching best the given name.
  654.  
  655. =cut
  656. ICMapEntry
  657. ICMapEntriesFilename(inst, entries, filename)
  658.     ICInstance      inst    
  659.     Handle          entries
  660.     Str255          filename
  661.     CODE:
  662.     if (gLastMacOSErr = ICMapEntriesFilename(inst, entries, filename, &RETVAL)) {
  663.         XSRETURN_UNDEF;
  664.     }
  665.     OUTPUT:
  666.     RETVAL
  667.  
  668. =item ICMapEntriesTypeCreator INST, ENTRIES, TYPE, CREATOR [, NAME]
  669.  
  670. Takes the type and creator (and optionally the name) of an outgoing
  671. file and returns the most appropriate C<ICMapEntry>.
  672.  
  673. =cut
  674. ICMapEntry
  675. ICMapEntriesTypeCreator(inst, entries, fType, fCreator, filename=)
  676.     ICInstance  inst
  677.     Handle      entries
  678.     OSType      fType
  679.     OSType      fCreator
  680.     Str255      filename
  681.     CODE:
  682.     if (items < 5)
  683.         filename[0] = 0;
  684.     if (gLastMacOSErr = ICMapEntriesTypeCreator(inst, entries, fType, fCreator, filename, &RETVAL)) {
  685.         XSRETURN_UNDEF;
  686.     }
  687.     OUTPUT:
  688.     RETVAL
  689.  
  690. =item ICCountMapEntries INST, ENTRIES
  691.  
  692. Counts the number of entries in the map.
  693.  
  694. =cut
  695. long
  696. ICCountMapEntries(inst, entries)
  697.     ICInstance  inst
  698.     Handle      entries
  699.     CODE:
  700.     if (gLastMacOSErr = ICCountMapEntries(inst, entries, &RETVAL)) {
  701.         XSRETURN_UNDEF;
  702.     }
  703.     OUTPUT:
  704.     RETVAL
  705.  
  706. =item ICGetIndMapEntry INST, ENTRIES, INDEX
  707.  
  708. Returns the position of a map entry and the entry itself.
  709.  
  710.     $map = ICGetIndMapEntry $inst, $entries, 5;
  711.     ($pos, $map) = ICGetIndMapEntry $inst, $entries, 5;
  712.  
  713. =cut
  714. void
  715. ICGetIndMapEntry(inst, entries, ndx)
  716.     ICInstance  inst
  717.     Handle      entries
  718.     long        ndx
  719.     PPCODE:
  720.     {
  721.         long        pos;
  722.         ICMapEntry  entry;
  723.         
  724.         if (gLastMacOSErr = ICGetIndMapEntry(inst, entries, ndx, &pos, &entry)) {
  725.             XSRETURN_EMPTY;
  726.         }
  727.         XS_XPUSH(long, pos);
  728.         XS_XPUSH(ICMapEntry, entry);
  729.     }
  730.  
  731. =item ICGetMapEntry INST, ENTRIES, POS
  732.  
  733. Returns the entry located at position pos in the mappings database.
  734.  
  735. =cut
  736. ICMapEntry
  737. ICGetMapEntry(inst, entries, pos)
  738.     ICInstance  inst
  739.     Handle      entries
  740.     long        pos
  741.     CODE:
  742.     if (gLastMacOSErr = ICGetMapEntry(inst, entries, pos, &RETVAL)) {
  743.         XSRETURN_UNDEF;
  744.     }
  745.     OUTPUT:
  746.     RETVAL
  747.  
  748. =item ICSetMapEntry INST, ENTRIES, POS, ENTRY
  749.  
  750. Replace the entry at position pos
  751.  
  752. =cut
  753. MacOSRet
  754. ICSetMapEntry(inst, entries, pos, entry)
  755.     ICInstance  inst
  756.     Handle      entries
  757.     long        pos
  758.     ICMapEntry &entry
  759.  
  760. =item ICDeleteMapEntry INST, ENTRIES, POS
  761.  
  762. Delete the entry at position pos
  763.  
  764. =cut
  765. MacOSRet
  766. ICDeleteMapEntry(inst, entries, pos)
  767.     ICInstance  inst
  768.     Handle      entries
  769.     long        pos
  770.  
  771. =item ICAddMapEntry INST, ENTRIES, ENTRY
  772.  
  773. Add an entry to the database.
  774.  
  775. =cut
  776. MacOSRet
  777. ICAddMapEntry(inst, entries, entry)
  778.     ICInstance  inst
  779.     Handle      entries
  780.     ICMapEntry &entry
  781.  
  782. long
  783. _ICMapFind(inst, entries, entry)
  784.     ICInstance  inst
  785.     Handle      entries
  786.     ICMapEntry  entry
  787.     CODE:
  788.     {
  789.         long        ndx;
  790.         ICMapEntry  ent;
  791.         
  792.         for (ndx = 0; ICGetIndMapEntry(inst, entries, ndx++, &RETVAL, &ent); )
  793.             if (EqualMapEntries(&entry, &ent))
  794.                 goto found;
  795.         XSRETURN_UNDEF;
  796. found:
  797.         ;
  798.     }
  799.     OUTPUT:
  800.     RETVAL
  801.  
  802. =back
  803.  
  804. =cut
  805.