Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 4263 → Rev 4264

/trunk/uspace/app/bdsh/input.c
146,7 → 146,6
void get_input(cliuser_t *usr)
{
char line[INPUT_MAX];
size_t len = 0;
 
console_set_style(STYLE_EMPHASIS);
printf("%s", usr->prompt);
153,9 → 152,8
console_set_style(STYLE_NORMAL);
 
read_line(line, INPUT_MAX);
len = strlen(line);
/* Make sure we don't have rubbish or a C/R happy user */
if (len == 0 || line[0] == '\n')
if (str_cmp(line, "") == 0 || str_cmp(line, "\n") == 0)
return;
usr->line = strdup(line);
 
/trunk/uspace/app/bdsh/cmds/mod_cmds.c
64,7 → 64,7
return -2;
 
for (mod = modules; mod->name != NULL; mod++, i++) {
if (!strcmp(mod->name, command))
if (!str_cmp(mod->name, command))
return i;
}
 
81,7 → 81,7
return -1;
 
for(i=0; mod_aliases[i] != NULL; i+=2) {
if (!strcmp(mod_aliases[i], command))
if (!str_cmp(mod_aliases[i], command))
return 1;
}
 
97,7 → 97,7
return (char *)NULL;
 
for(i=0; mod_aliases[i] != NULL; i++) {
if (!strcmp(mod_aliases[i], command))
if (!str_cmp(mod_aliases[i], command))
return (char *)mod_aliases[++i];
i++;
}
/trunk/uspace/app/bdsh/cmds/modules/mkdir/mkdir.c
149,7 → 149,7
while (dirs[i] != NULL) {
/* Sometimes make or scripts conjoin odd paths. Account for something
* like this: ../../foo/bar/../foo/foofoo/./bar */
if (!strcmp(dirs[i], "..") || !strcmp(dirs[i], ".")) {
if (!str_cmp(dirs[i], "..") || !str_cmp(dirs[i], ".")) {
if (0 != (chdir(dirs[i]))) {
cli_error(CL_EFAIL, "%s: impossible path: %s",
cmdname, path);
/trunk/uspace/app/bdsh/cmds/modules/help/help.c
107,7 → 107,7
}
 
if (argc == 3) {
if (!strcmp("extended", argv[2]))
if (!str_cmp("extended", argv[2]))
level = HELP_LONG;
else
level = HELP_SHORT;
/trunk/uspace/app/bdsh/cmds/modules/rm/rm.c
216,7 → 216,7
 
i = optind;
while (NULL != argv[i]) {
len = strlen(argv[i]) + 2;
len = str_size(argv[i]) + 2;
buff = (char *) realloc(buff, len);
if (buff == NULL) {
printf("rm: out of memory\n");
/trunk/uspace/app/bdsh/cmds/builtin_cmds.c
49,7 → 49,7
return -2;
 
for (cmd = builtins; cmd->name != NULL; cmd++, i++) {
if (!strcmp(cmd->name, command))
if (!str_cmp(cmd->name, command))
return i;
}
 
64,7 → 64,7
return -1;
 
for(i=0; builtin_aliases[i] != NULL; i+=2) {
if (!strcmp(builtin_aliases[i], command))
if (!str_cmp(builtin_aliases[i], command))
return 1;
}
 
79,7 → 79,7
return (char *)NULL;
 
for(i=0; builtin_aliases[i] != NULL; i++) {
if (!strcmp(builtin_aliases[i], command))
if (!str_cmp(builtin_aliases[i], command))
return (char *)builtin_aliases[++i];
i++;
}
/trunk/uspace/app/bdsh/exec.c
71,7 → 71,7
char *path_tok;
char *path[PATH_MAX];
int n = 0, i = 0;
size_t x = strlen(cmd) + 2;
size_t x = str_size(cmd) + 2;
 
found = (char *)malloc(PATH_MAX);
 
85,7 → 85,7
/* Extract the PATH env to a path[] array */
path[n] = strtok(path_tok, PATH_DELIM);
while (NULL != path[n]) {
if ((strlen(path[n]) + x ) > PATH_MAX) {
if ((str_size(path[n]) + x ) > PATH_MAX) {
cli_error(CL_ENOTSUP,
"Segment %d of path is too large, search ends at segment %d",
n, n-1);
/trunk/uspace/app/tester/devmap/devmap1.c
140,7 → 140,7
req = async_send_2(phone, DEVMAP_DRIVER_REGISTER, 0, 0, &answer);
 
retval = ipc_data_write_start(phone, (char *)name, strlen(name) + 1);
retval = ipc_data_write_start(phone, (char *)name, str_size(name) + 1);
 
if (retval != EOK) {
async_wait_for(req, NULL);
173,7 → 173,7
req = async_send_2(driver_phone, DEVMAP_DEVICE_GET_HANDLE, 0, 0,
&answer);
 
retval = ipc_data_write_start(driver_phone, name, strlen(name) + 1);
retval = ipc_data_write_start(driver_phone, name, str_size(name) + 1);
 
if (retval != EOK) {
printf("Failed to send device name '%s'.\n", name);
215,7 → 215,7
req = async_send_2(driver_phone, DEVMAP_DEVICE_REGISTER, 0, 0, &answer);
 
retval = ipc_data_write_start(driver_phone, (char *)name,
strlen(name) + 1);
str_size(name) + 1);
 
if (retval != EOK) {
printf("Failed to send device name '%s'.\n", name);
/trunk/uspace/app/tetris/scores.c
289,7 → 289,7
/* change = 0; */
/* me = thisuser(); */
/* for (i = 0, sp = &scores[0]; i < nscores; i++, sp++) { */
/* if (sp->hs_level != level || strcmp(sp->hs_name, me) != 0) */
/* if (sp->hs_level != level || str_cmp(sp->hs_name, me) != 0) */
/* continue; */
/* if (score > sp->hs_score) { */
/* (void)printf("%s bettered %s %d score of %d!\n", */
417,7 → 417,7
/* * This is O(n^2), but do you think we care? */
/* *\/ */
/* for (j = 0, pu = count; j < numnames; j++, pu++) */
/* if (strcmp(sp->hs_name, pu->name) == 0) */
/* if (str_cmp(sp->hs_name, pu->name) == 0) */
/* break; */
/* if (j == numnames) { */
/* /\* */
554,7 → 554,7
/* if (me != NULL && */
/* sp->hs_level == level && */
/* sp->hs_score == score && */
/* strcmp(sp->hs_name, me) == 0) { */
/* str_cmp(sp->hs_name, me) == 0) { */
/* putpad(SOstr); */
/* highlight = 1; */
/* } */
/trunk/uspace/app/tetris/screen.c
280,7 → 280,7
scr_msg(char *s, int set)
{
int l = strlen(s);
int l = str_size(s);
moveto(Rows - 2, ((Cols - l) >> 1) - 1);
if (set)
/trunk/uspace/app/tetris/tetris.c
277,7 → 277,7
/* classic = 1; */
/* break; */
/* case 'k': */
/* if (strlen(keys = optarg) != 6) */
/* if (str_size(keys = optarg) != 6) */
/* usage(); */
/* break; */
/* case 'l': */
/trunk/uspace/lib/libc/include/string.h
45,8 → 45,8
/**< No size limit constant */
#define STR_NO_LIMIT ((size_t) -1)
 
/**< Maximum size of a string containing cnt characters */
#define STR_BOUNDS(cnt) (cnt << 2)
/**< Maximum size of a string containing @c length characters */
#define STR_BOUNDS(length) ((length) << 2)
 
extern wchar_t str_decode(const char *str, size_t *offset, size_t sz);
extern int chr_encode(const wchar_t ch, char *str, size_t *offset, size_t sz);
81,7 → 81,6
* TODO: Get rid of this.
*/
 
extern int strcmp(const char *, const char *);
extern int strncmp(const char *, const char *, size_t);
extern int stricmp(const char *, const char *);
 
90,8 → 89,6
 
extern char *strcat(char *, const char *);
 
extern size_t strlen(const char *);
 
extern char *strdup(const char *);
 
extern char *strchr(const char *, int);
/trunk/uspace/lib/libc/include/stdio.h
49,7 → 49,7
int n; \
n = snprintf(buf, sizeof(buf), fmt, ##__VA_ARGS__); \
if (n > 0) \
(void) __SYSCALL3(SYS_KLOG, 1, (sysarg_t) buf, strlen(buf)); \
(void) __SYSCALL3(SYS_KLOG, 1, (sysarg_t) buf, str_size(buf)); \
}
 
typedef struct {
/trunk/uspace/lib/libc/generic/console.c
219,7 → 219,7
size_t len;
ssize_t rc;
 
len = strlen(s);
len = str_size(s);
while (len > 0) {
rc = console_write(s, len);
if (rc < 0)
/trunk/uspace/lib/libc/generic/getopt.c
382,7 → 382,7
current_argv_len = has_equal - current_argv;
has_equal++;
} else
current_argv_len = strlen(current_argv);
current_argv_len = str_size(current_argv);
for (i = 0; long_options[i].name; i++) {
/* find matching long option */
390,7 → 390,7
current_argv_len))
continue;
 
if (strlen(long_options[i].name) ==
if (str_size(long_options[i].name) ==
(unsigned)current_argv_len) {
/* exact match */
match = i;
/trunk/uspace/lib/libc/generic/string.c
606,31 → 606,6
return true;
}
 
/** Count the number of characters in the string, not including terminating 0.
*
* @param str String.
* @return Number of characters in string.
*/
size_t strlen(const char *str)
{
size_t counter = 0;
 
while (str[counter] != 0)
counter++;
 
return counter;
}
 
int strcmp(const char *a, const char *b)
{
int c = 0;
while (a[c] && b[c] && (!(a[c] - b[c])))
c++;
return (a[c] - b[c]);
}
 
int strncmp(const char *a, const char *b, size_t n)
{
size_t c = 0;
870,7 → 845,7
 
char * strdup(const char *s1)
{
size_t len = strlen(s1) + 1;
size_t len = str_size(s1) + 1;
void *ret = malloc(len);
 
if (ret == NULL)
/trunk/uspace/srv/rd/rd.c
196,7 → 196,7
req = async_send_2(phone, DEVMAP_DRIVER_REGISTER, 0, 0, &answer);
 
retval = ipc_data_write_start(phone, (char *) name, strlen(name) + 1);
retval = ipc_data_write_start(phone, (char *) name, str_size(name) + 1);
 
if (retval != EOK) {
async_wait_for(req, NULL);
219,7 → 219,8
 
req = async_send_2(driver_phone, DEVMAP_DEVICE_REGISTER, 0, 0, &answer);
 
retval = ipc_data_write_start(driver_phone, (char *) name, strlen(name) + 1);
retval = ipc_data_write_start(driver_phone, (char *) name,
str_size(name) + 1);
 
if (retval != EOK) {
async_wait_for(req, NULL);
/trunk/uspace/srv/loader/main.c
150,11 → 150,11
static void loader_set_args(ipc_callid_t rid, ipc_call_t *request)
{
ipc_callid_t callid;
size_t buf_len, arg_len;
size_t buf_size, arg_size;
char *p;
int n;
if (!ipc_data_write_receive(&callid, &buf_len)) {
if (!ipc_data_write_receive(&callid, &buf_size)) {
ipc_answer_0(callid, EINVAL);
ipc_answer_0(rid, EINVAL);
return;
170,7 → 170,7
argv = NULL;
}
arg_buf = malloc(buf_len + 1);
arg_buf = malloc(buf_size + 1);
if (!arg_buf) {
ipc_answer_0(callid, ENOMEM);
ipc_answer_0(rid, ENOMEM);
177,9 → 177,9
return;
}
ipc_data_write_finalize(callid, arg_buf, buf_len);
ipc_data_write_finalize(callid, arg_buf, buf_size);
arg_buf[buf_len] = '\0';
arg_buf[buf_size] = '\0';
/*
* Count number of arguments
186,9 → 186,9
*/
p = arg_buf;
n = 0;
while (p < arg_buf + buf_len) {
arg_len = strlen(p);
p = p + arg_len + 1;
while (p < arg_buf + buf_size) {
arg_size = str_size(p);
p = p + arg_size + 1;
++n;
}
206,11 → 206,11
*/
p = arg_buf;
n = 0;
while (p < arg_buf + buf_len) {
while (p < arg_buf + buf_size) {
argv[n] = p;
arg_len = strlen(p);
p = p + arg_len + 1;
arg_size = str_size(p);
p = p + arg_size + 1;
++n;
}
/trunk/uspace/srv/fs/tmpfs/tmpfs_dump.c
177,7 → 177,7
goto error;
tag[5] = 0;
if (strcmp(tag, "TMPFS") != 0)
if (str_cmp(tag, "TMPFS") != 0)
goto error;
if (!tmpfs_restore_recursion(dev, &bufpos, &buflen, &pos,
/trunk/uspace/srv/fs/tmpfs/tmpfs_ops.c
255,7 → 255,7
link_t *hlp = hash_table_find(&childp->names, &key);
assert(hlp);
tmpfs_name_t *namep = hash_table_get_instance(hlp, tmpfs_name_t, link);
return !strcmp(namep->name, component);
return !str_cmp(namep->name, component);
}
 
void *tmpfs_match(void *prnt, const char *component)
319,8 → 319,8
if (!namep)
return ENOMEM;
tmpfs_name_initialize(namep);
size_t len = strlen(nm);
namep->name = malloc(len + 1);
size_t size = str_size(nm);
namep->name = malloc(size + 1);
if (!namep->name) {
free(namep);
return ENOMEM;
454,8 → 454,8
* Receive the read request.
*/
ipc_callid_t callid;
size_t len;
if (!ipc_data_read_receive(&callid, &len)) {
size_t size;
if (!ipc_data_read_receive(&callid, &size)) {
ipc_answer_0(callid, EINVAL);
ipc_answer_0(rid, EINVAL);
return;
463,7 → 463,7
 
size_t bytes;
if (dentry->type == TMPFS_FILE) {
bytes = max(0, min(dentry->size - pos, len));
bytes = max(0, min(dentry->size - pos, size));
(void) ipc_data_read_finalize(callid, dentry->data + pos,
bytes);
} else {
494,7 → 494,7
link);
 
(void) ipc_data_read_finalize(callid, namep->name,
strlen(namep->name) + 1);
str_size(namep->name) + 1);
bytes = 1;
}
 
527,8 → 527,8
* Receive the write request.
*/
ipc_callid_t callid;
size_t len;
if (!ipc_data_write_receive(&callid, &len)) {
size_t size;
if (!ipc_data_write_receive(&callid, &size)) {
ipc_answer_0(callid, EINVAL);
ipc_answer_0(rid, EINVAL);
return;
537,13 → 537,13
/*
* Check whether the file needs to grow.
*/
if (pos + len <= dentry->size) {
if (pos + size <= dentry->size) {
/* The file size is not changing. */
(void) ipc_data_write_finalize(callid, dentry->data + pos, len);
ipc_answer_2(rid, EOK, len, dentry->size);
(void) ipc_data_write_finalize(callid, dentry->data + pos, size);
ipc_answer_2(rid, EOK, size, dentry->size);
return;
}
size_t delta = (pos + len) - dentry->size;
size_t delta = (pos + size) - dentry->size;
/*
* At this point, we are deliberately extremely straightforward and
* simply realloc the contents of the file on every write that grows the
561,8 → 561,8
memset(newdata + dentry->size, 0, delta);
dentry->size += delta;
dentry->data = newdata;
(void) ipc_data_write_finalize(callid, dentry->data + pos, len);
ipc_answer_2(rid, EOK, len, dentry->size);
(void) ipc_data_write_finalize(callid, dentry->data + pos, size);
ipc_answer_2(rid, EOK, size, dentry->size);
}
 
void tmpfs_truncate(ipc_callid_t rid, ipc_call_t *request)
/trunk/uspace/srv/fs/fat/fat_dentry.c
62,6 → 62,8
int fat_dentry_namecmp(char *name, const char *component)
{
int rc;
size_t size;
 
if (!(rc = stricmp(name, component)))
return rc;
if (!strchr(name, '.')) {
69,8 → 71,9
* There is no '.' in the name, so we know that there is enough
* space for appending an extra '.' to name.
*/
name[strlen(name)] = '.';
name[strlen(name) + 1] = '\0';
size = str_size(name);
name[size] = '.';
name[size + 1] = '\0';
rc = stricmp(name, component);
}
return rc;
/trunk/uspace/srv/fs/fat/fat_ops.c
487,7 → 487,7
b = fat_block_get(bs, childp, 0, BLOCK_FLAGS_NONE);
d = (fat_dentry_t *)b->data;
if (fat_classify_dentry(d) == FAT_DENTRY_LAST ||
strcmp(d->name, FAT_NAME_DOT) == 0) {
str_cmp(d->name, FAT_NAME_DOT) == 0) {
memset(d, 0, sizeof(fat_dentry_t));
strcpy(d->name, FAT_NAME_DOT);
strcpy(d->ext, FAT_EXT_PAD);
497,7 → 497,7
}
d++;
if (fat_classify_dentry(d) == FAT_DENTRY_LAST ||
strcmp(d->name, FAT_NAME_DOT_DOT) == 0) {
str_cmp(d->name, FAT_NAME_DOT_DOT) == 0) {
memset(d, 0, sizeof(fat_dentry_t));
strcpy(d->name, FAT_NAME_DOT_DOT);
strcpy(d->ext, FAT_EXT_PAD);
937,7 → 937,7
ipc_answer_1(rid, ENOENT, 0);
return;
hit:
(void) ipc_data_read_finalize(callid, name, strlen(name) + 1);
(void) ipc_data_read_finalize(callid, name, str_size(name) + 1);
bytes = (pos - spos) + 1;
}
 
/trunk/uspace/srv/pci/libpci/names.c
103,7 → 103,7
u32 id34 = id_pair(id3, id4);
unsigned int h = id_hash(cat, id12, id34);
struct id_entry *n = a->id_hash[h];
int len = strlen((char *) text);
int len = str_size((char *) text);
 
while (n && (n->id12 != id12 || n->id34 != id34 || n->cat != cat))
n = n->next;
/trunk/uspace/srv/devmap/devmap.c
563,7 → 563,7
ipc_answer_0(iid, EOK);
size_t name_size = strlen(device->name);
size_t name_size = str_size(device->name);
/* FIXME:
* We have no channel from DEVMAP to client, therefore
/trunk/uspace/srv/vfs/vfs_ops.c
91,7 → 91,7
if (rootfs.fs_handle) {
/* We already have the root FS. */
rwlock_write_lock(&namespace_rwlock);
if ((strlen(mp) == 1) && (mp[0] == '/')) {
if (str_cmp(mp, "/") == 0) {
/* Trying to mount root FS over root FS */
rwlock_write_unlock(&namespace_rwlock);
futex_up(&rootfs_futex);
124,7 → 124,7
rwlock_write_unlock(&namespace_rwlock);
} else {
/* We still don't have the root file system mounted. */
if ((strlen(mp) == 1) && (mp[0] == '/')) {
if (str_cmp(mp, "/") == 0) {
vfs_lookup_res_t mr_res;
vfs_node_t *mr_node;
ipcarg_t rindex;