• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ sclose函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中sclose函数的典型用法代码示例。如果您正苦于以下问题:C++ sclose函数的具体用法?C++ sclose怎么用?C++ sclose使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了sclose函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: main

/*
 * Application entry point.
 */
int main(int argc, char **argv) {

	// Skip first parameter (program name).
	argv++;
	
	// Open input file.
	STREAM sin;
	if (argv) {
		if (!(sin = sopenRead(*argv)))
			error("Error: Input file \"%s\" can not be open.", *argv)
		argv++;
	} else
		sin = STREAM_STDIN;
	
	// Open output file.
	STREAM sout;
	if (argv) {
		if (!(sout = sopenWrite(*argv)))
			error("Error: Output file \"%s\" can not be open.", *argv);
	} else
		sout = STREAM_STDOUT;
	
	// Proceed with filtering.
	filterComment(sin, sout);
	
	sclose(sin);
	sclose(sout);
	return 0;
}
开发者ID:ReCodEx,项目名称:worker,代码行数:32,代码来源:main.c


示例2: socket

char *Curl_if2ip(const char *interface, char *buf, int buf_size)
{
  int dummy;
  char *ip=NULL;

  if(!interface)
    return NULL;

  dummy = socket(AF_INET, SOCK_STREAM, 0);
  if (SYS_ERROR == dummy) {
    return NULL;
  }
  else {
    struct ifreq req;
    size_t len = strlen(interface);
    memset(&req, 0, sizeof(req));
    if(len >= sizeof(req.ifr_name))
      return NULL; /* this can't be a fine interface name */
    memcpy(req.ifr_name, interface, len+1);
    req.ifr_addr.sa_family = AF_INET;
#ifdef  IOCTL_3_ARGS
    if (SYS_ERROR == ioctl(dummy, SIOCGIFADDR, &req)) {
#else
    if (SYS_ERROR == ioctl(dummy, SIOCGIFADDR, &req, sizeof(req))) {
#endif
      sclose(dummy);
      return NULL;
    }
    else {
      struct in_addr in;

      union {
        struct sockaddr_in *sin;
        struct sockaddr *s;
      } soadd;

      soadd.s = &req.ifr_dstaddr;
      memcpy(&in, &(soadd.sin->sin_addr.s_addr), sizeof(in));
#if defined(HAVE_INET_NTOA_R)
      ip = inet_ntoa_r(in,buf,buf_size);
#else
      ip = strncpy(buf,inet_ntoa(in),buf_size);
      ip[buf_size - 1] = 0;
#endif
    }
    sclose(dummy);
  }
  return ip;
}

/* -- end of if2ip() -- */
#else
char *Curl_if2ip(const char *interface, char *buf, int buf_size)
{
    (void) interface;
    (void) buf;
    (void) buf_size;
    return NULL;
}
开发者ID:yyyyyao,项目名称:Slicer3-lib-mirrors,代码行数:59,代码来源:if2ip.c


示例3: zlibfile

/* <string> .libfile <string> false */
int                             /* exported for zsysvm.c */
zlibfile(i_ctx_t *i_ctx_p)
{
    os_ptr op = osp;
    int code;
    byte cname[DEFAULT_BUFFER_SIZE];
    uint clen;
    gs_parsed_file_name_t pname;
    stream *s;
    gx_io_device *iodev_dflt;

    check_ostack(2);
    code = parse_file_name(op, &pname, i_ctx_p->LockFilePermissions, imemory);
    if (code < 0)
        return code;
    iodev_dflt = iodev_default(imemory);
    if (pname.iodev == NULL)
        pname.iodev = iodev_dflt;
    if (pname.iodev != iodev_dflt) { /* Non-OS devices don't have search paths (yet). */
        code = zopen_file(i_ctx_p, &pname, "r", &s, imemory);
        if (code >= 0) {
            code = ssetfilename(s, op->value.const_bytes, r_size(op));
            if (code < 0) {
                sclose(s);
                return_error(e_VMerror);
            }
        }
        if (code < 0) {
            push(1);
            make_false(op);
            return 0;
        }
        make_stream_file(op, s, "r");
    } else {
        ref fref;

        code = lib_file_open(i_ctx_p->lib_path, imemory, i_ctx_p, pname.fname, pname.len,
                             (char *)cname, sizeof(cname), &clen, &fref);
        if (code >= 0) {
            s = fptr(&fref);
            code = ssetfilename(s, cname, clen);
            if (code < 0) {
                sclose(s);
                return_error(e_VMerror);
            }
        }
        if (code < 0) {
            if (code == e_VMerror || code == e_invalidfileaccess)
                return code;
            push(1);
            make_false(op);
            return 0;
        }
        ref_assign(op, &fref);
    }
    push(1);
    make_true(op);
    return 0;
}
开发者ID:ststeiger,项目名称:ghostsvg,代码行数:60,代码来源:zfile.c


示例4: socket

char *Curl_if2ip(const char *interface, char *buf, int buf_size)
{
  int dummy;
  char *ip=NULL;

  if(!interface)
    return NULL;

  dummy = socket(AF_INET, SOCK_STREAM, 0);
  if (SYS_ERROR == dummy) {
    return NULL;
  }
  else {
    struct ifreq req;
    size_t len = strlen(interface);
    memset(&req, 0, sizeof(req));
    if(len >= sizeof(req.ifr_name)) {
      sclose(dummy);
      return NULL; /* this can't be a fine interface name */
    }
    memcpy(req.ifr_name, interface, len+1);
    req.ifr_addr.sa_family = AF_INET;
#ifdef IOCTL_3_ARGS
    if (SYS_ERROR == ioctl(dummy, SIOCGIFADDR, &req)) {
#else
    if (SYS_ERROR == ioctl(dummy, SIOCGIFADDR, &req, sizeof(req))) {
#endif
      sclose(dummy);
      return NULL;
    }
    else {
      struct in_addr in;

      struct sockaddr_in *s = (struct sockaddr_in *)&req.ifr_dstaddr;
      memcpy(&in, &s->sin_addr, sizeof(in));
      ip = (char *) Curl_inet_ntop(s->sin_family, &in, buf, buf_size);
    }
    sclose(dummy);
  }
  return ip;
}

/* -- end of if2ip() -- */
#else
char *Curl_if2ip(const char *interf, char *buf, int buf_size)
{
    (void) interf;
    (void) buf;
    (void) buf_size;
    return NULL;
}
开发者ID:irmametra,项目名称:EiffelStudio,代码行数:51,代码来源:if2ip.c


示例5: memset

bool
HTTPMessage::Connect(const std::string &host, unsigned short port, int timeout_msec)
{
    struct sockaddr_in addr_out; 

    if ((sock_ = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
        return false;
    }

    memset(&addr_out, 0, sizeof(addr_out));
    addr_out.sin_family = AF_INET;
    addr_out.sin_port = htons(port);

    if ((addr_out.sin_addr.s_addr = inet_addr(host.c_str())) == INADDR_NONE) {
        sclose(sock_);
        return false;
    }

/* Il keepalive della connessione su sistemi unix
    int optval = 1;
    size_t optlen = sizeof(optval);
    ::setsockopt(sock_, SOL_SOCKET, SO_KEEPALIVE, &optval, optlen);
 */

    // su win devo anche cambiare il valore di 7200000msec per il keepalive
#ifdef WIN32
    tcp_keepalive kp;
    DWORD returned;
    kp.onoff = 1;
    kp.keepalivetime = 5000; // ogni 5 secondi
    kp.keepaliveinterval = 1000; // un secondo
    WSAIoctl(sock_, SIO_KEEPALIVE_VALS, (LPVOID) &kp,
             sizeof(kp), NULL, 0, &returned, NULL, NULL);
#endif

    int rc;
    if (timeout_msec < 0)
        rc = connect(sock_, (struct sockaddr *)&addr_out, sizeof(addr_out));
    else
        rc = connect_time(sock_, (struct sockaddr *)&addr_out, sizeof(addr_out), timeout_msec);

    if (rc == -1) {
        sclose(sock_);
        return false;
    }

    offset_ = 0;

    return true;
}
开发者ID:ggreco,项目名称:sfemu,代码行数:50,代码来源:http_message.cpp


示例6: main

int main(int argc, char *argv[])
{
  socket_t sock;
  struct sockaddr_in servaddr;
  char *server;
  int rc;
  char bye[3];
  int len;

  server = "127.0.0.1";

  sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
  if (sock == SOCKET_BAD)
    errorout("socket() failed");

  memset(&servaddr, 0, sizeof(servaddr));
  servaddr.sin_family = AF_INET;
  servaddr.sin_addr.s_addr = inet_addr(server);
  servaddr.sin_port = htons(SERVER_PORT);

  /* Establish the connection to the echo server */
  rc = connect(sock, (struct sockaddr *) &servaddr, sizeof(servaddr));
  if (rc < 0)
    errorout("connect() failed");

  printf("Connected!\n");
  write(sock, "not spdy", strlen("not spdy"));
  len = read(sock, bye, sizeof(bye));
  printf("Recv: %.*s\n", 3, bye); 

  sclose(sock);

  return 0;
}
开发者ID:colinmarc,项目名称:spindly,代码行数:34,代码来源:client.c


示例7: file_close_file

/* for normal (OS) files and for filters. */
int
file_close_file(stream * s)
{
    stream *stemp = s->strm;
    gs_memory_t *mem;
    int code = file_close_disable(s);

    if (code)
	return code;
    /*
     * Check for temporary streams created for filters.
     * There may be more than one in the case of a procedure-based filter,
     * or if we created an intermediate stream to ensure
     * a large enough buffer.  Note that these streams may have been
     * allocated by file_alloc_stream, so we mustn't free them.
     */
    while (stemp != 0 && stemp->is_temp != 0) {
	stream *snext = stemp->strm;

	mem = stemp->memory;
	if (stemp->is_temp > 1)
	    gs_free_object(mem, stemp->cbuf,
			   "file_close(temp stream buffer)");
	s_disable(stemp);
	stemp = snext;
    }
    mem = s->memory;
    gs_free_object(mem, s->cbuf, "file_close(buffer)");
    if (s->close_strm && stemp != 0)
	return sclose(stemp);
    return 0;
}
开发者ID:MasterPlexus,项目名称:vendor_goldenve,代码行数:33,代码来源:sfxcommon.c


示例8: main

int main(int argc, char *argv[])
{
  socket_t sock;
  struct sockaddr_in servaddr;
  char *server;
  int rc;
  char bye[3];
  int len;
  struct spindly_phys *phys_client;
  struct spindly_stream *stream_client;
  spindly_error_t spint;
  unsigned char *data;
  size_t datalen;

  server = "127.0.0.1";

  sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
  if (sock == SOCKET_BAD)
    errorout("socket() failed");

  /* create a spindly handle for the physical connection */
  phys_client = spindly_phys_init(SPINDLY_SIDE_CLIENT, SPINDLY_DEFAULT, NULL);

  memset(&servaddr, 0, sizeof(servaddr));
  servaddr.sin_family = AF_INET;
  servaddr.sin_addr.s_addr = inet_addr(server);
  servaddr.sin_port = htons(SERVER_PORT);

  /* Establish the connection to the echo server */
  rc = connect(sock, (struct sockaddr *) &servaddr, sizeof(servaddr));
  if (rc < 0)
    errorout("connect() failed");

  printf("Connected! Pretend TLS-NPN succeeded.\n");

  /* create a new stream on the physical connection */
  spint = spindly_stream_new(phys_client, 0, &stream_client, NULL, NULL);

  /* get data to send over the socket */
  spint = spindly_phys_outgoing(phys_client, &data, &datalen);

  printf("Ask for a new stream\n");

  /* send away the SPDY packet */
  rc = send(sock, data, datalen, 0);

  if(rc > 0) {
    /* tell spindly how much of that data that was actually sent */
    spindly_phys_sent(phys_client, rc);
    printf("Send %d bytes\n", rc);
  }

  /* now wait for data to arrive on the socket and demux it to figure out
     what the peer says to us */
  sleep(5);

  sclose(sock);

  return 0;
}
开发者ID:alepharchives,项目名称:spindly,代码行数:60,代码来源:client.c


示例9: make_rfs

/* Make a reusable file stream. */
static int
make_rfs(i_ctx_t *i_ctx_p, os_ptr op, stream *fs, long offset, long length)
{
    uint save_space = icurrent_space;
    uint stream_space = imemory_space((const gs_ref_memory_t *)fs->memory);
    gs_const_string fname;
    gs_parsed_file_name_t pname;
    stream *s;
    int code;

    if (sfilename(fs, &fname) < 0)
        return_error(e_ioerror);
    code = gs_parse_file_name(&pname, (const char *)fname.data, fname.size,
                              imemory);
    if (code < 0)
        return code;
    if (pname.len == 0)		/* %stdin% etc. won't have a filename */
        return_error(e_invalidfileaccess); /* can't reopen */
    if (pname.iodev == NULL)
        pname.iodev = iodev_default(imemory);
    /* Open the file again, to be independent of the source. */
    ialloc_set_space(idmemory, stream_space);
    code = zopen_file(i_ctx_p, &pname, "r", &s, imemory);
    ialloc_set_space(idmemory, save_space);
    if (code < 0)
        return code;
    if (sread_subfile(s, offset, length) < 0) {
        sclose(s);
        return_error(e_ioerror);
    }
    s->close_at_eod = false;
    make_stream_file(op, s, "r");
    return 0;
}
开发者ID:jonathan-mui,项目名称:ruby-ghostscript,代码行数:35,代码来源:zfrsd.c


示例10: destroy_thread_data

/*
 * destroy_thread_data() cleans up async resolver data.
 * Complementary of ares_destroy.
 */
static void destroy_thread_data( struct Curl_async *async ) {
	if ( async->hostname ) {
		free( async->hostname );
	}

	if ( async->os_specific ) {
		struct thread_data *td = (struct thread_data*) async->os_specific;
		curl_socket_t sock = td->dummy_sock;

		if ( sock != CURL_SOCKET_BAD ) {
			sclose( sock );
		}

		/* destroy the synchronization objects */
		if ( td->mutex_waiting ) {
			CloseHandle( td->mutex_waiting );
		}
		if ( td->event_resolved ) {
			CloseHandle( td->event_resolved );
		}

		free( async->os_specific );
	}
	async->hostname = NULL;
	async->os_specific = NULL;
}
开发者ID:AdrienJaguenet,项目名称:Enemy-Territory,代码行数:30,代码来源:hostthre.c


示例11: main

int main(void)
{
   FILE *fout;
   int i, fserial;


   fout = fopen("rom56.bin", "w");
   if (fout == NULL)
   {
      fprintf(stderr, "can't open rom56.bin for writing\n");
      exit(1);
   }
   fserial = sopen("/dev/ttyS0", B19200);
   if (fserial == -1)
   {
      fprintf(stderr, "can't open serial port\n");
      exit(1);
   }

   for (i=0; i<0x1000; i++)
   {
      fputc(sgetc(fserial), fout);
      printf(".");
   }

   fclose(fout);
   sclose(fserial);

   return 0;
}
开发者ID:dgchurchill,项目名称:nanowasp-tools,代码行数:30,代码来源:readrom.c


示例12: iobxInetTransportAccept

/*
** Accept an inbound connection from a peer transport.  This call should block until
** a connection has been established.
** When a connection has been accepted, the passed 'connectionid' is set.  This will be
** provided by the caller on all subsuquent calls made against the active connection.
*/
ObxRc iobxInetTransportAccept( void **connectionid ) {
	int                  addrlen = sizeof( struct sockaddr_in );
   ObxRc                rc = OBX_RC_OK;
   ObxInetConnectionBlock   *conblk = NULL;

   OBXDBGFLOW(("iobxInetTransportAccept() entry, connid=0x%08x\n", *connectionid));

   if ( obxServer.active ) {
      if ( *connectionid ) {
         conblk = *connectionid;
         if ( conblk->connected ) {
            conblk->connected = FALSE;
            sclose( conblk->fd );
         }
         OBXDBGINFO(("iobxInetTransportAccept() calling accept().\n"));
         if ( (conblk->fd = accept( obxServer.fd, (struct sockaddr *)&conblk->peer, &addrlen )) >= 0 ) {
            OBXDBGINFO(("iobxInetTransportAccept() accept() returns.\n"));
            conblk->connected = TRUE;
         } else {
            OBXDBGERR(("[ERROR] iobxInetTransportAccept() socket accept fails.\n"));
            OBXDBGSOCKERR();
            rc = OBX_RC_ERR_SOCKET_ACCEPT;
         }
      } else {
         OBXDBGERR(("[ERROR] iobxInetTransportAccept() bad plist on call.\n"));
         rc = OBX_RC_ERR_BADPLIST;           /* No connection block  */
      }
   } else {
      OBXDBGERR(("[ERROR] iobxInetTransportAccept() socket not listening.\n"));
      rc = OBX_RC_ERR_SOCKET_NOT_LISTENING;  /* listen() not called  */
   }
   return rc;
}
开发者ID:guadalinex-archive,项目名称:guadalinex-v5,代码行数:39,代码来源:inetTransport.c


示例13: gdev_vector_close_file

/* Close the output file and stream. */
int
gdev_vector_close_file(gx_device_vector * vdev)
{
    FILE *f = vdev->file;
    int err;

    if (vdev->dash_pattern) {
        gs_free_object(vdev->memory->stable_memory, vdev->dash_pattern, "vector free dash pattern");
        vdev->dash_pattern = 0;
    }
    if (vdev->bbox_device) {
        rc_decrement(vdev->bbox_device->icc_struct, "vector_close(bbox_device->icc_struct");
        vdev->bbox_device->icc_struct = NULL;
        gs_free_object(vdev->v_memory, vdev->bbox_device,
                   "vector_close(bbox_device)");
        vdev->bbox_device = 0;
    }

    if (vdev->strm) {
        sclose(vdev->strm);
        gs_free_object(vdev->v_memory, vdev->strm, "vector_close(strm)");
        vdev->strm = 0;
        gs_free_object(vdev->v_memory, vdev->strmbuf, "vector_close(strmbuf)");
        vdev->strmbuf = 0;
    }
    vdev->file = 0;
    if (f) {
        err = ferror(f);
        /* We prevented sclose from closing the file. */
        if (gx_device_close_output_file((gx_device *)vdev, vdev->fname, f) != 0
                || err != 0)
            return_error(gs_error_ioerror);
    }
    return 0;
}
开发者ID:hackqiang,项目名称:gs,代码行数:36,代码来源:gdevvec.c


示例14: trynextip

/* Used within the multi interface. Try next IP address, return TRUE if no
   more address exists */
static bool trynextip(struct connectdata *conn,
                      int sockindex,
                      bool *connected)
{
  curl_socket_t sockfd;
  Curl_addrinfo *ai;

  /* first close the failed socket */
  sclose(conn->sock[sockindex]);
  conn->sock[sockindex] = CURL_SOCKET_BAD;
  *connected = FALSE;

  if(sockindex != FIRSTSOCKET)
    return TRUE; /* no next */

  /* try the next address */
  ai = conn->ip_addr->ai_next;

  while (ai) {
    sockfd = singleipconnect(conn, ai, 0L, connected);
    if(sockfd != CURL_SOCKET_BAD) {
      /* store the new socket descriptor */
      conn->sock[sockindex] = sockfd;
      conn->ip_addr = ai;

      Curl_store_ip_addr(conn);
      return FALSE;
    }
    ai = ai->ai_next;
  }
  return TRUE;
}
开发者ID:AbrahamJewowich,项目名称:FreeSWITCH,代码行数:34,代码来源:connect.c


示例15: pipeback_shared

int pipeback_shared (const char *filename, const char *argv[], int exec_type)
{
    struct sigaction *sigact;
    char mbuf[256];

    sigact = scalloc (sizeof (struct sigaction), 1);
    sigact->sa_handler = SIG_IGN;
#ifdef NOCLDWAIT
    sigact->sa_flags = SA_NOCLDWAIT;
#endif
    if (sigaction (SIGCHLD, sigact, NULL))
    {
	error ("Error protecting against zombies!");
	exit (EXIT_FAILURE);
    }

    if (pipe (local_pipe))
    {
	error ("Error opening pipeback pipe!");
	exit (EXIT_FAILURE);
    }

    if (PipebackChildPID = fork())
    {
	sclose (local_pipe[1]);
	return local_pipe[0];
    }
    else
    {
	sclose (local_pipe[0]);
	sclose (1);
	dup (local_pipe[1]);
	sclose (2);
	dup (local_pipe[1]);
	sclose (local_pipe[1]);
	if (0 == exec_type)
	{
	    execv (filename, (char**) argv);
	}
	else
	{
	    execvp (filename, (char**) argv);
	}
	sprintf (mbuf, "Pipeback was unable to load program %s", filename);
	error (mbuf);
    }
}
开发者ID:syumprc,项目名称:solar-eclipse,代码行数:47,代码来源:pipeback.c


示例16: Curl_closesocket

/*
 * Close a socket.
 *
 * 'conn' can be NULL, beware!
 */
int Curl_closesocket(struct connectdata *conn,
                     curl_socket_t sock)
{
  if(conn && conn->fclosesocket)
    return conn->fclosesocket(conn->closesocket_client, sock);
  else
    return sclose(sock);
}
开发者ID:karottc,项目名称:dtc_jd,代码行数:13,代码来源:connect.c


示例17: socket

/*
 * Curl_getaddrinfo() when built ipv6-enabled (non-threading version).
 *
 * Returns name information about the given hostname and port number. If
 * successful, the 'addrinfo' is returned and the forth argument will point to
 * memory we need to free after use. That memory *MUST* be freed with
 * Curl_freeaddrinfo(), nothing else.
 */
Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
                                char *hostname,
                                int port,
                                int *waitp)
{
  struct addrinfo hints, *res;
  int error;
  char sbuf[NI_MAXSERV];
  curl_socket_t s;
  int pf;
  struct SessionHandle *data = conn->data;

  *waitp=0; /* don't wait, we have the response now */

  /* see if we have an IPv6 stack */
  s = socket(PF_INET6, SOCK_DGRAM, 0);
  if (s < 0) {
    /* Some non-IPv6 stacks have been found to make very slow name resolves
     * when PF_UNSPEC is used, so thus we switch to a mere PF_INET lookup if
     * the stack seems to be a non-ipv6 one. */

    pf = PF_INET;
  }
  else {
    /* This seems to be an IPv6-capable stack, use PF_UNSPEC for the widest
     * possible checks. And close the socket again.
     */
    sclose(s);

    /*
     * Check if a more limited name resolve has been requested.
     */
    switch(data->set.ip_version) {
    case CURL_IPRESOLVE_V4:
      pf = PF_INET;
      break;
    case CURL_IPRESOLVE_V6:
      pf = PF_INET6;
      break;
    default:
      pf = PF_UNSPEC;
      break;
    }
  }
 
  memset(&hints, 0, sizeof(hints));
  hints.ai_family = pf;
  hints.ai_socktype = SOCK_STREAM;
  hints.ai_flags = AI_CANONNAME;
  snprintf(sbuf, sizeof(sbuf), "%d", port);
  error = getaddrinfo(hostname, sbuf, &hints, &res);
  if (error) {
    infof(data, "getaddrinfo(3) failed for %s:%d\n", hostname, port);    
    return NULL;
  }

  return res;
}
开发者ID:yyyyyao,项目名称:Slicer3-lib-mirrors,代码行数:66,代码来源:hostip6.c


示例18: lib_file_open_search_with_combine

/* return zero for success, -ve for error, +1 for continue */
static int
lib_file_open_search_with_combine(gs_file_path_ptr  lib_path, const gs_memory_t *mem, i_ctx_t *i_ctx_p,
                                  const char *fname, uint flen, char *buffer, int blen, uint *pclen, ref *pfile,
                                  gx_io_device *iodev, bool starting_arg_file, char *fmode)
{
    stream *s;
    const gs_file_path *pfpath = lib_path;
    uint pi;

    for (pi = 0; pi < r_size(&pfpath->list); ++pi) {
        const ref *prdir = pfpath->list.value.refs + pi;
        const char *pstr = (const char *)prdir->value.const_bytes;
        uint plen = r_size(prdir), blen1 = blen;
        gs_parsed_file_name_t pname;
        gp_file_name_combine_result r;

        /* We need to concatenate and parse the file name here
         * if this path has a %device% prefix.              */
        if (pstr[0] == '%') {
            int code;

            /* We concatenate directly since gp_file_name_combine_*
             * rules are not correct for other devices such as %rom% */
            code = gs_parse_file_name(&pname, pstr, plen, mem);
            if (code < 0)
                continue;
            memcpy(buffer, pname.fname, pname.len);
            memcpy(buffer+pname.len, fname, flen);
            code = pname.iodev->procs.open_file(pname.iodev, buffer, pname.len + flen, fmode,
                                          &s, (gs_memory_t *)mem);
            if (code < 0)
                continue;
            make_stream_file(pfile, s, "r");
            /* fill in the buffer with the device concatenated */
            memcpy(buffer, pstr, plen);
            memcpy(buffer+plen, fname, flen);
            *pclen = plen + flen;
            return 0;
        } else {
            r = gp_file_name_combine(pstr, plen,
                    fname, flen, false, buffer, &blen1);
            if (r != gp_combine_success)
                continue;
            if (iodev_os_open_file(iodev, (const char *)buffer, blen1, (const char *)fmode,
                                    &s, (gs_memory_t *)mem) == 0) {
                if (starting_arg_file ||
                    check_file_permissions_aux(i_ctx_p, buffer, blen1) >= 0) {
                    *pclen = blen1;
                    make_stream_file(pfile, s, "r");
                    return 0;
                }
                sclose(s);
                return_error(e_invalidfileaccess);
            }
        }
    }
    return 1;
}
开发者ID:ststeiger,项目名称:ghostsvg,代码行数:59,代码来源:zfile.c


示例19: iobxInetTransportTerminate

/*
** Clean up all internals
*/
ObxRc iobxInetTransportTerminate( void ) {
   OBXDBGFLOW(("iobxInetTransportTerminate() entry.\n"));
   free(obxMeta.host);
   obxMeta.host = NULL;
   if (obxServer.active) {
      sclose(obxServer.fd);
      obxServer.active = FALSE;
   }
   return OBX_RC_OK;
}
开发者ID:guadalinex-archive,项目名称:guadalinex-v5,代码行数:13,代码来源:inetTransport.c


示例20: sscanf

int sscanf(const char *s, const char *fmt, ...){
	int n;
	FILE *f=sopenr(s);
	va_list args;
	va_start(args, fmt);
	n=vfscanf(f, fmt, args);
	va_end(args);
	sclose(f);
	return n;
}
开发者ID:Harvey-OS,项目名称:harvey,代码行数:10,代码来源:sscanf.c



注:本文中的sclose函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ scm_c_eval_string函数代码示例发布时间:2022-05-30
下一篇:
C++ sciprint函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap