1 // toys/android/log.c 2 3 struct log_data { 4 char *t, *p; 5 }; 6 7 // toys/example/demo_number.c 8 9 struct demo_number_data { 10 long M, D; 11 }; 12 13 // toys/example/hello.c 14 15 struct hello_data { 16 int unused; 17 }; 18 19 // toys/example/skeleton.c 20 21 struct skeleton_data { 22 union { 23 struct { 24 char *b; 25 long c; 26 struct arg_list *d; 27 long e; 28 char *also, *blubber; 29 } s; 30 struct { 31 long b; 32 } a; 33 }; 34 35 int more_globals; 36 }; 37 38 // toys/lsb/dmesg.c 39 40 struct dmesg_data { 41 long n, s; 42 43 int use_color; 44 time_t tea; 45 }; 46 47 // toys/lsb/gzip.c 48 49 struct gzip_data { 50 int level; 51 }; 52 53 // toys/lsb/hostname.c 54 55 struct hostname_data { 56 char *F; 57 }; 58 59 // toys/lsb/killall.c 60 61 struct killall_data { 62 char *s; 63 64 int signum; 65 pid_t cur_pid; 66 char **names; 67 short *err; 68 struct int_list { struct int_list *next; int val; } *pids; 69 }; 70 71 // toys/lsb/md5sum.c 72 73 struct md5sum_data { 74 int sawline; 75 unsigned *rconsttable32; 76 unsigned long long *rconsttable64; // for sha384,sha512 77 78 // Crypto variables blanked after summing 79 unsigned long long count, overflow; 80 union { 81 char c[128]; // bytes, 1024 bits 82 unsigned i32[16]; // 512 bits for md5,sha1,sha224,sha256 83 unsigned long long i64[16]; // 1024 bits for sha384,sha512 84 } state, buffer; 85 }; 86 87 // toys/lsb/mknod.c 88 89 struct mknod_data { 90 char *Z, *m; 91 }; 92 93 // toys/lsb/mktemp.c 94 95 struct mktemp_data { 96 char *p, *tmpdir; 97 }; 98 99 // toys/lsb/mount.c 100 101 struct mount_data { 102 struct arg_list *optlist; 103 char *type; 104 char *bigO; 105 106 unsigned long flags; 107 char *opts; 108 int okuser; 109 }; 110 111 // toys/lsb/passwd.c 112 113 struct passwd_data { 114 char *a; 115 }; 116 117 // toys/lsb/pidof.c 118 119 struct pidof_data { 120 char *o; 121 }; 122 123 // toys/lsb/seq.c 124 125 struct seq_data { 126 char *s, *f; 127 128 int precision, buflen; 129 }; 130 131 // toys/lsb/su.c 132 133 struct su_data { 134 char *s; 135 char *c; 136 }; 137 138 // toys/lsb/umount.c 139 140 struct umount_data { 141 struct arg_list *t; 142 143 char *types; 144 }; 145 146 // toys/net/ftpget.c 147 148 struct ftpget_data { 149 char *u, *p, *P; 150 151 int fd; 152 }; 153 154 // toys/net/host.c 155 156 struct host_data { 157 char *t; 158 159 char **nsname; 160 unsigned nslen; 161 }; 162 163 // toys/net/ifconfig.c 164 165 struct ifconfig_data { 166 int sockfd; 167 }; 168 169 // toys/net/microcom.c 170 171 struct microcom_data { 172 long s; 173 174 int fd, stok; 175 struct termios old_stdin, old_fd; 176 }; 177 178 // toys/net/netcat.c 179 180 struct netcat_data { 181 char *f, *s; 182 long q, p, W, w; 183 }; 184 185 // toys/net/netstat.c 186 187 struct netstat_data { 188 struct num_cache *inodes; 189 int wpad; 190 }; 191 192 // toys/net/ping.c 193 194 struct ping_data { 195 char *I; 196 long w, W, i, s, c, t, m; 197 198 struct sockaddr *sa; 199 int sock; 200 unsigned long sent, recv, fugit, min, max; 201 }; 202 203 // toys/net/sntp.c 204 205 struct sntp_data { 206 long r, t; 207 char *p, *m, *M; 208 }; 209 210 // toys/net/tunctl.c 211 212 struct tunctl_data { 213 char *u; 214 }; 215 216 // toys/other/acpi.c 217 218 struct acpi_data { 219 int ac, bat, therm, cool; 220 char *cpath; 221 }; 222 223 // toys/other/base64.c 224 225 struct base64_data { 226 long w; 227 unsigned total; 228 unsigned n; // number of bits used in encoding. 5 for base32, 6 for base64 229 unsigned align; // number of bits to align to 230 }; 231 232 // toys/other/blkdiscard.c 233 234 struct blkdiscard_data { 235 long o, l; 236 }; 237 238 // toys/other/blkid.c 239 240 struct blkid_data { 241 struct arg_list *s; 242 }; 243 244 // toys/other/blockdev.c 245 246 struct blockdev_data { 247 long setbsz, setra; 248 }; 249 250 // toys/other/chrt.c 251 252 struct chrt_data { 253 long p; 254 }; 255 256 // toys/other/dos2unix.c 257 258 struct dos2unix_data { 259 char *tempfile; 260 }; 261 262 // toys/other/fallocate.c 263 264 struct fallocate_data { 265 long o, l; 266 }; 267 268 // toys/other/fmt.c 269 270 struct fmt_data { 271 int width; 272 273 int level, pos; 274 }; 275 276 // toys/other/free.c 277 278 struct free_data { 279 unsigned bits; 280 unsigned long long units; 281 char *buf; 282 }; 283 284 // toys/other/gpiod.c 285 286 struct gpiod_data { 287 struct double_list *chips; 288 int chip_count; 289 }; 290 291 // toys/other/hexedit.c 292 293 struct hexedit_data { 294 char *data, *search, keybuf[16], input[80]; 295 long long len, base, pos; 296 int numlen, undo, undolen, mode; 297 unsigned rows, cols; 298 }; 299 300 // toys/other/hwclock.c 301 302 struct hwclock_data { 303 char *f; 304 }; 305 306 // toys/other/ionice.c 307 308 struct ionice_data { 309 long p, n, c; 310 }; 311 312 // toys/other/login.c 313 314 struct login_data { 315 char *h, *f; 316 317 int login_timeout, login_fail_timeout; 318 }; 319 320 // toys/other/losetup.c 321 322 struct losetup_data { 323 char *j; 324 long o, S; 325 326 int openflags; 327 dev_t jdev; 328 ino_t jino; 329 char *dir; 330 }; 331 332 // toys/other/lsattr.c 333 334 struct lsattr_data { 335 long v, p; 336 337 unsigned add, rm, set; 338 // !add and !rm tell us whether they were used, but `chattr =` is meaningful. 339 int have_set; 340 }; 341 342 // toys/other/lsusb.c 343 344 struct lsusb_data { 345 char *i; 346 long n; 347 348 void *ids, *class; 349 int count; 350 }; 351 352 // toys/other/makedevs.c 353 354 struct makedevs_data { 355 char *d; 356 }; 357 358 // toys/other/mix.c 359 360 struct mix_data { 361 long r, l; 362 char *d, *c; 363 }; 364 365 // toys/other/mkpasswd.c 366 367 struct mkpasswd_data { 368 long P; 369 char *m, *S; 370 }; 371 372 // toys/other/mkswap.c 373 374 struct mkswap_data { 375 char *L; 376 }; 377 378 // toys/other/modinfo.c 379 380 struct modinfo_data { 381 char *F, *k, *b; 382 383 long mod; 384 int count; 385 }; 386 387 // toys/other/nsenter.c 388 389 struct nsenter_data { 390 char *Uupnmi[6]; 391 long t; 392 }; 393 394 // toys/other/oneit.c 395 396 struct oneit_data { 397 char *c; 398 }; 399 400 // toys/other/openvt.c 401 402 struct openvt_data { 403 long c; 404 }; 405 406 // toys/other/pwgen.c 407 408 struct pwgen_data { 409 char *r; 410 }; 411 412 // toys/other/readelf.c 413 414 struct readelf_data { 415 char *x, *p; 416 417 char *elf, *shstrtab, *f; 418 unsigned long long shoff, phoff, size, shstrtabsz; 419 int bits, endian, shnum, shentsize, phentsize; 420 }; 421 422 // toys/other/reboot.c 423 424 struct reboot_data { 425 char *d; 426 }; 427 428 // toys/other/rtcwake.c 429 430 struct rtcwake_data { 431 long t, s; 432 char *m, *d; 433 }; 434 435 // toys/other/setfattr.c 436 437 struct setfattr_data { 438 char *x, *v, *n; 439 }; 440 441 // toys/other/sha3sum.c 442 443 struct sha3sum_data { 444 long a; 445 unsigned long long rc[24]; 446 }; 447 448 // toys/other/shred.c 449 450 struct shred_data { 451 long o, n, s; 452 }; 453 454 // toys/other/stat.c 455 456 struct stat_data { 457 char *c; 458 459 union { 460 struct stat st; 461 struct statfs sf; 462 } stat; 463 char *file, *pattern; 464 int patlen; 465 }; 466 467 // toys/other/swapon.c 468 469 struct swapon_data { 470 long p; 471 }; 472 473 // toys/other/switch_root.c 474 475 struct switch_root_data { 476 char *c; 477 478 dev_t rootdev; 479 }; 480 481 // toys/other/tac.c 482 483 struct tac_data { 484 struct double_list *dl; 485 }; 486 487 // toys/other/timeout.c 488 489 struct timeout_data { 490 char *s, *k; 491 492 int nextsig; 493 pid_t pid; 494 struct timespec kts; 495 struct itimerspec its; 496 timer_t timer; 497 }; 498 499 // toys/other/truncate.c 500 501 struct truncate_data { 502 char *s; 503 504 long size; 505 int type; 506 }; 507 508 // toys/other/uclampset.c 509 510 struct uclampset_data { 511 long M, m, p; 512 }; 513 514 // toys/other/watch.c 515 516 struct watch_data { 517 int n; 518 519 pid_t pid, oldpid; 520 }; 521 522 // toys/other/watchdog.c 523 524 struct watchdog_data { 525 long T, t; 526 527 int fd; 528 }; 529 530 // toys/other/xxd.c 531 532 struct xxd_data { 533 long s, g, o, l, c; 534 }; 535 536 // toys/pending/arp.c 537 538 struct arp_data { 539 char *hw_type; 540 char *af_type_A; 541 char *af_type_p; 542 char *interface; 543 544 int sockfd; 545 char *device; 546 }; 547 548 // toys/pending/arping.c 549 550 struct arping_data { 551 long count; 552 unsigned long time_out; 553 char *iface; 554 char *src_ip; 555 556 int sockfd; 557 unsigned long start, end; 558 unsigned sent_at, sent_nr, rcvd_nr, brd_sent, rcvd_req, brd_rcv, 559 unicast_flag; 560 }; 561 562 // toys/pending/bc.c 563 564 struct bc_data { 565 // This actually needs to be a BcVm*, but the toybox build 566 // system complains if I make it so. Instead, we'll just cast. 567 char *vm; 568 569 size_t nchars; 570 char *file, sig, max_ibase; 571 uint16_t line_len; 572 }; 573 574 // toys/pending/bootchartd.c 575 576 struct bootchartd_data { 577 char timestamp[32]; 578 long msec; 579 int proc_accounting; 580 581 pid_t pid; 582 }; 583 584 // toys/pending/brctl.c 585 586 struct brctl_data { 587 int sockfd; 588 }; 589 590 // toys/pending/chsh.c 591 592 struct chsh_data { 593 char *s; 594 }; 595 596 // toys/pending/crond.c 597 598 struct crond_data { 599 char *crontabs_dir; 600 char *logfile; 601 int loglevel_d; 602 int loglevel; 603 604 time_t crontabs_dir_mtime; 605 uint8_t flagd; 606 }; 607 608 // toys/pending/crontab.c 609 610 struct crontab_data { 611 char *user; 612 char *cdir; 613 }; 614 615 // toys/pending/dd.c 616 617 struct dd_data { 618 int show_xfer, show_records; 619 unsigned long long bytes, c_count, in_full, in_part, out_full, out_part; 620 struct timeval start; 621 struct { 622 char *name; 623 int fd; 624 unsigned char *buff, *bp; 625 long sz, count; 626 unsigned long long offset; 627 } in, out; 628 unsigned conv, iflag, oflag; 629 }; 630 631 // toys/pending/dhcp.c 632 633 struct dhcp_data { 634 char *iface; 635 char *pidfile; 636 char *script; 637 long retries; 638 long timeout; 639 long tryagain; 640 struct arg_list *req_opt; 641 char *req_ip; 642 struct arg_list *pkt_opt; 643 char *fdn_name; 644 char *hostname; 645 char *vendor_cls; 646 }; 647 648 // toys/pending/dhcp6.c 649 650 struct dhcp6_data { 651 char *interface_name, *pidfile, *script; 652 long retry, timeout, errortimeout; 653 char *req_ip; 654 int length, state, request_length, sock, sock1, status, retval, retries; 655 struct timeval tv; 656 uint8_t transction_id[3]; 657 struct sockaddr_in6 input_socket6; 658 }; 659 660 // toys/pending/dhcpd.c 661 662 struct dhcpd_data { 663 char *iface; 664 long port; 665 }; 666 667 // toys/pending/diff.c 668 669 struct diff_data { 670 long ct; 671 char *start; 672 struct arg_list *L_list; 673 674 int dir_num, size, is_binary, status, change, len[2]; 675 int *offset[2]; 676 struct stat st[2]; 677 }; 678 679 // toys/pending/dumpleases.c 680 681 struct dumpleases_data { 682 char *file; 683 }; 684 685 // toys/pending/expr.c 686 687 struct expr_data { 688 char **tok; // current token, not on the stack since recursive calls mutate it 689 690 char *refree; 691 }; 692 693 // toys/pending/fdisk.c 694 695 struct fdisk_data { 696 long sect_sz; 697 long sectors; 698 long heads; 699 long cylinders; 700 }; 701 702 // toys/pending/fold.c 703 704 struct fold_data { 705 int width; 706 }; 707 708 // toys/pending/fsck.c 709 710 struct fsck_data { 711 int fd_num; 712 char *t_list; 713 714 struct double_list *devices; 715 char *arr_flag; 716 char **arr_type; 717 int negate; 718 int sum_status; 719 int nr_run; 720 int sig_num; 721 long max_nr_run; 722 }; 723 724 // toys/pending/getfattr.c 725 726 struct getfattr_data { 727 char *n; 728 }; 729 730 // toys/pending/getopt.c 731 732 struct getopt_data { 733 struct arg_list *l; 734 char *o, *n; 735 }; 736 737 // toys/pending/getty.c 738 739 struct getty_data { 740 char *f, *l, *I, *H; 741 long t; 742 743 char *tty_name, buff[128]; 744 int speeds[20], sc; 745 struct termios termios; 746 }; 747 748 // toys/pending/groupadd.c 749 750 struct groupadd_data { 751 long gid; 752 }; 753 754 // toys/pending/hexdump.c 755 756 struct hexdump_data { 757 long s, n; 758 759 long long len, pos, ppos; 760 const char *fmt; 761 unsigned int fn, bc; // file number and byte count 762 char linebuf[16]; // line buffer - serves double duty for sqeezing repeat 763 // lines and for accumulating full lines accross file 764 // boundaries if necessesary. 765 }; 766 767 // toys/pending/ip.c 768 769 struct ip_data { 770 char stats, singleline, flush, *filter_dev, gbuf[8192]; 771 int sockfd, connected, from_ok, route_cmd; 772 int8_t addressfamily, is_addr; 773 }; 774 775 // toys/pending/ipcrm.c 776 777 struct ipcrm_data { 778 struct arg_list *qkey; 779 struct arg_list *qid; 780 struct arg_list *skey; 781 struct arg_list *sid; 782 struct arg_list *mkey; 783 struct arg_list *mid; 784 }; 785 786 // toys/pending/ipcs.c 787 788 struct ipcs_data { 789 int id; 790 }; 791 792 // toys/pending/klogd.c 793 794 struct klogd_data { 795 long level; 796 797 int fd; 798 }; 799 800 // toys/pending/last.c 801 802 struct last_data { 803 char *file; 804 805 struct arg_list *list; 806 }; 807 808 // toys/pending/lsof.c 809 810 struct lsof_data { 811 struct arg_list *p; 812 813 struct stat *sought_files; 814 struct double_list *all_sockets, *files; 815 int last_shown_pid, shown_header; 816 }; 817 818 // toys/pending/man.c 819 820 struct man_data { 821 char *M, *k; 822 823 char any, cell, ex, *f, k_done, *line, *m, **sct, **scts, **sufs; 824 regex_t reg; 825 }; 826 827 // toys/pending/mke2fs.c 828 829 struct mke2fs_data { 830 // Command line arguments. 831 long blocksize; 832 long bytes_per_inode; 833 long inodes; // Total inodes in filesystem. 834 long reserved_percent; // Integer precent of space to reserve for root. 835 char *gendir; // Where to read dirtree from. 836 837 // Internal data. 838 struct dirtree *dt; // Tree of files to copy into the new filesystem. 839 unsigned treeblocks; // Blocks used by dt 840 unsigned treeinodes; // Inodes used by dt 841 842 unsigned blocks; // Total blocks in the filesystem. 843 unsigned freeblocks; // Free blocks in the filesystem. 844 unsigned inodespg; // Inodes per group 845 unsigned groups; // Total number of block groups. 846 unsigned blockbits; // Bits per block. (Also blocks per group.) 847 848 // For gene2fs 849 unsigned nextblock; // Next data block to allocate 850 unsigned nextgroup; // Next group we'll be allocating from 851 int fsfd; // File descriptor of filesystem (to output to). 852 }; 853 854 // toys/pending/modprobe.c 855 856 struct modprobe_data { 857 struct arg_list *dirs; 858 859 struct arg_list *probes, *dbase[256]; 860 char *cmdopts; 861 int nudeps, symreq; 862 }; 863 864 // toys/pending/more.c 865 866 struct more_data { 867 struct termios inf; 868 int cin_fd; 869 }; 870 871 // toys/pending/route.c 872 873 struct route_data { 874 char *A; 875 }; 876 877 // toys/pending/sh.c 878 879 struct sh_data { 880 union { 881 struct { 882 char *c; 883 } sh; 884 struct { 885 char *a; 886 } exec; 887 }; 888 889 // keep SECONDS here: used to work around compiler limitation in run_command() 890 long long SECONDS; 891 char *isexec, *wcpat; 892 unsigned options, jobcnt, LINENO; 893 int hfd, pid, bangpid, varslen, srclvl, recursion; 894 895 // Callable function array 896 struct sh_function { 897 char *name; 898 struct sh_pipeline { // pipeline segments: linked list of arg w/metadata 899 struct sh_pipeline *next, *prev, *end; 900 int count, here, type, lineno; 901 struct sh_arg { 902 char **v; 903 int c; 904 } arg[1]; 905 } *pipeline; 906 unsigned long refcount; 907 } **functions; 908 long funcslen; 909 910 // runtime function call stack 911 struct sh_fcall { 912 struct sh_fcall *next, *prev; 913 914 // This dlist in reverse order: TT.ff current function, TT.ff->prev globals 915 struct sh_vars { 916 long flags; 917 char *str; 918 } *vars; 919 long varslen, shift; 920 921 struct sh_function *func; // TODO wire this up 922 struct sh_pipeline *pl; 923 char *ifs; 924 struct sh_arg arg; 925 struct arg_list *delete; 926 927 // Runtime stack of nested if/else/fi and for/do/done contexts. 928 struct sh_blockstack { 929 struct sh_blockstack *next; 930 struct sh_pipeline *start, *middle; 931 struct sh_process *pp; // list of processes piping in to us 932 int run, loop, *urd, pout, pipe; 933 struct sh_arg farg; // for/select arg stack, case wildcard deck 934 struct arg_list *fdelete; // farg's cleanup list 935 char *fvar; // for/select's iteration variable name 936 } *blk; 937 } *ff; 938 939 // TODO ctrl-Z suspend should stop script 940 struct sh_process { 941 struct sh_process *next, *prev; // | && || 942 struct arg_list *delete; // expanded strings 943 // undo redirects, a=b at start, child PID, exit status, has !, job # 944 int *urd, envlen, pid, exit, flags, job, dash; 945 long long when; // when job backgrounded/suspended 946 struct sh_arg *raw, arg; 947 } *pp; // currently running process 948 949 // job list, command line for $*, scratch space for do_wildcard_files() 950 struct sh_arg jobs, *wcdeck; 951 }; 952 953 // toys/pending/strace.c 954 955 struct strace_data { 956 long s, p; 957 958 char ioctl[32], *fmt; 959 long regs[256/sizeof(long)], syscall; 960 pid_t pid; 961 int arg; 962 }; 963 964 // toys/pending/stty.c 965 966 struct stty_data { 967 char *F; 968 969 int fd, col; 970 unsigned output_cols; 971 }; 972 973 // toys/pending/sulogin.c 974 975 struct sulogin_data { 976 long timeout; 977 struct termios crntio; 978 }; 979 980 // toys/pending/syslogd.c 981 982 struct syslogd_data { 983 char *socket; 984 char *config_file; 985 char *unix_socket; 986 char *logfile; 987 long interval; 988 long rot_size; 989 long rot_count; 990 char *remote_log; 991 long log_prio; 992 993 struct unsocks *lsocks; // list of listen sockets 994 struct logfile *lfiles; // list of write logfiles 995 int sigfd[2]; 996 }; 997 998 // toys/pending/tcpsvd.c 999 1000 struct tcpsvd_data { 1001 char *name; 1002 char *user; 1003 long bn; 1004 char *nmsg; 1005 long cn; 1006 1007 int maxc; 1008 int count_all; 1009 int udp; 1010 }; 1011 1012 // toys/pending/telnet.c 1013 1014 struct telnet_data { 1015 int sock; 1016 char buf[2048]; // Half sizeof(toybuf) allows a buffer full of IACs. 1017 struct termios old_term; 1018 struct termios raw_term; 1019 uint8_t mode; 1020 int echo, sga; 1021 int state, request; 1022 }; 1023 1024 // toys/pending/telnetd.c 1025 1026 struct telnetd_data { 1027 char *login_path; 1028 char *issue_path; 1029 int port; 1030 char *host_addr; 1031 long w_sec; 1032 1033 int gmax_fd; 1034 pid_t fork_pid; 1035 }; 1036 1037 // toys/pending/tftp.c 1038 1039 struct tftp_data { 1040 char *local_file; 1041 char *remote_file; 1042 long block_size; 1043 1044 struct sockaddr_storage inaddr; 1045 int af; 1046 }; 1047 1048 // toys/pending/tftpd.c 1049 1050 struct tftpd_data { 1051 char *user; 1052 1053 long sfd; 1054 struct passwd *pw; 1055 }; 1056 1057 // toys/pending/tr.c 1058 1059 struct tr_data { 1060 short map[256]; //map of chars 1061 int len1, len2; 1062 }; 1063 1064 // toys/pending/traceroute.c 1065 1066 struct traceroute_data { 1067 long max_ttl; 1068 long port; 1069 long ttl_probes; 1070 char *src_ip; 1071 long tos; 1072 long wait_time; 1073 struct arg_list *loose_source; 1074 long pause_time; 1075 long first_ttl; 1076 char *iface; 1077 1078 uint32_t gw_list[9]; 1079 int recv_sock; 1080 int snd_sock; 1081 unsigned msg_len; 1082 char *packet; 1083 uint32_t ident; 1084 int istraceroute6; 1085 }; 1086 1087 // toys/pending/useradd.c 1088 1089 struct useradd_data { 1090 char *dir; 1091 char *gecos; 1092 char *shell; 1093 char *u_grp; 1094 long uid; 1095 1096 long gid; 1097 }; 1098 1099 // toys/pending/vi.c 1100 1101 struct vi_data { 1102 char *s; 1103 int vi_mode, tabstop, list; 1104 int cur_col, cur_row, scr_row; 1105 int drawn_row, drawn_col; 1106 int count0, count1, vi_mov_flag; 1107 unsigned screen_height, screen_width; 1108 char vi_reg, *last_search; 1109 struct str_line { 1110 int alloc; 1111 int len; 1112 char *data; 1113 } *il; 1114 size_t screen, cursor; //offsets 1115 //yank buffer 1116 struct yank_buf { 1117 char reg; 1118 int alloc; 1119 char* data; 1120 } yank; 1121 1122 int modified; 1123 size_t filesize; 1124 // mem_block contains RO data that is either original file as mmap 1125 // or heap allocated inserted data 1126 // 1127 // 1128 // 1129 struct block_list { 1130 struct block_list *next, *prev; 1131 struct mem_block { 1132 size_t size; 1133 size_t len; 1134 enum alloc_flag { 1135 MMAP, //can be munmap() before exit() 1136 HEAP, //can be free() before exit() 1137 STACK, //global or stack perhaps toybuf 1138 } alloc; 1139 const char *data; 1140 } *node; 1141 } *text; 1142 1143 // slices do not contain actual allocated data but slices of data in mem_block 1144 // when file is first opened it has only one slice. 1145 // after inserting data into middle new mem_block is allocated for insert data 1146 // and 3 slices are created, where first and last slice are pointing to original 1147 // mem_block with offsets, and middle slice is pointing to newly allocated block 1148 // When deleting, data is not freed but mem_blocks are sliced more such way that 1149 // deleted data left between 2 slices 1150 struct slice_list { 1151 struct slice_list *next, *prev; 1152 struct slice { 1153 size_t len; 1154 const char *data; 1155 } *node; 1156 } *slices; 1157 }; 1158 1159 // toys/pending/wget.c 1160 1161 struct wget_data { 1162 char *p, *O; 1163 long max_redirect; 1164 1165 int sock, https; 1166 char *url; 1167 #if CFG_WGET_LIBTLS 1168 struct tls *tls; 1169 #elif CFG_WGET_OPENSSL 1170 struct ssl_ctx_st *ctx; 1171 struct ssl_st *ssl; 1172 #endif 1173 }; 1174 1175 // toys/posix/basename.c 1176 1177 struct basename_data { 1178 char *s; 1179 }; 1180 1181 // toys/posix/cal.c 1182 1183 struct cal_data { 1184 struct tm *now; 1185 }; 1186 1187 // toys/posix/chgrp.c 1188 1189 struct chgrp_data { 1190 uid_t owner; 1191 gid_t group; 1192 char *owner_name, *group_name; 1193 int symfollow; 1194 }; 1195 1196 // toys/posix/chmod.c 1197 1198 struct chmod_data { 1199 char *mode; 1200 }; 1201 1202 // toys/posix/cksum.c 1203 1204 struct cksum_data { 1205 unsigned crc_table[256]; 1206 }; 1207 1208 // toys/posix/cmp.c 1209 1210 struct cmp_data { 1211 long n; 1212 1213 int fd; 1214 char *name; 1215 }; 1216 1217 // toys/posix/cp.c 1218 1219 struct cp_data { 1220 union { 1221 // install's options 1222 struct { 1223 char *g, *o, *m, *t; 1224 } i; 1225 // cp's options 1226 struct { 1227 char *t, *preserve; 1228 } c; 1229 }; 1230 1231 char *destname; 1232 struct stat top; 1233 int (*callback)(struct dirtree *try); 1234 uid_t uid; 1235 gid_t gid; 1236 int pflags; 1237 }; 1238 1239 // toys/posix/cpio.c 1240 1241 struct cpio_data { 1242 char *F, *H; 1243 }; 1244 1245 // toys/posix/cut.c 1246 1247 struct cut_data { 1248 char *d, *O; 1249 struct arg_list *select[5]; // we treat them the same, so loop through 1250 1251 unsigned line; 1252 int pairs; 1253 regex_t reg; 1254 }; 1255 1256 // toys/posix/date.c 1257 1258 struct date_data { 1259 char *s, *r, *I, *D, *d; 1260 1261 unsigned nano; 1262 }; 1263 1264 // toys/posix/df.c 1265 1266 struct df_data { 1267 struct arg_list *t; 1268 1269 int units, width[6]; 1270 }; 1271 1272 // toys/posix/du.c 1273 1274 struct du_data { 1275 long d; 1276 1277 unsigned long depth, total; 1278 dev_t st_dev; 1279 void *inodes; 1280 }; 1281 1282 // toys/posix/env.c 1283 1284 struct env_data { 1285 struct arg_list *u; 1286 }; 1287 1288 // toys/posix/expand.c 1289 1290 struct expand_data { 1291 struct arg_list *t; 1292 1293 unsigned tabcount, *tab; 1294 }; 1295 1296 // toys/posix/file.c 1297 1298 struct file_data { 1299 int max_name_len; 1300 off_t len; 1301 }; 1302 1303 // toys/posix/find.c 1304 1305 struct find_data { 1306 char **filter; 1307 struct double_list *argdata; 1308 int topdir, xdev, depth; 1309 time_t now; 1310 long max_bytes; 1311 char *start; 1312 }; 1313 1314 // toys/posix/grep.c 1315 1316 struct grep_data { 1317 long m, A, B, C; 1318 struct arg_list *f, *e, *M, *S, *exclude_dir; 1319 char *color; 1320 1321 char *purple, *cyan, *red, *green, *grey; 1322 struct double_list *reg; 1323 char indelim, outdelim; 1324 int found, tried; 1325 }; 1326 1327 // toys/posix/head.c 1328 1329 struct head_data { 1330 long c, n; 1331 1332 int file_no; 1333 }; 1334 1335 // toys/posix/iconv.c 1336 1337 struct iconv_data { 1338 char *f, *t; 1339 1340 void *ic; 1341 }; 1342 1343 // toys/posix/id.c 1344 1345 struct id_data { 1346 int is_groups; 1347 }; 1348 1349 // toys/posix/kill.c 1350 1351 struct kill_data { 1352 char *s; 1353 struct arg_list *o; 1354 }; 1355 1356 // toys/posix/ln.c 1357 1358 struct ln_data { 1359 char *t; 1360 }; 1361 1362 // toys/posix/logger.c 1363 1364 struct logger_data { 1365 char *p, *t; 1366 }; 1367 1368 // toys/posix/ls.c 1369 1370 struct ls_data { 1371 long w; 1372 long l; 1373 char *color; 1374 1375 struct dirtree *files, *singledir; 1376 unsigned screen_width; 1377 int nl_title; 1378 char *escmore; 1379 }; 1380 1381 // toys/posix/mkdir.c 1382 1383 struct mkdir_data { 1384 char *m, *Z; 1385 }; 1386 1387 // toys/posix/mkfifo.c 1388 1389 struct mkfifo_data { 1390 char *m; 1391 char *Z; 1392 1393 mode_t mode; 1394 }; 1395 1396 // toys/posix/nice.c 1397 1398 struct nice_data { 1399 long n; 1400 }; 1401 1402 // toys/posix/nl.c 1403 1404 struct nl_data { 1405 char *s, *n, *b; 1406 long w, l, v; 1407 1408 // Count of consecutive blank lines for -l has to persist between files 1409 long lcount, slen; 1410 }; 1411 1412 // toys/posix/od.c 1413 1414 struct od_data { 1415 struct arg_list *t; 1416 char *A; 1417 long N, w, j; 1418 1419 int address_idx; 1420 unsigned types, leftover, star; 1421 char *buf; // Points to buffers[0] or buffers[1]. 1422 char *bufs[2]; // Used to detect duplicate lines. 1423 off_t pos; 1424 }; 1425 1426 // toys/posix/paste.c 1427 1428 struct paste_data { 1429 char *d; 1430 1431 int files; 1432 }; 1433 1434 // toys/posix/patch.c 1435 1436 struct patch_data { 1437 char *i, *d; 1438 long p, g, F; 1439 1440 void *current_hunk; 1441 long oldline, oldlen, newline, newlen, linenum, outnum; 1442 int context, state, filein, fileout, filepatch, hunknum; 1443 char *tempname; 1444 }; 1445 1446 // toys/posix/ps.c 1447 1448 struct ps_data { 1449 union { 1450 struct { 1451 struct arg_list *G, *g, *U, *u, *t, *s, *p, *O, *o, *P, *k; 1452 } ps; 1453 struct { 1454 long n, m, d, s; 1455 struct arg_list *u, *p, *o, *k, *O; 1456 } top; 1457 struct { 1458 char *L; 1459 struct arg_list *G, *g, *P, *s, *t, *U, *u; 1460 char *d; 1461 1462 void *regexes, *snapshot; 1463 int signal; 1464 pid_t self, match; 1465 } pgrep; 1466 }; 1467 1468 struct ptr_len gg, GG, pp, PP, ss, tt, uu, UU; 1469 struct dirtree *threadparent; 1470 unsigned width, height, scroll; 1471 dev_t tty; 1472 void *fields, *kfields; 1473 long long ticks, bits, time; 1474 int kcount, forcek, sortpos, pidlen; 1475 int (*match_process)(long long *slot); 1476 void (*show_process)(void *tb); 1477 }; 1478 1479 // toys/posix/renice.c 1480 1481 struct renice_data { 1482 long n; 1483 }; 1484 1485 // toys/posix/sed.c 1486 1487 struct sed_data { 1488 char *i; 1489 struct arg_list *f, *e; 1490 1491 // processed pattern list 1492 struct double_list *pattern; 1493 1494 char *nextline, *remember; 1495 void *restart, *lastregex; 1496 long nextlen, rememberlen, count; 1497 int fdout, noeol; 1498 unsigned xx; 1499 char delim; 1500 }; 1501 1502 // toys/posix/sort.c 1503 1504 struct sort_data { 1505 char *t; 1506 struct arg_list *k; 1507 char *o, *T, S; 1508 1509 void *key_list; 1510 unsigned linecount; 1511 char **lines, *name; 1512 }; 1513 1514 // toys/posix/split.c 1515 1516 struct split_data { 1517 long n, l, b, a; 1518 1519 char *outfile; 1520 }; 1521 1522 // toys/posix/strings.c 1523 1524 struct strings_data { 1525 long n; 1526 char *t; 1527 }; 1528 1529 // toys/posix/tail.c 1530 1531 struct tail_data { 1532 long n, c; 1533 char *s; 1534 1535 int file_no, last_fd, ss; 1536 struct xnotify *not; 1537 struct { 1538 char *path; 1539 int fd; 1540 dev_t dev; 1541 ino_t ino; 1542 } *F; 1543 }; 1544 1545 // toys/posix/tar.c 1546 1547 struct tar_data { 1548 char *f, *C; 1549 struct arg_list *T, *X; 1550 char *I, *to_command, *owner, *group, *mtime, *mode; 1551 struct arg_list *exclude; 1552 long strip_components; 1553 1554 struct double_list *incl, *excl, *seen; 1555 struct string_list *dirs; 1556 char *cwd; 1557 int fd, ouid, ggid, hlc, warn, adev, aino, sparselen, pid; 1558 long long *sparse; 1559 time_t mtt; 1560 1561 // hardlinks seen so far (hlc many) 1562 struct { 1563 char *arg; 1564 ino_t ino; 1565 dev_t dev; 1566 } *hlx; 1567 1568 // Parsed information about a tar header. 1569 struct tar_header { 1570 char *name, *link_target, *uname, *gname; 1571 long long size, ssize; 1572 uid_t uid; 1573 gid_t gid; 1574 mode_t mode; 1575 time_t mtime; 1576 dev_t device; 1577 } hdr; 1578 }; 1579 1580 // toys/posix/tee.c 1581 1582 struct tee_data { 1583 void *outputs; 1584 int out; 1585 }; 1586 1587 // toys/posix/touch.c 1588 1589 struct touch_data { 1590 char *t, *r, *d; 1591 }; 1592 1593 // toys/posix/ulimit.c 1594 1595 struct ulimit_data { 1596 long P; 1597 }; 1598 1599 // toys/posix/uniq.c 1600 1601 struct uniq_data { 1602 long w, s, f; 1603 1604 long repeats; 1605 }; 1606 1607 // toys/posix/uudecode.c 1608 1609 struct uudecode_data { 1610 char *o; 1611 }; 1612 1613 // toys/posix/wc.c 1614 1615 struct wc_data { 1616 unsigned long totals[4]; 1617 }; 1618 1619 // toys/posix/xargs.c 1620 1621 struct xargs_data { 1622 long s, n, P; 1623 char *E; 1624 1625 long entries, bytes, np; 1626 char delim; 1627 FILE *tty; 1628 }; 1629 1630 extern union global_union { 1631 struct log_data log; 1632 struct demo_number_data demo_number; 1633 struct hello_data hello; 1634 struct skeleton_data skeleton; 1635 struct dmesg_data dmesg; 1636 struct gzip_data gzip; 1637 struct hostname_data hostname; 1638 struct killall_data killall; 1639 struct md5sum_data md5sum; 1640 struct mknod_data mknod; 1641 struct mktemp_data mktemp; 1642 struct mount_data mount; 1643 struct passwd_data passwd; 1644 struct pidof_data pidof; 1645 struct seq_data seq; 1646 struct su_data su; 1647 struct umount_data umount; 1648 struct ftpget_data ftpget; 1649 struct host_data host; 1650 struct ifconfig_data ifconfig; 1651 struct microcom_data microcom; 1652 struct netcat_data netcat; 1653 struct netstat_data netstat; 1654 struct ping_data ping; 1655 struct sntp_data sntp; 1656 struct tunctl_data tunctl; 1657 struct acpi_data acpi; 1658 struct base64_data base64; 1659 struct blkdiscard_data blkdiscard; 1660 struct blkid_data blkid; 1661 struct blockdev_data blockdev; 1662 struct chrt_data chrt; 1663 struct dos2unix_data dos2unix; 1664 struct fallocate_data fallocate; 1665 struct fmt_data fmt; 1666 struct free_data free; 1667 struct gpiod_data gpiod; 1668 struct hexedit_data hexedit; 1669 struct hwclock_data hwclock; 1670 struct ionice_data ionice; 1671 struct login_data login; 1672 struct losetup_data losetup; 1673 struct lsattr_data lsattr; 1674 struct lsusb_data lsusb; 1675 struct makedevs_data makedevs; 1676 struct mix_data mix; 1677 struct mkpasswd_data mkpasswd; 1678 struct mkswap_data mkswap; 1679 struct modinfo_data modinfo; 1680 struct nsenter_data nsenter; 1681 struct oneit_data oneit; 1682 struct openvt_data openvt; 1683 struct pwgen_data pwgen; 1684 struct readelf_data readelf; 1685 struct reboot_data reboot; 1686 struct rtcwake_data rtcwake; 1687 struct setfattr_data setfattr; 1688 struct sha3sum_data sha3sum; 1689 struct shred_data shred; 1690 struct stat_data stat; 1691 struct swapon_data swapon; 1692 struct switch_root_data switch_root; 1693 struct tac_data tac; 1694 struct timeout_data timeout; 1695 struct truncate_data truncate; 1696 struct uclampset_data uclampset; 1697 struct watch_data watch; 1698 struct watchdog_data watchdog; 1699 struct xxd_data xxd; 1700 struct arp_data arp; 1701 struct arping_data arping; 1702 struct bc_data bc; 1703 struct bootchartd_data bootchartd; 1704 struct brctl_data brctl; 1705 struct chsh_data chsh; 1706 struct crond_data crond; 1707 struct crontab_data crontab; 1708 struct dd_data dd; 1709 struct dhcp_data dhcp; 1710 struct dhcp6_data dhcp6; 1711 struct dhcpd_data dhcpd; 1712 struct diff_data diff; 1713 struct dumpleases_data dumpleases; 1714 struct expr_data expr; 1715 struct fdisk_data fdisk; 1716 struct fold_data fold; 1717 struct fsck_data fsck; 1718 struct getfattr_data getfattr; 1719 struct getopt_data getopt; 1720 struct getty_data getty; 1721 struct groupadd_data groupadd; 1722 struct hexdump_data hexdump; 1723 struct ip_data ip; 1724 struct ipcrm_data ipcrm; 1725 struct ipcs_data ipcs; 1726 struct klogd_data klogd; 1727 struct last_data last; 1728 struct lsof_data lsof; 1729 struct man_data man; 1730 struct mke2fs_data mke2fs; 1731 struct modprobe_data modprobe; 1732 struct more_data more; 1733 struct route_data route; 1734 struct sh_data sh; 1735 struct strace_data strace; 1736 struct stty_data stty; 1737 struct sulogin_data sulogin; 1738 struct syslogd_data syslogd; 1739 struct tcpsvd_data tcpsvd; 1740 struct telnet_data telnet; 1741 struct telnetd_data telnetd; 1742 struct tftp_data tftp; 1743 struct tftpd_data tftpd; 1744 struct tr_data tr; 1745 struct traceroute_data traceroute; 1746 struct useradd_data useradd; 1747 struct vi_data vi; 1748 struct wget_data wget; 1749 struct basename_data basename; 1750 struct cal_data cal; 1751 struct chgrp_data chgrp; 1752 struct chmod_data chmod; 1753 struct cksum_data cksum; 1754 struct cmp_data cmp; 1755 struct cp_data cp; 1756 struct cpio_data cpio; 1757 struct cut_data cut; 1758 struct date_data date; 1759 struct df_data df; 1760 struct du_data du; 1761 struct env_data env; 1762 struct expand_data expand; 1763 struct file_data file; 1764 struct find_data find; 1765 struct grep_data grep; 1766 struct head_data head; 1767 struct iconv_data iconv; 1768 struct id_data id; 1769 struct kill_data kill; 1770 struct ln_data ln; 1771 struct logger_data logger; 1772 struct ls_data ls; 1773 struct mkdir_data mkdir; 1774 struct mkfifo_data mkfifo; 1775 struct nice_data nice; 1776 struct nl_data nl; 1777 struct od_data od; 1778 struct paste_data paste; 1779 struct patch_data patch; 1780 struct ps_data ps; 1781 struct renice_data renice; 1782 struct sed_data sed; 1783 struct sort_data sort; 1784 struct split_data split; 1785 struct strings_data strings; 1786 struct tail_data tail; 1787 struct tar_data tar; 1788 struct tee_data tee; 1789 struct touch_data touch; 1790 struct ulimit_data ulimit; 1791 struct uniq_data uniq; 1792 struct uudecode_data uudecode; 1793 struct wc_data wc; 1794 struct xargs_data xargs; 1795 } this; 1796