1) ping cleanup (compile fix from this patch already applied).
2) traceroute call not spare ntohl() now (and reduce size);
3) Fix for functions not declared static in insmod, ash, vi and mount.
4) a more simple API cmdedit :))
5) adds "stopped jobs" warning to ash on Ctrl-D and fixes "ignoreeof" option
6) reduce exporting library function index->strchr (traceroute), bzero->memset (syslogd)
#include <string.h>
#include "libbb.h"
-FILE *in_file, *out_file;
+static FILE *in_file, *out_file;
/* these are freed by gz_close */
static unsigned char *window;
static long bytes_out; /* number of output bytes */
static unsigned long outcnt; /* bytes in output buffer */
-unsigned hufts; /* track memory usage */
-unsigned long bb; /* bit buffer */
-unsigned bk; /* bits in bit buffer */
+static unsigned hufts; /* track memory usage */
+static unsigned long bb; /* bit buffer */
+static unsigned bk; /* bits in bit buffer */
typedef struct huft_s {
unsigned char e; /* number of extra bits or operation */
} v;
} huft_t;
-unsigned short mask_bits[] = {
+static const unsigned short mask_bits[] = {
0x0000,
0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff,
0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff
* Write the output window window[0..outcnt-1] and update crc and bytes_out.
* (Used for the decompressed data only.)
*/
-void flush_window()
+static void flush_window(void)
{
int n;
if (waitpid(gunzip_pid, NULL, 0) == -1) {
printf("Couldnt wait ?");
}
- if (window) {
free(window);
- }
- if (crc_table) {
free(crc_table);
- }
}
#include <string.h>
#include "libbb.h"
-FILE *in_file, *out_file;
+static FILE *in_file, *out_file;
/* these are freed by gz_close */
static unsigned char *window;
static long bytes_out; /* number of output bytes */
static unsigned long outcnt; /* bytes in output buffer */
-unsigned hufts; /* track memory usage */
-unsigned long bb; /* bit buffer */
-unsigned bk; /* bits in bit buffer */
+static unsigned hufts; /* track memory usage */
+static unsigned long bb; /* bit buffer */
+static unsigned bk; /* bits in bit buffer */
typedef struct huft_s {
unsigned char e; /* number of extra bits or operation */
} v;
} huft_t;
-unsigned short mask_bits[] = {
+static const unsigned short mask_bits[] = {
0x0000,
0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff,
0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff
* Write the output window window[0..outcnt-1] and update crc and bytes_out.
* (Used for the decompressed data only.)
*/
-void flush_window()
+static void flush_window(void)
{
int n;
if (waitpid(gunzip_pid, NULL, 0) == -1) {
printf("Couldnt wait ?");
}
- if (window) {
free(window);
- }
- if (crc_table) {
free(crc_table);
- }
}
if (!iflag)
nr = safe_read(parsefile->fd, buf, BUFSIZ - 1);
else {
- cmdedit_read_input((char*)cmdedit_prompt, buf);
- nr = strlen(buf);
+ nr = cmdedit_read_input((char*)cmdedit_prompt, buf);
}
}
#else
static struct nodelist *backquotelist;
static union node *redirnode;
-struct heredoc *heredoc;
+static struct heredoc *heredoc;
static int quoteflag; /* set if (part of) last token was quoted */
static int startlinno; /* line # where last token started */
/*
* Copyright (c) 1999 Herbert Xu <herbert@debian.org>
* This file contains code for the times builtin.
- * $Id: ash.c,v 1.10 2001/07/12 20:26:31 andersen Exp $
+ * $Id: ash.c,v 1.11 2001/07/17 01:12:35 andersen Exp $
*/
static int timescmd (int argc, char **argv)
{
*
*/
-extern void cmdedit_read_input(char *prompt, char command[BUFSIZ])
+
+int cmdedit_read_input(char *prompt, char command[BUFSIZ])
{
int break_out = 0;
* if the len=0 and no chars to delete */
if (len == 0) {
prepare_to_die:
+#if !defined(BB_FEATURE_ASH)
printf("exit");
goto_new_line();
/* cmdedit_reset_term() called in atexit */
exit(EXIT_SUCCESS);
+#else
+ break_out = -1; /* for control stoped jobs */
+ break;
+#endif
} else {
input_delete();
}
num_ok_lines++;
#endif
}
+ if(break_out>0) {
command[len++] = '\n'; /* set '\n' */
command[len] = 0;
+ }
#if defined(BB_FEATURE_CLEAN_UP) && defined(BB_FEATURE_COMMAND_TAB_COMPLETION)
input_tab(0); /* strong free */
#endif
free(cmdedit_prompt);
#endif
cmdedit_reset_term();
+ return len;
}
#ifndef CMDEDIT_H
#define CMDEDIT_H
-void cmdedit_read_input(char* promptStr, char* command); /* read a line of input */
+int cmdedit_read_input(char* promptStr, char* command);
#endif /* CMDEDIT_H */
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-char *vi_Version =
- "$Id: vi.c,v 1.11 2001/07/02 18:06:14 andersen Exp $";
+static const char vi_Version[] =
+ "$Id: vi.c,v 1.12 2001/07/17 01:12:36 andersen Exp $";
/*
* To compile for standalone use:
#ifndef MODUTILS_MODULE_H
static const int MODUTILS_MODULE_H = 1;
-#ident "$Id: insmod.c,v 1.67 2001/06/28 21:36:06 andersen Exp $"
+#ident "$Id: insmod.c,v 1.68 2001/07/17 01:12:36 andersen Exp $"
/* This file contains the structures used by the 2.0 and 2.1 kernels.
We do not use the kernel headers directly because we do not wish
#ifndef MODUTILS_OBJ_H
static const int MODUTILS_OBJ_H = 1;
-#ident "$Id: insmod.c,v 1.67 2001/06/28 21:36:06 andersen Exp $"
+#ident "$Id: insmod.c,v 1.68 2001/07/17 01:12:36 andersen Exp $"
/* The relocatable object is manipulated using elfin types. */
/* Generic object manipulation routines. */
-unsigned long obj_elf_hash(const char *);
+static unsigned long obj_elf_hash(const char *);
-unsigned long obj_elf_hash_n(const char *, unsigned long len);
+static unsigned long obj_elf_hash_n(const char *, unsigned long len);
-struct obj_symbol *obj_add_symbol (struct obj_file *f, const char *name,
- unsigned long symidx, int info, int secidx,
- ElfW(Addr) value, unsigned long size);
-
-struct obj_symbol *obj_find_symbol (struct obj_file *f,
+static struct obj_symbol *obj_find_symbol (struct obj_file *f,
const char *name);
-ElfW(Addr) obj_symbol_final_value(struct obj_file *f,
+static ElfW(Addr) obj_symbol_final_value(struct obj_file *f,
struct obj_symbol *sym);
-void obj_set_symbol_compare(struct obj_file *f,
+static void obj_set_symbol_compare(struct obj_file *f,
int (*cmp)(const char *, const char *),
unsigned long (*hash)(const char *));
-struct obj_section *obj_find_section (struct obj_file *f,
+static struct obj_section *obj_find_section (struct obj_file *f,
const char *name);
-void obj_insert_section_load_order (struct obj_file *f,
+static void obj_insert_section_load_order (struct obj_file *f,
struct obj_section *sec);
-struct obj_section *obj_create_alloced_section (struct obj_file *f,
+static struct obj_section *obj_create_alloced_section (struct obj_file *f,
const char *name,
unsigned long align,
unsigned long size);
-struct obj_section *obj_create_alloced_section_first (struct obj_file *f,
+static struct obj_section *obj_create_alloced_section_first (struct obj_file *f,
const char *name,
unsigned long align,
unsigned long size);
-void *obj_extend_section (struct obj_section *sec, unsigned long more);
+static void *obj_extend_section (struct obj_section *sec, unsigned long more);
-int obj_string_patch(struct obj_file *f, int secidx, ElfW(Addr) offset,
+static int obj_string_patch(struct obj_file *f, int secidx, ElfW(Addr) offset,
const char *string);
-int obj_symbol_patch(struct obj_file *f, int secidx, ElfW(Addr) offset,
+static int obj_symbol_patch(struct obj_file *f, int secidx, ElfW(Addr) offset,
struct obj_symbol *sym);
-int obj_check_undefineds(struct obj_file *f);
+static int obj_check_undefineds(struct obj_file *f);
-void obj_allocate_commons(struct obj_file *f);
+static void obj_allocate_commons(struct obj_file *f);
-unsigned long obj_load_size (struct obj_file *f);
+static unsigned long obj_load_size (struct obj_file *f);
-int obj_relocate (struct obj_file *f, ElfW(Addr) base);
+static int obj_relocate (struct obj_file *f, ElfW(Addr) base);
-struct obj_file *obj_load(FILE *f, int loadprogbits);
+static struct obj_file *obj_load(FILE *f, int loadprogbits);
-int obj_create_image (struct obj_file *f, char *image);
+static int obj_create_image (struct obj_file *f, char *image);
/* Architecture specific manipulation routines. */
-struct obj_file *arch_new_file (void);
+static struct obj_file *arch_new_file (void);
-struct obj_section *arch_new_section (void);
+static struct obj_section *arch_new_section (void);
-struct obj_symbol *arch_new_symbol (void);
+static struct obj_symbol *arch_new_symbol (void);
-enum obj_reloc arch_apply_relocation (struct obj_file *f,
+static enum obj_reloc arch_apply_relocation (struct obj_file *f,
struct obj_section *targsec,
struct obj_section *symsec,
struct obj_symbol *sym,
ElfW(RelM) *rel, ElfW(Addr) value);
-int arch_create_got (struct obj_file *f);
+static int arch_create_got (struct obj_file *f);
-struct new_module;
-int arch_init_module (struct obj_file *f, struct new_module *);
+static int arch_init_module (struct obj_file *f, struct new_module *);
#endif /* obj.h */
//----------------------------------------------------------------------------
/*======================================================================*/
-int flag_force_load = 0;
-int flag_autoclean = 0;
-int flag_verbose = 0;
-int flag_export = 1;
+static int flag_force_load = 0;
+static int flag_autoclean = 0;
+static int flag_verbose = 0;
+static int flag_export = 1;
/*======================================================================*/
struct new_module_symbol *syms;
};
-struct new_module_symbol *ksyms;
-size_t nksyms;
+static struct new_module_symbol *ksyms;
+static size_t nksyms;
-struct external_module *ext_modules;
-int n_ext_modules;
-int n_ext_modules_used;
+static struct external_module *ext_modules;
+static int n_ext_modules;
+static int n_ext_modules_used;
extern int delete_module(const char *);
static char m_filename[FILENAME_MAX + 1];
/*======================================================================*/
-struct obj_file *arch_new_file(void)
+static struct obj_file *arch_new_file(void)
{
struct arch_file *f;
f = xmalloc(sizeof(*f));
return &f->root;
}
-struct obj_section *arch_new_section(void)
+static struct obj_section *arch_new_section(void)
{
return xmalloc(sizeof(struct obj_section));
}
-struct obj_symbol *arch_new_symbol(void)
+static struct obj_symbol *arch_new_symbol(void)
{
struct arch_symbol *sym;
sym = xmalloc(sizeof(*sym));
return &sym->root;
}
-enum obj_reloc
+static enum obj_reloc
arch_apply_relocation(struct obj_file *f,
struct obj_section *targsec,
struct obj_section *symsec,
return ret;
}
-int arch_create_got(struct obj_file *f)
+static int arch_create_got(struct obj_file *f)
{
#if defined(BB_USE_GOT_ENTRIES) || defined(BB_USE_PLT_ENTRIES)
struct arch_file *ifile = (struct arch_file *) f;
return 1;
}
-int arch_init_module(struct obj_file *f, struct new_module *mod)
+static int arch_init_module(struct obj_file *f, struct new_module *mod)
{
return 1;
}
/*======================================================================*/
/* Standard ELF hash function. */
-inline unsigned long obj_elf_hash_n(const char *name, unsigned long n)
+static inline unsigned long obj_elf_hash_n(const char *name, unsigned long n)
{
unsigned long h = 0;
unsigned long g;
return h;
}
-unsigned long obj_elf_hash(const char *name)
+static unsigned long obj_elf_hash(const char *name)
{
return obj_elf_hash_n(name, strlen(name));
}
static int get_kernel_version(char str[STRVERSIONLEN])
{
struct utsname uts_info;
- char *p, *q;
- int a, b, c;
+ int kv;
if (uname(&uts_info) < 0)
return -1;
strncpy(str, uts_info.release, STRVERSIONLEN);
- p = uts_info.release;
- a = strtoul(p, &p, 10);
- if (*p != '.')
- return -1;
- b = strtoul(p + 1, &p, 10);
- if (*p != '.')
+ kv = get_kernel_revision();
+ if(kv==0)
return -1;
- c = strtoul(p + 1, &q, 10);
- if (p + 1 == q)
- return -1;
-
- return a << 16 | b << 8 | c;
}
/* String comparison for non-co-versioned kernel and module. */
return obj_elf_hash_n(str, len);
}
-void
+static void
obj_set_symbol_compare(struct obj_file *f,
int (*cmp) (const char *, const char *),
unsigned long (*hash) (const char *))
#endif /* BB_FEATURE_INSMOD_VERSION_CHECKING */
-
-struct obj_symbol *obj_add_symbol(struct obj_file *f, const char *name,
+static struct obj_symbol *
+obj_add_symbol(struct obj_file *f, const char *name,
unsigned long symidx, int info,
int secidx, ElfW(Addr) value,
unsigned long size)
return sym;
}
-struct obj_symbol *obj_find_symbol(struct obj_file *f, const char *name)
+static struct obj_symbol *
+obj_find_symbol(struct obj_file *f, const char *name)
{
struct obj_symbol *sym;
unsigned long hash = f->symbol_hash(name) % HASH_BUCKETS;
return NULL;
}
-ElfW(Addr)
+static ElfW(Addr)
obj_symbol_final_value(struct obj_file * f, struct obj_symbol * sym)
{
if (sym) {
}
}
-struct obj_section *obj_find_section(struct obj_file *f, const char *name)
+static struct obj_section *obj_find_section(struct obj_file *f, const char *name)
{
int i, n = f->header.e_shnum;
return ac;
}
-void
+static void
obj_insert_section_load_order(struct obj_file *f, struct obj_section *sec)
{
struct obj_section **p;
*p = sec;
}
-struct obj_section *obj_create_alloced_section(struct obj_file *f,
+static struct obj_section *obj_create_alloced_section(struct obj_file *f,
const char *name,
unsigned long align,
unsigned long size)
return sec;
}
-struct obj_section *obj_create_alloced_section_first(struct obj_file *f,
+static struct obj_section *obj_create_alloced_section_first(struct obj_file *f,
const char *name,
unsigned long align,
unsigned long size)
return sec;
}
-void *obj_extend_section(struct obj_section *sec, unsigned long more)
+static void *obj_extend_section(struct obj_section *sec, unsigned long more)
{
unsigned long oldsize = sec->header.sh_size;
if (more) {
}
-
/* Conditionally add the symbols from the given symbol set to the
new module. */
/*======================================================================*/
-int
+static int
obj_string_patch(struct obj_file *f, int secidx, ElfW(Addr) offset,
const char *string)
{
return 1;
}
-int
+static int
obj_symbol_patch(struct obj_file *f, int secidx, ElfW(Addr) offset,
struct obj_symbol *sym)
{
return 1;
}
-int obj_check_undefineds(struct obj_file *f)
+static int obj_check_undefineds(struct obj_file *f)
{
unsigned long i;
int ret = 1;
return ret;
}
-void obj_allocate_commons(struct obj_file *f)
+static void obj_allocate_commons(struct obj_file *f)
{
struct common_entry {
struct common_entry *next;
}
}
-unsigned long obj_load_size(struct obj_file *f)
+static unsigned long obj_load_size(struct obj_file *f)
{
unsigned long dot = 0;
struct obj_section *sec;
return dot;
}
-int obj_relocate(struct obj_file *f, ElfW(Addr) base)
+static int obj_relocate(struct obj_file *f, ElfW(Addr) base)
{
int i, n = f->header.e_shnum;
int ret = 1;
return ret;
}
-int obj_create_image(struct obj_file *f, char *image)
+static int obj_create_image(struct obj_file *f, char *image)
{
struct obj_section *sec;
ElfW(Addr) base = f->baseaddr;
/*======================================================================*/
-struct obj_file *obj_load(FILE * fp, int loadprogbits)
+static struct obj_file *obj_load(FILE * fp, int loadprogbits)
{
struct obj_file *f;
ElfW(Shdr) * section_headers;
* kernel for the module
*/
-int obj_load_progbits(FILE * fp, struct obj_file* f)
+static int obj_load_progbits(FILE * fp, struct obj_file* f)
{
char* imagebase = (char*) f->imagebase;
ElfW(Addr) base = f->baseaddr;
#include <string.h>
#include "libbb.h"
-FILE *in_file, *out_file;
+static FILE *in_file, *out_file;
/* these are freed by gz_close */
static unsigned char *window;
static long bytes_out; /* number of output bytes */
static unsigned long outcnt; /* bytes in output buffer */
-unsigned hufts; /* track memory usage */
-unsigned long bb; /* bit buffer */
-unsigned bk; /* bits in bit buffer */
+static unsigned hufts; /* track memory usage */
+static unsigned long bb; /* bit buffer */
+static unsigned bk; /* bits in bit buffer */
typedef struct huft_s {
unsigned char e; /* number of extra bits or operation */
} v;
} huft_t;
-unsigned short mask_bits[] = {
+static const unsigned short mask_bits[] = {
0x0000,
0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff,
0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff
* Write the output window window[0..outcnt-1] and update crc and bytes_out.
* (Used for the decompressed data only.)
*/
-void flush_window()
+static void flush_window(void)
{
int n;
if (waitpid(gunzip_pid, NULL, 0) == -1) {
printf("Couldnt wait ?");
}
- if (window) {
free(window);
- }
- if (crc_table) {
free(crc_table);
- }
}
#ifndef MODUTILS_MODULE_H
static const int MODUTILS_MODULE_H = 1;
-#ident "$Id: insmod.c,v 1.67 2001/06/28 21:36:06 andersen Exp $"
+#ident "$Id: insmod.c,v 1.68 2001/07/17 01:12:36 andersen Exp $"
/* This file contains the structures used by the 2.0 and 2.1 kernels.
We do not use the kernel headers directly because we do not wish
#ifndef MODUTILS_OBJ_H
static const int MODUTILS_OBJ_H = 1;
-#ident "$Id: insmod.c,v 1.67 2001/06/28 21:36:06 andersen Exp $"
+#ident "$Id: insmod.c,v 1.68 2001/07/17 01:12:36 andersen Exp $"
/* The relocatable object is manipulated using elfin types. */
/* Generic object manipulation routines. */
-unsigned long obj_elf_hash(const char *);
+static unsigned long obj_elf_hash(const char *);
-unsigned long obj_elf_hash_n(const char *, unsigned long len);
+static unsigned long obj_elf_hash_n(const char *, unsigned long len);
-struct obj_symbol *obj_add_symbol (struct obj_file *f, const char *name,
- unsigned long symidx, int info, int secidx,
- ElfW(Addr) value, unsigned long size);
-
-struct obj_symbol *obj_find_symbol (struct obj_file *f,
+static struct obj_symbol *obj_find_symbol (struct obj_file *f,
const char *name);
-ElfW(Addr) obj_symbol_final_value(struct obj_file *f,
+static ElfW(Addr) obj_symbol_final_value(struct obj_file *f,
struct obj_symbol *sym);
-void obj_set_symbol_compare(struct obj_file *f,
+static void obj_set_symbol_compare(struct obj_file *f,
int (*cmp)(const char *, const char *),
unsigned long (*hash)(const char *));
-struct obj_section *obj_find_section (struct obj_file *f,
+static struct obj_section *obj_find_section (struct obj_file *f,
const char *name);
-void obj_insert_section_load_order (struct obj_file *f,
+static void obj_insert_section_load_order (struct obj_file *f,
struct obj_section *sec);
-struct obj_section *obj_create_alloced_section (struct obj_file *f,
+static struct obj_section *obj_create_alloced_section (struct obj_file *f,
const char *name,
unsigned long align,
unsigned long size);
-struct obj_section *obj_create_alloced_section_first (struct obj_file *f,
+static struct obj_section *obj_create_alloced_section_first (struct obj_file *f,
const char *name,
unsigned long align,
unsigned long size);
-void *obj_extend_section (struct obj_section *sec, unsigned long more);
+static void *obj_extend_section (struct obj_section *sec, unsigned long more);
-int obj_string_patch(struct obj_file *f, int secidx, ElfW(Addr) offset,
+static int obj_string_patch(struct obj_file *f, int secidx, ElfW(Addr) offset,
const char *string);
-int obj_symbol_patch(struct obj_file *f, int secidx, ElfW(Addr) offset,
+static int obj_symbol_patch(struct obj_file *f, int secidx, ElfW(Addr) offset,
struct obj_symbol *sym);
-int obj_check_undefineds(struct obj_file *f);
+static int obj_check_undefineds(struct obj_file *f);
-void obj_allocate_commons(struct obj_file *f);
+static void obj_allocate_commons(struct obj_file *f);
-unsigned long obj_load_size (struct obj_file *f);
+static unsigned long obj_load_size (struct obj_file *f);
-int obj_relocate (struct obj_file *f, ElfW(Addr) base);
+static int obj_relocate (struct obj_file *f, ElfW(Addr) base);
-struct obj_file *obj_load(FILE *f, int loadprogbits);
+static struct obj_file *obj_load(FILE *f, int loadprogbits);
-int obj_create_image (struct obj_file *f, char *image);
+static int obj_create_image (struct obj_file *f, char *image);
/* Architecture specific manipulation routines. */
-struct obj_file *arch_new_file (void);
+static struct obj_file *arch_new_file (void);
-struct obj_section *arch_new_section (void);
+static struct obj_section *arch_new_section (void);
-struct obj_symbol *arch_new_symbol (void);
+static struct obj_symbol *arch_new_symbol (void);
-enum obj_reloc arch_apply_relocation (struct obj_file *f,
+static enum obj_reloc arch_apply_relocation (struct obj_file *f,
struct obj_section *targsec,
struct obj_section *symsec,
struct obj_symbol *sym,
ElfW(RelM) *rel, ElfW(Addr) value);
-int arch_create_got (struct obj_file *f);
+static int arch_create_got (struct obj_file *f);
-struct new_module;
-int arch_init_module (struct obj_file *f, struct new_module *);
+static int arch_init_module (struct obj_file *f, struct new_module *);
#endif /* obj.h */
//----------------------------------------------------------------------------
/*======================================================================*/
-int flag_force_load = 0;
-int flag_autoclean = 0;
-int flag_verbose = 0;
-int flag_export = 1;
+static int flag_force_load = 0;
+static int flag_autoclean = 0;
+static int flag_verbose = 0;
+static int flag_export = 1;
/*======================================================================*/
struct new_module_symbol *syms;
};
-struct new_module_symbol *ksyms;
-size_t nksyms;
+static struct new_module_symbol *ksyms;
+static size_t nksyms;
-struct external_module *ext_modules;
-int n_ext_modules;
-int n_ext_modules_used;
+static struct external_module *ext_modules;
+static int n_ext_modules;
+static int n_ext_modules_used;
extern int delete_module(const char *);
static char m_filename[FILENAME_MAX + 1];
/*======================================================================*/
-struct obj_file *arch_new_file(void)
+static struct obj_file *arch_new_file(void)
{
struct arch_file *f;
f = xmalloc(sizeof(*f));
return &f->root;
}
-struct obj_section *arch_new_section(void)
+static struct obj_section *arch_new_section(void)
{
return xmalloc(sizeof(struct obj_section));
}
-struct obj_symbol *arch_new_symbol(void)
+static struct obj_symbol *arch_new_symbol(void)
{
struct arch_symbol *sym;
sym = xmalloc(sizeof(*sym));
return &sym->root;
}
-enum obj_reloc
+static enum obj_reloc
arch_apply_relocation(struct obj_file *f,
struct obj_section *targsec,
struct obj_section *symsec,
return ret;
}
-int arch_create_got(struct obj_file *f)
+static int arch_create_got(struct obj_file *f)
{
#if defined(BB_USE_GOT_ENTRIES) || defined(BB_USE_PLT_ENTRIES)
struct arch_file *ifile = (struct arch_file *) f;
return 1;
}
-int arch_init_module(struct obj_file *f, struct new_module *mod)
+static int arch_init_module(struct obj_file *f, struct new_module *mod)
{
return 1;
}
/*======================================================================*/
/* Standard ELF hash function. */
-inline unsigned long obj_elf_hash_n(const char *name, unsigned long n)
+static inline unsigned long obj_elf_hash_n(const char *name, unsigned long n)
{
unsigned long h = 0;
unsigned long g;
return h;
}
-unsigned long obj_elf_hash(const char *name)
+static unsigned long obj_elf_hash(const char *name)
{
return obj_elf_hash_n(name, strlen(name));
}
static int get_kernel_version(char str[STRVERSIONLEN])
{
struct utsname uts_info;
- char *p, *q;
- int a, b, c;
+ int kv;
if (uname(&uts_info) < 0)
return -1;
strncpy(str, uts_info.release, STRVERSIONLEN);
- p = uts_info.release;
- a = strtoul(p, &p, 10);
- if (*p != '.')
- return -1;
- b = strtoul(p + 1, &p, 10);
- if (*p != '.')
+ kv = get_kernel_revision();
+ if(kv==0)
return -1;
- c = strtoul(p + 1, &q, 10);
- if (p + 1 == q)
- return -1;
-
- return a << 16 | b << 8 | c;
}
/* String comparison for non-co-versioned kernel and module. */
return obj_elf_hash_n(str, len);
}
-void
+static void
obj_set_symbol_compare(struct obj_file *f,
int (*cmp) (const char *, const char *),
unsigned long (*hash) (const char *))
#endif /* BB_FEATURE_INSMOD_VERSION_CHECKING */
-
-struct obj_symbol *obj_add_symbol(struct obj_file *f, const char *name,
+static struct obj_symbol *
+obj_add_symbol(struct obj_file *f, const char *name,
unsigned long symidx, int info,
int secidx, ElfW(Addr) value,
unsigned long size)
return sym;
}
-struct obj_symbol *obj_find_symbol(struct obj_file *f, const char *name)
+static struct obj_symbol *
+obj_find_symbol(struct obj_file *f, const char *name)
{
struct obj_symbol *sym;
unsigned long hash = f->symbol_hash(name) % HASH_BUCKETS;
return NULL;
}
-ElfW(Addr)
+static ElfW(Addr)
obj_symbol_final_value(struct obj_file * f, struct obj_symbol * sym)
{
if (sym) {
}
}
-struct obj_section *obj_find_section(struct obj_file *f, const char *name)
+static struct obj_section *obj_find_section(struct obj_file *f, const char *name)
{
int i, n = f->header.e_shnum;
return ac;
}
-void
+static void
obj_insert_section_load_order(struct obj_file *f, struct obj_section *sec)
{
struct obj_section **p;
*p = sec;
}
-struct obj_section *obj_create_alloced_section(struct obj_file *f,
+static struct obj_section *obj_create_alloced_section(struct obj_file *f,
const char *name,
unsigned long align,
unsigned long size)
return sec;
}
-struct obj_section *obj_create_alloced_section_first(struct obj_file *f,
+static struct obj_section *obj_create_alloced_section_first(struct obj_file *f,
const char *name,
unsigned long align,
unsigned long size)
return sec;
}
-void *obj_extend_section(struct obj_section *sec, unsigned long more)
+static void *obj_extend_section(struct obj_section *sec, unsigned long more)
{
unsigned long oldsize = sec->header.sh_size;
if (more) {
}
-
/* Conditionally add the symbols from the given symbol set to the
new module. */
/*======================================================================*/
-int
+static int
obj_string_patch(struct obj_file *f, int secidx, ElfW(Addr) offset,
const char *string)
{
return 1;
}
-int
+static int
obj_symbol_patch(struct obj_file *f, int secidx, ElfW(Addr) offset,
struct obj_symbol *sym)
{
return 1;
}
-int obj_check_undefineds(struct obj_file *f)
+static int obj_check_undefineds(struct obj_file *f)
{
unsigned long i;
int ret = 1;
return ret;
}
-void obj_allocate_commons(struct obj_file *f)
+static void obj_allocate_commons(struct obj_file *f)
{
struct common_entry {
struct common_entry *next;
}
}
-unsigned long obj_load_size(struct obj_file *f)
+static unsigned long obj_load_size(struct obj_file *f)
{
unsigned long dot = 0;
struct obj_section *sec;
return dot;
}
-int obj_relocate(struct obj_file *f, ElfW(Addr) base)
+static int obj_relocate(struct obj_file *f, ElfW(Addr) base)
{
int i, n = f->header.e_shnum;
int ret = 1;
return ret;
}
-int obj_create_image(struct obj_file *f, char *image)
+static int obj_create_image(struct obj_file *f, char *image)
{
struct obj_section *sec;
ElfW(Addr) base = f->baseaddr;
/*======================================================================*/
-struct obj_file *obj_load(FILE * fp, int loadprogbits)
+static struct obj_file *obj_load(FILE * fp, int loadprogbits)
{
struct obj_file *f;
ElfW(Shdr) * section_headers;
* kernel for the module
*/
-int obj_load_progbits(FILE * fp, struct obj_file* f)
+static int obj_load_progbits(FILE * fp, struct obj_file* f)
{
char* imagebase = (char*) f->imagebase;
ElfW(Addr) base = f->baseaddr;
}
}
-extern int
+static int
mount_one(char *blockDevice, char *directory, char *filesystemType,
unsigned long flags, char *string_flags, int useMtab, int fakeIt,
char *mtab_opts, int whineOnErrors, int mount_all)
/* vi: set sw=4 ts=4: */
/*
- * $Id: ping.c,v 1.45 2001/07/13 20:56:27 kraai Exp $
+ * $Id: ping.c,v 1.46 2001/07/17 01:12:36 andersen Exp $
* Mini ping implementation for busybox
*
* Copyright (C) 1999 by Randolph Chung <tausq@debian.org>
if (h->h_addrtype != AF_INET)
error_msg_and_die("unknown address type; only AF_INET is currently supported.");
- pingaddr.sin_family = AF_INET; /* h->h_addrtype */
memcpy(&pingaddr.sin_addr, h->h_addr, sizeof(pingaddr.sin_addr));
strncpy(buf, h->h_name, sizeof(buf) - 1);
hostname = buf;
* If the nflag has been supplied, give
* numeric value, otherwise try for symbolic name.
*/
-static inline char *
-inetname(struct in_addr in)
+static inline void
+inetname(struct sockaddr_in *from)
{
char *cp;
- static char line[50];
struct hostent *hp;
static char domain[MAXHOSTNAMELEN + 1];
static int first = 1;
+ const char *ina;
if (first && !nflag) {
first = 0;
if (gethostname(domain, MAXHOSTNAMELEN) == 0 &&
- (cp = index(domain, '.')))
+ (cp = strchr(domain, '.')))
(void) strcpy(domain, cp + 1);
else
domain[0] = 0;
}
cp = 0;
- if (!nflag && in.s_addr != INADDR_ANY) {
- hp = gethostbyaddr((char *)&in, sizeof (in), AF_INET);
+ if (!nflag && from->sin_addr.s_addr != INADDR_ANY) {
+ hp = gethostbyaddr((char *)&(from->sin_addr), sizeof (from->sin_addr), AF_INET);
if (hp) {
- if ((cp = index(hp->h_name, '.')) &&
+ if ((cp = strchr(hp->h_name, '.')) &&
!strcmp(cp + 1, domain))
*cp = 0;
cp = (char *)hp->h_name;
}
}
- if (cp)
- (void) strcpy(line, cp);
- else {
- in.s_addr = ntohl(in.s_addr);
- strcpy(line, inet_ntoa(in));
- }
- return (line);
+ ina = inet_ntoa(from->sin_addr);
+ if (nflag)
+ printf(" %s", ina);
+ else
+ printf(" %s (%s)", (cp ? cp : ina), ina);
}
static inline void
hlen = ip->ip_hl << 2;
cc -= hlen;
- if (nflag)
- printf(" %s", inet_ntoa(from->sin_addr));
- else
- printf(" %s (%s)", inetname(from->sin_addr),
- inet_ntoa(from->sin_addr));
-
+ inetname(from);
#ifdef BB_FEATURE_TRACEROUTE_VERBOSE
if (verbose)
printf (" %d bytes to %s", cc, inet_ntoa (ip->ip_dst));
/* vi: set sw=4 ts=4: */
/*
- * $Id: ping.c,v 1.45 2001/07/13 20:56:27 kraai Exp $
+ * $Id: ping.c,v 1.46 2001/07/17 01:12:36 andersen Exp $
* Mini ping implementation for busybox
*
* Copyright (C) 1999 by Randolph Chung <tausq@debian.org>
if (h->h_addrtype != AF_INET)
error_msg_and_die("unknown address type; only AF_INET is currently supported.");
- pingaddr.sin_family = AF_INET; /* h->h_addrtype */
memcpy(&pingaddr.sin_addr, h->h_addr, sizeof(pingaddr.sin_addr));
strncpy(buf, h->h_name, sizeof(buf) - 1);
hostname = buf;
if (!iflag)
nr = safe_read(parsefile->fd, buf, BUFSIZ - 1);
else {
- cmdedit_read_input((char*)cmdedit_prompt, buf);
- nr = strlen(buf);
+ nr = cmdedit_read_input((char*)cmdedit_prompt, buf);
}
}
#else
static struct nodelist *backquotelist;
static union node *redirnode;
-struct heredoc *heredoc;
+static struct heredoc *heredoc;
static int quoteflag; /* set if (part of) last token was quoted */
static int startlinno; /* line # where last token started */
/*
* Copyright (c) 1999 Herbert Xu <herbert@debian.org>
* This file contains code for the times builtin.
- * $Id: ash.c,v 1.10 2001/07/12 20:26:31 andersen Exp $
+ * $Id: ash.c,v 1.11 2001/07/17 01:12:35 andersen Exp $
*/
static int timescmd (int argc, char **argv)
{
*
*/
-extern void cmdedit_read_input(char *prompt, char command[BUFSIZ])
+
+int cmdedit_read_input(char *prompt, char command[BUFSIZ])
{
int break_out = 0;
* if the len=0 and no chars to delete */
if (len == 0) {
prepare_to_die:
+#if !defined(BB_FEATURE_ASH)
printf("exit");
goto_new_line();
/* cmdedit_reset_term() called in atexit */
exit(EXIT_SUCCESS);
+#else
+ break_out = -1; /* for control stoped jobs */
+ break;
+#endif
} else {
input_delete();
}
num_ok_lines++;
#endif
}
+ if(break_out>0) {
command[len++] = '\n'; /* set '\n' */
command[len] = 0;
+ }
#if defined(BB_FEATURE_CLEAN_UP) && defined(BB_FEATURE_COMMAND_TAB_COMPLETION)
input_tab(0); /* strong free */
#endif
free(cmdedit_prompt);
#endif
cmdedit_reset_term();
+ return len;
}
#ifndef CMDEDIT_H
#define CMDEDIT_H
-void cmdedit_read_input(char* promptStr, char* command); /* read a line of input */
+int cmdedit_read_input(char* promptStr, char* command);
#endif /* CMDEDIT_H */
struct iovec iov[IOV_COUNT];
struct iovec *v = iov;
- bzero(&res, sizeof(res));
+ memset(&res, 0, sizeof(res));
snprintf(res, sizeof(res), "<%d>", pri);
v->iov_base = res ;
v->iov_len = strlen(res);
struct hostent *hostinfo;
int len = sizeof(remoteaddr);
- bzero(&remoteaddr, len);
+ memset(&remoteaddr, 0, len);
remotefd = socket(AF_INET, SOCK_DGRAM, 0);
struct iovec iov[IOV_COUNT];
struct iovec *v = iov;
- bzero(&res, sizeof(res));
+ memset(&res, 0, sizeof(res));
snprintf(res, sizeof(res), "<%d>", pri);
v->iov_base = res ;
v->iov_len = strlen(res);
struct hostent *hostinfo;
int len = sizeof(remoteaddr);
- bzero(&remoteaddr, len);
+ memset(&remoteaddr, 0, len);
remotefd = socket(AF_INET, SOCK_DGRAM, 0);
* If the nflag has been supplied, give
* numeric value, otherwise try for symbolic name.
*/
-static inline char *
-inetname(struct in_addr in)
+static inline void
+inetname(struct sockaddr_in *from)
{
char *cp;
- static char line[50];
struct hostent *hp;
static char domain[MAXHOSTNAMELEN + 1];
static int first = 1;
+ const char *ina;
if (first && !nflag) {
first = 0;
if (gethostname(domain, MAXHOSTNAMELEN) == 0 &&
- (cp = index(domain, '.')))
+ (cp = strchr(domain, '.')))
(void) strcpy(domain, cp + 1);
else
domain[0] = 0;
}
cp = 0;
- if (!nflag && in.s_addr != INADDR_ANY) {
- hp = gethostbyaddr((char *)&in, sizeof (in), AF_INET);
+ if (!nflag && from->sin_addr.s_addr != INADDR_ANY) {
+ hp = gethostbyaddr((char *)&(from->sin_addr), sizeof (from->sin_addr), AF_INET);
if (hp) {
- if ((cp = index(hp->h_name, '.')) &&
+ if ((cp = strchr(hp->h_name, '.')) &&
!strcmp(cp + 1, domain))
*cp = 0;
cp = (char *)hp->h_name;
}
}
- if (cp)
- (void) strcpy(line, cp);
- else {
- in.s_addr = ntohl(in.s_addr);
- strcpy(line, inet_ntoa(in));
- }
- return (line);
+ ina = inet_ntoa(from->sin_addr);
+ if (nflag)
+ printf(" %s", ina);
+ else
+ printf(" %s (%s)", (cp ? cp : ina), ina);
}
static inline void
hlen = ip->ip_hl << 2;
cc -= hlen;
- if (nflag)
- printf(" %s", inet_ntoa(from->sin_addr));
- else
- printf(" %s (%s)", inetname(from->sin_addr),
- inet_ntoa(from->sin_addr));
-
+ inetname(from);
#ifdef BB_FEATURE_TRACEROUTE_VERBOSE
if (verbose)
printf (" %d bytes to %s", cc, inet_ntoa (ip->ip_dst));
}
}
-extern int
+static int
mount_one(char *blockDevice, char *directory, char *filesystemType,
unsigned long flags, char *string_flags, int useMtab, int fakeIt,
char *mtab_opts, int whineOnErrors, int mount_all)
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-char *vi_Version =
- "$Id: vi.c,v 1.11 2001/07/02 18:06:14 andersen Exp $";
+static const char vi_Version[] =
+ "$Id: vi.c,v 1.12 2001/07/17 01:12:36 andersen Exp $";
/*
* To compile for standalone use: