void Push_Node(NodeList_t *NodeList, struct FlowNode *node) { pthread_mutex_lock(&NodeList->m_list); if ( NodeList->length == 0 ) { // empty list NodeList->list = node; node->left = NULL; node->right = NULL; } else { NodeList->last->right = node; node->left = NodeList->last; node->right = NULL; } NodeList->last = node; NodeList->length++; #ifdef DEVEL int proto = node->proto; printf("pushed node 0x%llx proto: %u, length: %u first: %llx, last: %llx\n", (unsigned long long)node, proto, NodeList->length, (unsigned long long)NodeList->list, (unsigned long long)NodeList->last); ListCheck(NodeList); #endif pthread_mutex_unlock(&NodeList->m_list); pthread_cond_signal(&NodeList->c_list); } // End of Push_Node
struct FlowNode *Pop_Node(NodeList_t *NodeList, int *done) { struct FlowNode *node; int proto; pthread_mutex_lock(&NodeList->m_list); while ( NodeList->length == 0 && !*done ) pthread_cond_wait(&NodeList->c_list, &NodeList->m_list); if ( NodeList->length == 0 && *done ) { pthread_mutex_unlock(&NodeList->m_list); dbg_printf("Pop_Node done\n"); return NULL; } if ( NodeList->list == NULL ) { // should never happen - list is supposed to have at least one item pthread_mutex_unlock(&NodeList->m_list); LogError("Unexpected empty FlowNode_ProcessList"); return NULL; } node = NodeList->list; NodeList->list = node->right; if ( NodeList->list ) NodeList->list->left = NULL; else NodeList->last = NULL; node->left = NULL; node->right = NULL; proto = node->proto; NodeList->length--; #ifdef DEVEL printf("popped node 0x%llx proto: %u, length: %u first: %llx, last: %llx\n", (unsigned long long)node, proto, NodeList->length, (unsigned long long)NodeList->list, (unsigned long long)NodeList->last); ListCheck(NodeList); #endif pthread_mutex_unlock(&NodeList->m_list); return node; } // End of Pop_Node
void ListInsert(List L, int index, char e) { LNode *p = (LNode *)malloc(sizeof(LNode)); p->data = e, p->next = NULL, p->pre = NULL; int i = -1; LNode *q = L.head; //finde index-1 while(q && i < index - 1) { q = q->next; i++; } //insert p if(q->next) q->next->pre = p; p->next = q->next; p->pre = q; q->next = p; ListCheck(p); }
DBGSTATIC NET_API_STATUS Parse2( IN DWORD argc, IN LPTSTR argv[], IN LPNET_CONFIG_HANDLE ConfigHandle ) /*++ Routine Description : parse command line arguments, range-check them and set global variables. parameter units range/value default --------- ----- ----------- ------- /REPLICATE - import/export/both REPL_ROLE_IMPORT /EXPORTPATH pathname - repl\export /IMPORTPATH pathname - repl\import /EXPORTLIST names 0-32 0 /IMPORTLIST srvnames 0-32 0 /TRYUSER - yes/no YES /LOGON username - - /PASSWORD password - - /INTERVAL minutes 1-60 5 /PULSE integer 1-10 3 /GUARDTIME minutes 0 to (interval/2) 2 /RANDOM seconds 1-120 60 Arguments : argc : argument count argv : argument string array pointer. ConfigHandle : config handle for replicator section. Return Value : return NO_ERROR if successfully parse parameter ERROR_INVALID_PARAMETER, on syntax error and so on... --*/ { NET_API_STATUS ApiStatus; LPWSTR ParmStrValue; // get and check common parameter to master and client. // /REPL switch ApiStatus = GetParameter(argc, argv, ConfigHandle, rep_REPL, &P_repl ); if (ApiStatus != NO_ERROR) { return( ApiStatus ); } if(P_repl[0] == L'\0') { ReplConfigReportBadParmValue( rep_REPL, NULL ); return( ERROR_INVALID_PARAMETER ); } if(_wcsicmp(P_repl, BOTH_SW) == 0) { ReplGlobalRole = REPL_ROLE_BOTH; } else if(_wcsicmp(P_repl, EXPORT_SW) == 0) { ReplGlobalRole = REPL_ROLE_EXPORT; } else if(_wcsicmp(P_repl, IMPORT_SW) == 0) { ReplGlobalRole = REPL_ROLE_IMPORT; } else { ReplConfigReportBadParmValue( rep_REPL, NULL ); return( ERROR_INVALID_PARAMETER ); } IF_DEBUG(REPL) { // debug code NetpKdPrint(( "[Repl] Repl parameter \n")); NetpKdPrint((" REPL = %ws \n", P_repl)); } // get and check repl master parameters if (ReplRoleIncludesMaster( ReplGlobalRole )) { IF_DEBUG(REPL) { // debug code NetpKdPrint(( "[Repl] Repl master parameters \n")); } // EXPORTPATH ApiStatus = GetParameter(argc, argv, ConfigHandle, rep_EXPPATH, &P_exppath ); if (ApiStatus != NO_ERROR) { return( ApiStatus ); } ApiStatus = PathCheck(&P_exppath, ITYPE_PATH_ABSD, rep_EXPPATH); if (ApiStatus != NO_ERROR) { return( ApiStatus ); } IF_DEBUG(REPL) { // debug code NetpKdPrint((" EXPORT PATH = %ws \n", P_exppath)); } // EXPORTLIST ApiStatus = GetParameter(argc, argv, ConfigHandle, rep_EXPLIST, &P_explist ); if (ApiStatus != NO_ERROR) { return( ApiStatus ); } ApiStatus = ListCheck(P_explist, rep_EXPLIST); if (ApiStatus != NO_ERROR) { return( ApiStatus ); } IF_DEBUG(REPL) { // debug code NetpKdPrint((" EXPORT LIST = %ws \n", P_explist)); } // INTERVAL ApiStatus = GetParameter(argc, argv, ConfigHandle, rep_SYNC, &ParmStrValue ); if (ApiStatus != NO_ERROR) { return( ApiStatus ); } ApiStatus = DwordCheck(ParmStrValue, MIN_SYNC, MAX_SYNC, rep_SYNC, &P_sync ); if (ApiStatus != NO_ERROR) { return( ApiStatus ); } IF_DEBUG(REPL) { // debug code NetpKdPrint((" INTERVAL = 0x%lx \n", P_sync)); } // PULSE ApiStatus = GetParameter(argc, argv, ConfigHandle, rep_PULSE, &ParmStrValue ); if (ApiStatus != NO_ERROR) { return( ApiStatus ); } ApiStatus = DwordCheck(ParmStrValue, MIN_PULSE, MAX_PULSE, rep_PULSE, &P_pulse ); if (ApiStatus != NO_ERROR) { return( ApiStatus ); } IF_DEBUG(REPL) { // debug code NetpKdPrint((" PULSE = 0x%lx \n", P_pulse)); } // GUARD ApiStatus = GetParameter(argc, argv, ConfigHandle, rep_GUARD, &ParmStrValue ); if (ApiStatus != NO_ERROR) { return( ApiStatus ); } ApiStatus = DwordCheck(ParmStrValue, MIN_GUARD, MAX_GUARD, rep_GUARD, &P_guard ); if (ApiStatus != NO_ERROR) { return( ApiStatus ); } IF_DEBUG(REPL) { // debug code NetpKdPrint((" GUARD = 0x%lx \n", P_guard)); } if(P_guard > (P_sync / 2)) { NetpKdPrint(( "[REPL-MASTER] guard and sync parms conflict.\n")); ReplFinish( SERVICE_UIC_CODE( SERVICE_UIC_CONFLPARM, 0), NULL); return( ERROR_INVALID_PARAMETER ); } } if (ReplRoleIncludesClient( ReplGlobalRole )) { IF_DEBUG(REPL) { // debug code NetpKdPrint(( "[Repl] Repl client parameters \n")); } // IMPORTPATH ApiStatus = GetParameter(argc, argv, ConfigHandle, rep_IMPPATH, &P_imppath ); if (ApiStatus != NO_ERROR) { return( ApiStatus ); } ApiStatus = PathCheck(&P_imppath, ITYPE_PATH_ABSD, rep_IMPPATH); if (ApiStatus != NO_ERROR) { return( ApiStatus ); } IF_DEBUG(REPL) { // debug code NetpKdPrint((" IMPORT PATH = %ws \n", P_imppath)); } // IMPORTLIST ApiStatus = GetParameter(argc, argv, ConfigHandle, rep_IMPLIST, &P_implist ); if (ApiStatus != NO_ERROR) { return( ApiStatus ); } ApiStatus = ListCheck(P_implist, rep_IMPLIST); if (ApiStatus != NO_ERROR) { return( ApiStatus ); } IF_DEBUG(REPL) { // debug code NetpKdPrint((" IMPORT LIST = %ws \n", P_implist)); } // TRY USER ApiStatus = GetParameter(argc, argv, ConfigHandle, rep_TRYUSER, &ParmStrValue ); if (ApiStatus != NO_ERROR) { return( ApiStatus ); } ApiStatus = YesNoCheck(ParmStrValue, rep_TRYUSER, &P_tryuser ); if (ApiStatus != NO_ERROR) { return( ApiStatus ); } IF_DEBUG(REPL) { // debug code NetpKdPrint((" TRYUSER = "******"\n", (DWORD) P_tryuser)); } // LOGON ApiStatus = GetParameter(argc, argv, ConfigHandle, rep_LOGON, &P_logon ); if (ApiStatus != NO_ERROR) { return( ApiStatus ); } ApiStatus = NameCheck(&P_logon, NAMETYPE_USER, rep_LOGON); if (ApiStatus != NO_ERROR) { return( ApiStatus ); } IF_DEBUG(REPL) { // debug code NetpKdPrint((" LOGON = %ws \n", P_logon)); } // PASSWORD ApiStatus = GetParameter(argc, argv, ConfigHandle, rep_PASSWD, &P_passwd ); if (ApiStatus != NO_ERROR) { return( ApiStatus ); } ApiStatus = NameCheck(&P_passwd, NAMETYPE_PASSWORD, rep_PASSWD); if (ApiStatus != NO_ERROR) { return( ApiStatus ); } IF_DEBUG(REPL) { // debug code NetpKdPrint((" PASSWORD = %ws \n", P_passwd)); } // RANDOM ApiStatus = GetParameter(argc, argv, ConfigHandle, rep_RANDOM, &ParmStrValue ); if (ApiStatus != NO_ERROR) { return( ApiStatus ); } ApiStatus = DwordCheck(ParmStrValue, MIN_RANDOM, MAX_RANDOM, rep_RANDOM, &P_random); if (ApiStatus != NO_ERROR) { return( ApiStatus ); } IF_DEBUG(REPL) { // debug code NetpKdPrint((" RANDOM = 0x%lx \n", P_random)); } } return( NO_ERROR ); }