Basestation function analysis (1)

Source: Internet
Author: User

CTI time C ++ switch RAC Oca. com Composition

--- Restore content start ---

1. _ tmain () is a program entry point function provided by Microsoft operating system (Windows) for automatic conversion of Unicode and ANSI character sets.

First, this _ tmain () is an alias for the main used in Unicode. Since it is an alias, there should be macro-defined. Where should we define it? In the confusing <stdafx. h>, there are two rows.
# Include <stdio. h>
# Include <tchar. h>
We can find the macro definition of _ tmain in the header file <tchar. h>: # DEFINE _ tmain
Therefore, after pre-compilation, _ tmain becomes main.

Int _ tmain (INT argc, tchar * argv [])
When the current character set of your program is Unicode, int _ tmain (INT argc, tchar * argv []) will be translated
Int wmain (INT argc, wchar_t * argv [])
When the current character set of your program is ANSI, int _ tmain (INT argc, tchar * argv []) will be translated
Int main (INT argc, char * argv [])

2. ccommfunc: getprogrammedir get the current path of the program

The getmodulefilename function returns the complete path name (ended with '\ 0') of the executable or DLL file loaded by the current process. This module must be loaded by the address space of the current process. To obtain the file path of another loaded module, use the getmodulefilenameex () function.

Strpath = strpath. substr (0, strpath. rfind ("\") + 1); find the/symbol on the right and take the characters on the left and.

3. cinifile

Readstring reads a string value.

Readint reads an integer.

Writestring writes a string value in the specified section and key.

Writeint writes an integer to the specified section and key.

Load_ini_file: load the configuration file

Getprivateprofilestring parsing configuration file

 

4. Assert https://www.cnblogs.com/lvchaoshun/p/7816288.html

5. createmutex is a computer function used to identify whether the current system has an instance of a specified process. If not, create a mutex.

The return value is long. If the execution is successful, the handle of the mutex object is returned. Zero indicates an error. Getlasterror is set. If a valid handle is returned but the specified name already exists, getlasterror will also be set to error_already_exists, and the value of binitialowner will be ignored. If the caller limits the permission, getlasterror will return error_access_denied. In this case, use the openmutex function. 6. // test log

Mytrace (log_level_info, "basestationservice start."); is defined as follows:

# Define mytrace (ilevel,...) g_clientlog.writelog (ilevel, _ file __, _ line __, _ va_args __)

7. waitforsingleobject puts the thread in the waiting state, such as waiting for an event to be triggered.

The waitforsingleobject function is used to detect the signal status of the hhandle event. When this function is called in a thread, the thread temporarily suspends. If the suspended dwmilliseconds is within milliseconds, if the waiting object of the thread changes to a signal state, the function returns immediately. If the timeout time has reached dwmilliseconds milliseconds, but the object indicated by hhandle has not become a signal state, the function returns the same result.

1 DWORD winapi waitforsingleobject (2 3 handle hhandle, // wait trigger handle, such as the previously mentioned event handle 4 5 DWORD dwmilliseconds // wait for a long time, if the unit is Ms, for example, 5000, 5 S. If the unit is infinite, 6 7 is infinite );

8. // obtain the file size first

Fseek (FP, 0, seek_end );
Long size = ftell (FP );
Fclose (FP );

9.

 

Char szbuff [1024] = {0 };
Va_list argptr;

       va_start(argptr, pszFmt);            vsnprintf(szBuff, 1023, pszFmt, argptr);            va_end(argptr);
Va_start, function name. The process of reading variable parameters is actually in the stack, using pointers to traverse the parameter list in the stack segment, the process of reading the parameter content one by one from the low address to the high address.

10. vsnprintf is one of the C language library functions and is a variable parameter. It is used to print data to strings and customize the data format. The header file is # include <stdarg. h>.
Function declaration: int _ vsnprintf (char * STR, size_t size, const char * format, va_list AP );
  1. Char * STR [out]: stores the formatted string generated here.
  2. Size_t size [in], the maximum number of characters acceptable for STR (non-bytes, Unicode one character two bytes), to prevent array overflow.
  3. Const char * Format [in] specifies the output format string, which determines the type, number, and order of variable parameters you need to provide.
  4. Va_list AP [in], va_list variable. Va: Variable-argument: Variable Parameter

Function: Format and output variable parameters to a character array.

11. getlocaltime is a Windows API function used to obtain the current local system date and time.

12. releasemutex is a linear instruction with control over the mutex owned by the release thread.

Mutex is a simple form of synchronization (called mutex )). The mutex prohibits multiple threads from entering the protected code "critical section" at the same time ).

13

Handle m_heventstopthread; // heartbeat thread event handle m_hlivethread; // heartbeat thread handle bool m_blive; // bus connection flag // cbuffpool m_poolbuff; // global simple memory pool int I _count_msg; // record the number of dropped packets

14. extern "C"

The msgswitch dynamic library does not have source code. You do not need to know the init1 initial module.

15.: registerpolicy registers the callback handler, which is a global function of MFC. Therefore, add ::

16. Handle 60604959

In Windows, handles are used to identify projects, including modules, tasks, instances, files, memory blocks, menus, controls, fonts, resources, including icons, cursors, string, etc. The GDI object, including bitmap, paint brush, Meta File, color palette, paint brush, area, and device description table handle are used to identify (created or used by the application) A unique integer of an object. Windows uses various handles to identify such objects as application instances, windows, controls, bitmaps, and GDI objects.

17. cmsgswitchmgr: cmsgswitchmgr (void) constructor Initialization

CMsgSwitchMgr::CMsgSwitchMgr( void )    :m_hLiveThread(NULL)    ,m_hEventStopThread(NULL)    ,m_bLive(false){}

The constructor initialization list starts with a colon, followed by a list of data members separated by commas (,). Each data member is followed by an initialization formula in parentheses.

18. createevent is a Windows API function. It is used to create or open a named or unknown event object. To specify an access mask for an object, use the createeventex function.

Handle createevent (lpsecurity_attributeslpeventattributes, // Security Attribute boolbmanualreset, // reset method boolbinitialstate, // initial state: lpctstrlpname // Object Name); 19. _ beginthreadex creation thread 1733125520. _ cribd C run time implement "Implementation of C Runtime Library"

_ Ptiddata PTD; // point to the thread data block

_ Ptiddata PTD; // pointer to per-thread data See note 1 uintptr_t thdl; // thread handle unsigned long err = 0l; // return from getlasterror () unsigned dummyid; // dummy returned thread ID number --------------------- morewindows Source: csdn Original: https://blog.csdn.net/morewindows/article/details/7421759 copyright statement: This article is the original author of the blog, reprinted Please attach the blog link!

7421759

For details, refer to the above. Although I don't quite understand.

From the source code above, the _ beginthreadex () function will allocate and initialize a _ tiddata block when creating a new thread. The _ tiddata block is naturally used to store data that requires exclusive use of threads. In fact, the _ tiddata block will be further associated with itself when the new line is running. Then when the new thread calls a standard C Runtime library function such as strtok (), it will first obtain the address of the _ tiddata block and then store the data to be protected into the _ tiddata block. In this way, each thread will only access and modify its own data without tampering with the data of other threads. Therefore, if the function in the Standard C Runtime library is used in the code, use _ beginthreadex () instead of createthread (). I believe that when you read this sentence, you will be very impressed with this short sentence. If an interviewer asks, you can also answer ^_^ smoothly and accurately.
---------------------
Morewindows
Source: csdn
Original: 7421759
Copyright Disclaimer: This article is an original article by the blogger. For more information, see the blog post link!

21.81288272? Utm_source = blogxgwz0

PRIVATE: static cbsapp * m_pinstance; // Single Instance Object Pointer

In C ++, static members belong to the entire class rather than an object, and static member variables are only stored for all objects to share. So it can be shared among all objects. Using static member variables to share data among multiple objects does not undermine the hidden principle, ensuring security and saving memory.

22. MySQL * m_db_ptr;

23. tlock

Initializecriticalsection 8099297

24. livethread function:

Wait_object_0: indicates that the waiting object (such as a thread or mutex) has been properly executed or released.

25. querysql

26. mysql_real_query

Execute the SQL query directed by the query. It should be a string of length bytes. A query must consist of a single SQL statement. You should not add a terminated semicolon (";") or \ g after the statement.
For queries that contain binary data, you must use mysql_real_query () instead of mysql_query (), because binary code data may contain the "\ 0" character, and mysql_real_query () is worse than mysql_query () faster because it calls strlen () for the query string ().

After mysql_store_result is successfully called mysql_query,Mysql_store_result ()Returns null.

Mysql_fetch_row () can also be used to obtain the query result set. The difference is that the return value of a function is not a string but an array.

The number of rows in the returned result set of mysql_num_rows.

27. JSON: Value JSON: value is a very important type, which can represent any type. Such as int, String, object, array

 

 

--- Restore content end ---

Basestation function analysis (1)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.