void configure() { ::configure(); set_culture("Losthavener"); set_race("orc"); set_sex(Sex_Male); set_level(60); add_friend("SINBYEN_GUARD"); add_friend("SINBYEN_CITIZEN"); add_enemy("SINBYEN_UNDEAD"); add_enemy("SINBYEN_DEMON"); set_culture_name("Shanks", False, "Headmaster"); set_alignment(({ 0, 0 }));
void line_eval(char* line) { if(line[0] == '/') { char inpt_command = line[1]; if(inpt_command == 'f') { add_friend(); } else if (inpt_command == 'r') { do_header(); printf("\n\n"); } else if (inpt_command == 'l') { list_friends(); } else if (inpt_command == 'd') { delete_friend(); } /* Send message to friend */ else if (inpt_command == 'm') { message_friend(); } else if (inpt_command == 'n') { change_nickname(); } else if (inpt_command == 's') { change_status(1); } else if (inpt_command == 'a') { if (friend_request_received == 1) accept_friend_request(line); } /* EXIT */ else if (inpt_command == 'q') { strcpy(line, "---Offline"); change_status(0); exit(EXIT_SUCCESS); } } }
void read_frineds_data() { char* previous_user1 = ""; char* previous_user2 = ""; total_friendship = 0; FILE* fp = fopen("database/friend.txt", "r"); if (fp != NULL) { char *user1, *user2; while (1) { user1 = read_one_line(fp); user2 = read_one_line(fp); if (user1 == NULL || user2 == NULL) break; if (strcmp(previous_user1, user1) != 0 || strcmp(previous_user2, user2) != 0) { User_Node user1_node = user_search_node(user1); User_Node user2_node = user_search_node(user2); if (user1_node == NULL || user2_node == NULL) continue; //add_friend(user1_node->friends, user2_node->friends); add_friend(user2_node->follower, user1_node->follower); total_friendship++; previous_user1 = user1; previous_user2 = user2; } } fclose(fp); } }
int main(int argc, char *argv[]) { if (argc < 4 && argc != 2) { printf("usage %s ip port public_key (of the DHT bootstrap node)\n or\n %s Save.bak\n", argv[0], argv[0]); exit(0); } init_tox(); if(argc > 3) { IP_Port bootstrap_ip_port; bootstrap_ip_port.port = htons(atoi(argv[2])); bootstrap_ip_port.ip.i = inet_addr(argv[1]); DHT_bootstrap(bootstrap_ip_port, hex_string_to_bin(argv[3])); } else { FILE *file = fopen(argv[1], "rb"); if ( file==NULL ){return 1;} int read; uint8_t buffer[128000]; read = fread(buffer, 1, 128000, file); printf("Messenger loaded: %i\n", load_tox_state(buffer, read)); fclose(file); } friend_add_request_callback(print_request); message_receive_callback(print_message); printf("OUR ID: "); uint32_t i; for(i = 0; i < 32; i++) { if(self_public_key[i] < 16) printf("0"); printf("%hhX",self_public_key[i]); } set_self_name((uint8_t *)"Anon", 5); char temp_id[128]; printf("\nEnter the client_id of the friend you wish to add (32 bytes HEX format):\n"); if(scanf("%s", temp_id) != 1) { return 1; } int num = add_friend(hex_string_to_bin(temp_id), (uint8_t*)"Install Gentoo", sizeof("Install Gentoo")); perror("Initialization"); while(1) { uint8_t name[128]; get_friend_name(num, name); printf("%s\n", name); send_message(num, (uint8_t*)"Test", 5); process_tox(); c_sleep(30); FILE *file = fopen("Save.bak", "wb"); if ( file==NULL ){return 1;} uint8_t * buffer = malloc(tox_state_size()); save_tox_state(buffer); fwrite(buffer, 1, tox_state_size(), file); free(buffer); fclose(file); } }
tree do_friend (tree ctype, tree declarator, tree decl, tree attrlist, enum overload_flags flags, bool funcdef_flag) { gcc_assert (TREE_CODE (decl) == FUNCTION_DECL); gcc_assert (!ctype || MAYBE_CLASS_TYPE_P (ctype)); /* Every decl that gets here is a friend of something. */ DECL_FRIEND_P (decl) = 1; /* Unfortunately, we have to handle attributes here. Normally we would handle them in start_decl_1, but since this is a friend decl start_decl_1 never gets to see it. */ /* Set attributes here so if duplicate decl, will have proper attributes. */ cplus_decl_attributes (&decl, attrlist, 0); if (TREE_CODE (declarator) == TEMPLATE_ID_EXPR) { declarator = TREE_OPERAND (declarator, 0); if (is_overloaded_fn (declarator)) declarator = DECL_NAME (get_first_fn (declarator)); } if (ctype) { /* CLASS_TEMPLATE_DEPTH counts the number of template headers for the enclosing class. FRIEND_DEPTH counts the number of template headers used for this friend declaration. TEMPLATE_MEMBER_P is true if a template header in FRIEND_DEPTH is intended for DECLARATOR. For example, the code template <class T> struct A { template <class U> struct B { template <class V> template <class W> friend void C<V>::f(W); }; }; will eventually give the following results 1. CLASS_TEMPLATE_DEPTH equals 2 (for `T' and `U'). 2. FRIEND_DEPTH equals 2 (for `V' and `W'). 3. TEMPLATE_MEMBER_P is true (for `W'). */ int class_template_depth = template_class_depth (current_class_type); int friend_depth = processing_template_decl - class_template_depth; /* We will figure this out later. */ bool template_member_p = false; tree cname = TYPE_NAME (ctype); if (TREE_CODE (cname) == TYPE_DECL) cname = DECL_NAME (cname); /* A method friend. */ if (flags == NO_SPECIAL && declarator == cname) DECL_CONSTRUCTOR_P (decl) = 1; grokclassfn (ctype, decl, flags); if (friend_depth) { if (!uses_template_parms_level (ctype, class_template_depth + friend_depth)) template_member_p = true; } /* A nested class may declare a member of an enclosing class to be a friend, so we do lookup here even if CTYPE is in the process of being defined. */ if (class_template_depth || COMPLETE_TYPE_P (ctype) || (CLASS_TYPE_P (ctype) && TYPE_BEING_DEFINED (ctype))) { if (DECL_TEMPLATE_INFO (decl)) /* DECL is a template specialization. No need to build a new TEMPLATE_DECL. */ ; else if (class_template_depth) /* We rely on tsubst_friend_function to check the validity of the declaration later. */ decl = push_template_decl_real (decl, /*is_friend=*/true); else decl = check_classfn (ctype, decl, template_member_p ? current_template_parms : NULL_TREE); if (template_member_p && decl && TREE_CODE (decl) == FUNCTION_DECL) decl = DECL_TI_TEMPLATE (decl); if (decl) add_friend (current_class_type, decl, /*complain=*/true); } else error ("member %qD declared as friend before type %qT defined", decl, ctype); } /* A global friend. @@ or possibly a friend from a base class ?!? */ else if (TREE_CODE (decl) == FUNCTION_DECL) { int is_friend_template = PROCESSING_REAL_TEMPLATE_DECL_P (); /* Friends must all go through the overload machinery, even though they may not technically be overloaded. Note that because classes all wind up being top-level in their scope, their friend wind up in top-level scope as well. */ if (funcdef_flag) SET_DECL_FRIEND_CONTEXT (decl, current_class_type); if (! DECL_USE_TEMPLATE (decl)) { /* We must check whether the decl refers to template arguments before push_template_decl_real adds a reference to the containing template class. */ int warn = (warn_nontemplate_friend && ! funcdef_flag && ! is_friend_template && current_template_parms && uses_template_parms (decl)); if (is_friend_template || template_class_depth (current_class_type) != 0) /* We can't call pushdecl for a template class, since in general, such a declaration depends on template parameters. Instead, we call pushdecl when the class is instantiated. */ decl = push_template_decl_real (decl, /*is_friend=*/true); else if (current_function_decl) { /* This must be a local class. 11.5p11: If a friend declaration appears in a local class (9.8) and the name specified is an unqualified name, a prior declaration is looked up without considering scopes that are outside the innermost enclosing non-class scope. For a friend function declaration, if there is no prior declaration, the program is ill-formed. */ tree t = lookup_name_innermost_nonclass_level (DECL_NAME (decl)); if (t) decl = pushdecl_maybe_friend (decl, /*is_friend=*/true); else { error ("friend declaration %qD in local class without " "prior declaration", decl); return error_mark_node; } } else { /* We can't use pushdecl, as we might be in a template class specialization, and pushdecl will insert an unqualified friend decl into the template parameter scope, rather than the namespace containing it. */ tree ns = decl_namespace_context (decl); push_nested_namespace (ns); decl = pushdecl_namespace_level (decl, /*is_friend=*/true); pop_nested_namespace (ns); } if (warn) { static int explained; bool warned; warned = warning (OPT_Wnon_template_friend, "friend declaration " "%q#D declares a non-template function", decl); if (! explained && warned) { inform (input_location, "(if this is not what you intended, make sure " "the function template has already been declared " "and add <> after the function name here) "); explained = 1; } } } if (decl == error_mark_node) return error_mark_node; add_friend (current_class_type, is_friend_template ? DECL_TI_TEMPLATE (decl) : decl, /*complain=*/true); DECL_FRIEND_P (decl) = 1; } return decl; }
/***** * User created Social Network * * Allows user to simulate their own social network * Hashes user names and creates UID matrix * Assigns interests at random * Creates similarity matricies */ int build_graph(int*** uu, int*** ii, int*** interests, int** uid){ int opt=0, m; node *head = NULL, *cur=NULL, *ref=NULL, *parent=NULL; char** name; while(1){ printf(GRAPH_MENU); scanf("%d", &opt); switch(opt){ case 0: m = list_length(head); // Network Size to_array(head, uid); // UIDs assign_interests(m, interests, END); // Interest Matrix similarity(m, *interests, uu, ii); // Similarities HEAD = head; return m; case 1: // Add Node ref = get_node(); name = get_name(); fill_node(ref,name); head = add_node(head, ref); cur = head; break; case 2: // Add Friend if(cur != NULL) name = get_name(); if(search(head, name, &parent) == NULL){ //Friend Doesn't Exist Yet ref = get_node(); fill_node(ref, name); head = add_node(head, ref); } else ref = search(head, name, &parent); add_friend(cur, name); add_friend(ref, cur->name); break; case 3: // Switch Node cur = search(head, get_name(), &parent); break; case 4: // View Nodes print_list(head); break; case 5: // View Friends printf("%s %s's Friends: \n", cur->name[0], cur->name[1]); if(cur != NULL) view_leaf(cur->root); printf("\n"); break; default: printf("Invalid Option\n"); } } }