[Tcladdressbook-commits] Source TclAddressBook.c,1.19,1.20
Status: Alpha
Brought to you by:
bdesgraupes
|
From: <bde...@us...> - 2003-12-14 10:53:18
|
Update of /cvsroot/tcladdressbook/Source
In directory sc8-pr-cvs1:/tmp/cvs-serv12518/Source
Modified Files:
TclAddressBook.c
Log Message:
[getme] and [record] return keyed lists
Index: TclAddressBook.c
===================================================================
RCS file: /cvsroot/tcladdressbook/Source/TclAddressBook.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- TclAddressBook.c 11 Dec 2003 10:35:13 -0000 1.19
+++ TclAddressBook.c 13 Dec 2003 17:26:13 -0000 1.20
@@ -614,7 +614,7 @@
* See the user documentation for details on what it does.
*
* Syntax:
- * addressbook getme arrayvar
+ * addressbook getme varname
*
* Results:
* A standard Tcl result.
@@ -631,23 +631,27 @@
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *CONST objv[], /* Argument values. */
- Tcl_Obj *resultPtr) /* Pointer to store the result. */
+ Tcl_Obj *resultPtr) /* Pointer to store the result. */
{
ABAddressBookRef ab;
CONST84 char * var;
int length;
if (objc != 3) {
- Tcl_WrongNumArgs(interp, 2, objv, "arrayvar");
+ Tcl_WrongNumArgs(interp, 2, objv, "varname");
return TCL_ERROR;
}
var = Tcl_GetStringFromObj(objv[2], &length);
-
+ if (!var || !strlen(var)) {
+ Tcl_AppendStringsToObj(resultPtr, "Varname cannot be empty", (char *) NULL);
+ return TCL_ERROR;
+ }
+
// Get the address book
ab = ABGetSharedAddressBook();
- // Store the record's data in the array variable "var"
+ // Store the record's data in the variable "var"
TclAB_GetAllValues(interp, ab, ABGetMe(ab), var, rec_person);
Tcl_ResetResult(interp);
@@ -1100,7 +1104,7 @@
* See the user documentation for details on what it does.
*
* Syntax:
- * addressbook record recordID arrayvar
+ * addressbook record recordID varname
*
* Results:
* A standard Tcl result.
@@ -1127,13 +1131,17 @@
int kind, length, result;
if (objc != 4) {
- Tcl_WrongNumArgs(interp, 2, objv, "recordID arrayvar");
+ Tcl_WrongNumArgs(interp, 2, objv, "recordID varname");
return TCL_ERROR;
}
var = Tcl_GetStringFromObj(objv[3], &length);
+ if (!var || !strlen(var)) {
+ Tcl_AppendStringsToObj(resultPtr, "Varname cannot be empty", (char *) NULL);
+ return TCL_ERROR;
+ }
+
theUID = Tcl_GetStringFromObj(objv[2], &length);
-
uidRef = CFStringCreateWithCString(NULL, theUID, GetApplicationTextEncoding());
// Get the address book
ab = ABGetSharedAddressBook();
@@ -1151,7 +1159,7 @@
return TCL_ERROR;
}
- // Store the record's data in the array variable "var"
+ // Store the record's data in the variable "var"
TclAB_GetAllValues(interp, ab, theRecord, var, kind);
CFRelease(theRecord);
@@ -1573,7 +1581,7 @@
CFRelease(propertyRef);
return TCL_ERROR;
}
- TclAB_GetValue(interp, ab, propertyRef, valueRef, NULL, kind);
+ TclAB_GetValue(interp, ab, propertyRef, valueRef, 0, kind);
CFRelease(valueRef);
}
CFRelease(propertyRef);
|