/* * GroupLoad: Look up the group with the given name. If a group exists, fill in * g with information about the group and return GROUP_MATCH. * If the group name is ambiguous, return GROUP_AMBIGUOUS. * Otherwise, return GROUP_NOMATCH. */ int GroupLoad(char *name, UserGroup *g) { int index; char buf[MAX_GROUPLINE], *ptr; index = FindGroupByName(name); switch(index) { case GROUP_NOMATCH: return GROUP_NOMATCH; case GROUP_AMBIGUOUS: return GROUP_AMBIGUOUS; default: // Load and copy group info GetPrivateProfileString(group_section, groups[index], "", buf, MAX_GROUPLINE, cinfo->ini_file); ptr = strtok(buf, name_separator); g->num_users = 0; while (ptr != NULL && g->num_users < MAX_GROUPSIZE) { strncpy(g->names[g->num_users], ptr, MAX_CHARNAME); g->names[g->num_users][MAX_CHARNAME] = 0; ptr = strtok(NULL, name_separator); g->num_users++; } return GROUP_MATCH; } }
BOOL fsDownloads_GroupsMgr::GetGroup(fsDownloadGroup *pGroup, int iGroup) { if (iGroup >= GetCount () || iGroup < 0) iGroup = FindGroupByName (GRP_OTHER_NAME); *pGroup = m_vGroups [iGroup]; return TRUE; }
/* * GroupDelete: Remove the group with the given name. * Return True on success. */ Bool GroupDelete(char *group_name) { int index, i; index = FindGroupByName(group_name); switch(index) { case GROUP_NOMATCH: GameMessage(GetString(hInst, IDS_BADGROUPNAME)); return False; case GROUP_AMBIGUOUS: GameMessage(GetString(hInst, IDS_DUPLICATEGROUPNAME)); return False; } group_name = groups[index]; // Remove INI entry WritePrivateProfileString(group_section, group_name, NULL, cinfo->ini_file); // Remove group from internal group structure for (i=index; i < num_groups - 1; i++) strcpy(groups[i], groups[i + 1]); num_groups--; return True; }
/* * GroupAdd: Add the names in args to the given group name. If the group doesn't * exist, create it. * Return number of names added to group (0 on failure). */ int GroupAdd(char *group_name, char *args) { UserGroup g; int index, i, num_added; char *ptr, *name; Bool add_name; num_added = 0; index = FindGroupByName(group_name); switch(index) { case GROUP_NOMATCH: GameMessage(GetString(hInst, IDS_BADGROUPNAME)); return 0; case GROUP_AMBIGUOUS: GameMessage(GetString(hInst, IDS_DUPLICATEGROUPNAME)); return 0; default: group_name = groups[index]; GroupLoad(group_name, &g); break; } name = GetPlayerName(args, &ptr); while (name != NULL) { if (g.num_users >= MAX_GROUPSIZE) { GameMessagePrintf(GetString(hInst, IDS_GROUPFULL), MAX_GROUPNAME, group_name); break; } // Check for duplicates add_name = True; for (i=0; i < g.num_users; i++) if (!stricmp(g.names[i], name)) { add_name = False; break; } if (add_name) { strncpy(g.names[g.num_users], name, MAX_CHARNAME); g.names[g.num_users][MAX_CHARNAME] = 0; g.num_users++; num_added++; } name = GetPlayerName(ptr, &ptr); } GroupSave(group_name, &g); return num_added; }
const wxString & IniParser::GetValue(const wxString& group, const wxString& key, bool caseSensitive) const { static wxString ret; ret.Clear(); int g = FindGroupByName(group, caseSensitive); int k = FindKeyByName(g, key, caseSensitive); if (g != -1 && k != -1) return m_Array[g].pairs[k].value; return ret; }
/* * GroupDeleteNames: Remove the given names from the given group. * Return number of names deleted, or -1 if the group itself was deleted. */ int GroupDeleteNames(char *group_name, char *args) { int i, j, index, num_deleted; UserGroup g; char *name, *ptr; index = FindGroupByName(group_name); switch(index) { case GROUP_NOMATCH: GameMessage(GetString(hInst, IDS_BADGROUPNAME)); return 0; case GROUP_AMBIGUOUS: GameMessage(GetString(hInst, IDS_DUPLICATEGROUPNAME)); return 0; default: group_name = groups[index]; break; } GroupLoad(group_name, &g); // Remove each name num_deleted = 0; name = GetPlayerName(args, &ptr); while (name != NULL) { for (i=0; i < g.num_users; i++) if (!stricmp(g.names[i], name)) { for (j=i; j < g.num_users - 1; j++) strcpy(g.names[j], g.names[j + 1]); g.num_users--; num_deleted++; break; } name = GetPlayerName(ptr, &ptr); } // XXX Don't delete empty groups (???) #if 0 if (g.num_users == 0) { GroupDelete(group_name); return -1; } #endif GroupSave(group_name, &g); return num_deleted; }
void fsDownloads_GroupsMgr::DeleteGroup(LPCSTR pszGroup) { int grp = FindGroupByName (pszGroup); if (grp == -1) return; m_vGroups.del (grp); CRegKey key; key.Attach (m_hGroups); key.RecurseDeleteKey (pszGroup); key.Detach (); }
/* * GroupPrint: Display the members of the group with the given name. */ void GroupPrint(char *group_name) { UserGroup g; int i, index; COLORREF color; BYTE style; ID id; char buf[MAX_CHARNAME + 10]; index = FindGroupByName(group_name); switch (index) { case GROUP_NOMATCH: GameMessage(GetString(hInst, IDS_BADGROUPNAME)); break; case GROUP_AMBIGUOUS: GameMessage(GetString(hInst, IDS_DUPLICATEGROUPNAME)); break; default: group_name = groups[index]; GroupLoad(group_name, &g); GameMessagePrintf(GetString(hInst, IDS_GROUPMEMBERS), MAX_GROUPNAME, group_name); color = RGB(0, 0, 0); style = STYLE_NORMAL; EditBoxStartAdd(); for (i=0; i < g.num_users; i++) { if (i != 0) DisplayMessage(", ", color, style); id = FindPlayerByNameExact(g.names[i]); // Show player in red if logged on if (id == 0 || id == INVALID_ID) DisplayMessage(g.names[i], color, style); else { sprintf(buf, "~r%s~n", g.names[i]); DisplayMessage(buf, color, style); } } EditBoxEndAdd(); break; } }
vmsDownloadsGroupSmartPtr vmsDownloadsGroupsMgr::FindGroupByName(LPCSTR pszName, PDLDS_GROUPS_TREE pRoot) { fsString strName; while (*pszName && *pszName != '\\' && *pszName != '/') strName += *pszName++; if (*pszName) pszName++; for (int i = 0; i < pRoot->GetLeafCount (); i++) { if (lstrcmpi (pRoot->GetLeaf (i)->GetData ()->strName, strName) == 0) { if (*pszName) return FindGroupByName (pszName, pRoot->GetLeaf (i)); return pRoot->GetLeaf (i)->GetData (); } } return NULL; }
vmsDownloadsGroupSmartPtr vmsDownloadsGroupsMgr::FindGroupByName(LPCSTR pszName) { return FindGroupByName (pszName, GetGroupsTree ()); }
Bool ReadNodesCit(NodesCitC **newNode, const char *NameOrAddrToFind, ModemConsoleE W, Bool option) #endif { FILE *fBuf; char *words[256]; int i; char path[80]; int count; uint lineno = 0; l_slot logslot; if (!read_node_ddata()) { TWwPrintf(W, getmsg(59)); return (FALSE); } const char **nodekeywords = (const char **) nddd->aux; const char **nettypes = (const char **) nddd->next->aux; const char **nodemsgs = (const char **) nddd->next->next->aux; label NameToFind; CopyStringToBuffer(NameToFind, NameOrAddrToFind); if (SameString(NameOrAddrToFind, getnodemsg(2))) { // if default, start fresh if (!clearNode(newNode)) { dump_node_ddata(); return (FALSE); } } else { // else first read in default #ifdef WINCIT ReadNodesCit(TW, newNode, getnodemsg(2), W, FALSE); #else ReadNodesCit(newNode, getnodemsg(2), W, FALSE); #endif if (*newNode) { #ifdef WINCIT logslot = nodexists(NameOrAddrToFind, TW ? TW->LogOrder : NULL); #else logslot = nodexists(NameOrAddrToFind); #endif if (logslot == CERROR) { TWwDoCR(W); TWwPrintf(W, getnodemsg(3), NameOrAddrToFind); if (strlen(NameOrAddrToFind) < 4) { char temp[4]; CopyStringToBuffer(temp, NameOrAddrToFind); strlwr(temp); TWwPrintf(W, getnodemsg(4), temp, cfg.locID); } dump_node_ddata(); return (FALSE); } label Alias, LocID; #ifdef WINCIT if (!*LogTab[TW ? TW->LogOrder[logslot] : logslot].GetAlias(Alias, sizeof(Alias)) || !*LogTab[TW ? TW->LogOrder[logslot] : logslot].GetLocID(LocID, sizeof(LocID))) #else if (!*LTab(logslot).GetAlias(Alias, sizeof(Alias)) || !*LTab(logslot).GetLocID(LocID, sizeof(LocID))) #endif { TWwDoCR(W); TWwPrintf(W, getnodemsg(5), NameOrAddrToFind); dump_node_ddata(); return (FALSE); } (*newNode)->SetAlias(Alias); (*newNode)->SetLocID(LocID); label FileName; sprintf(FileName, getnodemsg(6), (*newNode)->GetAlias()); (*newNode)->SetMailFileName(FileName); // Make sure NameToFind is a name, not address. #ifdef WINCIT LogTab[TW ? TW->LogOrder[logslot] : logslot].GetName(NameToFind, sizeof(NameToFind)); #else LTab(logslot).GetName(NameToFind, sizeof(NameToFind)); #endif // Support for optional nodes.cit entries. (*newNode)->SetName(NameToFind); } } if (!*newNode) { cOutOfMemory(44); dump_node_ddata(); return (FALSE); } compactMemory(); sprintf(path, sbs, cfg.homepath, getnodemsg(8)); if ((fBuf = fopen(path, FO_R)) == NULL) // ASCII mode { TWdoccr(); TWcPrintf(getmsg(15), getnodemsg(8)); TWdoccr(); dump_node_ddata(); return (option); } char line[256]; Bool FoundOurEntry = FALSE; long pos = ftell(fBuf); while (fgets(line, 254, fBuf) != NULL) { lineno++; if (line[0] != '#') { pos = ftell(fBuf); continue; } // Don't read anything until we found our entry, except possible beginnings of our entry. (#NODE...) if (!FoundOurEntry && strnicmp(line + 1, nodekeywords[NOK_NODE], strlen(nodekeywords[NOK_NODE])) != SAMESTRING) { pos = ftell(fBuf); continue; } // Save a copy of the line in case this is the #LOGIN macro: parse_it // changes what is passed to it. char ltmp[256]; CopyStringToBuffer(ltmp, line); count = parse_it(words, line); // Look up our first word in table of keywords. for (i = 0; i < NOK_NUM; i++) { if (SameString(words[0] + 1, nodekeywords[i])) { //^ add one for '#' break; } } if (i < NOK_NUM && !words[1][0]) // valid keywords need a param { TWcPrintf(getnodemsg(9), getnodemsg(8), ltoac(lineno), nodekeywords[i], ns); TWdoccr(); continue; } if (i == NOK_NODE) { // This is a #NODE line... if we have alread found our entry, // then this is the start of the next one, and we are done. if (FoundOurEntry) { fclose(fBuf); dump_node_ddata(); return (TRUE); } // This is a #NODE line... if it is for us, then we have now // found our entry. If not, then we continue looking. if (SameString(NameToFind, words[1])) { FoundOurEntry = TRUE; } else { pos = ftell(fBuf); continue; } } switch (i) { case NOK_BAUD: { PortSpeedE PS = digitbaud(atol(words[1])); if (PS == PS_ERROR) { TWcPrintf(getnodemsg(9), getnodemsg(8), ltoac(lineno), nodekeywords[i], words[1]); TWdoccr(); } else { (*newNode)->SetBaud(PS); } break; } case NOK_DIALOUT: case NOK_PHONE: { (*newNode)->SetDialOut(words[1]); if (strlen(words[1]) > 49) { TWcPrintf(getnodemsg(1), getnodemsg(8), ltoac(lineno), nodekeywords[i], 50); TWdoccr(); } break; } case NOK_PREDIAL: { (*newNode)->SetPreDial(words[1]); if (strlen(words[1]) > 63) { TWcPrintf(getnodemsg(1), getnodemsg(8), ltoac(lineno), nodekeywords[i], 64); TWdoccr(); } break; } case NOK_FETCH_TIMEOUT: { (*newNode)->SetFetchTimeout(atoi(words[1])); break; } case NOK_ZIP: { if (!words[2][0]) // need second param { TWcPrintf(getnodemsg(9), getnodemsg(8), ltoac(lineno), nodekeywords[i], ns); TWdoccr(); continue; } else { (*newNode)->SetCreatePacket(words[1]); if (strlen(words[1]) > 39) { TWcPrintf(getnodemsg(1), getnodemsg(8), ltoac(lineno), nodekeywords[i], 40); TWdoccr(); } (*newNode)->SetExtractPacket(words[2]); if (strlen(words[2]) > 39) { TWcPrintf(getnodemsg(1), getnodemsg(8), ltoac(lineno), nodekeywords[i], 40); TWdoccr(); } } break; } case NOK_NETWORK: { (*newNode)->SetNetworkRevisionNumber(0); NETTYPES j; for (j = (NETTYPES) 0; j < NET_NUM; j = (NETTYPES) (j + 1)) { if (SameString(words[1], nettypes[j])) { break; } } if (j == NET_DCIT11) { j = NET_DCIT10; } if (j == NET_6_9a) { (*newNode)->SetNetworkRevisionNumber(1); j = NET_6_9; } if (j == NET_NUM) { TWcPrintf(getnodemsg(9), getnodemsg(8), ltoac(lineno), nodekeywords[i], words[1]); TWdoccr(); } else { (*newNode)->SetNetworkType(j); } break; } case NOK_PROTOCOL: { (*newNode)->SetProtocol(words[1][0]); break; } case NOK_AUTOHALL: { (*newNode)->SetAutoHall(hallexists(words[1])); if (strlen(words[1]) > LABELSIZE) { TWcPrintf(getnodemsg(1), getnodemsg(8), ltoac(lineno), nodekeywords[i], LABELSIZE + 1); TWdoccr(); } break; } case NOK_AUTOGROUP: { (*newNode)->SetAutoGroup(FindGroupByName(words[1])); if (strlen(words[1]) > LABELSIZE) { TWcPrintf(getnodemsg(1), getnodemsg(8), ltoac(lineno), nodekeywords[i], LABELSIZE + 1); TWdoccr(); } break; } case NOK_MAPUNKGROUP: { g_slot GroupSlot = FindGroupByName(words[1]); if (GroupSlot == CERROR) { GroupSlot = SPECIALSECURITY; } (*newNode)->SetMapUnknownGroup(GroupSlot); if (strlen(words[1]) > LABELSIZE) { TWcPrintf(getnodemsg(1), getnodemsg(8), ltoac(lineno), nodekeywords[i], LABELSIZE + 1); TWdoccr(); } break; } case NOK_LOGIN: { (*newNode)->SetLoginMacro(ltmp + strlen(nodekeywords[NOK_LOGIN]) + 1); break; } case NOK_NODE: { // A bit silly. (*newNode)->SetName(words[1]); if (strlen(words[1]) > LABELSIZE) { TWcPrintf(getnodemsg(1), getnodemsg(8), ltoac(lineno), nodekeywords[i], LABELSIZE + 1); TWdoccr(); } if (count > 2) { (*newNode)->SetOldRegion(words[2]); if (strlen(words[2]) > LABELSIZE) { TWcPrintf(getnodemsg(1), getnodemsg(8), ltoac(lineno), nodekeywords[i], LABELSIZE + 1); TWdoccr(); } } else { (*newNode)->SetOldRegion(ns); } (*newNode)->FreeMappedGroups(); (*newNode)->SetRoomOffset(0); break; } case NOK_DIAL_TIMEOUT: { (*newNode)->SetDialTimeout(atoi(words[1])); break; } case NOK_REQUEST: { (*newNode)->SetRequest(atoi(words[1])); break; } case NOK_WAIT_TIMEOUT: { (*newNode)->SetWaitTimeout(atoi(words[1])); break; } case NOK_AUTOROOM: { (*newNode)->SetAutoRoom(atoi(words[1])); break; } case NOK_VERBOSE: { (*newNode)->SetDefaultVerbose(); const char **verbosekeywords = (const char **) nddd->next->next->next->aux; for (int j = 1; j < count; j++) { if (SameString(words[j], getnodemsg(39))) { (*newNode)->SetDefaultVerbose(); } else if (SameString(words[j], getnodemsg(40))) { (*newNode)->SetDefaultVerbose(); (*newNode)->SetVerbose(NCV_FILE69INFULL, TRUE); (*newNode)->SetVerbose(NCV_NOACCESS, TRUE); } else if (SameString(words[j], getnodemsg(41))) { (*newNode)->SetDefaultVerbose(); (*newNode)->SetVerbose(NCV_FILE69INFULL, TRUE); (*newNode)->SetVerbose(NCV_NOACCESS, TRUE); (*newNode)->SetVerbose(NCV_ROOMCREATED, TRUE); (*newNode)->SetVerbose(NCV_ROOMNOTCREATED, TRUE); (*newNode)->SetVerbose(NCV_NETIDNOTFOUND, TRUE); (*newNode)->SetVerbose(NCV_NONETIDONSYSTEM, TRUE); } else { const char *Keyword; Bool NewSetting; if (words[j][0] == '!') { Keyword = words[j] + 1; NewSetting = FALSE; } else { Keyword = words[j]; NewSetting = TRUE; } NCV_Type TestType; for (TestType = (NCV_Type) 0; TestType < NCV_MAX; TestType = (NCV_Type) (TestType + 1)) { if (SameString(Keyword, verbosekeywords[TestType])) { (*newNode)->SetVerbose(TestType, NewSetting); break; } } if (TestType == NCV_MAX) { if (SameString(Keyword, getnodemsg(13))) { // ALL for (TestType = (NCV_Type) 0; TestType < NCV_MAX; TestType = (NCV_Type) (TestType + 1)) { (*newNode)->SetVerbose(TestType, NewSetting); } } else { TWcPrintf(getnodemsg(12), getnodemsg(8), ltoac(lineno), words[0], Keyword); TWdoccr(); } } } } break; } case NOK_CHAT: { (*newNode)->SetDefaultChat(); const char **chatkeywords = (const char **) nddd->next->next->next->next->aux; for (int j = 1; j < count; j++) { const char *Keyword; Bool NewSetting; if (words[j][0] == '!') { Keyword = words[j] + 1; NewSetting = FALSE; } else { Keyword = words[j]; NewSetting = TRUE; } NCC_Type TestType; for (TestType = (NCC_Type) 0; TestType < NCC_MAX; TestType = (NCC_Type) (TestType + 1)) { if (SameString(Keyword, chatkeywords[TestType])) { (*newNode)->SetChat(TestType, NewSetting); break; } } if (TestType == NCV_MAX) { if (SameString(Keyword, getnodemsg(13))) { // ALL for (TestType = (NCC_Type) 0; TestType < NCC_MAX; TestType = (NCC_Type) (TestType + 1)) { (*newNode)->SetChat(TestType, NewSetting); } } else { TWcPrintf(getnodemsg(12), getnodemsg(8), ltoac(lineno), words[0], Keyword); TWdoccr(); } } } break; } case NOK_REDIAL: { (*newNode)->SetRedial(atoi(words[1])); break; } case NOK_ROOM: { (*newNode)->SetRoomOffset(pos); fclose(fBuf); dump_node_ddata(); return (TRUE); } case NOK_GROUP: { if (!(*newNode)->AddMappedGroups(words[1], words[2])) { TWcPrintf(getnodemsg(10), words[1]); TWdoccr(); } if (strlen(words[1]) > LABELSIZE) { TWcPrintf(getnodemsg(1), getnodemsg(8), ltoac(lineno), nodekeywords[i], LABELSIZE + 1); TWdoccr(); } if (strlen(words[2]) > LABELSIZE) { TWcPrintf(getnodemsg(1), getnodemsg(8), ltoac(lineno), nodekeywords[i], LABELSIZE + 1); TWdoccr(); } break; } case NOK_GATEWAY: { (*newNode)->SetGateway(atoi(words[1])); break; } case NOK_FETCH: { (*newNode)->SetFetch(atoi(words[1])); break; } case NOK_NETFAIL: { (*newNode)->SetNetFail(atoi(words[1])); break; } case NOK_OUTPUTPACE: { (*newNode)->SetOutputPace(atoi(words[1])); break; } case NOK_IPADDRESS: { #ifdef WINCIT (*newNode)->SetIpAddress(words[1]); if (strlen(words[1]) > 255) { TWcPrintf(getnodemsg(1), getnodemsg(8), ltoac(lineno), nodekeywords[i], 256); TWdoccr(); } #endif break; } case NOK_IPPORT: { #ifdef WINCIT (*newNode)->SetIpPort(atoi(words[1])); #endif break; } default: { TWcPrintf(getnodemsg(11), getnodemsg(8), ltoac(lineno), words[0]); TWdoccr(); break; } } pos = ftell(fBuf); } fclose(fBuf); if (!FoundOurEntry && !option && debug) { TWwDoCR(W); TWwPrintf(W, getmsg(206), NameOrAddrToFind); TWwDoCR(W); } dump_node_ddata(); if (option) { return (TRUE); } else { return (FoundOurEntry); } }
void sfGetgroupslot(strList *params) { SETINT(FindGroupByName(evaluateString(params->string))); }