void AddException(char *who, struct Channel *cptr, char *mask) { struct Exception *tempe; /* don't add any duplicates -- jilles */ if (FindException(cptr, mask) != NULL) return; tempe = (struct Exception *) MyMalloc(sizeof(struct Exception)); memset(tempe, 0, sizeof(struct Exception)); if (who) tempe->who = MyStrdup(who); tempe->mask = MyStrdup(mask); tempe->when = current_ts; tempe->next = cptr->exceptlist; tempe->prev = NULL; if (tempe->next) tempe->next->prev = tempe; cptr->exceptlist = tempe; } /* AddException() */
void AddBan(char *who, struct Channel *cptr, char *ban) { time_t CurrTime = current_ts; struct ChannelBan *tempban; /* don't add any duplicates -- jilles */ if (FindBan(cptr, ban) != NULL) return; tempban = (struct ChannelBan *) MyMalloc(sizeof(struct ChannelBan)); memset(tempban, 0, sizeof(struct ChannelBan)); if (who) tempban->who = MyStrdup(who); tempban->mask = MyStrdup(ban); tempban->when = CurrTime; tempban->next = cptr->firstban; tempban->prev = NULL; if (tempban->next) tempban->next->prev = tempban; cptr->firstban = tempban; } /* AddBan() */
void AddJupe(char *name, char *reason, char *who) { struct Jupe *tempjupe; unsigned int ii; int nickjupe = 1; for (ii = 0; ii < strlen(name); ++ii) { if (IsKWildChar(name[ii])) { nickjupe = 0; break; } } tempjupe = (struct Jupe *) MyMalloc(sizeof(struct Jupe)); memset(tempjupe, 0, sizeof(struct Jupe)); tempjupe->name = MyStrdup(name); tempjupe->reason = MyStrdup(reason); tempjupe->who = MyStrdup(who); tempjupe->isnick = nickjupe; tempjupe->prev = NULL; tempjupe->next = JupeList; if (tempjupe->next) tempjupe->next->prev = tempjupe; JupeList = tempjupe; ++Network->TotalJupes; } /* AddJupe() */
void MoveMemos(struct NickInfo *source, struct NickInfo *dest) { struct MemoInfo *srcmptr, /* pointer to source's memos */ *dstmptr; /* pointer to dest's memos */ struct Memo *memoptr, *mtmp; if (!source || !dest) return; if (!(srcmptr = FindMemoList(source->nick))) return; /* source has no memos to copy */ if (!(dstmptr = FindMemoList(dest->nick))) { /* * Create a memo structure for dest */ dstmptr = MakeMemoList(); dstmptr->name = MyStrdup(dest->nick); AddMemoList(dstmptr); } /* * Go through source's memo list and create duplicate * structures in dest's list */ for (memoptr = srcmptr->memos; memoptr; memoptr = memoptr->next) { mtmp = MakeMemo(); mtmp->sender = MyStrdup(memoptr->sender); mtmp->sent = memoptr->sent; mtmp->index = ++dstmptr->memocnt; mtmp->flags = memoptr->flags; mtmp->text = MyStrdup(memoptr->text); /* * Now add mtmp, which is a duplicate of memoptr, to dest's * memo list */ AddMemo(dstmptr, mtmp); if (!(mtmp->flags & MS_READ)) dstmptr->newmemos++; /* * Mark all of source's memos for deletion */ memoptr->flags |= MS_DELETE; } /* * Purge source's memos */ PurgeMemos(srcmptr); } /* MoveMemos() */
void es_add(char *nick, char *user, char *host, char *msg, time_t time, int type) { int ac; char userhost[USERLEN + HOSTLEN + 2], **av, *mymsg; aSeen *seen = MyMalloc(sizeof(aSeen)); #ifdef NOSQUITSEEN if (type == 1) { mymsg = MyStrdup(msg); ac = SplitBuf(mymsg, &av); if (ac == 2) { if (FindServer(av[0]) && FindServer(av[1])) { MyFree(mymsg); MyFree(av); return ; } } MyFree(mymsg); MyFree(av); } #endif if (++seenc > SeenMaxRecs) { aSeen *sp = seenb; MyFree(seenb->userhost); MyFree(seenb->msg); if (seenb->next) seenb->next->prev = NULL; seenb = seenb->next; MyFree(sp); seenc--; } memset(userhost, 0, sizeof(userhost)); memset(seen, 0, sizeof(aSeen)); strncpy(seen->nick, nick, NICKLEN); strncpy(userhost, user, USERLEN); strcat(userhost, "@"); strncat(userhost, host, HOSTLEN); seen->userhost = MyStrdup(userhost); seen->msg = (type == 1) ? MyStrdup(msg) : NULL; seen->time = time; seen->type = type; seen->prev = seenp; seen->next = NULL; if (seenp) seenp->next = seen; seenp = seen; if (!seenb) seenb = seen; }
static void netlist_style (LibraryMenuType *net, const char *style) { if (net->Style) MYFREE (net->Style); if (style) net->Style = MyStrdup ((char *)style, "Netlist(Style)"); }
/* * AddVote() * adds a vote, returns -1 if they already voted, or 0 * if it's added */ int AddVote(char *name, char *who) { struct JupeVote *tempvote, *votematch = NULL; int exists = 0; int i; time_t unixtime = current_ts; /* check if someone voted for this server already */ for (tempvote = VoteList; tempvote; tempvote = tempvote->next) if (match(name, tempvote->name)) { exists = 1; for (i = 0; i < JUPEVOTES; i++) /* see if they already voted for this server */ if (tempvote->who[i] && match(who, tempvote->who[i])) return -1; votematch = tempvote; } if(exists) /* add vote to total */ { votematch->who[votematch->count] = MyStrdup(who); votematch->count++; votematch->lasttime = unixtime; } else /* add new vote to linked list */ { tempvote = (struct JupeVote *) MyMalloc(sizeof(struct JupeVote)); memset(tempvote, 0, sizeof(struct JupeVote)); tempvote->name = MyStrdup(name); tempvote->who[0] = MyStrdup(who); tempvote->count = 1; tempvote->lasttime = unixtime; tempvote->prev = NULL; tempvote->next = VoteList; if (tempvote->next) tempvote->next->prev = tempvote; VoteList = tempvote; } return 0; }
void SetModes(char *source, int plus, char mode, struct Channel *chptr, char *args) { int acnt, mcnt, ii; char done[MAXLINE], sendstr[MAXLINE]; char **av, *temp, *mtmp; if (!source || !chptr || !args) return; temp = MyStrdup(args); acnt = SplitBuf(temp, &av); memset(&done, 0, MAXLINE); mcnt = 1; for (ii = 0; ii < acnt; ii++) { strcat(done, av[ii]); /* Rewrote this to fix that nasty " " at the end of done[] -kre */ if (mcnt != MaxModes) strcat(done, " "); else { mcnt = 0; mtmp = modestr(MaxModes, mode); ircsprintf(sendstr, "%s%s %s", plus ? "+" : "-", mtmp, done); toserv(":%s MODE %s %s\n", source, chptr->name, sendstr); UpdateChanModes(0, source, chptr, sendstr); MyFree(mtmp); memset(&done, 0, MAXLINE); } mcnt++; } if (done[0] != '\0') { mtmp = modestr(mcnt - 1, mode); ircsprintf(sendstr, "%s%s %s", plus ? "+" : "-", mtmp, done); toserv(":%s MODE %s %s\n", source, chptr->name, sendstr); UpdateChanModes(0, source, chptr, sendstr); MyFree(mtmp); } MyFree(temp); MyFree(av); } /* SetModes() */
/* * AddInviteException() * Add hostmask 'mask' set by 'who' to channel invite exception list * -Janos * * XXX: This code is all from AddException(). They have to be merged into * single function that has an additional argument which will differ * exceptions -kre */ void AddInviteException(char *who, struct Channel *cptr, char *mask) { struct InviteException *tempinvex; tempinvex = (struct InviteException *) MyMalloc(sizeof(struct InviteException)); memset(tempinvex, 0, sizeof(struct InviteException)); if (who) tempinvex->who = MyStrdup(who); tempinvex->mask = MyStrdup(mask); tempinvex->when = current_ts; tempinvex->next = cptr->inviteexceptlist; tempinvex->prev = NULL; if (tempinvex->next) tempinvex->next->prev = tempinvex; cptr->inviteexceptlist = tempinvex; } /* AddInviteException() */
static void transfer_names(ElementTypePtr old_element, ElementTypePtr new_element) { PAD_OR_PIN_LOOP_HYG(old_element, _old); { const char* old_name = pad_or_pin_name(&pp_old); PAD_OR_PIN_LOOP_HYG(new_element, _new); { if (pad_or_pin_number_cmp(&pp_old, &pp_new) == 0) { if (pp_new.pad) { MYFREE(pp_new.pad->Name); pp_new.pad->Name = MyStrdup((char*)old_name, "transfer_names()"); } else if (pp_new.pin) { MYFREE(pp_new.pin->Name); pp_new.pin->Name = MyStrdup((char*)old_name, "transfer_names()"); } } } END_LOOP; } END_LOOP; }
void KickBan(int ban, char *source, struct Channel *channel, char *nicks, char *reason) { char *mask, *tempnix, **av, *bans; char temp[MAXLINE]; int ac, ii; struct Luser *lptr; if (!source || !channel || !nicks) return; tempnix = MyStrdup(nicks); ac = SplitBuf(tempnix, &av); if (ban) { bans = (char *) MyMalloc(sizeof(char)); bans[0] = '\0'; for (ii = 0; ii < ac; ii++) { if (!(lptr = FindClient(av[ii]))) continue; mask = HostToMask(lptr->username, lptr->hostname); ircsprintf(temp, "*!%s", mask); bans = (char *) MyRealloc(bans, strlen(bans) + strlen(temp) + (2 * sizeof(char))); strcat(bans, temp); strcat(bans, " "); MyFree(mask); } SetModes(source, 1, 'b', channel, bans); MyFree(bans); } for (ii = 0; ii < ac; ii++) { toserv(":%s REMOVE %s %s :%s\n", source, channel->name, av[ii], reason ? reason : ""); RemoveFromChannel(channel, FindClient(av[ii])); } MyFree(tempnix); MyFree(av); } /* KickBan() */
int StoreMemo(char *target, char *text, struct Luser *lptr) { struct MemoInfo *mi; struct Memo *memoptr; assert(target && text && lptr); if (!(mi = FindMemoList(target))) { mi = MakeMemoList(); mi->name = MyStrdup(target); AddMemoList(mi); } if (MaxMemos && (mi->memocnt >= MaxMemos)) { notice(n_MemoServ, lptr->nick, "%s has reached the maximum memo limit, and cannot receive more", target); return (0); } ++mi->memocnt; ++mi->newmemos; memoptr = MakeMemo(); memoptr->sender = MyStrdup(lptr->nick); memoptr->sent = current_ts; memoptr->index = mi->memocnt; memoptr->text = MyStrdup(text); AddMemo(mi, memoptr); return (memoptr->index); } /* StoreMemo() */
static void transfer_text(ElementTypePtr old_element, ElementTypePtr new_element) { int i; for (i = 0; i < MAX_ELEMENTNAMES; i++) { TextTypePtr old_text = &old_element->Name[i]; TextTypePtr new_text = &new_element->Name[i]; MYFREE(new_text->TextString); new_text->X = old_text->X; new_text->Y = old_text->Y; new_text->Direction = old_text->Direction; new_text->Flags = old_text->Flags; new_text->Scale = old_text->Scale; new_text->TextString = ((old_text->TextString && *old_text->TextString) ? MyStrdup(old_text->TextString, "transfer_text()") : NULL); } }
/* --------------------------------------------------------------------------- * copies a line */ static void * CopyLine (LayerTypePtr Layer, LineTypePtr Line) { LineTypePtr line; line = CreateDrawnLineOnLayer (Layer, Line->Point1.X + DeltaX, Line->Point1.Y + DeltaY, Line->Point2.X + DeltaX, Line->Point2.Y + DeltaY, Line->Thickness, Line->Clearance, MaskFlags (Line->Flags, FOUNDFLAG)); if (!line) return (line); if (Line->Number) line->Number = MyStrdup (Line->Number, "CopyLine"); DrawLine (Layer, line, 0); AddObjectToCreateUndoList (LINE_TYPE, Layer, line, line); return (line); }
EXPORT turnoutInfo_t * CreateNewStructure( char * scale, char * title, wIndex_t segCnt, trkSeg_p segData, BOOL_T updateList ) { turnoutInfo_t * to; #ifdef REORIGSTRUCT coOrd orig; #endif if (segCnt == 0) return NULL; to = FindCompound( FIND_STRUCT, scale, title ); if (to == NULL) { DYNARR_APPEND( turnoutInfo_t *, structureInfo_da, 10 ); to = (turnoutInfo_t*)MyMalloc( sizeof *to ); structureInfo(structureInfo_da.cnt-1) = to; to->title = MyStrdup( title ); to->scaleInx = LookupScale( scale ); }
void UpdateChanModes(struct Luser *lptr, char *who, struct Channel *cptr, char *modes) { int add; char *tmp, *p; register char ch; struct Luser *userptr; #if defined(NICKSERVICES) && defined(CHANNELSERVICES) int cs_deoped = 0; /* was chanserv deoped? */ #endif char **modeargs; /* arguements to +l/k/o/v modes */ char tempargs[MAXLINE]; int argcnt; /* number of arguements */ int argidx; /* current index in modeargs[] */ #ifndef SAVE_TS char sendstr[MAXLINE]; #endif if (!cptr) return; assert(lptr || who); if (lptr) { SendUmode(OPERUMODE_M, "*** %s: Mode [%s] by %s!%s@%s", cptr->name, modes, lptr->nick, lptr->username, lptr->hostname); putlog(LOG3, "%s: mode change \"%s\" by %s!%s@%s", cptr->name, modes, lptr->nick, lptr->username, lptr->hostname); } else { SendUmode(OPERUMODE_M, "*** %s: Mode [%s] by %s", cptr->name, modes, who); putlog(LOG3, "%s: mode change \"%s\" by %s", cptr->name, modes, who); } if ((tmp = strchr(modes, ' '))) strcpy(tempargs, *(tmp + 1) ? tmp + 1 : ""); else tempargs[0] = '\0'; argcnt = SplitBuf(tempargs, &modeargs); /* * This routine parses the given channel modes and keeps * the corresponding lists correctly updated - also make * sure OperServ and ChanServ remain opped */ add = 0; argidx = (-1); for (tmp = modes; *tmp; ++tmp) { ch = *tmp; if (IsSpace(ch)) break; switch (ch) { case ' ': case '\n': case '\r': break; case '-': { add = 0; break; } case '+': { add = 1; break; } /* * Op/DeOp */ case 'o': { ++argidx; if (argidx >= argcnt) { /* * there are more 'o' flags than there are nicknames, * just break */ break; } if (!(userptr = FindClient(modeargs[argidx]))) break; SetChannelMode(cptr, add, MODE_O, userptr, 0); if (add) { #ifdef STATSERVICES if (lptr) ++lptr->numops; #endif } /* if (add) */ else { if (userptr == Me.osptr) { if (!FloodCheck(cptr, lptr, Me.osptr, 0)) { #ifdef SAVE_TS os_part(cptr); os_join(cptr); #else toserv(":%s MODE %s +o %s\n", n_OperServ, cptr->name, n_OperServ); #endif } if (!lptr) { putlog(LOG1, "%s: %s attempted to deop %s", cptr->name, who, n_OperServ); } else { putlog(LOG1, "%s: %s!%s@%s attempted to deop %s", cptr->name, lptr->nick, lptr->username, lptr->hostname, n_OperServ); } } #if defined(NICKSERVICES) && defined(CHANNELSERVICES) else if (userptr == Me.csptr) { cs_deoped = 1; } #endif /* defined(NICKSERVICES) && defined(CHANNELSERVICES) */ #ifdef STATSERVICES if (lptr) ++lptr->numdops; #endif } /* else if (!add) */ #if defined(NICKSERVICES) && defined(CHANNELSERVICES) cs_CheckModes(lptr, FindChan(cptr->name), !add, MODE_O, userptr); #endif break; } /* case 'o' */ /* * Voice/DeVoice */ case 'v': { ++argidx; if (argidx >= argcnt) break; if (!(userptr = FindClient(modeargs[argidx]))) break; SetChannelMode(cptr, add, MODE_V, userptr, 0); if (add) { #ifdef STATSERVICES if (lptr) ++lptr->numvoices; #endif } else { #ifdef STATSERVICES if (lptr) ++lptr->numdvoices; #endif } /* else if (!add) */ #if defined(NICKSERVICES) && defined(CHANNELSERVICES) cs_CheckModes(lptr, FindChan(cptr->name), !add, MODE_V, userptr); #endif break; } /* case 'v' */ #ifdef HYBRID7 /* HalfOp/DeHalfOp -Janos */ case 'h': { ++argidx; if (argidx >= argcnt) break; if (!(userptr = FindClient(modeargs[argidx]))) break; SetChannelMode(cptr, add, MODE_H, userptr, 0); if (add) { #ifdef STATSERVICES if (lptr) ++lptr->numhops; #endif } else { #ifdef STATSERVICES if (lptr) ++lptr->numdhops; #endif } /* else if (!add) */ #if defined(NICKSERVICES) && defined(CHANNELSERVICES) cs_CheckModes(lptr, FindChan(cptr->name), !add, MODE_H, userptr); #endif break; } /* case 'h'*/ #endif /* HYBRID7 */ /* * Channel limit */ case 'l': { if (add) { ++argidx; if (argidx >= argcnt) break; cptr->limit = atoi(modeargs[argidx]); } else cptr->limit = 0; #if defined(NICKSERVICES) && defined(CHANNELSERVICES) cs_CheckModes(lptr, FindChan(cptr->name), !add, MODE_L, 0); #endif break; } /* case 'l' */ /* * Channel key */ case 'k': { ++argidx; if (argidx >= argcnt) break; #ifndef BLOCK_ALLOCATION if (cptr->key) MyFree(cptr->key); #endif if (add) { #ifdef BLOCK_ALLOCATION strncpy(cptr->key, modeargs[argidx], KEYLEN); cptr->key[KEYLEN] = '\0'; #else cptr->key = MyStrdup(modeargs[argidx]); #endif /* BLOCK_ALLOCATION */ } else { #ifdef BLOCK_ALLOCATION cptr->key[0] = '\0'; #else cptr->key = 0; #endif /* BLOCK_ALLOCATION */ } #if defined(NICKSERVICES) && defined(CHANNELSERVICES) cs_CheckModes(lptr, FindChan(cptr->name), !add, MODE_K, 0); #endif break; } /* case 'k' */ /* * Channel forwarding target */ case 'f': { ++argidx; if (argidx >= argcnt) break; #ifndef BLOCK_ALLOCATION if (cptr->forward) MyFree(cptr->forward); #endif if (add) { #ifdef BLOCK_ALLOCATION strncpy(cptr->forward, modeargs[argidx], CHANNELLEN); cptr->forward[CHANNELLEN] = '\0'; #else cptr->forward = MyStrdup(modeargs[argidx]); #endif /* BLOCK_ALLOCATION */ } else { #ifdef BLOCK_ALLOCATION cptr->forward[0] = '\0'; #else cptr->forward = 0; #endif /* BLOCK_ALLOCATION */ } #if defined(NICKSERVICES) && defined(CHANNELSERVICES) cs_CheckModes(lptr, FindChan(cptr->name), !add, MODE_F, 0); #endif break; } /* case 'f' */ /* * Channel ban */ case 'b': { ++argidx; if (argidx >= argcnt) break; /* if it's a forwarding ban like nick!ident@host!#channel * just drop the forward channel * found by CheeToS -- jilles */ p = strchr(modeargs[argidx], '!'); if (p != NULL) { p = strchr(p + 1, '!'); if (p != NULL) *p = '\0'; } if (add) AddBan(who, cptr, modeargs[argidx]); else DeleteBan(cptr, modeargs[argidx]); if (p != NULL) *p = '!'; break; } /* case 'b' */ #ifdef GECOSBANS /* * Channel deny */ case 'd': { ++argidx; if (argidx >= argcnt) break; if (add) AddGecosBan(who, cptr, modeargs[argidx]); else DeleteGecosBan(cptr, modeargs[argidx]); break; } /* case 'd' */ #endif /* GECOSBANS */ /* * Channel exception */ case 'e': { ++argidx; if (argidx >= argcnt) break; if (add) AddException(who, cptr, modeargs[argidx]); else DeleteException(cptr, modeargs[argidx]); break; } /* case 'e' */ #ifdef HYBRID7 /* Channel invite exception -Janos */ case 'I': { ++argidx; if (argidx >= argcnt) break; if (add) AddInviteException(who, cptr, modeargs[argidx]); else DeleteInviteException(cptr, modeargs[argidx]); break; } /* case 'I' */ #endif /* HYBRID7 */ default: { int modeflag = 0; if (ch == 's') modeflag = MODE_S; else if (ch == 'p') modeflag = MODE_P; else if (ch == 'n') modeflag = MODE_N; else if (ch == 't') modeflag = MODE_T; else if (ch == 'm') modeflag = MODE_M; else if (ch == 'i') modeflag = MODE_I; else if (ch == 'r') modeflag = MODE_R; else if (ch == 'z') modeflag = MODE_Z; else if (ch == 'P') modeflag = MODE_CAPP; #if 0 /* doesn't exist in 1.0.34 */ else if (ch == 'F') modeflag = MODE_CAPF; #endif else if (ch == 'Q') modeflag = MODE_CAPQ; #ifdef HYBRID7 else if (ch == 'a') modeflag = MODE_A; #endif else if (ch == 'c') modeflag = MODE_C; else if (ch == 'g') modeflag = MODE_G; else if (ch == 'L') modeflag = MODE_CAPL; else if (ch == 'R') modeflag = MODE_CAPR; if (modeflag) { if (add) cptr->modes |= modeflag; else cptr->modes &= ~modeflag; } #if defined(NICKSERVICES) && defined(CHANNELSERVICES) if (modeflag) cs_CheckModes(lptr, FindChan(cptr->name), !add, modeflag, 0); #endif break; } /* default: */ } /* switch (*tmp) */ } /* for (tmp = modes; *tmp; ++tmp) */ MyFree(modeargs); #if defined(NICKSERVICES) && defined(CHANNELSERVICES) if ((cs_deoped) && (!FloodCheck(cptr, lptr, Me.csptr, 0))) { /* reop ChanServ */ #ifdef SAVE_TS cs_part(cptr); cs_join(FindChan(cptr->name)); #else toserv(":%s MODE %s +o %s\n", n_ChanServ, cptr->name, n_ChanServ); #endif if (!lptr) putlog(LOG1, "%s: %s attempted to deop %s", cptr->name, who, n_ChanServ); else putlog(LOG1, "%s: %s!%s@%s attempted to deop %s", cptr->name, lptr->nick, lptr->username, lptr->hostname, n_ChanServ); } #endif /* defined(NICKSERVICES) && defined(CHANNELSERVICES) */ } /* UpdateChanModes() */
static void CreateSubTree(struct Level **level, struct Level *parent, void *typeptr, int hostc, char **hostv) { struct Level *tmpnode; char *ch; if (hostc == 0) return; /* * First search the current level for an exact match * of hostv[hostc - 1]. - if found proceed to the next * level down from there. * We can't use IsOnLevel() here because we need an * exact match (strcasecmp) - we don't want stuff like * "c?m" and "com" being put in the same node. */ for (tmpnode = *level; tmpnode; tmpnode = tmpnode->nextpiece) { if (!strcasecmp(tmpnode->name, hostv[hostc - 1])) { /* * We have found a matching host piece on this * level - no need to allocate a new level * structure. Now we will recursively call * CreateSubTree() again using tmpnode->nextlevel * as the level pointer, indicating that we want * to see if the next lower index of hostv * (hostv[hostc - 2]) is in the next level. If so, * again recursively call CreateSubTree(). Eventually * we might reach a level that does not contain * the corresponding index of hostv[]. When that * happens, the loop will fail and we will * drop below to allocate a new level structure. * If that does not happen, we have an exact duplicate * of a previous I/K line, in which case hostc will * be 1, and we add typeptr to the node's list of * pointers (the username may differ). */ if (hostc == 1) LinkStructPointer(typeptr, &tmpnode); CreateSubTree(&tmpnode->nextlevel, tmpnode, typeptr, hostc - 1, hostv); return; } } /* * If we reach this point, one of two conditions must * be true. * 1) *level is NULL, which means we must initialize it * and then add our hostv[] index to it. * 2) The host piece hostv[hostc - 1] was not found * on this level - allocate a new structure for it. */ tmpnode = (struct Level *) MyMalloc(sizeof(struct Level)); memset(tmpnode, 0, sizeof(struct Level)); tmpnode->name = MyStrdup(hostv[hostc - 1]); if (parent) { tmpnode->prevlevel = parent; ++parent->SubNodes; ++parent->UnsearchedSubNodes; } for (ch = tmpnode->name; *ch; ++ch) { if (IsWild(*ch)) { tmpnode->flags |= LV_WILDCARD; break; } } if (hostc == 1) { /* * Since hostc is 1, this is the very last hostname piece * we need to add to the sub tree. This is the piece that * will contain a pointer to the corresponding Iline or * Kline structure, so SearchSubTree() will know when to * stop. * Now, it is quite possible that later on we will need to * add more host pieces past this current piece. For example, * suppose our tree looks like this after this call: * * com * | * varner -> [struct Iline *iptr (for @varner.com)] * * Then, suppose later we wish to add an Iline for * @koruna.varner.com. Our tree should then look like this: * * com * | * varner -> [struct Iline (for @varner.com)] * | * koruna -> [struct Iline (for @koruna.varner.com)] * * SearchSubTree() will then know that both levels are a * complete I/K line, and depending on how big the hostname * it is looking for, will know how deep to go. */ LinkStructPointer(typeptr, &tmpnode); } if (*level == NULL) { /* * Set the level to our newly allocated structure */ *level = tmpnode; } else { /* * The level already exists, and possibly has some * host pieces on it - add our new piece after * *level. For example, if the level originally looked * like: * * ... * | * "com" --> "net" --> "org" --> NULL * * It will now look like: * * ... * | * "com" --> tmpnode->name --> "net" --> "org" --> NULL */ tmpnode->nextpiece = (*level)->nextpiece; (*level)->nextpiece = tmpnode; } /* * We've just added hostv[hostc - 1] to the correct level, * but as long as hostc != 0, there are more host pieces * to add. Recursively call CreateSubTree() until there * are no more pieces to add. */ CreateSubTree(&tmpnode->nextlevel, tmpnode, typeptr, hostc - 1, hostv); } /* CreateSubTree() */
void DeleteClient(struct Luser *user) { struct UserChannel *chnext; #ifdef NICKSERVICES struct NickInfo *nptr, *realptr; #ifdef CHANNELSERVICES struct aChannelPtr *fnext; #endif #endif /* NICKSERVICES */ if (user == NULL) return; SendUmode(OPERUMODE_CAPE, "*** Client exit: %s!%s@%s [%s]", user->nick, user->username, user->hostname, user->server ? user->server->name : "*unknown*"); #ifdef NICKSERVICES realptr = FindNick(user->nick); nptr = GetMaster(realptr); if (nptr && realptr) { if (LastSeenInfo && (realptr->flags & NS_IDENTIFIED)) { /* * Update last seen user@host info */ if (realptr->lastu) MyFree(realptr->lastu); if (realptr->lasth) MyFree(realptr->lasth); realptr->lastu = MyStrdup(user->username); realptr->lasth = MyStrdup(user->hostname); } /* * they're quitting - unmark them as identified */ realptr->flags &= ~NS_IDENTIFIED; } #ifdef CHANNELSERVICES while (user->founder_channels) { fnext = user->founder_channels->next; RemFounder(user, user->founder_channels->cptr); user->founder_channels = fnext; } #endif #endif /* NICKSERVICES */ #ifdef ALLOW_FUCKOVER /* check if user was a target of o_fuckover() */ CheckFuckoverTarget(user, NULL); #endif if (user->server) user->server->numusers--; while (user->firstchan) { chnext = user->firstchan->next; RemoveFromChannel(user->firstchan->chptr, user); user->firstchan = chnext; } HashDelClient(user, 0); /* keep oper count updated */ if (user->umodes & UMODE_O) { Network->TotalOperators--; if (user->server) user->server->numopers--; } #ifndef BLOCK_ALLOCATION MyFree(user->nick); MyFree(user->username); MyFree(user->hostname); MyFree(user->realname); #endif /* BLOCK_ALLOCATION */ if (user->prev) user->prev->next = user->next; else ClientList = user->next; if (user->next) user->next->prev = user->prev; #ifdef BLOCK_ALLOCATION BlockSubFree(ClientHeap, user); #else MyFree(user); #endif /* BLOCK_ALLOCATION */ Network->TotalUsers--; } /* DeleteClient() */
struct Luser * AddClient(char **line) { char *ch; struct Luser *tempuser, *newptr; #ifdef BLOCK_ALLOCATION tempuser = (struct Luser *) BlockSubAllocate(ClientHeap); if (!tempuser) /* shouldn't happen - but I'm paranoid :) */ return (NULL); memset(tempuser, 0, sizeof(struct Luser)); strlcpy(tempuser->nick, line[1], NICKLEN + 1); strlcpy(tempuser->username, line[5], USERLEN + 1); strlcpy(tempuser->hostname, line[6], HOSTLEN + 1); strlcpy(tempuser->realname, line[8] + 1, REALLEN + 1); #else tempuser = (struct Luser *) MyMalloc(sizeof(struct Luser)); memset(tempuser, 0, sizeof(struct Luser)); tempuser->nick = MyStrdup(line[1]); tempuser->username = MyStrdup(line[5]); tempuser->hostname = MyStrdup(line[6]); tempuser->realname = MyStrdup(line[8] + 1); #endif /* BLOCK_ALLOCATION */ tempuser->since = atol(line[3]); #ifdef NICKSERVICES tempuser->nick_ts = tempuser->since; #if defined SVSNICK || defined FORCENICK tempuser->flags &= ~(UMODE_NOFORCENICK); #endif #endif /* NICKSERVICES */ if ((tempuser->server = FindServer(line[7]))) { tempuser->server->numusers++; #ifdef STATSERVICES if (tempuser->server->numusers > tempuser->server->maxusers) { tempuser->server->maxusers = tempuser->server->numusers; tempuser->server->maxusers_ts = current_ts; } #endif } ch = &line[4][1]; while (*ch) { switch (*ch) { case 'i': case 'I': { tempuser->umodes |= UMODE_I; break; } case 's': case 'S': { tempuser->umodes |= UMODE_S; break; } case 'w': case 'W': { tempuser->umodes |= UMODE_W; break; } case 'o': case 'O': { tempuser->umodes |= UMODE_O; Network->TotalOperators++; #ifdef STATSERVICES if (Network->TotalOperators > Network->MaxOperators) { Network->MaxOperators = Network->TotalOperators; Network->MaxOperators_ts = current_ts; if ((Network->MaxOperators % 5) == 0) { /* inform +y people of new max oper count */ SendUmode(OPERUMODE_Y, "*** New Max Operator Count: %ld", Network->MaxOperators); putlog(LOG2, "New Max Operator Count: %ld", Network->MaxOperators); } } if (Network->TotalOperators > Network->MaxOperatorsT) { Network->MaxOperatorsT = Network->TotalOperators; Network->MaxOperatorsT_ts = current_ts; } #endif if (tempuser->server) { tempuser->server->numopers++; #ifdef STATSERVICES if (tempuser->server->numopers > tempuser->server->maxopers) { tempuser->server->maxopers = tempuser->server->numopers; tempuser->server->maxopers_ts = current_ts; } #endif } break; } /* case 'O' */ #ifdef DANCER case 'e': case 'E': { struct NickInfo *realptr; realptr = FindNick(tempuser->nick); if (realptr) { realptr->flags |= NS_IDENTIFIED; tempuser->umodes |= UMODE_E; RecordCommand("User %s has +e umode, marking as identified", tempuser->nick); } else { /* Is it one of mine? */ int mine = 0; struct aService *sptr; for (sptr = ServiceBots; sptr->name; ++sptr) if (!irccmp(tempuser->nick, *(sptr->name))) { mine = 1; break; } if (!mine) { /* Blech, who is screwing with us? */ toserv(":%s MODE %s -e\r\n", Me.name, tempuser->nick); RecordCommand("User %s has +e umode but is not known to me, setting -e", tempuser->nick); } } break; } #endif /* DANCER */ default: break; } /* switch (*ch) */ ch++; } tempuser->next = ClientList; tempuser->prev = NULL; if (tempuser->next) tempuser->next->prev = tempuser; ClientList = tempuser; /* add client to the hash table */ newptr = HashAddClient(ClientList, 0); Network->TotalUsers++; #ifdef STATSERVICES if (Network->TotalUsers > Network->MaxUsers) { Network->MaxUsers = Network->TotalUsers; Network->MaxUsers_ts = current_ts; if ((Network->MaxUsers % 10) == 0) { /* notify +y people of new max user count */ SendUmode(OPERUMODE_Y, "*** New Max Client Count: %ld", Network->MaxUsers); putlog(LOG2, "New Max Client Count: %ld", Network->MaxUsers); } } if (Network->TotalUsers > Network->MaxUsersT) { Network->MaxUsersT = Network->TotalUsers; Network->MaxUsersT_ts = current_ts; } #endif /* STATSERVICES */ #ifdef ALLOW_GLINES /* * It's possible the client won't exist anymore, because if the user * is a clone and AutoKillClones is enabled, HashAddClient() would * have already killed the user, in which case newptr will be * NULL - CheckGlined() checks for null pointers */ CheckGlined(newptr); /* Check if new user is glined */ #endif return (tempuser); } /* AddClient() */
/* * es_loaddata() * * Load Seen database - return 1 if successful, -1 if not, and -2 if the * errors are unrecoverable */ int es_loaddata() { FILE *fp; char line[MAXLINE], **av; char *keyword; int ac, ret = 1, cnt, type = 0; aSeen *seen; if ((fp = fopen(SeenServDB, "r")) == NULL) { /* SeenServ data file doesn't exist */ return ( -1); } FreeSeen(); cnt = 0; /* load data into list */ while (fgets(line, MAXLINE - 1, fp)) { cnt++; ac = SplitBuf(line, &av); if (!ac) { /* probably a blank line */ MyFree(av); continue; } if (av[0][0] == ';') { MyFree(av); continue; } if (!ircncmp("->", av[0], 2)) { /* * check if there are enough args */ if (ac < 4) { fatal(1, "%s:%d Invalid database format (FATAL)", SeenServDB, cnt); ret = -2; MyFree(av); continue; } keyword = av[0] + 2; type = 0; if (!ircncmp(keyword, "QUIT", 4)) { type = 1; } else if (!ircncmp(keyword, "NICK", 4)) { type = 2; } if (type) { seen = MyMalloc(sizeof(aSeen)); memset(seen, 0, sizeof(aSeen)); strncpy(seen->nick, av[1], NICKLEN); seen->userhost = MyStrdup(av[2]); seen->msg = (type == 1) ? MyStrdup(av[4] + 1) : NULL; seen->time = atol(av[3]); seen->type = type; seen->prev = seenp; seen->next = NULL; if (seenp) seenp->next = seen; seenp = seen; if (!seenb) seenb = seen; ++seenc; } } MyFree(av); } /* while */ fclose(fp); return (ret); } /* es_loaddata */
static int dparse(char *line, int linenum, int rehash) { struct Directive *dptr; int larc; /* line arg count */ char *larv[PARAM_MAX]; /* holds line arguements */ char *lineptr, *tmp; int ret, ii, pcnt; ret = 2; /* * We can't use SplitBuf() to break up the line, since * it doesn't handle quotes etc. - do it manually */ larc = 0; for (lineptr = line; *lineptr; lineptr++) { if (larc >= PARAM_MAX) { fatal(1, "%s:%d Too many parameters (max: %d)", SETPATH, linenum, PARAM_MAX); ret = 0; break; } if (!lineptr || !*lineptr) break; while (*lineptr && IsSpace(*lineptr)) lineptr++; if (!*lineptr) break; tmp = lineptr; if (*lineptr == '"') { /* we encountered a quote */ /* advance past quotation mark */ tmp++; lineptr++; /* * Now advance lineptr until we hit another quotation mark, * or the end of the line */ while (*lineptr && (*lineptr != '"')) { /* * If they want to include double quotes, they can * put a \" inside the quoted string, so advance * lineptr past it twice, once for the '\' and once * for the '"'. */ if (*lineptr == '\\') lineptr++; lineptr++; } if (!*lineptr) { /* we hit EOL without reaching another quotation mark */ fatal(1, "%s:%d Unterminated quote", SETPATH, linenum); ret = 0; break; } *lineptr = '\0'; } /* if (*lineptr == '"') */ else { /* * Advance lineptr until we hit a space */ while (*lineptr && !IsSpace(*lineptr)) lineptr++; if (*lineptr) *lineptr = '\0'; } larv[larc++] = tmp; } /* for (lineptr = line; *lineptr; lineptr++) */ if (!ret || !larc) return (ret); if (!(dptr = FindDirective(larv[0]))) { fatal(1, "%s:%d Unknown directive [%s] (ignoring)", SETPATH, linenum, larv[0]); return (1); } if (rehash && (dptr->flag == D_NORUNTIME)) { /* * SETPATH is being parsed during a rehash, and we * hit a non-run time configurable option, ignore it */ return (2); } pcnt = 1; for (ii = 0; ii < PARAM_MAX; ii++, pcnt++) { if (!dptr->param[ii].type) break; /* * Now assign our variable (dptr->param[ii].ptr) to the * corresponding larv[] slot */ if ((dptr->param[ii].type != PARAM_SET) && (pcnt >= larc)) { fatal(1, "%s:%d Not enough arguements to [%s] directive", SETPATH, linenum, dptr->name); return (0); } #if 0 /* * There should be code which check for too many arguments for * PARAM_SET - because of bugs in previous HybServ1 code I am leaving * this code under undef, but it _should_ go into distribution once. * However, I don't wont to break old `save -conf' files. -kre */ if ((dptr->param[ii].type == PARAM_SET) && (pcnt > 1)) { fatal(1, "%s:%d Too many arguments for [%s] directive", SETPATH, linenum, dptr->name); return 0; } #endif switch (dptr->param[ii].type) { case PARAM_STRING: { if ((*(char **) dptr->param[ii].ptr) != NULL) { /* * If this is a rehash, make sure we free the old * string before allocating a new one. If this * is NOT a rehash, we should never get here, because * ClearDirectives() would have already zeroed * all ptr fields of directives[] */ MyFree(*(char **) dptr->param[ii].ptr); } *(char **) dptr->param[ii].ptr = MyStrdup(larv[pcnt]); break; } case PARAM_INT: { int value; value = IsNum(larv[pcnt]); if (!value) { fatal(1, "%s:%d Invalid integer", SETPATH, linenum); ret = 0; break; } /* * We have to call atoi() anyway since IsNum() would * have returned 1 if larv[pcnt] was "0", but IsNum() * is a good way of making sure we have a valid integer */ *(int *) dptr->param[ii].ptr = atoi(larv[pcnt]); break; } case PARAM_TIME: { long value; value = timestr(larv[pcnt]); /* Now, let us consider this a bit. Function timestr() will try to * extract as much data as it can. And sometimes we actually * _want_ to put 0 in time field to turn off that feature. So we * will have it turned off whether it has garbage there, or is 0. * Sounds OK, does it? -kre */ /* if (!value) { fatal(1, "%s:%d Invalid time format", SETPATH, linenum); ret = 0; break; } */ *(long *) dptr->param[ii].ptr = value; break; } case PARAM_SET: { *(int *) dptr->param[ii].ptr = 1; break; } case PARAM_PORT: { int value; value = IsNum(larv[pcnt]); if (!value) { fatal(1, "%s:%d Invalid port number (must be between 1 and 65535)", SETPATH, linenum); ret = 0; break; } value = atoi(larv[pcnt]); if ((value < 1) || (value > 65535)) { fatal(1, "%s:%d Invalid port number (must be between 1 and 65535)", SETPATH, linenum); ret = 0; break; } *(int *) dptr->param[ii].ptr = value; break; } default: { /* we shouldn't get here */ fatal(1, "%s:%d Unknown parameter type [%d] for directive [%s]", SETPATH, linenum, dptr->param[ii].type, dptr->name); ret = 0; break; } } /* switch (dptr->param[ii].type) */ } /* for (ii = 0; ii < PARAM_MAX; ii++, pcnt++) */ return (ret); } /* dparse() */
static void m_send(struct Luser *lptr, struct NickInfo *nptr, int ac, char **av) { char *memotext, /* memo text */ *to; /* who the memo is sent to */ int index; struct NickInfo *master = NULL, *realptr = NULL; #ifdef CHANNELSERVICES struct ChanInfo *ci = NULL; #endif if (ac < 3) { notice(n_MemoServ, lptr->nick, "Syntax: SEND <nick/channel> <text>"); notice(n_MemoServ, lptr->nick, ERR_MORE_INFO, n_MemoServ, "SEND"); return; } if (*av[1] == '#') { #ifndef CHANNELSERVICES notice(n_MemoServ, lptr->nick, "Channel services are disabled"); return; #else if (!(ci = FindChan(av[1]))) { notice(n_MemoServ, lptr->nick, ERR_CH_NOT_REGGED, av[1]); return; } if (!HasAccess(ci, lptr, CA_AUTOOP)) { notice(n_MemoServ, lptr->nick, "AutoOp access is required to send a memo to [\002%s\002]", ci->name); return; } to = ci->name; #endif /* CHANNELSERVICES */ } else { /* it was sent to a nickname */ if (!(realptr = FindNick(av[1]))) { notice(n_MemoServ, lptr->nick, ERR_NOT_REGGED, av[1]); return; } master = GetMaster(realptr); assert(master != 0); if (!(master->flags & NS_MEMOS)) { notice(n_MemoServ, lptr->nick, "[\002%s\002] is rejecting all memos", av[1]); return; } to = master->nick; } /* get the actual memo text now */ if (ac < 3) memotext = MyStrdup(""); else memotext = GetString(ac - 2, av + 2); index = StoreMemo(to, memotext, lptr); if (index) { notice(n_MemoServ, lptr->nick, "Memo has been recorded for [\002%s\002]", realptr ? realptr->nick : to); if (realptr && master) { /* * It was sent to a nickname - check if they are online * and identified and optionally notify them * * we should have here linklist traversal and notifying all clients. * however, that could be a bit cpu intensitive to do for every * memo, so i haven't done it so far. -kre */ if ((master->flags & NS_MEMONOTIFY) && (realptr->flags & NS_IDENTIFIED) && FindClient(realptr->nick)) { notice(n_MemoServ, realptr->nick, "You have a new memo from \002%s\002 (#%d)", lptr->nick, index); notice(n_MemoServ, realptr->nick, "Type \002/msg %s READ %d\002 to read it", n_MemoServ, index); } } /* if (ni) */ #ifdef CHANNELSERVICES else { struct Channel *chptr; struct ChanAccess *ca; char *newtext; /* * It was sent to a channel - notify every AOP or higher */ if ((ci) && (chptr = FindChannel(to))) { struct ChannelUser *cu; struct NickInfo *tmpn; for (cu = chptr->firstuser; cu; cu = cu->next) { if (FindService(cu->lptr)) continue; tmpn = GetLink(cu->lptr->nick); if (HasAccess(ci, cu->lptr, CA_AUTOOP)) { if (tmpn) { /* don't notify people who don't want memos */ if (!(tmpn->flags & NS_MEMOS) || !(tmpn->flags & NS_MEMONOTIFY)) continue; } notice(n_MemoServ, cu->lptr->nick, "New channel memo from \002%s\002 (#%d)", lptr->nick, index); notice(n_MemoServ, cu->lptr->nick, "Type \002/msg %s READ %s %d\002 to read it", n_MemoServ, chptr->name, index); } } } newtext = (char *) MyMalloc(strlen(memotext) + strlen(ci->name) + 4); ircsprintf(newtext, "(%s) %s", ci->name, memotext); for (ca = ci->access; ca; ca = ca->next) { if (ca->nptr) StoreMemo(ca->nptr->nick, newtext, lptr); } MyFree(newtext); } /* else */ #endif /* CHANNELSERVICES */ } /* if (index) */ MyFree (memotext); } /* m_send() */
struct Channel * AddChannel(char **line, int nickcnt, char **nicks) { char *names; char **anames; char *currnick; char modes[MAXLINE]; struct Channel *chname, *cptr; struct Channel *tempchan; int ii, ncnt, acnt; ncnt = 5; /* default position for channel nicks, if no limit/key */ strcpy(modes, line[4]); while (line[ncnt][0] != ':') { strcat(modes, " "); strcat(modes, line[ncnt]); ncnt++; } if (nickcnt > 0) { acnt = nickcnt; anames = nicks; } else { names = line[ncnt]; names++; /* point past the leading : */ ii = strlen(names); /* kill the \n char on the end */ if (IsSpace(names[ii - 2])) names[ii - 2] = '\0'; else if (IsSpace(names[ii - 1])) names[ii - 1] = '\0'; acnt = SplitBuf(names, &anames); } if (!(cptr = FindChannel(line[3]))) { #ifdef BLOCK_ALLOCATION tempchan = (struct Channel *) BlockSubAllocate(ChannelHeap); memset(tempchan, 0, sizeof(struct Channel)); strncpy(tempchan->name, line[3], CHANNELLEN); #else tempchan = (struct Channel *) MyMalloc(sizeof(struct Channel)); memset(tempchan, 0, sizeof(struct Channel)); tempchan->name = MyStrdup(line[3]); #endif /* BLOCK_ALLOCATION */ tempchan->since = atol(line[2]); tempchan->numusers = acnt; tempchan->next = ChannelList; tempchan->prev = NULL; if (tempchan->next) tempchan->next->prev = tempchan; HashAddChan(tempchan); ChannelList = tempchan; chname = ChannelList; ++Network->TotalChannels; #ifdef STATSERVICES if (Network->TotalChannels > Network->MaxChannels) { Network->MaxChannels = Network->TotalChannels; Network->MaxChannels_ts = current_ts; if ((Network->MaxChannels % 10) == 0) { /* notify +y people about new max channel count */ SendUmode(OPERUMODE_Y, "*** New Max Channel Count: %ld", Network->MaxChannels); } } if (Network->TotalChannels > Network->MaxChannelsT) { Network->MaxChannelsT = Network->TotalChannels; Network->MaxChannelsT_ts = current_ts; } #endif /* STATSERVICES */ } else /* it's an existing channel, but someone has joined it */ { cptr->numusers += acnt; chname = cptr; } /* Add the channel to each nick's channel list */ for (ii = 0; ii < acnt; ii++) { currnick = GetNick(anames[ii]); if (!currnick) continue; if (!IsChannelMember(chname, FindClient(currnick))) { /* * Use anames[ii] instead of currnick here so we get * the @/+ flags */ AddToChannel(chname, anames[ii]); } else chname->numusers--; } /* finally, add the modes for the channel */ UpdateChanModes(0, line[0] + 1, chname, modes); /* * Only free anames[] if there was no nick list * given */ if (!nickcnt) MyFree(anames); return (chname); } /* AddChannel() */
static int FontEdit (int argc, char **argv, int Ux, int Uy) { FontType *font; SymbolType *symbol; LayerTypePtr lfont, lorig, lwidth, lgrid; int s, l; if (hid_actionl ("New", "Font", 0)) return 1; while (PCB->Data->LayerN > 4) MoveLayer (4, -1); for (l = 0; l < 4; l++) { MoveLayerToGroup (l, l); } PCB->MaxWidth = CELL_SIZE * 18; PCB->MaxHeight = CELL_SIZE * ((MAX_FONTPOSITION + 15) / 16 + 2); PCB->Grid = 500.0; PCB->Data->Layer[0].Name = MyStrdup ("Font", "FontEdit"); PCB->Data->Layer[1].Name = MyStrdup ("OrigFont", "FontEdit"); PCB->Data->Layer[2].Name = MyStrdup ("Width", "FontEdit"); PCB->Data->Layer[3].Name = MyStrdup ("Grid", "FontEdit"); hid_action ("PCBChanged"); hid_action ("LayersChanged"); lfont = PCB->Data->Layer + 0; lorig = PCB->Data->Layer + 1; lwidth = PCB->Data->Layer + 2; lgrid = PCB->Data->Layer + 3; font = &PCB->Font; for (s = 0; s <= MAX_FONTPOSITION; s++) { int ox = (s % 16 + 1) * CELL_SIZE; int oy = (s / 16 + 1) * CELL_SIZE; int w, miny, maxy, maxx = 0; symbol = &font->Symbol[s]; miny = 500; maxy = font->MaxHeight; for (l = 0; l < symbol->LineN; l++) { CreateDrawnLineOnLayer (lfont, symbol->Line[l].Point1.X + ox, symbol->Line[l].Point1.Y + oy, symbol->Line[l].Point2.X + ox, symbol->Line[l].Point2.Y + oy, symbol->Line[l].Thickness, symbol->Line[l].Thickness, NoFlags ()); CreateDrawnLineOnLayer (lorig, symbol->Line[l].Point1.X + ox, symbol->Line[l].Point1.Y + oy, symbol->Line[l].Point2.X + ox, symbol->Line[l].Point2.Y + oy, symbol->Line[l].Thickness, symbol->Line[l].Thickness, NoFlags ()); if (maxx < symbol->Line[l].Point1.X) maxx = symbol->Line[l].Point1.X; if (maxx < symbol->Line[l].Point2.X) maxx = symbol->Line[l].Point2.X; } w = maxx + symbol->Delta + ox; CreateDrawnLineOnLayer (lwidth, w, miny + oy, w, maxy + oy, 100, 100, NoFlags ()); } for (l = 0; l < 16; l++) { int x = (l + 1) * CELL_SIZE; CreateDrawnLineOnLayer (lgrid, x, 0, x, PCB->MaxHeight, 100, 100, NoFlags ()); } for (l = 0; l <= MAX_FONTPOSITION / 16 + 1; l++) { int y = (l + 1) * CELL_SIZE; CreateDrawnLineOnLayer (lgrid, 0, y, PCB->MaxWidth, y, 100, 100, NoFlags ()); } return 0; }
int ms_loaddata() { FILE *fp; char line[MAXLINE], **av; char *keyword; int ac, ret = 1, cnt; struct MemoInfo *mi = NULL; struct NickInfo *nickptr; if (!(fp = fopen(MemoServDB, "r"))) { /* MemoServ data file doesn't exist */ return -1; } cnt = 0; /* load data into list */ while (fgets(line, MAXLINE - 1, fp)) { cnt++; ac = SplitBuf(line, &av); if (!ac) { /* probably a blank line */ MyFree(av); continue; } if (av[0][0] == ';') { /* its a comment */ MyFree(av); continue; } if (!ircncmp("->", av[0], 2)) { /* * check if there are enough args */ if (ac < 5) { fatal(1, "%s:%d Invalid database format (FATAL)", MemoServDB, cnt); ret = -2; MyFree(av); continue; } /* check if there is no nickname before it */ if (!mi) { fatal(1, "%s:%d No nickname associated with data", MemoServDB, cnt); if (ret > 0) ret = -1; MyFree(av); continue; } keyword = av[0] + 2; if (!ircncmp(keyword, "TEXT", 4)) { struct Memo *memoptr; memoptr = MakeMemo(); memoptr->sender = MyStrdup(av[1]); memoptr->sent = atol(av[2]); memoptr->flags = atol(av[3]); if (!(memoptr->flags & MS_READ)) mi->newmemos++; memoptr->text = MyStrdup(av[4] + 1); memoptr->index = ++mi->memocnt; AddMemo(mi, memoptr); } } /* if (!ircncmp("->", keyword, 2)) */ else { if (mi) { if (!mi->memos) { fatal(1, "%s:%d No memos for entry [%s] (skipping)", MemoServDB, cnt, mi->name); MyFree(mi->name); MyFree(mi); mi = NULL; if (ret > 0) ret = -1; } else AddMemoList(mi); } /* * make sure there are enough args on the line: * <nickname> */ if (ac < 1) { fatal(1, "%s:%d Invalid database format (FATAL)", MemoServDB, cnt); ret = -2; mi = NULL; MyFree(av); continue; } if (!(nickptr = FindNick(av[0]))) { fatal(1, "%s:%d Memo entry [%s] is not a registered nickname (skipping)", MemoServDB, cnt, av[0]); if (ret > 0) ret = -1; mi = NULL; MyFree(av); continue; } #ifdef LINKED_NICKNAMES if (nickptr->master) { /* * nickptr is a leaf nickname - they should not have * memo entries */ fatal(1, "%s:%d Memo entry [%s] is not a master nickname (skipping)", MemoServDB, cnt, av[0]); if (ret > 0) ret = (-1); mi = NULL; MyFree(av); continue; } #endif /* LINKED_NICKNAMES */ mi = MakeMemoList(); mi->name = MyStrdup(av[0]); } MyFree(av); } /* while (fgets(line, MAXLINE - 1, fp)) */ if (mi) { if (!mi->memos) { fatal(1, "%s:%d No memos for entry [%s] (skipping)", MemoServDB, cnt, mi->name); MyFree(mi->name); MyFree(mi); if (ret > 0) ret = -1; } else AddMemoList(mi); } fclose (fp); return (ret); } /* ms_loaddata() */
static void m_reply(struct Luser *lptr, struct NickInfo *nptr, int ac, char **av) { struct MemoInfo *from; struct Memo *memoptr; struct NickInfo *master, *realptr; char *memotext; int index, ii; if (!nptr) return; if (ac < 3) { notice(n_MemoServ, lptr->nick, "Syntax: REPLY <index> <text>"); notice(n_MemoServ, lptr->nick, ERR_MORE_INFO, n_MemoServ, "REPLY"); return; } if (!(from = FindMemoList(nptr->nick))) { notice(n_MemoServ, lptr->nick, "You have no recorded memos"); return; } index = IsNum(av[1]); if ((index < 0) || (index > from->memocnt)) { notice(n_MemoServ, lptr->nick, "[\002%s\002] is an invalid index", av[1]); return; } master = realptr = NULL; for (memoptr = from->memos; memoptr; memoptr = memoptr->next) { if (memoptr->index == index) { if (!(realptr = FindNick(memoptr->sender))) { notice(n_MemoServ, lptr->nick, ERR_NOT_REGGED, av[2]); return; } master = GetMaster(realptr); assert(master != 0); if (!(master->flags & NS_MEMOS)) { notice(n_MemoServ, lptr->nick, "[\002%s\002] is rejecting all memos", master->nick); return; } break; } } if (!master || !realptr) return; if (ac >= 3) { memotext = (char *) MyMalloc(strlen("[Re]: ") + strlen(av[2]) + 1); ircsprintf(memotext, "[Re]: %s", av[2]); ii = 3; while (ii < ac) { memotext = (char *) MyRealloc(memotext, strlen(memotext) + strlen(av[ii]) + (2 * sizeof(char))); strcat(memotext, " "); strcat(memotext, av[ii]); ii++; } } else memotext = MyStrdup(""); index = StoreMemo(master->nick, memotext, lptr); if (index) { notice(n_MemoServ, lptr->nick, "Memo has been recorded for [\002%s\002]", master->nick); /* * It was sent to a nickname - check if they are online * and notify them */ if ((master->flags & NS_MEMONOTIFY) && (realptr->flags & NS_IDENTIFIED) && FindClient(realptr->nick)) { notice(n_MemoServ, realptr->nick, "You have a new memo from \002%s\002 (#%d)", lptr->nick, index); notice(n_MemoServ, realptr->nick, "Type \002/msg %s READ %d\002 to read it", n_MemoServ, index); } } /* if (index) */ MyFree(memotext); } /* m_reply() */
static void m_forward(struct Luser *lptr, struct NickInfo *nptr, int ac, char **av) { struct MemoInfo *from, *target; struct Memo *memoptr = NULL; struct Memo *fromptr; char *to; /* who the memo is sent to */ int index, cnt; char buf[MAXLINE]; struct NickInfo *master, *realptr; #ifdef CHANNELSERVICES struct ChanInfo *ci = NULL; #endif if (!nptr) return; if (ac < 3) { notice(n_MemoServ, lptr->nick, "Syntax: FORWARD <index|ALL> <nick/channel>"); notice(n_MemoServ, lptr->nick, ERR_MORE_INFO, n_MemoServ, "FORWARD"); return; } if (!(from = FindMemoList(nptr->nick))) { notice(n_MemoServ, lptr->nick, "You have no recorded memos"); return; } index = IsNum(av[1]); if ((index < 0) || (index > from->memocnt) || (!index && (irccmp(av[1], "ALL") != 0))) { notice(n_MemoServ, lptr->nick, "[\002%s\002] is an invalid index", av[1]); return; } master = realptr = NULL; if (*av[2] == '#') { #ifndef CHANNELSERVICES notice(n_MemoServ, lptr->nick, "Channel services are disabled"); return; #else if (!(ci = FindChan(av[2]))) { notice(n_MemoServ, lptr->nick, ERR_CH_NOT_REGGED, av[2]); return; } if (!HasAccess(ci, lptr, CA_AUTOOP)) { notice(n_MemoServ, lptr->nick, "AutoOp access is required to forward a memo to [\002%s\002]", ci->name); return; } to = ci->name; #endif } else { /* it was sent to a nickname */ if (!(realptr = FindNick(av[2]))) { notice(n_MemoServ, lptr->nick, ERR_NOT_REGGED, av[2]); return; } master = GetMaster(realptr); assert(master != 0); if (!(master->flags & NS_MEMOS)) { notice(n_MemoServ, lptr->nick, "[\002%s\002] is rejecting all memos", realptr->nick); return; } to = master->nick; } if (!(target = FindMemoList(to))) { target = MakeMemoList(); target->name = MyStrdup(to); AddMemoList(target); } else if (from == target) { /* * If we let someone forward memos to themselves, * the below loop will never end, eventually malloc()'ing too * much and crashing - head it off at the pass */ notice(n_MemoServ, lptr->nick, "You cannot forward memos to yourself"); return; } if (MaxMemos && (target->memocnt >= MaxMemos)) { notice(n_MemoServ, lptr->nick, "%s has reached the maximum memo limit, and cannot receive more", to); return; } cnt = 0; for (fromptr = from->memos; fromptr; fromptr = fromptr->next) { if (!index || (fromptr->index == index)) { memset(&buf, 0, MAXLINE); target->memocnt++; target->newmemos++; cnt++; memoptr = MakeMemo(); memoptr->sender = MyStrdup(lptr->nick); memoptr->sent = current_ts; memoptr->index = target->memocnt; strcpy(buf, "[Fwd]: "); strncat(buf, fromptr->text, MAXLINE - 8); memoptr->text = MyStrdup(buf); AddMemo(target, memoptr); if (MaxMemos && (target->memocnt >= MaxMemos)) break; } } if (!index) ircsprintf(buf, "All memos have"); else ircsprintf(buf, "Memo #%d has", index); notice(n_MemoServ, lptr->nick, "%s been forwarded to [\002%s\002]", buf, target->name); if (master && realptr) { /* * It was sent to a nickname - check if they are online * and notify them */ if ((master->flags & NS_MEMONOTIFY) && (realptr->flags & NS_IDENTIFIED) && FindClient(realptr->nick)) { notice(n_MemoServ, realptr->nick, "You have %d new forwarded memo%s from \002%s\002", cnt, (cnt == 1) ? "" : "s", memoptr->sender); notice(n_MemoServ, realptr->nick, "Type \002/msg %s LIST\002 to view %s", n_MemoServ, (cnt == 1) ? "it" : "them"); } } /* if (master && realptr) */ #ifdef CHANNELSERVICES else { struct Channel *chptr; /* * It was sent to a channel - notify every AOP or higher */ if ((ci) && (chptr = FindChannel(target->name))) { struct ChannelUser *cu; struct NickInfo *tmpn; for (cu = chptr->firstuser; cu; cu = cu->next) { if (FindService(cu->lptr)) continue; tmpn = GetLink(cu->lptr->nick); if (HasAccess(ci, cu->lptr, CA_AUTOOP)) { if (tmpn) { if (!(tmpn->flags & NS_MEMOS) || !(tmpn->flags & NS_MEMONOTIFY)) continue; } notice(n_MemoServ, cu->lptr->nick, "%d new forwarded channel memo%s from \002%s\002", cnt, (cnt == 1) ? "" : "s", memoptr->sender); notice(n_MemoServ, cu->lptr->nick, "Type \002/msg %s LIST %s\002 to view %s", n_MemoServ, chptr->name, (cnt == 1) ? "it" : "them"); } } } } /* else */ #endif /* CHANNELSERVICES */ } /* m_forward() */