int plot_annotations_add_named_target(plotann_t* ann, const char* name) { target_t tar; int i, N; // Try bright stars N = bright_stars_n(); for (i=0; i<N; i++) { const brightstar_t* bs = bright_stars_get(i); if (!bs->name && !bs->common_name) continue; if (strcaseeq(name, bs->name) || strcaseeq(name, bs->common_name)) { tar.ra = bs->ra; tar.dec = bs->dec; if (strcaseeq(name, bs->name)) tar.name = bs->name; else tar.name = bs->common_name; logmsg("Found %s: RA,Dec (%g,%g)\n", name, bs->ra, bs->dec); bl_append(ann->targets, &tar); return 0; } } // Try NGC objects ngc_entry* e = ngc_get_entry_named(name); if (!e) { ERROR("Failed to find target named \"%s\"", name); return -1; } tar.name = ngc_get_name_list(e, " / "); tar.ra = e->ra; tar.dec = e->dec; logmsg("Found %s: RA,Dec (%g,%g)\n", tar.name, tar.ra, tar.dec); bl_append(ann->targets, &tar); return 0; }
static int msg_autoop(const char *replyto, struct userlist *user, char *data) { if (data == NULL) { if (botinfo->autoop == 1) { msgreply(user, replyto, "Autoop ON"); } else { msgreply(user, replyto, "Autoop OFF"); } return (0); } if (strcaseeq("off", data)) { botinfo->autoop = 0; msgreply(user, replyto, "Autoop OFF"); return (0); } if (strcaseeq("on", data)) { botinfo->autoop = 1; msgreply(user, replyto, "Autoop ON"); return (0); } msgreply(user, replyto, "Syntax error: Autoop <on/off>"); return (0); }
/* The title of the page, plus the user's HEADERFILE */ void html_pagetitle(FILE *outf, Outchoices *od) { fputs("<h1><a NAME=\"Top\">", outf); if (!strcaseeq(od->logo, "none")) { fputs("<IMG src=\"", outf); if (od->logo[0] != '/' && strstr(od->logo, "://") == NULL) htmlputs(outf, od, od->imagedir, IN_HREF); htmlputs(outf, od, od->logo, IN_HREF); if (STREQ(od->logo, "analogo")) fprintf(outf, ".%s", od->pngimages?"png":"gif"); /* Above: '.' not EXTSEP even on RISC OS */ fputs("\" alt=\"\"> ", outf); } if (strcaseeq(od->hosturl, "none")) { fprintf(outf, "%s</a> ", od->lngstr[webstatsfor_]); htmlputs(outf, od, od->hostname, FROM_CFG); } else { fprintf(outf, "%s</a> <a HREF=\"", od->lngstr[webstatsfor_]); htmlputs(outf, od, od->hosturl, IN_HREF); fputs("\">", outf); htmlputs(outf, od, od->hostname, FROM_CFG); fputs("</a>", outf); } fputs("</h1>\n\n", outf); if (!strcaseeq(od->headerfile, "none")) html_includefile(outf, od, od->headerfile, 'h'); }
static void config_handle_key_tag(MBKeyboardConfigState *state, const char **attr) { const char *val; DBG("got key"); state->current_key = mb_kbd_key_new(state->keyboard); if ((val = attr_get_val("obey-caps", attr)) != NULL) { if (strcaseeq(val, "true")) mb_kbd_key_set_obey_caps(state->current_key, True); } if ((val = attr_get_val("extended", attr)) != NULL) { if (strcaseeq(val, "true")) mb_kbd_key_set_extended(state->current_key, True); } if ((val = attr_get_val("width", attr)) != NULL) { if (atoi(val) > 0) mb_kbd_key_set_req_uwidth(state->current_key, atoi(val)); } if ((val = attr_get_val("fill", attr)) != NULL) { if (strcaseeq(val, "true")) mb_kbd_key_set_fill(state->current_key, True); } mb_kbd_row_append_key(state->current_row, state->current_key); }
/** * Open a file via taglib and add file type information * * Open files, that taglib supports but taggit doesn't have specific support * for using TagLibs generic interface only. That will stop us from working * with multi-artist files for those types, but it's better than nothing. * * @param file file name to open * * @return copy of the generated struct taggit_file; *NOT* a pointer * to it! Destroy using taggit_file_destroy(). * @sideeffects none */ struct taggit_file taggit_file_open(const char *file) { struct taggit_file rc; char *ext; ext = (char *)strrchr(file, (int)'.'); if (ext == NULL || *(ext + 1) == '\0') goto err; ext++; if (strcaseeq(ext, (char *)"mp3")) { rc.data = reinterpret_cast<TagLib_File *> (new TagLib::MPEG::File(file)); rc.type = FT_MPEG; } else if (strcaseeq(ext, (char *)"ogg")) { rc.data = reinterpret_cast<TagLib_File *> (new TagLib::Ogg::Vorbis::File(file)); rc.type = FT_OGGVORBIS; } else if (strcaseeq(ext, (char *)"oga")) { TagLib::File *f; f = new TagLib::Ogg::FLAC::File(file); if (f->isValid()) { rc.data = reinterpret_cast<TagLib_File *>(f); rc.type = FT_OGGFLAC; } else { delete f; rc.data = reinterpret_cast<TagLib_File *> (new TagLib::Ogg::Vorbis::File(file)); rc.type = FT_OGGVORBIS; } } else if (strcaseeq(ext, (char *)"flac")) { rc.data = reinterpret_cast<TagLib_File *> (new TagLib::FLAC::File(file)); rc.type = FT_FLAC; } else { TagLib_File *f; f = taglib_file_new(file); if (!taglib_file_is_valid(f)) { taglib_file_free(f); goto err; } else { rc.data = f; rc.type = FT_UNKNOWN; } } return rc; err: fprintf(stderr, "Cannot handle file: \"%s\" - skipping.\n", file); rc.data = NULL; rc.type = FT_INVALID; return rc; }
/* The title of the page, plus the user's HEADERFILE */ void cro_pagetitle(FILE *outf, Outchoices *od) { if (!strcaseeq(od->headerfile, "none")) cro_includefile(outf, od, od->headerfile, 'h'); fprintf(outf, "x%sVE%sanalog %s\n", od->compsep, od->compsep, VNUMBER); fprintf(outf, "x%sHN%s%s\n", od->compsep, od->compsep, od->hostname); if (!strcaseeq(od->hosturl, "none")) fprintf(outf, "x%sHU%s%s\n", od->compsep, od->compsep, od->hosturl); }
/* This tries to identify local host and domain names * described in RFC6761 plus the redhatism of localdomain */ return strcaseeq(hostname, "localhost") || strcaseeq(hostname, "localhost.") || strcaseeq(hostname, "localhost.localdomain") || strcaseeq(hostname, "localhost.localdomain.") || endswith_no_case(hostname, ".localhost") || endswith_no_case(hostname, ".localhost.") || endswith_no_case(hostname, ".localhost.localdomain") || endswith_no_case(hostname, ".localhost.localdomain."); } #if 0 /* NM_IGNORED */ bool is_gateway_hostname(const char *hostname) { assert(hostname); /* This tries to identify the valid syntaxes for the our * synthetic "gateway" host. */ return strcaseeq(hostname, "gateway") || strcaseeq(hostname, "gateway."); }
static param_t parse_parameter(char *param) { if (strcaseeq(param, "COUNT")) { return PARAM_COUNT; } if (strcaseeq(param, "KEY")) { return PARAM_KEY; } if (strcaseeq(param, "IV")) { return PARAM_IV; } if (strcaseeq(param, "PLAINTEXT") || strcaseeq(param, "PT")) { return PARAM_PLAINTEXT; } if (strcaseeq(param, "CIPHERTEXT") || strcaseeq(param, "CT")) { return PARAM_CIPHERTEXT; } if (strcaseeq(param, "AAD")) { return PARAM_AAD; } if (strcaseeq(param, "TAG")) { return PARAM_ICV; } return PARAM_UNKNOWN; }
bool is_gateway_hostname(const char *hostname) { assert(hostname); /* This tries to identify the valid syntaxes for the our * synthetic "gateway" host. */ return strcaseeq(hostname, "_gateway") || strcaseeq(hostname, "_gateway.") #if ENABLE_COMPAT_GATEWAY_HOSTNAME || strcaseeq(hostname, "gateway") || strcaseeq(hostname, "gateway.") #endif ; }
int handle_command(struct userlist *user, const char *dest, char *message) { const char *command; char *rest, *trest; const char *replyto; struct commandlist *listptr; int ret; if(user->access < 0) { /* banned users get nothing */ return(0); } if(user->access > botinfo->floodexempt) { if(botinfo->ctcpdelay != 0 && botinfo->cmddelay+user->lastcmd >= currtime) { time(&user->lastcmd); return(0); } } time(&user->lastcmd); if (strcaseeq(dest, user->userinfo->server->nick)) replyto = unick(user); else replyto = dest; command = strtok(message, " "); rest = strtok(NULL, ""); listptr = usercommandlist; while (listptr != NULL) { if (strcaseeq(command, listptr->cmd)) { if (user->access <= listptr->access) { if ( rest != NULL && (listptr->flags & cmd_param_rw )) { trest = strdup(rest); ret = listptr->function(replyto, user, trest); safefree(trest); return(ret); } else { ret = listptr->function(replyto, user, rest); return (ret); } } else { return (access_too_low(user, replyto)); } } listptr = listptr->next; } return (0); }
static int XFlashClient(XFlash *Xf){ Connection *Conn = Xf->xf_Conn; FILE *fc; FILE *tc; IStr(req,128); IStr(com,128); IStr(arg,128); const char *dp; IStr(svhost,128); int svsock; int port; IStr(dispenv,128); int actid; fc = fdopen(FromC,"r"); tc = fdopen(ToC,"w"); if( tc == NULL || fc == NULL ){ return -1; } Xf->xf_xfsockfp = tc; toFlash(Xf,"INIT2"); fflush(tc); strcpy(svhost,"127.0.0.1"); for( port = 6001; port < 6010; port++ ){ svsock = server_open("XFlash",AVStr(svhost),port,1); if( 0 <= svsock ){ break; } } sprintf(dispenv,"DISPLAY=127.0.0.1:%d.0",port-6000); fprintf(stderr,"--- env[%s]\n",dispenv); actid = thread_fork(0,0,"XFlash-TH",(IFUNCP)Xnew,Xf,svsock); for(;;){ if( fgets(req,sizeof(req),fc) == NULL ){ break; } dp = wordScan(req,com); dp = lineScan(dp,arg); fprintf(stderr,"---- [%s][%s]\n",com,arg); if( strcaseeq(com,"quit") || strcaseeq(com,"exit") ){ break; } if( strcaseeq(com,"x") ){ forkXclient(arg,dispenv); } } return 0; }
bool is_localhost(const char *hostname) { assert(hostname); /* This tries to identify local host and domain names * described in RFC6761 plus the redhatism of localdomain */ return strcaseeq(hostname, "localhost") || strcaseeq(hostname, "localhost.") || strcaseeq(hostname, "localhost.localdomain") || strcaseeq(hostname, "localhost.localdomain.") || endswith_no_case(hostname, ".localhost") || endswith_no_case(hostname, ".localhost.") || endswith_no_case(hostname, ".localhost.localdomain") || endswith_no_case(hostname, ".localhost.localdomain."); }
coeff_t * alloc_coeff_model (const char *coeff_model_name, rpf_t *rpf, rpf_t *dc_rpf, unsigned min_level, unsigned max_level) /* * Allocate a new coefficients model which is identified by the string * 'coeff_model_name'. 'rpf' and 'dc_rpf' define the reduced * precision formats the should be used to quantize normal and DC * components, respectively. 'min_level' and 'max_level' define the * range of range approximations. * * Return value: * pointer to the allocated coefficients model * * Note: * Refer to 'coeff.h' for a short description of the member functions. */ { unsigned n; for (n = 0; coeff_models [n].identifier; n++) /* step through all id's */ if (strcaseeq (coeff_models [n].identifier, coeff_model_name)) return coeff_models [n].function (rpf, dc_rpf, min_level, max_level); warning ("Can't initialize coefficients model '%s'. " "Using default value '%s'.", coeff_model_name, coeff_models [0].identifier); return coeff_models [0].function (rpf, dc_rpf, min_level, max_level); }
void set_myFQDN(void) { char FQDN[HOST_NAME_MAX + 1]; int r = gethostname(FQDN, sizeof(FQDN)); size_t len; if (r != 0) { log_errno((e, "gethostname() failed in set_myFQDN")); } else { FQDN[sizeof(FQDN) - 1] = '\0'; /* insurance */ len = strlen(FQDN); if (len > 0 && FQDN[len-1] == '.') { /* nuke trailing . */ FQDN[len-1] = '\0'; } if (!strcaseeq(FQDN, "localhost.localdomain")) { myids[MYID_HOSTNAME]->destroy(myids[MYID_HOSTNAME]); myids[MYID_HOSTNAME] = identification_create_from_string(FQDN); } } }
int POP_STARTTLS_withCL(Connection *Conn,FILE *fc,FILE *tc,PCStr(com),PCStr(arg)){ /* if( strcaseeq(com,"CAPA") ){ if( needSTLS(Conn) ){ fputs("+OK Capability list follows\r\n",tc); fputs("STLS\r\n",tc); fputs(".\r\n",tc); return 1; } } */ if( strcaseeq(com,"STLS") ){ if( willSTLS_CL(Conn) ){ int fcl; SSLstart = 1; fcl = insertTLS_CL(Conn,ToC,ToS); SSLstart = 0; if( 0 <= fcl ){ fputs("+OK\r\n",tc); fflush(tc); PollIn(fcl,TIMEOUT_STLS); dup2(fcl,fileno(tc)); dup2(fcl,fileno(fc)); close(fcl); }else{ fputs("-ERR\r\n",tc); } return 1; } } return 0; }
void scan_M17N(DGC*ctx,PCStr(conf)){ IStr(nam,128); IStr(val,128); fieldScan(conf,nam,val); if( strcaseeq(nam,"on") ){ m17n_enabled = 1; } else if( strcaseeq(nam,"off") ){ m17n_enabled = 0; } else if( strcaseeq(nam,"lib") ){ /* add the path to the default search path of dylib */ } }
/* * See header */ eap_type_t eap_type_from_string(char *name) { int i; static struct { char *name; eap_type_t type; } types[] = { {"identity", EAP_IDENTITY}, {"md5", EAP_MD5}, {"otp", EAP_OTP}, {"gtc", EAP_GTC}, {"tls", EAP_TLS}, {"ttls", EAP_TTLS}, {"sim", EAP_SIM}, {"aka", EAP_AKA}, {"peap", EAP_PEAP}, {"mschapv2", EAP_MSCHAPV2}, {"tnc", EAP_TNC}, {"dynamic", EAP_DYNAMIC}, {"radius", EAP_RADIUS}, }; for (i = 0; i < countof(types); i++) { if (strcaseeq(name, types[i].name)) { return types[i].type; } } return 0; }
int FTP_dataSTLS_FCL(Connection *Conn,Connection *dataConn,int cldata) { int fcldata; if( (ClientFlags & PF_STLS_ON) == 0 ){ return -1; } if( strcaseeq(iSERVER_PROTO,"ftps") ){ /* accepted as SERVER=ftps */ /* 9.9.8 suppress SSL for data-conn. with STLS=fcl:ftps */ if( willFTPS_dataSSL_CL(Conn) == 0 ){ return -4; } } if( FtpTLSX_VALID ){ if( FtpTLSX->ftp_PROT == 'C' ){ return -2; } if( FtpTLSX->ftp_PROT == 0 ){ if( FTPS_detect_dataSSL(Conn,cldata) <= 0 ){ return -3; } } } dataConn->cl.p_flags = ClientFlags & ~PF_STLS_ON; fcldata = insertTLS_CL(dataConn,cldata,-1); return fcldata; }
int POP_STARTTLS_withSV(Connection *Conn,FILE *ts,FILE *fs,PCStr(user)){ CStr(resp,1024); if( ServerFlags & (PF_SSL_ON|PF_STLS_ON) ){ return 1; } if( willSTLS_SV(Conn) ){ if( strcaseeq(DST_PROTO,"pop3s") ){ return -3; } sv1log("POP D-S: STLS to server\n"); fputs("STLS\r\n",ts); fflush(ts); if( fgets(resp,sizeof(resp),fs) == NULL ) return -1; sv1log("POP S-D: %s",resp); if( *resp == '+' ){ int fsv; fsv = insertTLS_SV(Conn,ToC,ToS); if( 0 <= fsv ){ dup2(fsv,fileno(ts)); dup2(fsv,fileno(fs)); close(fsv); return 0; } }else{ return -2; } } return 0; }
int IMAP_STARTTLS_withCL(Connection *Conn,FILE *fc,FILE *tc,PCStr(tag),PCStr(com),PCStr(arg)){ if( willSTLS_CL(Conn) == 0 ) return 0; if( strcaseeq(com,"STARTTLS") ){ int fcl; SSLstart = 1; fcl = insertTLS_CL(Conn,ToC,ToS); SSLstart = 0; if( 0 <= fcl ){ fprintf(tc,"%s OK Begin TLS negotiation\r\n",tag); fflush(tc); PollIn(fcl,TIMEOUT_STLS); dup2(fcl,fileno(tc)); dup2(fcl,fileno(fc)); close(fcl); }else{ fprintf(tc,"%s BAD\r\n",tag); } return 1; } return 0; }
int IMAP_STARTTLS_withSV(Connection *Conn,FILE *ts,FILE *fs,PCStr(user)){ CStr(resp,1024); CStr(code,1024); if( willSTLS_SV(Conn) ){ fputs("stls0 STARTTLS\r\n",ts); fflush(ts); if( fgets(resp,sizeof(resp),fs) == NULL ) return -1; *code = 0; Xsscanf(resp,"%*s %s",AVStr(code)); if( strcaseeq(code,"OK") ){ int fsv; fsv = insertTLS_SV(Conn,ToC,ToS); if( 0 <= fsv ){ dup2(fsv,fileno(ts)); dup2(fsv,fileno(fs)); close(fsv); return 0; } }else{ return -2; } } return 0; }
/** * Search oakley_hash_names for a match, eg: * "md5" <=> "OAKLEY_MD5" * @param str String containing Hash name (eg: MD5, SHA1) * @param len Length of str (note: not NUL-terminated) * @return int Registered # of Hash ALG if loaded. */ static int aalg_getbyname_ike(const char *str) { int ret = -1; int num_read; DBG(DBG_CONTROL, DBG_log("entering aalg_getbyname_ike()")); if (str == NULL || str == '\0') return ret; ret = alg_enum_search(&oakley_hash_names, "OAKLEY_", "", str); if (ret >= 0) return ret; /* Special value for no authentication since zero is already used. */ if (strcaseeq(str, "null")) return INT_MAX; /* support idXXX as syntax, matching iana numbers directly */ num_read = -1; if (sscanf(str, "id%d%n", &ret, &num_read) >= 1 && num_read == (int) strlen(str)) return ret; return -1; }
domain_pool_t * alloc_domain_pool (const char *domain_pool_name, unsigned max_domains, unsigned max_edges, const wfa_t *wfa) /* * Allocate a new domain pool identified by the string * 'domain_pool_name'. Maximum number of domain images (each one * represented by one state of the given 'wfa') is specified by * 'max_domains'. * * Return value: * pointer to the allocated domain pool * * Note: * refer to 'domain-pool.h' for a short description of the member functions. */ { unsigned n; if (!max_domains) { warning ("Can't generate empty domain pool. " "Using at least DC component."); max_domains = 1; } for (n = 0; domain_pools [n].identifier; n++) /* step through all id's */ if (strcaseeq (domain_pools [n].identifier, domain_pool_name)) return domain_pools [n].function (max_domains, max_edges, wfa); warning ("Can't initialize domain pool '%s'. Using default value '%s'.", domain_pool_name, domain_pools [0].identifier); return domain_pools [0].function (max_domains, max_edges, wfa); }
unsigned int parser_loose_enum(struct keyword *k, const char *s) { const struct keyword_def *kd = k->keydef; int kevcount; const struct keyword_enum_value *kev; unsigned int valresult; assert(kd->type == kt_loose_enum || kd->type == kt_rsakey); assert(kd->validenum != NULL && kd->validenum->values != NULL); for (kevcount = kd->validenum->valuesize, kev = kd->validenum->values; kevcount > 0 && !strcaseeq(s, kev->name); kev++, kevcount--) ; /* if we found something */ if (kevcount != 0) { assert(kev->value != 0); valresult = kev->value; k->string = NULL; return valresult; } k->string = strdup(s); /* ??? why not xstrdup? */ return 255; }
void set_myFQDN(void) { char FQDN[HOST_NAME_MAX + 1]; int r = gethostname(FQDN, sizeof(FQDN)); free_id_content(&myids[MYID_HOSTNAME]); myids[MYID_HOSTNAME] = empty_id; if (r != 0) { log_errno((e, "gethostname() failed in set_myFQDN")); } else { FQDN[sizeof(FQDN) - 1] = '\0'; /* insurance */ { size_t len = strlen(FQDN); if (len > 0 && FQDN[len - 1] == '.') { /* nuke trailing . */ FQDN[len - 1] = '\0'; } } if (!strcaseeq(FQDN, "localhost.localdomain")) { clonetochunk(myids[MYID_HOSTNAME].name, FQDN, strlen(FQDN), "my FQDN"); myids[MYID_HOSTNAME].kind = ID_FQDN; calc_myid_str(MYID_HOSTNAME); } } }
static int redirect(FILE *fs,PCStr(qcmd),PCStr(resp),PVStr(serv),PVStr(req)){ const char *dp; const char *pfx = "mail server, use "; CStr(rtag,LNSIZE); CStr(rstat,LNSIZE); dp = wordScan(resp,rtag); dp = wordScan(dp,rstat); if( strcaseeq(qcmd,"LOGIN") && strcaseeq(rstat,"NO") ){ if( dp = strstr(resp,"[ALERT]") ) if( dp = strstr(dp,pfx) ) if( Xsscanf(dp+strlen(pfx),"%[-.0-9a-zA-Z]",AVStr(serv)) ){ return 1; } } return 0; }
static void conf_reqpass(char *data) { if (strcaseeq(data, "ON")) { botinfo->reqpass = 1; } else { botinfo->reqpass = 0; } }
int willSTLS_CL(Connection *Conn){ if( Conn->from_myself ){ Verbose("## STLS ## no client %X [%d/%d/%d] %X %s:%d\n", Conn->from_myself,ClientSock,FromC,ToC, ClientFlags,Client_Host,Client_Port); return 0; } if( (ClientFlags & PF_STLS_CHECKED) == 0 ){ CTX_pushClientInfo(Conn); checkWithSTLS(Conn,"FCL",CLNT_PROTO,""); if( (ClientFlags & PF_STLS_OPT) == 0 ) if( ClientFlags & PF_STLS_DO ) if( 0 < STLS_implicit_wait ) if( STLS_wait_set == 0 ) if( STLS_implicit_wait < 10 ) if( strcaseeq(CLNT_PROTO,"tcprelay") || strcaseeq(CLNT_PROTO,"https") ){ waitSTLS_CL(Conn,(int)((8-STLS_implicit_wait)*1000)); } if( ClientFlags & PF_STLS_DO ) if( 0 < STLS_implicit_wait ) waitSTLS_CL(Conn,(int)(STLS_implicit_wait*1000)); /* if( 0 < PollIn(ClientSock,(int)(STLS_implicit_wait*1000)) ) if( isinSSL(ClientSock) ){ int fcl; fcl = insertFCLX(Conn,"starttls",CLNT_PROTO,FromC,ToS); syslog_ERROR("## STLS ## IMPLICIT SSL ON %d,%d,%d,%d\n", ClientSock,FromC,ToC,fcl); if( 0 <= fcl ){ dup2(fcl,FromC); close(fcl); ClientFlags |= PF_STLS_ON; } } */ HL_popClientInfo(); } if( ClientFlags & PF_STLS_ON ) return 0; return ClientFlags & PF_STLS_DO; }
static void conf_nserv(char *data) { if (strcaseeq("ON", data)) { botinfo->ns = 1; } else { botinfo->ns = 0 ; } debug_log("NickServ routines=%s\n", data) ; }
int asFunc(PCStr(arg1)){ CStr(name,128); refQStr(dp,name); int fi; const char *n1; strcpy(name,arg1); if( dp = strrpbrk(name,"\\/") ) ovstrcpy(name,dp+1); if( dp = strtailstrX(name,".exe",1) ) setVStrEnd(dp,0); for( fi = 0; n1 = subfuncs[fi].f_name; fi++ ){ if( strcaseeq(name,n1) ) return fi+1; if( strncaseeq(name,"dg",2) && strcaseeq(name+2,n1) ) return fi+1; } return 0; }