CN114546542A - General library function calling method and system - Google Patents

General library function calling method and system Download PDF

Info

Publication number
CN114546542A
CN114546542A CN202210436682.5A CN202210436682A CN114546542A CN 114546542 A CN114546542 A CN 114546542A CN 202210436682 A CN202210436682 A CN 202210436682A CN 114546542 A CN114546542 A CN 114546542A
Authority
CN
China
Prior art keywords
function
library
pointer
library function
calling
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210436682.5A
Other languages
Chinese (zh)
Inventor
张洲
于珊珊
韩会杰
赵赟
王浩
李蕾
杨诏钧
孔金珠
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Kirin Software Co Ltd
Original Assignee
Kirin Software Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Kirin Software Co Ltd filed Critical Kirin Software Co Ltd
Priority to CN202210436682.5A priority Critical patent/CN114546542A/en
Publication of CN114546542A publication Critical patent/CN114546542A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/448Execution paradigms, e.g. implementations of programming paradigms
    • G06F9/4488Object-oriented
    • G06F9/449Object-oriented method invocation or resolution
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/36Software reuse
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/547Remote procedure calls [RPC]; Web services

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

The invention relates to the technical field of computer science, in particular to a general library function calling method and a general library function calling system, which comprise the following steps: s1, configuring a plurality of library functions, compiling the library functions and storing the library functions in a cache, wherein each library function corresponds to one RESTful interface; s2, configuring a safety linkage center, wherein the safety linkage center is used for calling the library function through the RESTful interface; s3, configuring a function pointer based on abstract parameter type, and inputting the function name and real parameters of the called library into the function pointer; s4, acquiring pointer assignment, wherein the pointer assignment is obtained through abstraction of the function name and the real parameters of the called library; and S5, outputting the pointer assignment to the safety linkage center so that the safety linkage center calls the corresponding library function. The method can improve the expansibility and the universality of library function calling.

Description

