We are not allowed to do your schoolwork for you. But I'll give you a few hints. Code like this:
Quote:
Originally posted by jj1814
is not going to run a "date" command. It's simply incredible that you think it might. execve is not going to ignore its arguments. You need to parse the command line and dynamically build arguments for the execve call.
And you should switch to execv anyway. As it is, you are clobbering the environment.
And, for now, require the user to enter "/usr/bin/date" rather than "date" so you don't need to search the PATH. You can get fancy later.
I've just installed redhat 6.2 on one of my systems and am trying to install the gcc c compiler after downloading an rpm from the redhat site. The damn thing gives me:
only major numbers <= 3 are supported by this version of RPM
what do I do, it does the same with the latest rpm of php
... (7 Replies)
Hi everyone,
I have a requirement that requires me to fill an sqlite database with 100,000 entries (no duplicates).
I will start out by giving the command that will insert the values necessary to populate the database:
# sqlite /var/local/database/dblist "insert into list... (2 Replies)
I've been able to generate output based on the code scarfake provided me (thanks again man).
A little background so everyone more or less knows whats going on:
I needed code that would propagate a database with 100,000 entries, for capacity testing purposes, something like a stress test.
... (5 Replies)
I don't want to speak about the goods or bads of both kinds of Operating systems, I only want to share a little experience with you to comment it.
I live in Spain and I have home some old unix systems, some of them that I want to sell or change for other things, like a pair of Sun Blade 2000... (0 Replies)
I have a file that is 20 - 80+ MB in size that is a certain type of log file.
It logs one of our processes and this process is multi-threaded. Therefore the log file is kind of a mess. Here's an example:
The logfile looks like: "DATE TIME - THREAD ID - Details", and a new file is created... (4 Replies)
I am writing a bash script to automate the installation of web environment on a base install of Fedora. And I'm at the limit of my last nerve and my bash skills. My brain is screaming at me: "Give up and use perl", but I am trying to stick to bash since the script will modify the perl environment... (6 Replies)
Hi guys!
I'll simplify my problem. I have the following code:
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <signal.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/wait.h>
#define max 25
#define buffdim 50
void p1();
void p2();... (2 Replies)
Discussion started by: pfpietro
2 Replies
LEARN ABOUT DEBIAN
hash_install
HASH(3pub) C Programmer's Manual HASH(3pub)NAME
hash_create, hash_destroy, hash_install, hash_lookup, hash_uninstall, hash_iter - generic hash tables
SYNOPSIS
#include <publib.h>
Hashtab *hash_create(unsigned long (*fun)(void *),
int (*cmp)(const void *, const void *));
void hash_destroy(Hashtab *ht);
void *hash_install(Hashtab *ht, void *data, size_t size);
void *hash_lookup(Hashtab *ht, void *data);
int hash_uninstall(Hashtab *ht, void *data);
int hash_iter(Hashtab *ht, int (*doit)(void *, void *), void *param);
DESCRIPTION
These functions implement generic hash tables. The table is created by hash_create and destroyed by hash_destroy. The fun argument is a
pointer to the hashing function, which must convert a datum to an unsigned long, which is then converted to an index into the hashing ta-
ble. cmp is a qsort(3)-like comparison functions, used to compare to (wannabe) hash table elements.
hash_install installs a new datum into the table. A pointer to the data and the size of the data are given as the arguments. If the size
is 0, only the pointer value is copied to the table. Otherwise a copy of the data is made into dynamically allocated memory.
hash_lookup attempts to find a datum in the hash table. A pointer to another datum is given as the argument. The comparison function
should compare equal (return 0) the desired datum and this datum (but the argument needn't be a fully initialized datum, although that is
up to the writer of the comparison function). There cannot be two elements in the hash table that are equal (the comparison function
returns 0 for them). It is up to the user to handle collisions.
hash_uninstall removes an element from a table. The argument is a pointer to a datum that identifies the element.
hash_iter goes through every element in the hash table and calls the doit function for each. The first argument it provides to doit is the
element in question, the second is whatever was given to hash_iter as param. If doit returns -1 or 0 for any element in the hash table,
hash_iter immediately returns without going through the remaining elements in the hash table. Any other return value from doit is ignored.
RETURNS
hash_create returns a pointer to the new hash table, or NULL if it fails.
hash_install returns a pointer to an element in the table (either the installed one, or one that was already installed, if one tries to
install the same datum twice).
hash_uninstall returns 0 if it found the element in the array, or -1 if it didn't.
hash_lookup return a pointer to the element it finds, or NULL if it doesn't find anything beautiful.
hash_iter returns -1, 0, or 1. If hash_iter receives a return value of -1 or 0 for some element from doit, hash_iter immediately returns
-1 or 0, respectively. In all other cases hash_iter returns 1.
SEE ALSO publib(3), qsort(3), bsearch(3)AUTHOR
Lars Wirzenius (lars.wirzenius@helsinki.fi)
Publib C Programmer's Manual HASH(3pub)