void *env_parameters (long function,void *value) { void *ret = NIL; switch ((int) function) { case SET_USERNAME: myUserName = cpystr ((char *) value); case GET_USERNAME: ret = (void *) myUserName; break; case SET_HOMEDIR: myHomeDir = cpystr ((char *) value); case GET_HOMEDIR: ret = (void *) myHomeDir; break; case SET_LOCALHOST: myLocalHost = cpystr ((char *) value); case GET_LOCALHOST: ret = (void *) myLocalHost; break; case SET_NEWSRC: if (myNewsrc) fs_give ((void **) &myNewsrc); myNewsrc = cpystr ((char *) value); case GET_NEWSRC: if (!myNewsrc) { /* set news file name if not defined */ char tmp[MAILTMPLEN]; sprintf (tmp,"%s:.newsrc",myhomedir ()); myNewsrc = cpystr (tmp); } ret = (void *) myNewsrc; break; } return ret; }
/* * Return a pretty command, on some OS's we might do something * different than just display the command. * * free_ret - whether or not to free the return value */ char * execview_pretty_command(MCAP_CMD_S *mc_cmd, int *free_ret) { char *str; int rv_to_free = 0; if(free_ret) *free_ret = rv_to_free; if(!mc_cmd) return NULL; str = mc_cmd->command; #ifdef _WINDOWS if(*str == '*' || (*str == '\"' && str[1] == '*')){ if(!strncmp(str + ((*str == '\"') ? 2 : 1), "DDE*", 4)) str = cpystr("via app already running"); else if(!strncmp(str + ((*str == '\"') ? 2 : 1),"ShellEx*",8)) str = cpystr("via Explorer defined app"); else str = cpystr("via Windows-specific method"); rv_to_free = 1; } #elif OSX_TARGET if(mc_cmd->special_handling){ CFStringRef str_ref = NULL, kind_str_ref = NULL; CFURLRef url_ref; char buf[256]; if((str_ref = CFStringCreateWithCString(NULL, mc_cmd->command, kCFStringEncodingASCII)) == NULL) return ""; if((url_ref = CFURLCreateWithString(NULL, str_ref, NULL)) == NULL) return ""; if(LSCopyDisplayNameForURL(url_ref, &kind_str_ref) != noErr) return ""; if(CFStringGetCString(kind_str_ref, buf, (CFIndex)255, kCFStringEncodingASCII) == false) return ""; buf[255] = '\0'; str = cpystr(buf); rv_to_free = 1; if(kind_str_ref) CFRelease(kind_str_ref); } #else /* always pretty */ #endif if(free_ret) *free_ret = rv_to_free; return(str); }
/* * Insert % before existing %'s so printf will print a real %. * This is a special routine just for contexts. It only does the % stuffing * for %'s inside of the braces of the context name, not for %'s to * the right of the braces, which we will be using for printf format strings. * Returns a malloced string which the caller is responsible for. */ char * context_percent_quote(char *context) { char *pq = NULL; if(!context || !*context) pq = cpystr(""); else{ if(IS_REMOTE(context)){ char *end, *p, *q; /* don't worry about size efficiency, just allocate double */ pq = (char *) fs_get((2*strlen(context) + 1) * sizeof(char)); end = strchr(context, '}'); p = context; q = pq; while(*p){ if(*p == '%' && p < end) *q++ = '%'; *q++ = *p++; } *q = '\0'; } else pq = cpystr(context); } return(pq); }
char *tcp_clienthost () { if (!myClientHost) { size_t sadrlen; struct sockaddr *sadr = ip_newsockaddr (&sadrlen); if (getpeername (0,sadr,(void *) &sadrlen)) { char *s,*t,*v,tmp[MAILTMPLEN]; if ((s = getenv (t = "SSH_CLIENT")) || (s = getenv (t = "KRB5REMOTEADDR")) || (s = getenv (t = "SSH2_CLIENT"))) { if (v = strchr (s,' ')) *v = '\0'; sprintf (v = tmp,"%.80s=%.80s",t,s); } else v = "UNKNOWN"; myClientHost = cpystr (v); } else { /* get stdin's peer name */ myClientHost = tcp_name (sadr,T); if (!myClientAddr) myClientAddr = cpystr (ip_sockaddrtostring (sadr)); if (myClientPort < 0) myClientPort = ip_sockaddrtoport (sadr); } fs_give ((void **) &sadr); } return myClientHost; }
/** * Encodes a zorba String if necessary (if it contains non-ascii chars) * and assigns it to the passed char-pointer-reference. */ void encodeStringForEMailHeader(const zorba::String& aString, char*& aCClientVal) { // check if string contains non ascii chars bool lContainsNonAscii = false; for ( zorba::String::const_iterator lIter = aString.begin(); lIter != aString.end(); ++lIter) { unsigned int u = static_cast<unsigned int>(*lIter); if (!(u == '\t' || u == '\n' || u == '\t' || (u >= 32 && u <= 127))) { lContainsNonAscii = true; break; } } if (lContainsNonAscii) { // if string contains non-ascii chars, we encode it with // base64 encoding and generate a header value according to // http://tools.ietf.org/html/rfc2047 (MIME encoded-word syntax). zorba::String lEncodedValue; zorba::base64::encode(aString, &lEncodedValue); zorba::String lFullValue = zorba::String("=?UTF-8?B?") + lEncodedValue + zorba::String("?="); aCClientVal = cpystr(lFullValue.c_str()); } else { // if string contains ascii chars only, do don't encode anything aCClientVal = cpystr(aString.c_str()); } }
static int checkpw_conv (int num_msg,const struct pam_message **msg, struct pam_response **resp,void *appdata_ptr) { int i; struct checkpw_cred *cred = (struct checkpw_cred *) appdata_ptr; struct pam_response *reply = fs_get (sizeof (struct pam_response) * num_msg); for (i = 0; i < num_msg; i++) switch (msg[i]->msg_style) { case PAM_PROMPT_ECHO_ON: /* assume want user name */ reply[i].resp_retcode = PAM_SUCCESS; reply[i].resp = cpystr (cred->uname); break; case PAM_PROMPT_ECHO_OFF: /* assume want password */ reply[i].resp_retcode = PAM_SUCCESS; reply[i].resp = cpystr (cred->pass); break; case PAM_TEXT_INFO: case PAM_ERROR_MSG: reply[i].resp_retcode = PAM_SUCCESS; reply[i].resp = NULL; break; default: /* unknown message style */ fs_give ((void **) &reply); return PAM_CONV_ERR; } *resp = reply; return PAM_SUCCESS; }
void *env_parameters (long function,void *value) { void *ret = NIL; switch ((int) function) { case SET_HOMEDIR: myHomeDir = cpystr ((char *) value); case GET_HOMEDIR: ret = (void *) myHomeDir; break; case SET_LOCALHOST: myLocalHost = cpystr ((char *) value); case GET_LOCALHOST: ret = (void *) myLocalHost; break; case SET_NEWSRC: if (myNewsrc) fs_give ((void **) &myNewsrc); myNewsrc = cpystr ((char *) value); case GET_NEWSRC: if (!myNewsrc) { /* set news file name if not defined */ char tmp[MAILTMPLEN]; sprintf (tmp,"%s\\newsrc",myhomedir ()); myNewsrc = cpystr (tmp); } ret = (void *) myNewsrc; break; case SET_DISABLE822TZTEXT: no822tztext = value ? T : NIL; case GET_DISABLE822TZTEXT: ret = (void *) (no822tztext ? VOIDT : NIL); break; } return ret; }
IELEM_S * copy_ielem(IELEM_S *src) { IELEM_S *head = NULL; if(src){ head = new_ielem(NULL); if(src->next) head->next = copy_ielem(src->next); head->type = src->type; head->wid = src->wid; if(src->color){ head->color = new_color_pair(src->color->fg, src->color->bg); head->freecolor = 1; } if(src->data){ head->data = cpystr(src->data); head->datalen = strlen(head->data); head->freedata = 1; } if(src->print_format){ head->print_format = cpystr(src->print_format); head->freeprintf = strlen(head->print_format) + 1; } } return(head); }
void *env_parameters (long function,void *value) { void *ret = NIL; char tmp[MAILTMPLEN]; switch ((int) function) { case SET_HOMEDIR: if (myHomeDir) fs_give ((void **) &myHomeDir); myHomeDir = cpystr ((char *) value); case GET_HOMEDIR: /* set home directory if not defined */ if (!myHomeDir) myHomeDir = cpystr (""); ret = (void *) myHomeDir; break; case SET_LOCALHOST: myLocalHost = cpystr ((char *) value); case GET_LOCALHOST: ret = (void *) myLocalHost ? myLocalHost : "random-mac"; break; case SET_NEWSRC: if (myNewsrc) fs_give ((void **) &myNewsrc); myNewsrc = cpystr ((char *) value); case GET_NEWSRC: if (!myNewsrc) { /* set news file name if not defined */ sprintf (tmp,"%s:News State",myhomedir ()); myNewsrc = cpystr (tmp); } ret = (void *) myNewsrc; break; } return ret; }
ADDRESS * address_from_ldap(LDAP_CHOOSE_S *winning_e) { ADDRESS *ret_a = NULL; if(winning_e){ char *a; BerElement *ber; ret_a = mail_newaddr(); for(a = ldap_first_attribute(winning_e->ld, winning_e->selected_entry, &ber); a != NULL; a = ldap_next_attribute(winning_e->ld, winning_e->selected_entry, ber)){ int i; char *p; char **vals; dprint((9, "attribute: %s\n", a ? a : "?")); if(!ret_a->personal && strcmp(a, winning_e->info_used->cnattr) == 0){ dprint((9, "Got cnattr:")); vals = ldap_get_values(winning_e->ld, winning_e->selected_entry, a); for(i = 0; vals[i] != NULL; i++) dprint((9, " %s\n", vals[i] ? vals[i] : "?")); if(vals && vals[0]) ret_a->personal = cpystr(vals[0]); ldap_value_free(vals); } else if(!ret_a->mailbox && strcmp(a, winning_e->info_used->mailattr) == 0){ dprint((9, "Got mailattr:")); vals = ldap_get_values(winning_e->ld, winning_e->selected_entry, a); for(i = 0; vals[i] != NULL; i++) dprint((9, " %s\n", vals[i] ? vals[i] : "?")); /* use first one */ if(vals && vals[0]){ if((p = strindex(vals[0], '@')) != NULL){ ret_a->host = cpystr(p+1); *p = '\0'; } ret_a->mailbox = cpystr(vals[0]); } ldap_value_free(vals); } our_ldap_memfree(a); } } return(ret_a); }
char *myusername () { struct stat sbuf; char tmp[MAILTMPLEN]; if (!myUserName) { /* get user name if don't have it yet */ myUserName = cpystr (cuserid (NIL)); myHomeDir = cpystr ("SYS$LOGIN"); } return myUserName; }
char *tcp_canonical (char *name) { char host[MAILTMPLEN]; struct hostent *he; /* look like domain literal? */ if (name[0] == '[' && name[strlen (name) - 1] == ']') return cpystr (name); /* note that Unix requires lowercase! */ else return cpystr ((he = gethostbyname (lcase (strcpy (host,name)))) ? he->h_name : name); }
/* Write RFC822 address with 1522 decoding of personal name * and optional quoting. * * The idea is that there are some places where we'd just like to display * the personal name as is before applying confusing quoting. However, * we do want to be careful not to break things that should be quoted so * we'll only use this where we are sure. Quoting may look ugly but it * doesn't usually break anything. */ void rfc822_write_address_decode(char *dest, size_t destlen, struct mail_address *adr, int do_quote) { RFC822BUFFER buf; extern const char *rspecials; ADDRESS *copy, *a; /* * We want to print the adr list after decoding it. C-client knows * how to parse and print, so we want to use that. But c-client * doesn't decode. So we make a copy of the address list, decode * things there, and let c-client print that. */ copy = copyaddrlist(adr); for(a = copy; a; a = a->next){ if(a->host){ /* ordinary address? */ if(a->personal && *a->personal){ unsigned char *p; p = rfc1522_decode_to_utf8((unsigned char *) tmp_20k_buf, SIZEOF_20KBUF, a->personal); if(p && (char *) p != a->personal){ fs_give((void **) &a->personal); a->personal = cpystr((char *) p); } } } else if(a->mailbox && *a->mailbox){ /* start of group? */ unsigned char *p; p = rfc1522_decode_to_utf8((unsigned char *) tmp_20k_buf, SIZEOF_20KBUF, a->mailbox); if(p && (char *) p != a->mailbox){ fs_give((void **) &a->mailbox); a->mailbox = cpystr((char *) p); } } } buf.end = (buf.beg = buf.cur = dest) + destlen; buf.f = rfc822_dummy_soutr; *buf.cur = '\0'; buf.s = NIL; (void) rfc822_output_address_list(&buf, copy, 0, do_quote ? rspecials : rspecials_minus_quote_and_dot); *buf.cur = '\0'; if(copy) mail_free_address(©); }
char *tcp_clienthost () { if (!myClientHost) { struct sockaddr_in sin; int sinlen = sizeof (struct sockaddr_in); myClientHost = /* get stdin's peer name */ getpeername (0,(struct sockaddr *) &sin,(void *) &sinlen) ? cpystr ("UNKNOWN") : ((sin.sin_family == AF_INET) ? tcp_name (&sin,T) : cpystr ("NON-IPv4")); } return myClientHost; }
char *tcp_serveraddr () { if (!myServerAddr) { size_t sadrlen; struct sockaddr *sadr = ip_newsockaddr (&sadrlen); myServerAddr = /* get stdin's peer name */ ((getsockname (0,sadr,&sadrlen) == SOCKET_ERROR) || (sadrlen <= 0)) ? cpystr ("UNKNOWN") : cpystr (ip_sockaddrtostring (sadr)); fs_give ((void **) &sadr); } return myServerAddr; }
char *myhomedir () { if (!myHomeDir) { /* get home directory name if not yet known */ char *s; if ((s = getenv ("PINEHOME")) || (s = getenv ("HOME")) || (s = getenv ("ETC"))) { myHomeDir = cpystr (s); while (s = strchr (myHomeDir,'/')) *s = '\\'; if ((s = strrchr (myHomeDir,'\\')) && !s[1]) *s = '\0'; } else myHomeDir = cpystr (""); } return myHomeDir; }
/* * These chars are not allowed in keywords. * * Returns 0 if ok, 1 if not. * Returns an allocated error message on error. */ int keyword_check(char *kw, char **error) { register char *t; char buf[100], *p; if(!kw || !kw[0]) return 1; kw = nick_to_keyword(kw); for(p = kw; p && *p; p++) if(!isascii(*p)){ if(error) *error = cpystr("Keywords must be all ASCII characters"); return 1; } if((t = strindex(kw, SPACE)) || (t = strindex(kw, '{')) || (t = strindex(kw, '(')) || (t = strindex(kw, ')')) || (t = strindex(kw, ']')) || (t = strindex(kw, '%')) || (t = strindex(kw, '"')) || (t = strindex(kw, '\\')) || (t = strindex(kw, '*'))){ char s[4]; s[0] = '"'; s[1] = *t; s[2] = '"'; s[3] = '\0'; if(error){ snprintf(buf, sizeof(buf), "%s not allowed in keywords", *t == SPACE ? "Spaces" : *t == '"' ? "Quotes" : *t == '%' ? "Percents" : s); *error = cpystr(buf); } return 1; } return 0; }
char *tcp_serveraddr () { if (!myServerAddr) { size_t sadrlen; struct sockaddr *sadr = ip_newsockaddr (&sadrlen); if (getsockname (0,sadr,(void *) &sadrlen)) myServerAddr = cpystr ("UNKNOWN"); else { /* get stdin's name */ myServerAddr = cpystr (ip_sockaddrtostring (sadr)); if (myServerPort < 0) myServerPort = ip_sockaddrtoport (sadr); } fs_give ((void **) &sadr); } return myServerAddr; }
char * mc_conf_path(char *def_path, char *env_path, char *user_file, int separator, char *stdpath) { char *path; /* We specify MIMETYPES as a path override */ if(def_path) /* there may need to be an override specific to pine */ path = cpystr(def_path); else if(env_path) path = cpystr(env_path); else{ #if defined(DOS) || defined(OS2) char *s; /* * This gets interesting. Since we don't have any standard location * for config/data files, look in the same directory as the PINERC * and the same dir as PINE.EXE. This is similar to the UNIX * situation with personal config info coming before * potentially shared config data... */ if(s = last_cmpnt(ps_global->pinerc)){ strncpy(tmp_20k_buf+1000, ps_global->pinerc, MIN(s - ps_global->pinerc,SIZEOF_20KBUF-1000)); tmp_20k_buf[1000+MIN(s - ps_global->pinerc,SIZEOF_20KBUF-1000-1)] = '\0'; } else strncpy(tmp_20k_buf+1000, ".\\", SIZEOF_20KBUF-1000); /* pinerc directory version of file */ build_path(tmp_20k_buf+2000, tmp_20k_buf+1000, user_file, SIZEOF_20KBUF-2000); tmp_20k_buf[SIZEOF_20KBUF-1] = '\0'; /* pine.exe directory version of file */ build_path(tmp_20k_buf+3000, ps_global->pine_dir, user_file, SIZEOF_20KBUF-3000); tmp_20k_buf[SIZEOF_20KBUF-1] = '\0'; /* combine them */ snprintf(tmp_20k_buf, SIZEOF_20KBUF, "%s%c%s", tmp_20k_buf+2000, separator, tmp_20k_buf+3000); #else /* !DOS */ build_path(tmp_20k_buf, ps_global->home_dir, stdpath, SIZEOF_20KBUF); #endif /* !DOS */ path = cpystr(tmp_20k_buf); } return(path); }
KEYWORD_S * new_keyword_s(char *keyword, char *nickname) { KEYWORD_S *kw = NULL; kw = (KEYWORD_S *) fs_get(sizeof(*kw)); memset(kw, 0, sizeof(*kw)); if(keyword && *keyword) kw->kw = cpystr(keyword); if(nickname && *nickname) kw->nick = cpystr(nickname); return(kw); }
char *tcp_clientaddr () { if (!myClientAddr) { char buf[NI_MAXHOST]; size_t sadrlen; struct sockaddr *sadr = ip_newsockaddr (&sadrlen); if (getpeername (0,sadr,(void *) &sadrlen)) myClientAddr = cpystr ("UNKNOWN"); else { /* get stdin's peer name */ myClientAddr = cpystr (ip_sockaddrtostring (sadr,buf)); if (myClientPort < 0) myClientPort = ip_sockaddrtoport (sadr); } fs_give ((void **) &sadr); } return myClientAddr; }
char *tcp_name (struct sockaddr_in *sin,long flag) { char *ret,*t,adr[MAILTMPLEN],tmp[MAILTMPLEN]; sprintf (ret = adr,"[%.80s]",inet_ntoa (sin->sin_addr)); if (allowreversedns) { struct hostent *he; blocknotify_t bn = (blocknotify_t)mail_parameters(NIL,GET_BLOCKNOTIFY,NIL); void *data; if (tcpdebug) { sprintf (tmp,"Reverse DNS resolution %s",adr); mm_log (tmp,TCPDEBUG); } (*bn) (BLOCK_DNSLOOKUP,NIL);/* quell alarms */ data = (*bn) (BLOCK_SENSITIVE,NIL); /* translate address to name */ if (t = tcp_name_valid ((he = gethostbyaddr ((char *) &sin->sin_addr, sizeof (struct in_addr), sin->sin_family)) ? (char *) he->h_name : NIL)) { /* produce verbose form if needed */ if (flag) sprintf (ret = tmp,"%s %s",t,adr); else ret = t; } (*bn) (BLOCK_NONSENSITIVE,data); (*bn) (BLOCK_NONE,NIL); /* alarms OK now */ if (tcpdebug) mm_log ("Reverse DNS resolution done",TCPDEBUG); } return cpystr (ret); }
OM_uint32 gss_import_name (OM_uint32 *minor_status, gss_buffer_t input_name_buffer, gss_OID input_name_type,gss_name_t *output_name) { OM_uint32 major_status = GSS_S_COMPLETE; TimeStamp expiry; static CredHandle gss_cred; char *s,tmp[MAILTMPLEN]; *minor_status = 0; /* never any minor status */ if (!gss_default_cred) { /* default credentials set up yet? */ if (AcquireCredentialsHandle/* no, acquire them now */ (NIL,MICROSOFT_KERBEROS_NAME_A,SECPKG_CRED_OUTBOUND,NIL,NIL,NIL,NIL, &gss_cred,&expiry) != SEC_E_OK) return GSS_S_FAILURE; /* have default credentials now */ gss_default_cred = &gss_cred; } /* must be the gss_nt_service_name format */ if (input_name_type != gss_nt_service_name) major_status = GSS_S_BAD_NAMETYPE; /* name must be of sane length */ else if (input_name_buffer->length > (MAILTMPLEN/2)) major_status = GSS_S_BAD_NAME; else { /* copy name */ memcpy (tmp,input_name_buffer->value,input_name_buffer->length); tmp[input_name_buffer->length] = '\0'; if (s = strchr (tmp,'@')) { /* find service/host/delimiter */ *s = '/'; /* convert to full service principal name */ *output_name = cpystr (tmp); } else major_status = GSS_S_BAD_NAME; } return major_status; }
void *ip_nametoaddr (char *name,size_t *len,int *family,char **canonical, void **next,void **cleanup) { char **adl,tmp[MAILTMPLEN]; struct hostent *he; /* cleanup data never permitted */ if (cleanup && *cleanup) abort (); if (name) { /* first lookup? */ /* yes, do case-independent lookup */ if ((strlen (name) < MAILTMPLEN) && (he = gethostbyname (lcase (strcpy (tmp,name))))) { adl = he->h_addr_list; if (len) *len = he->h_length; if (family) *family = he->h_addrtype; if (canonical) *canonical = cpystr ((char *) he->h_name); if (next) *next = (void *) adl; } else { /* error */ adl = NIL; if (len) *len = 0; if (family) *family = 0; if (canonical) *canonical = NIL; if (next) *next = NIL; } } /* return next in series */ else if (next && (adl = (char **) *next)) *next = ++adl; else adl = NIL; /* failure */ return adl ? (void *) *adl : NIL; }
char *tcp_name (struct sockaddr *sadr,long flag) { char *ret,*t,adr[MAILTMPLEN],tmp[MAILTMPLEN]; sprintf (ret = adr,"[%.80s]",ip_sockaddrtostring (sadr)); if (allowreversedns) { blocknotify_t bn = (blocknotify_t)mail_parameters(NIL,GET_BLOCKNOTIFY,NIL); void *data; if (tcpdebug) { sprintf (tmp,"Reverse DNS resolution %s",adr); mm_log (tmp,TCPDEBUG); } (*bn) (BLOCK_DNSLOOKUP,NIL);/* quell alarms */ data = (*bn) (BLOCK_SENSITIVE,NIL); /* translate address to name */ if (t = tcp_name_valid (ip_sockaddrtoname (sadr))) { /* produce verbose form if needed */ if (flag) sprintf (ret = tmp,"%s %s",t,adr); else ret = t; } (*bn) (BLOCK_NONSENSITIVE,data); (*bn) (BLOCK_NONE,NIL); /* alarms OK now */ if (tcpdebug) mm_log ("Reverse DNS resolution done",TCPDEBUG); } return cpystr (ret); }
char *tcp_serverhost () { if (!myServerHost) { /* once-only */ size_t sadrlen; struct sockaddr *sadr = ip_newsockaddr (&sadrlen); /* get stdin's name */ if (getsockname (0,sadr,(void *) &sadrlen)) myServerHost = cpystr (mylocalhost ()); else { /* get stdin's name */ myServerHost = tcp_name (sadr,NIL); if (!myServerAddr) myServerAddr = cpystr (ip_sockaddrtostring (sadr)); if (myServerPort < 0) myServerPort = ip_sockaddrtoport (sadr); } fs_give ((void **) &sadr); } return myServerHost; }
void openlog (const char *ident,int logopt,int facility) { char tmp[MAILTMPLEN]; if (!check_nt ()) return; /* no-op on non-NT system */ if (loghdl) fatal ("Duplicate openlog()!"); loghdl = RegisterEventSource (NIL,ident); sprintf (tmp,(logopt & LOG_PID) ? "%s[%d]" : "%s",ident,getpid ()); loghdr = cpystr (tmp); /* save header for later */ }
/* * Insert into "var", which currently has values "oldvarval", the "newline" * at position "insert". */ int ccs_var_insert(struct pine *ps, char *newline, struct variable *var, char **oldvarval, int insert) { int count, i, offset; char **newl, ***alval; for(count = 0; oldvarval && oldvarval[count]; count++) ; if(insert < 0 || insert > count){ q_status_message(SM_ORDER,3,5, "unexpected problem inserting folder"); return(0); } newl = (char **)fs_get((count + 2) * sizeof(char *)); newl[insert] = cpystr(newline); newl[count + 1] = NULL; for(i = offset = 0; oldvarval && oldvarval[i]; i++){ if(i == insert) offset = 1; newl[i + offset] = cpystr(oldvarval[i]); } alval = ALVAL(var, ew); if(alval){ free_list_array(alval); if(newl){ for(i = 0; newl[i] ; i++) /* count elements */ ; *alval = (char **) fs_get((i+1) * sizeof(char *)); for(i = 0; newl[i] ; i++) (*alval)[i] = cpystr(newl[i]); (*alval)[i] = NULL; } } free_list_array(&newl); return(1); }
LDAP_SERV_S * copy_ldap_serv_info(LDAP_SERV_S *src) { LDAP_SERV_S *info = NULL; if(src){ info = (LDAP_SERV_S *) fs_get(sizeof(*info)); /* * Initialize to defaults. */ memset((void *)info, 0, sizeof(*info)); info->serv = src->serv ? cpystr(src->serv) : NULL; info->base = src->base ? cpystr(src->base) : NULL; info->cust = src->cust ? cpystr(src->cust) : NULL; info->binddn = src->binddn ? cpystr(src->binddn) : NULL; info->nick = src->nick ? cpystr(src->nick) : NULL; info->mail = src->mail ? cpystr(src->mail) : NULL; info->mailattr = cpystr((src->mailattr && src->mailattr[0]) ? src->mailattr : DEF_LDAP_MAILATTR); info->snattr = cpystr((src->snattr && src->snattr[0]) ? src->snattr : DEF_LDAP_SNATTR); info->gnattr = cpystr((src->gnattr && src->gnattr[0]) ? src->gnattr : DEF_LDAP_GNATTR); info->cnattr = cpystr((src->cnattr && src->cnattr[0]) ? src->cnattr : DEF_LDAP_CNATTR); info->port = (src->port < 0) ? LDAP_PORT : src->port; info->time = (src->time < 0) ? DEF_LDAP_TIME : src->time; info->size = (src->size < 0) ? DEF_LDAP_SIZE : src->size; info->type = (src->type < 0) ? DEF_LDAP_TYPE : src->type; info->srch = (src->srch < 0) ? DEF_LDAP_SRCH : src->srch; info->scope = (src->scope < 0) ? DEF_LDAP_SCOPE : src->scope; info->impl = src->impl; info->rhs = src->rhs; info->ref = src->ref; info->nosub = src->nosub; info->tls = src->tls; } return(info); }
char *mylocalhost () { char tmp[MAILTMPLEN]; struct hostent *hn; if (!myLocalHost) { /* have local host yet? */ gethostname(tmp,MAILTMPLEN);/* get local host name */ myLocalHost = cpystr ((hn = gethostbyname (tmp)) ? hn->h_name : tmp); } return myLocalHost; }