General library function calling method and system
Technical Field
The invention relates to the technical field of computer science, in particular to a general library function calling method and system, electronic equipment and a readable storage medium.
Background
In the prior art, when the function parameter types of different modules of a terminal are only fixed N, function types that may occur are enumerated one by one. And when calling, selecting the pointer of the corresponding type according to the specific situation, and calling the library function. Through the implementation scheme of completely enumerating the function parameter types, on one hand, the expansibility is poor, and when other modules are newly added or change RESTful interfaces, the functions are necessarily designed and implemented according to several fixed function types. On the other hand, when the fixed function types are more, the process of selecting the corresponding format function pointer during actual calling has certain addressing time to generate performance consumption.
Therefore, it is necessary to provide a library function calling method, which improves the extensibility and versatility of library function calling.
Disclosure of Invention
Solves the technical problem
Aiming at the defects in the prior art, the invention provides a library function universal calling method which can improve the expansibility and the universality of library function calling.
Technical scheme
In order to achieve the purpose, the invention is realized by the following technical scheme:
the invention provides a general library function calling method, which comprises the following steps:
s1, configuring a plurality of library functions, compiling the library functions and storing the library functions in a cache, wherein each library function corresponds to one RESTful interface;
s2, configuring a safety linkage center, wherein the safety linkage center is used for calling the library function through the RESTful interface;
s3, configuring a function pointer based on abstract parameter type, and inputting the function name and real parameters of the called library into the function pointer;
s4, acquiring pointer assignment, wherein the pointer assignment is obtained through abstraction of the function name and the real parameters of the called library;
and S5, outputting the pointer assignment to the safety linkage center so that the safety linkage center calls the corresponding library function.
Further, the transmission protocol of the safety linkage center and the RESTful interface is an http protocol.
Further, step S1 specifically includes: and arranging the library function information to be called into a document, and mapping the library function name to a URL (uniform resource locator) according to a specific rule when the system is started, wherein the URL comprises the function name so as to enable the request URL of the http protocol to be correspondingly called with the library function.
Further, the safety linkage center monitors a data access layer to judge whether the function pointer exists, and if the function pointer exists in the data access layer, the corresponding library function is called from the cache.
Based on the same invention concept, the invention also provides a library function universal calling system, which comprises: a configuration module for configuring a plurality of library functions;
the storage module is used for compiling the library functions and storing the library functions in a cache;
the safety linkage center is used for calling the library function through a RESTful interface;
and the function pointer is used for inputting the function name and the real parameters of the called library, obtaining pointer assignment according to the function name and the real parameters of the called library in an abstract mode, and outputting the pointer assignment to the safety linkage center so that the safety linkage center calls the corresponding library function.
Furthermore, the safety linkage center also comprises a first monitoring module for monitoring whether the function pointer exists in the data access layer;
and the first execution module is used for calling the corresponding library function from the cache according to the pointer assignment output by the function pointer if the function pointer is monitored to exist in the data access layer.
Further, still include:
the second monitoring module is used for monitoring whether a return value is generated in the process of executing the library function;
the judging module is used for judging whether the library function is completely called according to the monitoring result;
and the second execution module is used for calling the next library function according to a preset rule if the library function is judged to be executed completely.
Based on the same inventive concept, the present invention also provides an electronic device, which includes a processor and a memory, where the memory stores a computer program, and the computer program implements the method of any one of the above when executed by the processor.
Based on the same inventive concept, the present invention further provides a readable storage medium, in which a computer program is stored, and the computer program, when executed by a processor, implements the method of any one of the above.
Advantageous effects
Compared with the known public technology, the technical scheme provided by the invention has the following beneficial effects: by adopting the scheme of the invention, the safety linkage center is low coupled with the specifically related function types, the expansibility of each function module of the system is enhanced, and the operation and maintenance cost generated by adapting and upgrading the linkage center is greatly reduced.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below. It is obvious that the drawings in the following description are only some embodiments of the invention, and that for a person skilled in the art, other drawings can be derived from them without inventive effort.
Fig. 1 is a schematic flow chart of a library function general calling method according to an embodiment of the present invention;
fig. 2 is a schematic diagram of a library function universal call system according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention. It is to be understood that the embodiments described are only a few embodiments of the present invention, and not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Referring to fig. 1, the present invention provides a library function universal calling method, including the following steps:
s1, configuring a plurality of library functions, compiling the library functions and storing the library functions in a cache, wherein each library function corresponds to one RESTful interface;
s2, configuring a safety linkage center, wherein the safety linkage center is used for calling the library function through the RESTful interface;
s3, configuring a function pointer based on abstract parameter type, and inputting the function name and real parameters of the called library into the function pointer;
s4, acquiring pointer assignment, wherein the pointer assignment is obtained through abstraction of the function name and the real parameters of the called library;
and S5, outputting the pointer assignment to the safety linkage center so that the safety linkage center calls a corresponding library function.
Because the safety linkage center provides the ability of calling a local RESTful interface to the outside through the RESTful interface, the safety linkage center registers the function of each module as the RESTful interface corresponding to a specific URL when being started, an external caller organizes the requested module name, function name and specific parameters into an https request message, and the external caller remotely calls the corresponding function on the terminal. The function types of each module of the terminal are various and complex, the function type is required to be declared on the conventional premise of calling the function through the dynamic library, and the function entry address returned by the dlsym is received by using the function pointer of the corresponding type. In an actual service scene, when a function type is newly added, the safety linkage center can be scheduled only after definition, adaptation and recompilation are carried out on the newly added type. In the conventional deployment mode, due to the fact that the linkage center has certain coupling with the function type corresponding to the specific service, expansibility is poor, and huge operation and maintenance cost is brought by subsequent frequent upgrading of the safety linkage center. The technical scheme of the invention can better solve the problem. When the function pointer based on the abstract parameter type is used in combination with a dl (dlopen, dlsym and dlclose) library function, the called function name and the actual parameters can be transmitted from the outside, and the dlsym acquires the pointer to assign the abstract parameter function pointer and then pushes the abstract parameter function pointer according to the appointed type and sequence of the transmitted parameters to finish interface calling.
In this embodiment, the transmission protocol between the security linkage center and the RESTful interface is an http protocol. Step S1 specifically includes: and arranging the library function information to be called into a document, and mapping the library function name to a URL (uniform resource locator) according to a specific rule when the system is started, wherein the URL comprises the function name so as to enable the request URL of the http protocol to correspond to the library function. And the safety linkage center monitors a data access layer to judge whether the function pointer exists, and if the function pointer exists in the data access layer, calls the corresponding library function from the cache.
Based on the same inventive concept, referring to fig. 2, the present invention further provides a library function universal call system, including: a configuration module 301, configured to configure a plurality of library functions; a storage module 302, configured to compile and store the library functions in a cache; the safety linkage center is used for calling the library function through a RESTful interface; and the function pointer is used for inputting the function name and the real parameters of the called library, obtaining pointer assignment according to the function name and the real parameters of the called library in an abstract mode, and outputting the pointer assignment to the safety linkage center so that the safety linkage center calls the corresponding library function.
In this embodiment, the safety linkage center further includes a first monitoring module 303, configured to monitor whether the function pointer exists in the data access layer; a first executing module 304, configured to, if it is detected that the function pointer exists in the data access layer, call, from the cache, a corresponding library function according to a pointer assignment output by the function pointer. A second monitoring module 305, configured to monitor whether a return value is generated during execution of the library function; the judging module 306 is configured to judge whether the database target function is completely called according to the monitoring result; a second executing module 307, configured to call a next library function according to a predetermined rule if it is determined that the library function is executed completely.
Based on the same inventive concept, the present invention further provides an electronic device, which includes a processor and a memory, where the memory stores a computer program, and the computer program implements the library function general-purpose calling method when executed by the processor.
The processor may be, in some embodiments, a Central Processing Unit (CPU), a controller, a microcontroller, a microprocessor (e.g., a GPU), or other data Processing chip. The processor is typically used to control the overall operation of the electronic device. In this embodiment, the processor is configured to execute the program code stored in the memory or process data, for example, execute the program code of the method of the library function general call method.
The memory includes at least one type of readable storage medium including a flash memory, a hard disk, a multimedia card, a card type memory (e.g., SD or DX memory, etc.), a Random Access Memory (RAM), a Static Random Access Memory (SRAM), a Read Only Memory (ROM), an Electrically Erasable Programmable Read Only Memory (EEPROM), a Programmable Read Only Memory (PROM), a magnetic memory, a magnetic disk, an optical disk, etc. In some embodiments, the storage may be an internal storage unit of the electronic device, such as a hard disk or a memory of the electronic device. In other embodiments, the memory may also be an external storage device of the electronic device, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like provided on the electronic device. Of course, the memory may also include both internal and external memory units of the electronic device. In this embodiment, the memory is generally used for storing an operating method installed in the electronic device and various types of application software, such as program codes of the library function general-purpose calling method. In addition, the memory may also be used to temporarily store various types of data that have been output or are to be output.
Based on the same inventive concept, the present invention further provides a readable storage medium, wherein a computer program is stored in the readable storage medium, and when the computer program is executed by a processor, the computer program implements the library function general-purpose calling method.
The invention has the advantages that the safety linkage center can be coupled with the function types specifically related, the expansibility of each function module of the system is enhanced, and the operation and maintenance cost generated by the linkage center adapting and upgrading along with the linkage center is greatly reduced.
The above examples are only intended to illustrate the technical solution of the present invention, but not to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and the modifications or the substitutions do not cause the essence of the corresponding technical solutions to depart from the scope of the technical solutions of the embodiments of the present invention.

