01-20-2006
struct tm problem
I receive an integer as argument for a function.
within function definition i want it to be of type struct tm.
eg..
main()
{
int a;
......
}
function(...,..,a,..)
int a;
{
struct tm tm;
if(!a)
^ time(&a);
^ memcpy(&tm,localtime(&LogTime),sizeof(struct tm));
}
gives me error at the line ^ why ?
10 More Discussions You Might Find Interesting
1. Programming
Hi
We are using a code generator for initializing structures with the #define macro. Compiling it with the GCC 2.8.1 (with -ansi) it OK. But when we are using the SUN C 5.0 compiler it screams.
Following is a code sample:
#include <stdlib.h>
#include <stdio.h>
typedef struct TEST3 {... (4 Replies)
Discussion started by: amatsaka
4 Replies
2. Programming
I have a struct as follows...
struct A
{
int a;
ucontext_t X; //ucontext_t is another structure
}
How do I define a pointer to the above structure variable X of the type ucontext_t from within another function?
eg. void foo()
{
struct A a;
/////WHAT COMES IN... (1 Reply)
Discussion started by: jacques83
1 Replies
3. Programming
in my .c file i have a struct atop of the program defined as follows:
#define MAX 10
int curtab;
static struct tab {
int count;
int use;
} tab;
with the initial function following it like so:
int tab_create(int init_count)
{
int i;
for(i=0; i < MAX; i++)
{... (1 Reply)
Discussion started by: micmac700
1 Replies
4. UNIX for Advanced & Expert Users
iam trying to built a firewall.so i have used netfilter for it.
in function main_hook sock_buff is returning null and in my log file continuously "sock buff null" is printed plse help to solve this problem..
(using print_string iam printing strings on current terminal (terminal we ping))
... (1 Reply)
Discussion started by: pavan6754
1 Replies
5. UNIX for Dummies Questions & Answers
Can someone tell me how to do this?
Just a thought that entered my mind when learning about structs.
First thought was:
struct one
{
struct two;
}
struct two
{
three;
}
one->two->three
would this be how you would access "three"? (1 Reply)
Discussion started by: unbelievable21
1 Replies
6. Programming
Hi,
I found on linuxgazette.net/93/bhaskaran.html page very useful sample of virtual driver (not connected to real hardware).
I try to compile it with no effect.
So:
I got fresh Ubuntu 9.10 (kernel 2.6.31-14)
My source is saved in networkAdapter.c file in /usr/src/myModules directory.
I... (21 Replies)
Discussion started by: Chrisdot
21 Replies
7. UNIX for Dummies Questions & Answers
what is struct winsize used for?
i tried looking it up, but no luck. (0 Replies)
Discussion started by: l flipboi l
0 Replies
8. Programming
I have the following code and getting the compilation errors
baseLib/DynBaseObj.h:80: error: expected constructor, destructor, or type conversion before ‘(' token
baseLib/DynBaseObj.h:89: error: expected constructor, destructor, or type conversion before ‘(' token
baseLib/DynBaseObj.h:101:... (0 Replies)
Discussion started by: kristinu
0 Replies
9. Programming
Hello,
i'm trying to implement the times() function and i'm programming in C.
I'm using the "struct tms" structure which consists of the fields:
The tms_utime structure member is the CPU time charged for the execution of user instructions of the calling process.
The tms_stime structure... (1 Reply)
Discussion started by: g_p
1 Replies
10. Programming
Hi,
I have received an application that stores some properties in a file. The existing struct looks like this:
struct TData
{
UINT uSizeIncludingStrings;
// copy of Telnet data struct
UINT uSize;
// basic properties:
TCHAR szHost; //defined in Sshconfig
UINT iPortNr;
TCHAR... (2 Replies)
Discussion started by: Powerponken
2 Replies
LEARN ABOUT OPENSOLARIS
rtime
RTIME(3) Linux Programmer's Manual RTIME(3)
NAME
rtime - get time from a remote machine
SYNOPSIS
#include <rpc/auth_des.h>
int rtime(struct sockaddr_in *addrp, struct rpc_timeval *timep,
struct rpc_timeval *timeout);
DESCRIPTION
This function uses the Time Server Protocol as described in RFC 868 to obtain the time from a remote machine.
The Time Server Protocol gives the time in seconds since 00:00:00 UTC, 1 Jan 1900, and this function subtracts the appropriate constant in
order to convert the result to seconds since the Epoch, 1970-01-01 00:00:00 +0000 (UTC).
When timeout is non-NULL, the udp/time socket (port 37) is used. Otherwise, the tcp/time socket (port 37) is used.
RETURN VALUE
On success, 0 is returned, and the obtained 32-bit time value is stored in timep->tv_sec. In case of error -1 is returned, and errno is
set appropriately.
ERRORS
All errors for underlying functions (sendto(2), poll(2), recvfrom(2), connect(2), read(2)) can occur. Moreover:
EIO The number of returned bytes is not 4.
ETIMEDOUT
The waiting time as defined in timeout has expired.
ATTRIBUTES
For an explanation of the terms used in this section, see attributes(7).
+----------+---------------+---------+
|Interface | Attribute | Value |
+----------+---------------+---------+
|rtime() | Thread safety | MT-Safe |
+----------+---------------+---------+
NOTES
Only IPv4 is supported.
Some in.timed versions support only TCP. Try the example program with use_tcp set to 1.
Libc5 uses the prototype
int rtime(struct sockaddr_in *, struct timeval *, struct timeval *);
and requires <sys/time.h> instead of <rpc/auth_des.h>.
BUGS
rtime() in glibc 2.2.5 and earlier does not work properly on 64-bit machines.
EXAMPLE
This example requires that port 37 is up and open. You may check that the time entry within /etc/inetd.conf is not commented out.
The program connects to a computer called "linux". Using "localhost" does not work. The result is the localtime of the computer "linux".
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <time.h>
#include <rpc/auth_des.h>
#include <netdb.h>
static int use_tcp = 0;
static char *servername = "linux";
int
main(void)
{
struct sockaddr_in name;
struct rpc_timeval time1 = {0,0};
struct rpc_timeval timeout = {1,0};
struct hostent *hent;
int ret;
memset(&name, 0, sizeof(name));
sethostent(1);
hent = gethostbyname(servername);
memcpy(&name.sin_addr, hent->h_addr, hent->h_length);
ret = rtime(&name, &time1, use_tcp ? NULL : &timeout);
if (ret < 0)
perror("rtime error");
else {
time_t t = time1.tv_sec;
printf("%s
", ctime(&t));
}
exit(EXIT_SUCCESS);
}
SEE ALSO
ntpdate(1), inetd(8)
COLOPHON
This page is part of release 4.15 of the Linux man-pages project. A description of the project, information about reporting bugs, and the
latest version of this page, can be found at https://www.kernel.org/doc/man-pages/.
GNU 2017-09-15 RTIME(3)