aboutsummaryrefslogtreecommitdiff
path: root/www/tclhttpd/files/patch-src__limit.c
blob: 5f8e65a3899f5dc79dec3905f83421533137b21b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
--- src/limit.c	Thu May  1 19:42:14 2003
+++ src/limit.c	Fri Nov 19 13:21:15 2004
@@ -9,6 +9,5 @@
 
 
-static int  LimitCmd _ANSI_ARGS_((ClientData clientData,
-            Tcl_Interp *interp, int argc, char *argv[]));
+Tcl_ObjCmdProc  LimitCmd;
 
 #undef TCL_STORAGE_CLASS
@@ -29,9 +28,8 @@
  */
 int
-LimitCmd(ClientData data, Tcl_Interp *interp, int argc, char *argv[])
+LimitCmd(ClientData data, Tcl_Interp *interp, int argc, Tcl_Obj *CONST objv[])
 {
-    int max;
-    char buf[32];
     struct rlimit limit;
+    Tcl_Obj *limObj[2];
     Tcl_ResetResult(interp);
     if (getrlimit(RLIMIT_NOFILE, &limit) < 0) {
@@ -40,12 +38,18 @@
     }
     if (argc > 1) {
-    Tcl_GetInt(interp, argv[1], (int *)&limit.rlim_cur);
+        long	rlim_cur;
+
+        if (Tcl_GetLongFromObj(interp, objv[1], &rlim_cur) != TCL_OK)
+            return TCL_ERROR;
+        limit.rlim_cur = rlim_cur;
         if (setrlimit(RLIMIT_NOFILE, &limit) < 0) {
-        Tcl_AppendResult(interp, "NOFILE: ", Tcl_PosixError(interp), NULL);
-        return TCL_ERROR;
-    }
+            Tcl_AppendResult(interp, "NOFILE: ", Tcl_PosixError(interp), NULL);
+            return TCL_ERROR;
+        }
     }
     /* bad, bad style, direct writing to interp->result */
-    sprintf(interp->result, "%d %d", limit.rlim_cur, limit.rlim_max);
+    limObj[0] = Tcl_NewLongObj((long)limit.rlim_cur);
+    limObj[1] = Tcl_NewLongObj((long)limit.rlim_max);
+    Tcl_SetObjResult(interp, Tcl_NewListObj(2, limObj));
     return TCL_OK;
 }
@@ -71,5 +75,5 @@
     #endif
 
-    Tcl_CreateCommand(interp, "limit", LimitCmd, NULL, NULL);
+    Tcl_CreateObjCommand(interp, "limit", LimitCmd, NULL, NULL);
     code = Tcl_PkgProvide(interp, "limit", "1.0");
     if (code != TCL_OK) {