Claims (9)

1. A general library function calling method is characterized by comprising the following steps:
s1, configuring a plurality of library functions, compiling the library functions and storing the library functions in a cache, wherein each library function corresponds to one RESTful interface;
s2, configuring a safety linkage center, wherein the safety linkage center is used for calling the library function through the RESTful interface;
s3, configuring a function pointer based on abstract parameter type, and inputting the function name and real parameters of the called library into the function pointer;
s4, pointer assignment is obtained, and the pointer assignment is obtained through abstraction of the called library function name and the actual parameters;
and S5, outputting the pointer assignment to the safety linkage center so that the safety linkage center calls the corresponding library function.
2. The library function universal call method of claim 1, wherein the transmission protocol of the security linkage center and the RESTful interface is an http protocol.
3. The library function universal calling method according to claim 2, wherein the step S1 specifically includes: and arranging the library function information to be called into a document, and mapping the library function to a URL (uniform resource locator) according to a specific rule when the system is started, wherein the URL comprises a library function name so that the request URL of the http protocol and the library function are called correspondingly.
4. The universal library function calling method according to claim 1, wherein the security linkage center monitors a data access layer to determine whether the function pointer exists, and if the data access layer is monitored to have the function pointer, calls the corresponding library function from the cache.
5. A library function universal call system, comprising: a configuration module for configuring a plurality of library functions;
the storage module is used for compiling the library functions and storing the library functions in a cache;
the safety linkage center is used for calling the library function through a RESTful interface;
and the function pointer is used for inputting the function name and the real parameters of the called library, obtaining pointer assignment according to the function name and the real parameters of the called library in an abstract mode, and outputting the pointer assignment to the safety linkage center so that the safety linkage center calls the corresponding library function.
6. The library function universal call system according to claim 5, wherein the security linkage center further comprises a first monitoring module for monitoring whether the function pointer exists in the data access layer;
and the first execution module is used for calling a corresponding library function from the cache according to the pointer assignment output by the function pointer if the function pointer is monitored to exist in the data access layer.
7. The library function universal calling system according to claim 6, further comprising:
the second monitoring module is used for monitoring whether a return value is generated in the process of executing the library function;
the judging module is used for judging whether the library function is completely called according to the monitoring result;
and the second execution module is used for calling the next library function according to a preset rule if the library function is judged to be executed completely.
8. An electronic device, comprising a processor and a memory, the memory having stored thereon a computer program which, when executed by the processor, implements the method of any of claims 1-4.
9. A readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out the method of any one of claims 1 to 4.
CN202210436682.5A 2022-04-25 2022-04-25 General library function calling method and system Pending CN114546542A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210436682.5A CN114546542A (en) 2022-04-25 2022-04-25 General library function calling method and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210436682.5A CN114546542A (en) 2022-04-25 2022-04-25 General library function calling method and system

