示例#1
0
文件: main.c 项目: kimi8187/backtrace
int main()
{
	int a = 4, b = 5;
	int (*funcptr)(int, int) = func0;
	
	int c = func0(a, b);
	printf("%s: c = %d\n", __FUNCTION__, c);
	
	printf("funcptr's name = %s\n", addr_to_name((unsigned long)funcptr));
	return 0;
}
示例#2
0
/*
 *                           u_accept
 * Wait for a from a host on a specified port.
 *
 * parameters:
 *      fd = file descriptor previously bound to listening port
 *      hostn = name of host to listen for
 *      hostnsize = size of hostn buffer
 * returns:  communication file descriptor or -1 on error
 *
 * comments: This function is used by the server to wait for a
 * communication.  It blocks until a remote request is received
 * from the port bound to the given file descriptor.
 * hostn is filled with an ASCII string containing the remote
 * host name.  It must point to a buffer of size at least hostnsize.
 * If the name does not fit, as much of the name as is possible is put
 * into the buffer.
 * If hostn is NULL or hostnsize <= 0, no hostname is copied.
 */
int u_accept(int fd, char *hostn, int hostnsize)
{
   int len = sizeof(struct sockaddr);
   struct sockaddr_in net_client;
   int retval;

   while ( ((retval =
           accept(fd, (struct sockaddr *)(&net_client), &len)) == -1) &&
          (errno == EINTR) )
      ;
   if ( (retval == -1) || (hostn == NULL) || (hostnsize <= 0) )
      return retval;
   addr_to_name(net_client.sin_addr,hostn,hostnsize);
   return retval;
}