Re(2): MoreSCF
Re(2): MoreSCF
- Subject: Re(2): MoreSCF
- From: Jens Bauer <email@hidden>
- Date: Fri, 24 May 2002 19:05:54 +0200
Hi Quinn and Morgan,
On Fri, 24 May, 2002, Quinn <email@hidden> wrote:
>
At 14:02 -0700 23/5/02, Morgan Redman wrote:
>
>If you use MoreSCMakeNewDialupSet and pass a userVisibleName that is
>
>already in use, what happens?
>
>
>
>Does it return in error, or replace with the new configuration?
>
>
Neither. It creates another configuration with the same user visible
>
name. User visible names are not required to be unique for SCF to
>
work, although you're going to confuse the user if you create two
>
sets with same name. To avoid that you can use
>
MoreSCFindSetByUserVisibleNameAndCopyID to check if the name already
>
exists.
I modified one of your routines, to check if the name already exists.
Please note: This source may be outdated, for best results, you should
have a look at TestSetEnumerationAndSwitch from the current MoreSCF.
/* A modified copy of Quinn's TestSetEnumerationAndSwitch from
MoreSCFTest.c */
/* userVisibleName : the name of the set to search for
* foundSetID : the found setID (remember to CFRelease this)
* result : standard MacOS error code
*/
OSStatus MoreSCFSetFind(CFStringRef userVisibleName, CFStringRef *foundSetID)
{
OSStatus err;
ItemCount setCount;
ItemCount setIndex;
CFArrayRef setIDs;
ItemCount indexOfCurrentSet;
#ifdef _JB_DEBUG
fprintf(stderr, "MoreSCFSetFind\n");
#endif
setIDs = nil;
*foundSetID = nil;
// Enumeration
err = MoreSCCopySetIDs(&setIDs, &indexOfCurrentSet);
if (err == noErr) {
setCount = CFArrayGetCount(setIDs);
for (setIndex = 0; setIndex < setCount; setIndex++) {
CFStringRef userVis;
userVis = nil;
err = MoreSCCopyUserVisibleNameOfSet(CFArrayGetValueAtIndex(setIDs,
setIndex), &userVis);
if (err == noErr) {
if(CFEqual(userVis, userVisibleName))
{
*foundSetID = CFStringCreateCopy(nil, CFArrayGetValueAtIndex(setIDs,
setIndex));
break;
}
}
CFQRelease(userVis);
if (err != noErr) {
break;
}
}
}
CFQRelease(setIDs);
if (err != noErr) {
#ifdef _JB_DEBUG
fprintf(stderr, "777 Failed with error %ld!\n", err);
#endif
}
return(err);
}
If it works, give credit to Quinn. If there are any problems, blame me. :)
Love,
Jens
--
Jens Bauer, Faster Software.
-Let's make the World better, shall we ?
_______________________________________________
macnetworkprog mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/macnetworkprog
Do not post admin requests to the list. They will be ignored.