Changeset 5414
- Timestamp:
- 10/26/09 05:52:07 (4 years ago)
- Location:
- luci/trunk/libs/nixio/src
- Files:
-
- 12 modified
-
address.c (modified) (3 diffs)
-
binary.c (modified) (1 diff)
-
bind.c (modified) (1 diff)
-
bit.c (modified) (6 diffs)
-
file.c (modified) (4 diffs)
-
fs.c (modified) (4 diffs)
-
io.c (modified) (1 diff)
-
nixio.c (modified) (1 diff)
-
process.c (modified) (2 diffs)
-
sockopt.c (modified) (1 diff)
-
splice.c (modified) (2 diffs)
-
user.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
luci/trunk/libs/nixio/src/address.c
r5061 r5414 324 324 325 325 lua_pushstring(L, addr.host); 326 lua_push number(L, addr.port);326 lua_pushinteger(L, addr.port); 327 327 return 2; 328 328 } … … 343 343 344 344 lua_pushstring(L, addr.host); 345 lua_push number(L, addr.port);345 lua_pushinteger(L, addr.port); 346 346 return 2; 347 347 } … … 421 421 struct nixio__nds *stats = c->ifa_data; 422 422 423 lua_push number(L, stats->rx_packets);423 lua_pushinteger(L, stats->rx_packets); 424 424 lua_setfield(L, -2, "rx_packets"); 425 425 426 lua_push number(L, stats->tx_packets);426 lua_pushinteger(L, stats->tx_packets); 427 427 lua_setfield(L, -2, "tx_packets"); 428 428 429 lua_push number(L, stats->rx_bytes);429 lua_pushinteger(L, stats->rx_bytes); 430 430 lua_setfield(L, -2, "rx_bytes"); 431 431 432 lua_push number(L, stats->tx_bytes);432 lua_pushinteger(L, stats->tx_bytes); 433 433 lua_setfield(L, -2, "tx_bytes"); 434 434 435 lua_push number(L, stats->rx_errors);435 lua_pushinteger(L, stats->rx_errors); 436 436 lua_setfield(L, -2, "rx_errors"); 437 437 438 lua_push number(L, stats->tx_errors);438 lua_pushinteger(L, stats->tx_errors); 439 439 lua_setfield(L, -2, "tx_errors"); 440 440 441 lua_push number(L, stats->rx_dropped);441 lua_pushinteger(L, stats->rx_dropped); 442 442 lua_setfield(L, -2, "rx_dropped"); 443 443 444 lua_push number(L, stats->tx_dropped);444 lua_pushinteger(L, stats->tx_dropped); 445 445 lua_setfield(L, -2, "tx_dropped"); 446 446 447 lua_push number(L, stats->multicast);447 lua_pushinteger(L, stats->multicast); 448 448 lua_setfield(L, -2, "multicast"); 449 449 450 lua_push number(L, stats->collisions);450 lua_pushinteger(L, stats->collisions); 451 451 lua_setfield(L, -2, "collisions"); 452 452 } else { -
luci/trunk/libs/nixio/src/binary.c
r4756 r5414 98 98 size_t len; 99 99 const char *buffer = luaL_checklstring(L, 1, &len); 100 uint32_t value = luaL_opt number(L, 2, 0);100 uint32_t value = luaL_optinteger(L, 2, 0); 101 101 102 102 value = ~value; -
luci/trunk/libs/nixio/src/bind.c
r4437 r5414 262 262 if (!nixio__addr_parse(&addr, (struct sockaddr *)&saddr)) { 263 263 lua_pushstring(L, addr.host); 264 lua_push number(L, addr.port);264 lua_pushinteger(L, addr.port); 265 265 return 3; 266 266 } else { -
luci/trunk/libs/nixio/src/bit.c
r5064 r5414 22 22 23 23 /* 52 bit maximum precision */ 24 #define NIXIO_BIT_BMAX 5225 #define NIXIO_BIT_NMAX 0xffffffff fffff24 #define NIXIO_BIT_BMAX 32 25 #define NIXIO_BIT_NMAX 0xffffffff 26 26 27 27 #define NIXIO_BIT_XOP(BIT_XOP) \ 28 uint64_t oper = luaL_check number(L, 1); \28 uint64_t oper = luaL_checkinteger(L, 1); \ 29 29 const int args = lua_gettop(L); \ 30 30 \ 31 31 for (int i = 2; i <= args; i++) { \ 32 uint64_t oper2 = luaL_check number(L, i); \32 uint64_t oper2 = luaL_checkinteger(L, i); \ 33 33 oper BIT_XOP oper2; \ 34 34 } \ 35 35 \ 36 lua_push number(L, oper); \36 lua_pushinteger(L, oper); \ 37 37 return 1; \ 38 38 … … 55 55 56 56 static int nixio_bit_not(lua_State *L) { 57 lua_push number(L, (~((uint64_t)luaL_checknumber(L, 1))) & NIXIO_BIT_NMAX);57 lua_pushinteger(L, (~((uint64_t)luaL_checkinteger(L, 1))) & NIXIO_BIT_NMAX); 58 58 return 1; 59 59 } 60 60 61 61 static int nixio_bit_shl(lua_State *L) { 62 uint64_t oper = luaL_check number(L, 1);62 uint64_t oper = luaL_checkinteger(L, 1); 63 63 oper <<= luaL_checkinteger(L, 2); 64 64 if (oper > NIXIO_BIT_NMAX) { 65 65 return luaL_error(L, "arithmetic overflow"); 66 66 } else { 67 lua_push number(L, oper);67 lua_pushinteger(L, oper); 68 68 return 1; 69 69 } … … 71 71 72 72 static int nixio_bit_ashr(lua_State *L) { 73 int64_t oper = luaL_check number(L, 1);74 lua_push number(L, oper >> luaL_checkinteger(L, 2));73 int64_t oper = luaL_checkinteger(L, 1); 74 lua_pushinteger(L, oper >> luaL_checkinteger(L, 2)); 75 75 return 1; 76 76 } 77 77 78 78 static int nixio_bit_shr(lua_State *L) { 79 uint64_t oper = luaL_check number(L, 1);80 lua_push number(L, oper >> luaL_checkinteger(L, 2));79 uint64_t oper = luaL_checkinteger(L, 1); 80 lua_pushinteger(L, oper >> luaL_checkinteger(L, 2)); 81 81 return 1; 82 82 } … … 87 87 88 88 static int nixio_bit_check(lua_State *L) { 89 uint64_t oper = luaL_check number(L, 1);90 uint64_t oper2 = luaL_check number(L, 2);89 uint64_t oper = luaL_checkinteger(L, 1); 90 uint64_t oper2 = luaL_checkinteger(L, 2); 91 91 lua_pushboolean(L, (oper & oper2) == oper2); 92 92 return 1; … … 94 94 95 95 static int nixio_bit_cast(lua_State *L) { 96 lua_push number(L, ((uint64_t)luaL_checknumber(L, 1)) & NIXIO_BIT_NMAX);96 lua_pushinteger(L, ((uint64_t)luaL_checkinteger(L, 1)) & NIXIO_BIT_NMAX); 97 97 return 1; 98 98 } 99 99 100 100 static int nixio_bit_swap(lua_State *L) { 101 uint64_t op = luaL_check number(L, 1);101 uint64_t op = luaL_checkinteger(L, 1); 102 102 op = (op >> 24) | ((op >> 8) & 0xff00) | ((op & 0xff00) << 8) | (op << 24); 103 lua_push number(L, op);103 lua_pushinteger(L, op); 104 104 return 1; 105 105 } … … 127 127 lua_newtable(L); 128 128 luaL_register(L, NULL, R); 129 lua_push number(L, NIXIO_BIT_BMAX);129 lua_pushinteger(L, NIXIO_BIT_BMAX); 130 130 lua_setfield(L, -2, "bits"); 131 lua_push number(L, NIXIO_BIT_NMAX);131 lua_pushinteger(L, NIXIO_BIT_NMAX); 132 132 lua_setfield(L, -2, "max"); 133 133 lua_setfield(L, -2, "bit"); -
luci/trunk/libs/nixio/src/file.c
r5106 r5414 227 227 static int nixio_file_seek(lua_State *L) { 228 228 int fd = nixio__checkfd(L, 1); 229 off_t len = (off_t)luaL_check number(L, 2);229 off_t len = (off_t)luaL_checkinteger(L, 2); 230 230 int whence; 231 231 const char *whstr = luaL_optlstring(L, 3, "set", NULL); … … 243 243 return nixio__perror(L); 244 244 } else { 245 lua_push number(L, len);245 lua_pushinteger(L, len); 246 246 return 1; 247 247 } … … 254 254 return nixio__perror(L); 255 255 } else { 256 lua_push number(L, pos);256 lua_pushinteger(L, pos); 257 257 return 1; 258 258 } … … 292 292 int fd = nixio__checkfd(L, 1); 293 293 const char *flag = luaL_checkstring(L, 2); 294 off_t len = (off_t)luaL_opt number(L, 3, 0);294 off_t len = (off_t)luaL_optinteger(L, 3, 0); 295 295 int stat; 296 296 -
luci/trunk/libs/nixio/src/fs.c
r4887 r5414 84 84 return mode; 85 85 } 86 } else if (lua_is number(L, idx)) {86 } else if (lua_isinteger(L, idx)) { 87 87 int decmode = lua_tointeger(L, idx); 88 88 int s = (decmode % 10000) / 1000; … … 258 258 return nixio__pstatus(L, !utimes(path, NULL)); 259 259 } else { 260 double atime = luaL_check number(L, 2);261 double mtime = luaL_opt number(L, 3, atime);260 double atime = luaL_checkinteger(L, 2); 261 double mtime = luaL_optinteger(L, 3, atime); 262 262 struct timeval times[2]; 263 263 264 264 times[0].tv_sec = atime; 265 times[0].tv_usec = (long)((atime - (int64_t)atime) * 1000000);265 times[0].tv_usec = 0; 266 266 times[1].tv_sec = mtime; 267 times[1].tv_usec = (long)((mtime - (int64_t)mtime) * 1000000);267 times[1].tv_usec = 0; 268 268 269 269 return nixio__pstatus(L, !utimes(path, times)); … … 318 318 lua_setfield(L, -2, "rdev"); 319 319 320 lua_push number(L, buf->st_size);320 lua_pushinteger(L, buf->st_size); 321 321 lua_setfield(L, -2, "size"); 322 322 … … 470 470 lua_createtable(L, 0, 12); 471 471 472 lua_push number(L, buf->f_bavail);472 lua_pushinteger(L, buf->f_bavail); 473 473 lua_setfield(L, -2, "bavail"); 474 474 475 lua_push number(L, buf->f_bfree);475 lua_pushinteger(L, buf->f_bfree); 476 476 lua_setfield(L, -2, "bfree"); 477 477 478 lua_push number(L, buf->f_blocks);478 lua_pushinteger(L, buf->f_blocks); 479 479 lua_setfield(L, -2, "blocks"); 480 480 481 lua_push number(L, buf->f_bsize);481 lua_pushinteger(L, buf->f_bsize); 482 482 lua_setfield(L, -2, "bsize"); 483 483 484 lua_push number(L, buf->f_frsize);484 lua_pushinteger(L, buf->f_frsize); 485 485 lua_setfield(L, -2, "frsize"); 486 486 487 lua_push number(L, buf->f_favail);487 lua_pushinteger(L, buf->f_favail); 488 488 lua_setfield(L, -2, "favail"); 489 489 490 lua_push number(L, buf->f_ffree);490 lua_pushinteger(L, buf->f_ffree); 491 491 lua_setfield(L, -2, "ffree"); 492 492 493 lua_push number(L, buf->f_files);493 lua_pushinteger(L, buf->f_files); 494 494 lua_setfield(L, -2, "files"); 495 495 496 lua_push number(L, buf->f_flag);496 lua_pushinteger(L, buf->f_flag); 497 497 lua_setfield(L, -2, "flag"); 498 498 499 lua_push number(L, buf->f_fsid);499 lua_pushinteger(L, buf->f_fsid); 500 500 lua_setfield(L, -2, "fsid"); 501 501 502 lua_push number(L, buf->f_namemax);502 lua_pushinteger(L, buf->f_namemax); 503 503 lua_setfield(L, -2, "namemax"); 504 504 -
luci/trunk/libs/nixio/src/io.c
r4437 r5414 142 142 if (!nixio__addr_parse(&naddr, (struct sockaddr *)&addrobj)) { 143 143 lua_pushstring(L, naddr.host); 144 lua_push number(L, naddr.port);144 lua_pushinteger(L, naddr.port); 145 145 return 3; 146 146 } else { -
luci/trunk/libs/nixio/src/nixio.c
r4440 r5414 148 148 149 149 /* module version */ 150 lua_push number(L, VERSION);150 lua_pushinteger(L, VERSION); 151 151 lua_setfield(L, -2, "version"); 152 152 -
luci/trunk/libs/nixio/src/process.c
r4437 r5414 226 226 } else { 227 227 lua_createtable(L, 0, 4); 228 lua_push number(L, buf.tms_cstime);228 lua_pushinteger(L, buf.tms_cstime); 229 229 lua_setfield(L, -2, "cstime"); 230 230 231 lua_push number(L, buf.tms_cutime);231 lua_pushinteger(L, buf.tms_cutime); 232 232 lua_setfield(L, -2, "cutime"); 233 233 234 lua_push number(L, buf.tms_stime);234 lua_pushinteger(L, buf.tms_stime); 235 235 lua_setfield(L, -2, "stime"); 236 236 237 lua_push number(L, buf.tms_utime);237 lua_pushinteger(L, buf.tms_utime); 238 238 lua_setfield(L, -2, "utime"); 239 239 … … 366 366 lua_createtable(L, 0, 12); 367 367 368 lua_push number(L, info.bufferram);368 lua_pushinteger(L, info.bufferram); 369 369 lua_setfield(L, -2, "bufferram"); 370 370 371 lua_push number(L, info.freehigh);371 lua_pushinteger(L, info.freehigh); 372 372 lua_setfield(L, -2, "freehigh"); 373 373 374 lua_push number(L, info.freeram);374 lua_pushinteger(L, info.freeram); 375 375 lua_setfield(L, -2, "freeram"); 376 376 377 lua_push number(L, info.freeswap);377 lua_pushinteger(L, info.freeswap); 378 378 lua_setfield(L, -2, "freeswap"); 379 379 380 380 lua_createtable(L, 0, 3); 381 381 for (int i=0; i<3; i++) { 382 lua_push number(L, info.loads[i] / 65536.);382 lua_pushinteger(L, info.loads[i] / 65536.); 383 383 lua_rawseti(L, -2, i+1); 384 384 } 385 385 lua_setfield(L, -2, "loads"); 386 386 387 lua_push number(L, info.mem_unit);387 lua_pushinteger(L, info.mem_unit); 388 388 lua_setfield(L, -2, "mem_unit"); 389 389 390 lua_push number(L, info.procs);390 lua_pushinteger(L, info.procs); 391 391 lua_setfield(L, -2, "procs"); 392 392 393 lua_push number(L, info.sharedram);393 lua_pushinteger(L, info.sharedram); 394 394 lua_setfield(L, -2, "sharedram"); 395 395 396 lua_push number(L, info.totalhigh);396 lua_pushinteger(L, info.totalhigh); 397 397 lua_setfield(L, -2, "totalhigh"); 398 398 399 lua_push number(L, info.totalram);399 lua_pushinteger(L, info.totalram); 400 400 lua_setfield(L, -2, "totalram"); 401 401 402 lua_push number(L, info.totalswap);402 lua_pushinteger(L, info.totalswap); 403 403 lua_setfield(L, -2, "totalswap"); 404 404 405 lua_push number(L, info.uptime);405 lua_pushinteger(L, info.uptime); 406 406 lua_setfield(L, -2, "uptime"); 407 407 -
luci/trunk/libs/nixio/src/sockopt.c
r4440 r5414 205 205 } 206 206 lua_pushstring(L, buf); 207 lua_push number(L, val.ipv6mr_interface);207 lua_pushinteger(L, val.ipv6mr_interface); 208 208 return 2; 209 209 } -
luci/trunk/libs/nixio/src/splice.c
r5312 r5414 91 91 } 92 92 93 lua_push number(L, spliced);93 lua_pushinteger(L, spliced); 94 94 return 1; 95 95 } … … 152 152 #endif 153 153 154 lua_push number(L, spliced);154 lua_pushinteger(L, spliced); 155 155 return 1; 156 156 } -
luci/trunk/libs/nixio/src/user.c
r4437 r5414 79 79 errno = 0; 80 80 if (lua_isnumber(L, 1)) { 81 gr = getgrgid(lua_to number(L, 1));81 gr = getgrgid(lua_tointeger(L, 1)); 82 82 } else if (lua_isstring(L, 1)) { 83 83 gr = getgrnam(lua_tostring(L, 1)); … … 132 132 errno = 0; 133 133 if (lua_isnumber(L, 1)) { 134 pw = getpwuid(lua_to number(L, 1));134 pw = getpwuid(lua_tointeger(L, 1)); 135 135 } else if (lua_isstring(L, 1)) { 136 136 pw = getpwnam(lua_tostring(L, 1));