Publications (1)

Publication Number Publication Date
CN114546542A true CN114546542A (en) 2022-05-27

Family

ID=81667645

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210436682.5A Pending CN114546542A (en) 2022-04-25 2022-04-25 General library function calling method and system

Country Status (1)

Country Link
CN (1) CN114546542A (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106874059A (en) * 2016-12-30 2017-06-20 长沙湘计海盾科技有限公司 A kind of method of image processing function in hardware-accelerated OpenCV storehouses
CN110502530A (en) * 2019-07-03 2019-11-26 平安科技(深圳)有限公司 Database functions call method, system, computer equipment and storage medium
CN111857675A (en) * 2020-08-03 2020-10-30 北京思特奇信息技术股份有限公司 Method and system for realizing RESTFUL service based on C + +
US20200356400A1 (en) * 2019-05-10 2020-11-12 Kontain Inc. Scalable and Secure Containers

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106874059A (en) * 2016-12-30 2017-06-20 长沙湘计海盾科技有限公司 A kind of method of image processing function in hardware-accelerated OpenCV storehouses
US20200356400A1 (en) * 2019-05-10 2020-11-12 Kontain Inc. Scalable and Secure Containers
CN110502530A (en) * 2019-07-03 2019-11-26 平安科技(深圳)有限公司 Database functions call method, system, computer equipment and storage medium
CN111857675A (en) * 2020-08-03 2020-10-30 北京思特奇信息技术股份有限公司 Method and system for realizing RESTFUL service based on C + +

Similar Documents

Publication Publication Date Title
CN108427705B (en) Electronic device, distributed system log query method and storage medium
CN108494771B (en) Electronic device, firewall opening verification method and storage medium
CN108462760B (en) Electronic device, automatic cluster access domain name generation method and storage medium
CN107896162B (en) Deployment method and device of monitoring system, computer equipment and storage medium
CN108491301B (en) Electronic device, abnormality early warning method based on redis and storage medium
CN108415925B (en) Electronic device, data call log generation and query method and storage medium
CN109885612B (en) Synchronous validation method and device for intelligent contracts of block chains
CN112035344A (en) Multi-scenario test method, device, equipment and computer readable storage medium
CN112181746A (en) Fault repairing method, device and equipment for vehicle-mounted operating system
CN111651169B (en) Block chain intelligent contract operation method and system based on web container
CN108427639B (en) Automated testing method, application server and computer readable storage medium
CN110333916B (en) Request message processing method, device, computer system and readable storage medium
CN111240772A (en) Data processing method and device based on block chain and storage medium
CN111125170A (en) Cross-service data acquisition method and device of micro-service and micro-service equipment
CN112818270B (en) Data cross-domain transfer method and device and computer equipment
CN111722857A (en) Updating method and device of software development kit, electronic equipment and storage medium
CN112015496A (en) Interface calling method and device, computer equipment and storage medium
CN114546542A (en) General library function calling method and system
CN116450165A (en) Method, system, terminal and storage medium for quickly building environment and deploying program
CN107861807B (en) Optimization method and device for program call
CN109697072A (en) Information processing method, device and equipment
CN112383434A (en) Interface simulation method and device for network request, electronic equipment and storage medium
CN110673931A (en) Distributed calculation method for document synthesis, document synthesis system and control device thereof
CN108664293B (en) Application control method and device in android system
CN111078571A (en) Test method for simulation response, terminal device and computer readable storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication

Application publication date: 20220527

RJ01 Rejection of invention patent application after publication