MCPcopy Create free account
hub / github.com/3proxy/3proxy / make_ace

Function make_ace

src/conf.c:800–1062  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

798}
799
800struct ace * make_ace (int argc, unsigned char ** argv){
801 struct ace * acl;
802 unsigned char *arg;
803 struct iplist *ipl=NULL;
804 struct portlist *portl=NULL;
805 struct userlist *userl=NULL;
806 struct hostname *hostnamel=NULL;
807 int res;
808
809 acl = myalloc(sizeof(struct ace));
810 if(!acl) return acl;
811 memset(acl, 0, sizeof(struct ace));
812 if(argc > 0 && strcmp("*", (char *)argv[0])) {
813 arg = argv[0];
814 arg = (unsigned char *)strtok((char *)arg, ",");
815 do {
816 if(!acl->users) {
817 acl->users = userl = myalloc(sizeof(struct userlist));
818 }
819 else {
820 userl->next = myalloc(sizeof(struct userlist));
821 userl = userl -> next;
822 }
823 if(!userl) {
824 fprintf(stderr, "No memory for ACL entry, line %d\n", linenum);
825 return(NULL);
826 }
827 memset(userl, 0, sizeof(struct userlist));
828 userl->user=(unsigned char*)mystrdup((char *)arg);
829 } while((arg = (unsigned char *)strtok((char *)NULL, ",")));
830 }
831 if(argc > 1 && strcmp("*", (char *)argv[1])) {
832 arg = (unsigned char *)strtok((char *)argv[1], ",");
833 do {
834 if(!acl->src) {
835 acl->src = ipl = myalloc(sizeof(struct iplist));
836 }
837 else {
838 ipl->next = myalloc(sizeof(struct iplist));
839 ipl = ipl -> next;
840 }
841 if(!ipl) {
842 fprintf(stderr, "No memory for ACL entry, line %d\n", linenum);
843 return(NULL);
844 }
845 memset(ipl, 0, sizeof(struct iplist));
846 if (scanipl(arg, ipl)) {
847 fprintf(stderr, "Invalid IP, IP range or CIDR, line %d\n", linenum);
848 return(NULL);
849 }
850 } while((arg = (unsigned char *)strtok((char *)NULL, ",")));
851 }
852 if(argc > 2 && strcmp("*", (char *)argv[2])) {
853 arg = (unsigned char *)strtok((char *)argv[2], ",");
854 do {
855 int arglen;
856 unsigned char *pattern;
857

Callers 1

h_aceFunction · 0.85

Calls 3

myallocFunction · 0.85
mystrdupFunction · 0.85
scaniplFunction · 0.85

Tested by

no test coverage detected