int w, h;
unsigned long idx;
gdImagePtr im = NULL;
- FILE *filePtr;
+ FILE *filePtr = NULL;
ClientData clientdata;
char *cmd, buf[50];
- int fileByName;
+ Tcl_Channel chan;
+ int fileByName, mode;
cmd = Tcl_GetString(objv[1]);
if (strcmp(cmd, "create") == 0) {
}
} else {
fileByName = 0; /* first try to get file from open channel */
- if (Tcl_GetOpenFile
- (interp, Tcl_GetString(objv[2]), 0, 1,
- &clientdata) == TCL_OK) {
- filePtr = (FILE *) clientdata;
+ if ((chan = Tcl_GetChannel(interp,Tcl_GetString(objv[2]),&mode)) != NULL) {
+ if (!strncmp(Tcl_ChannelName(Tcl_GetChannelType(chan)),"file",4)) {
+ Tcl_AppendResult(interp, "Bad channel: \"", Tcl_GetString(objv[2]),
+ "\". Not a file.", (char *)NULL);
+ return TCL_ERROR;
+ }
+ if (Tcl_GetChannelHandle(chan,TCL_READABLE, &clientdata) == TCL_OK) {
+ filePtr = (FILE *) clientdata;
+ }
} else {
- /* Not a channel, or Tcl_GetOpenFile() not supported.
- * See if we can open directly.
- */
+ /* Not a channel. See if we can open directly. */
fileByName++;
if ((filePtr = fopen(Tcl_GetString(objv[2]), "rb")) == NULL) {
return TCL_ERROR;
FILE *filePtr;
ClientData clientdata;
char *cmd;
- int fileByName;
+ Tcl_Channel chan;
+ int fileByName, mode;
cmd = Tcl_GetString(objv[1]);
/* Get the image pointer. */
/* Get the file reference. */
fileByName = 0; /* first try to get file from open channel */
- if (Tcl_GetOpenFile(interp, Tcl_GetString(objv[3]), 1, 1, &clientdata)
- == TCL_OK) {
- filePtr = (FILE *) clientdata;
+ if ((chan = Tcl_GetChannel(interp,Tcl_GetString(objv[2]),&mode)) != NULL) {
+ if (!strncmp(Tcl_ChannelName(Tcl_GetChannelType(chan)),"file",4)) {
+ Tcl_AppendResult(interp, "Bad channel: \"", Tcl_GetString(objv[2]),
+ "\". Not a file.", (char *)NULL);
+ return TCL_ERROR;
+ }
+ if (!(mode & TCL_WRITABLE)) {
+ Tcl_AppendResult(interp, "Bad channel: \"", Tcl_GetString(objv[2]),
+ "\". Not writeable.", (char *)NULL);
+ return TCL_ERROR;
+ }
+ if (Tcl_GetChannelHandle(chan,TCL_WRITABLE, &clientdata) == TCL_OK) {
+ filePtr = (FILE *) clientdata;
+ } else {
+ return TCL_ERROR;
+ }
} else {
/* Not a channel, or Tcl_GetOpenFile() not supported.
* See if we can open directly.
int Gdtclft_Init(Tcl_Interp * interp)
#else
#ifdef __WIN32__
-EXPORT(int, Gdtclft_Init) (interp)
+__declspec(dllexport) int Gdtclft_Init(Tcl_Interp *interp)
+/*
+EXPORT(Gdtclft_Init) (interp)
+*/
#else
int Gdtclft_Init(Tcl_Interp * interp)
#endif
int Gdtclft_SafeInit(Tcl_Interp * interp)
#else
#ifdef __WIN32__
+__declspec(dllexport) int Gdtclft_Init(Tcl_Interp *interp)
+/*
EXPORT(int, Gdtclft_SafeInit) (interp)
+*/
#else
int Gdtclft_SafeInit(Tcl_Interp * interp)
#endif
Agedge_t **ep, *e;
Agsym_t *a;
char c, buf[256], **argv2;
- int i, j, length, argc2, rc;
+ int i, j, length, argc2, rc, chanmode;
+ Tcl_Channel chan;
unsigned long id;
GVC_t *gvc = (GVC_t *) clientData;
gvc->job->output_lang =
gvrender_select(gvc->job, gvc->job->output_langname);
+ /* NEW CODE: Use new Tcl_Channel based API */
+ chanmode = 0;
+ chan = Tcl_GetChannel(interp,argv[2],&chanmode);
+ if (chan == NULL) {
+ Tcl_AppendResult(interp, "Bad channel: \"", argv[2],
+ "\"", (char *)NULL);
+ return TCL_ERROR;
+ }
+ if (!(chanmode & TCL_WRITABLE)) {
+ Tcl_AppendResult(interp, "Bad channel: \"", argv[2],
+ "\". Not writeable.", (char *)NULL);
+ return TCL_ERROR;
+ }
+ if (!strncmp(Tcl_ChannelName(Tcl_GetChannelType(chan)),"file",4)) {
+ Tcl_AppendResult(interp, "Bad channel: \"", argv[2],
+ "\". Not a file.", (char *)NULL);
+ return TCL_ERROR;
+ }
+ if (Tcl_GetChannelHandle(chan,TCL_WRITABLE,
+ (ClientData*) &(gvc->job->output_file)) != TCL_OK)
+ return TCL_ERROR;
+
+ /* OLD UNIX only code
if (Tcl_GetOpenFile (interp, argv[2], 1, 1,
(ClientData *) &(gvc->job->output_file)) != TCL_OK)
return TCL_ERROR;
+ */
/* make sure that layout is done - unless canonical output */
if ((!GD_drawing(g) || argc > 4)
#if defined(_BLD_tcldot) && defined(_DLL)
__EXPORT__
#endif
+#ifdef __WIN32__
+__declspec(dllexport) int Tcldot_Init(Tcl_Interp * interp)
+#else
int Tcldot_Init(Tcl_Interp * interp)
+#endif
{
GVC_t *gvc;
#ifndef DISABLE_CODEGENS
return TCL_OK;
}
+#ifdef __WIN32__
+__declspec(dllexport) int Tcldot_SafeInit(Tcl_Interp * interp)
+#else
int Tcldot_SafeInit(Tcl_Interp * interp)
+#endif
{
return Tcldot_Init(interp);
}