MCPcopy Create free account
hub / github.com/git/git / imap_open_store

Function imap_open_store

imap-send.c:1145–1366  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1143}
1144
1145static struct imap_store *imap_open_store(struct imap_server_conf *srvc, const char *folder)
1146{
1147 struct credential cred = CREDENTIAL_INIT;
1148 struct imap_store *ctx;
1149 struct imap *imap;
1150 char *arg, *rsp;
1151 int s = -1, preauth;
1152
1153 CALLOC_ARRAY(ctx, 1);
1154
1155 ctx->cfg = srvc;
1156 ctx->imap = CALLOC_ARRAY(imap, 1);
1157 imap->buf.sock.fd[0] = imap->buf.sock.fd[1] = -1;
1158 imap->in_progress_append = &imap->in_progress;
1159
1160 /* open connection to IMAP server */
1161
1162 if (srvc->tunnel) {
1163 struct child_process tunnel = CHILD_PROCESS_INIT;
1164
1165 imap_info("Starting tunnel '%s'... ", srvc->tunnel);
1166
1167 strvec_push(&tunnel.args, srvc->tunnel);
1168 tunnel.use_shell = 1;
1169 tunnel.in = -1;
1170 tunnel.out = -1;
1171 if (start_command(&tunnel))
1172 die("cannot start proxy %s", srvc->tunnel);
1173
1174 imap->buf.sock.fd[0] = tunnel.out;
1175 imap->buf.sock.fd[1] = tunnel.in;
1176
1177 imap_info("OK\n");
1178 } else {
1179#ifndef NO_IPV6
1180 struct addrinfo hints, *ai0, *ai;
1181 int gai;
1182 char portstr[6];
1183
1184 xsnprintf(portstr, sizeof(portstr), "%d", srvc->port);
1185
1186 memset(&hints, 0, sizeof(hints));
1187 hints.ai_socktype = SOCK_STREAM;
1188 hints.ai_protocol = IPPROTO_TCP;
1189
1190 imap_info("Resolving %s... ", srvc->host);
1191 gai = getaddrinfo(srvc->host, portstr, &hints, &ai);
1192 if (gai) {
1193 fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(gai));
1194 goto bail;
1195 }
1196 imap_info("OK\n");
1197
1198 for (ai0 = ai; ai; ai = ai->ai_next) {
1199 char addr[NI_MAXHOST];
1200
1201 s = socket(ai->ai_family, ai->ai_socktype,
1202 ai->ai_protocol);

Callers 2

append_msgs_to_imapFunction · 0.85
list_imap_foldersFunction · 0.85

Calls 15

imap_infoFunction · 0.85
strvec_pushFunction · 0.85
start_commandFunction · 0.85
xsnprintfFunction · 0.85
ssl_socket_connectFunction · 0.85
buffer_getsFunction · 0.85
next_argFunction · 0.85
parse_response_codeFunction · 0.85
imap_execFunction · 0.85
server_fill_credentialFunction · 0.85
try_auth_methodFunction · 0.85
imap_warnFunction · 0.85

Tested by

no test coverage detected